2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * emp_config.c: Allows config file to control server config. from a file
30 * Known contributors to this file:
32 * Steve McClure, 1998-2000
38 * 1. Change other constants - such as Num Countries etc.
39 * Just requires variables to be assigned, then dynamic allocation in
40 * a few places. Some checks needed in the server to check the world
41 * hasn't changed size etc.
42 * 2. Could look at loading in planes, units etc. Should be easy enough.
47 #include <stdlib.h> /* atoi free atol */
57 #include "gen.h" /* parse */
59 /* for systems without strdup */
61 extern char *strdup();
64 /* All the configurable variables ... */
65 extern s_char *infodir, *datadir, *gamedir, *loginport, *privname,
68 extern double buil_tower_bt, buil_tower_bc;
69 extern double buytax, flakscale, maxmult, minmult, tradetax, uwbrate;
70 extern double buil_bc, buil_bt, combat_mob, edu_cons, hap_cons, money_civ;
71 extern double money_land, money_mil, money_plane, money_res, money_ship;
72 extern double money_uw, people_damage, powe_cost, unit_damage, babyeat;
73 extern double collateral_dam, assault_penalty;
74 extern double bankint, eatrate, fcrate, fgrate, obrate, mission_mob_cost;
76 extern float btu_build_rate, easy_tech, hard_tech, land_mob_scale;
77 extern float level_age_rate, plane_mob_scale, sect_mob_scale;
78 extern float ship_mob_scale, tech_log_base, ally_factor, edu_avg, hap_avg;
80 extern int buil_tower_bh;
81 extern int startmob, at_least_one_100, buil_bh, etu_per_update;
82 extern int land_grow_scale, land_mob_max, m_m_p_d, max_btus, max_idle;
83 extern int plane_grow_scale, plane_mob_max, players_at_00, sect_mob_max;
84 extern int ship_grow_scale, ship_mob_max, torpedo_damage;
85 extern int fort_max_interdiction_range;
86 extern int land_max_interdiction_range;
87 extern int ship_max_interdiction_range;
88 extern int sect_mob_neg_factor;
89 extern int lost_items_timeout;
92 extern int MARK_DELAY;
93 extern int TRADE_DELAY;
95 extern int morale_base;
96 extern float fire_range_factor;
98 extern long adj_update;
100 extern int update_policy;
101 extern s_char *update_times;
103 extern int update_window;
104 extern int blitz_time;
105 extern int update_demandpolicy;
106 extern s_char *update_demandtimes;
107 extern int update_wantmin;
108 extern int update_missed;
109 extern s_char *game_days;
110 extern s_char *game_hours;
112 /* conditional ones */
113 extern double decay_per_etu, fallout_spread;
115 extern int fuel_mult;
118 extern long last_demand_update;
120 extern float drnuke_const;
121 extern float start_education, start_happiness;
122 extern float start_technology, start_research;
124 extern int trade_1_dist, trade_2_dist, trade_3_dist;
125 extern float trade_1, trade_2, trade_3, trade_ally_bonus, trade_ally_cut;
128 static int emp_config_dummy;
130 /* things that can be changed */
131 struct keymatch configkeys[] = {
132 {"", intset, (caddr_t)&emp_config_dummy, 0,
133 "\n### Server configuration and information"},
134 {"data", optstrset, (caddr_t)&datadir, 0,
135 "Directory the data is stored in"},
136 {"info", optstrset, (caddr_t)&infodir, 0,
137 "Directory the info pages are stored in"},
138 {"port", optstrset, (caddr_t)&loginport, 0,
139 "TCP/IP port the server will start up on"},
140 {"privname", optstrset, (caddr_t)&privname, 0,
141 "Name of the deity"},
142 {"privlog", optstrset, (caddr_t)&privlog, 0,
143 "E-mail of the deity"},
144 {"WORLD_X", worldxset, (caddr_t)&WORLD_X, 0,
145 "World size X dimension (enforced to be even by subtracting 1 if necessary)"},
146 {"WORLD_Y", intset, (caddr_t)&WORLD_Y, 0,
147 "World size Y dimension"},
149 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Update policy"},
150 {"update_policy", intset, (caddr_t)&update_policy, 0,
151 "0 - normal, 1 - update_times, 2 - blitz, 3 - demand only"},
152 {"etu_per_update", intset, (caddr_t)&etu_per_update, 0,
153 "Number of ETUs per update"},
154 {"s_p_etu", longset, (caddr_t)&s_p_etu, 0,
155 "Seconds per etu, updates will occur every s_p_etu * etu_per_update seconds"},
156 {"adj_update", longset, (caddr_t)&adj_update, 0,
157 "Move the update forward or backward (in seconds)"},
158 {"update_window", intset, (caddr_t)&update_window, 0,
159 "Window the update will occur in (in seconds) before and after the update time"},
160 {"update_times", optstrset, (caddr_t)&update_times, 0,
161 "Times when updates occur under policy #1. Must coincide with schedule."},
162 {"hourslop", intset, (caddr_t)&hourslop, 0,
163 "Number of minutes update check can slip to match update_times"},
164 {"blitz_time", intset, (caddr_t)&blitz_time, 0,
165 "Number of minutes between updates under policy #2."},
167 {"", intset, (caddr_t)&emp_config_dummy, 0,
168 "\n\n### Demand update policy"},
169 {"update_demandpolicy", intset, (caddr_t)&update_demandpolicy, 0,
170 "0 - emp_tm checks, 1 - after setting, 2 - demand updates disabled"},
171 {"update_wantmin", intset, (caddr_t)&update_wantmin, 0,
172 "number of requests needed for demand update"},
173 {"update_missed", intset, (caddr_t)&update_missed, 0,
174 "number of demand updates country can miss before veto update"},
175 {"update_demandtimes", optstrset, (caddr_t)&update_demandtimes, 0,
176 "Times when demand updates can occur. Ranges CANNOT cross midnight."},
178 {"", intset, (caddr_t)&emp_config_dummy, 0,
179 "\n\n### Game hours restrictions"},
180 {"game_days", optstrset, (caddr_t)&game_days, 0,
181 "Days game is up and running (Su Mo Tu We Th Fr Sa)"},
182 {"game_hours", optstrset, (caddr_t)&game_hours, 0,
183 "Hours game is up and running (6:00-18:00)"},
185 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Options\n"},
186 {"option", optionset, (caddr_t)NULL, 0, NULL},
187 {"nooption", optiondel, (caddr_t)NULL, 0, NULL},
190 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Countries"},
191 {"btu_build_rate", floatset, (caddr_t)&btu_build_rate, 0,
192 "Rate at which BTUs accumulate (etu * civ * eff * btu_build_rate)"},
193 {"m_m_p_d", intset, (caddr_t)&m_m_p_d, 0,
194 "Maximum minutes per day a country is allowed to be logged in"},
195 {"max_btus", intset, (caddr_t)&max_btus, 0,
196 "Maximum number of BTUs a country can have"},
197 {"max_idle", intset, (caddr_t)&max_idle, 0,
198 "Maximum number of minutes a player can sit idle while logged in"},
199 {"players_at_00", intset, (caddr_t)&players_at_00, 0,
200 "Players have their coordinate system at deity 0,0 (0 - no, 1 - yes)"},
201 {"at_least_one_100", intset, (caddr_t)&at_least_one_100, 0,
202 "Initialize new countries with at least one sector with 100 of all resource"},
203 {"powe_cost", doubleset, (caddr_t)&powe_cost, 0,
204 "Number of BTUs needed to generate a new power report"},
205 {"war_cost", intset, (caddr_t)&War_Cost, 0,
206 "Cost to declare war (if SLOW_WAR is on)"},
208 {"", intset, (caddr_t)&emp_config_dummy, 0,
209 "\n\n### Technology/Research/Education/Happiness"},
210 {"easy_tech", floatset, (caddr_t)&easy_tech, 0,
211 "Amount of tech built with no penalty"},
212 {"hard_tech", floatset, (caddr_t)&hard_tech, 0,
213 "Amount of in-efficiently built tech"},
214 {"start_tech", floatset, (caddr_t)&start_technology, 0,
215 "Starting technology for new countries"},
216 {"start_happy", floatset, (caddr_t)&start_happiness, 0,
217 "Starting happiness for new countries"},
218 {"start_research", floatset, (caddr_t)&start_research, 0,
219 "Starting research for new countries"},
220 {"start_edu", floatset, (caddr_t)&start_education, 0,
221 "Starting education for new countries"},
222 {"level_age_rate", floatset, (caddr_t)&level_age_rate, 0,
223 "ETU rate at which tech decays (0 -> no decline)"},
224 {"tech_log_base", floatset, (caddr_t)&tech_log_base, 0,
225 "Log base to apply to tech breakthroughs above the easy tech level"},
226 {"ally_factor", floatset, (caddr_t)&ally_factor, 0,
227 "Shared tech with allies (1 / ally_factor)"},
228 {"edu_avg", floatset, (caddr_t)&edu_avg, 0,
229 "Number of ETUs education is averaged over"},
230 {"hap_avg", floatset, (caddr_t)&hap_avg, 0,
231 "Number of ETUs happiness is averaged over"},
232 {"edu_cons", doubleset, (caddr_t)&edu_cons, 0,
233 "Education consumption (1 breakthrough per edu_cons)"},
234 {"hap_cons", doubleset, (caddr_t)&hap_cons, 0,
235 "Happiness consumption (1 breakthrough per hap_cons)"},
237 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Sectors"},
238 {"startmob", intset, (caddr_t)&startmob, 0,
239 "Starting mobility for sanctuaries"},
240 {"sect_mob_scale", floatset, (caddr_t)§_mob_scale, 0,
241 "Sector mobility accumulation (sect_mob_scale * ETUs per update)"},
242 {"sect_mob_max", intset, (caddr_t)§_mob_max, 0,
243 "Maximum mobility for sectors"},
244 {"buil_bh", intset, (caddr_t)&buil_bh, 0,
245 "Number of hcms required to build a bridge span"},
246 {"buil_bc", doubleset, (caddr_t)&buil_bc, 0,
247 "Cash required to build a bridge span"},
248 {"buil_bt", doubleset, (caddr_t)&buil_bt, 0,
249 "Technology required to build a bridge span"},
250 {"buil_tower_bh", intset, (caddr_t)&buil_tower_bh, 0,
251 "Number of hcms required to build a bridge tower"},
252 {"buil_tower_bc", doubleset, (caddr_t)&buil_tower_bc, 0,
253 "Cash required to build a bridge tower"},
254 {"buil_tower_bt", doubleset, (caddr_t)&buil_tower_bt, 0,
255 "Technology required to build a bridge tower"},
257 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Land Units"},
258 {"land_mob_scale", floatset, (caddr_t)&land_mob_scale, 0,
259 "Land unit mobility accumulation (land_mob_scale * ETUs per update)"},
260 {"land_grow_scale", intset, (caddr_t)&land_grow_scale, 0,
261 "How fast efficiency grows for land units each update (* ETUs)"},
262 {"land_mob_max", intset, (caddr_t)&land_mob_max, 0,
263 "Maximum mobility for land units"},
264 {"money_land", doubleset, (caddr_t)&money_land, 0,
265 "Cost per ETU to maintain land units (percentage of unit price)"},
266 {"morale_base", intset, (caddr_t)&morale_base, 0,
267 "Base level for setting morale of land units"},
269 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Planes"},
270 {"plane_mob_scale", floatset, (caddr_t)&plane_mob_scale, 0,
271 "Plane mobility accumulation (plane_mob_scale * ETUs per update)"},
272 {"plane_grow_scale", intset, (caddr_t)&plane_grow_scale, 0,
273 "How fast efficiency grows for planes each update (* ETUs)"},
274 {"plane_mob_max", intset, (caddr_t)&plane_mob_max, 0,
275 "Maximum mobility for planes"},
276 {"money_plane", doubleset, (caddr_t)&money_plane, 0,
277 "Cost per ETU to maintain planes (percentage of plane price)"},
279 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Ships"},
280 {"ship_mob_scale", floatset, (caddr_t)&ship_mob_scale, 0,
281 "Ship mobility accumulation (ship_mob_scale * ETUs per update)"},
282 {"ship_grow_scale", intset, (caddr_t)&ship_grow_scale, 0,
283 "How fast efficiency grows for ships each update (* ETUs)"},
284 {"ship_mob_max", intset, (caddr_t)&ship_mob_max, 0,
285 "Maximum mobility for ships"},
286 {"money_ship", doubleset, (caddr_t)&money_ship, 0,
287 "Cost per ETU to maintain ships (percentage of ship price)"},
288 {"torpedo_damage", intset, (caddr_t)&torpedo_damage, 0,
289 "Torpedo damage (damage is X + 1dX + 1dX)"},
291 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Combat/Damage"},
292 {"fort_max_interdiction_range", intset,
293 (caddr_t)&fort_max_interdiction_range, 0,
294 "Maximum range (in sectors) a fort will try to interdict another country"},
295 {"land_max_interdiction_range", intset,
296 (caddr_t)&land_max_interdiction_range, 0,
297 "Maximum range (in sectors) a land unit will try to interdict another country"},
298 {"ship_max_interdiction_range", intset,
299 (caddr_t)&ship_max_interdiction_range, 0,
300 "Maximum range (in sectors) a ship will try to interdict another country"},
301 {"flakscale", doubleset, (caddr_t)&flakscale, 0,
302 "Scale factor for flak damage"},
303 {"combat_mob", doubleset, (caddr_t)&combat_mob, 0,
304 "How much mobility do units spend for combat (* casualties/bodies)"},
305 {"people_damage", doubleset, (caddr_t)&people_damage, 0,
306 "People take this amount of normal damage"},
307 {"unit_damage", doubleset, (caddr_t)&unit_damage, 0,
308 "Land units take this amount of normal damage"},
309 {"collateral_dam", doubleset, (caddr_t)&collateral_dam, 0,
310 "Side effect damage amount done to sector"},
311 {"assault_penalty", doubleset, (caddr_t)&assault_penalty, 0,
312 "Amount of normal attacking efficiency for paratroopers and assaulting"},
313 {"fire_range_factor", floatset, (caddr_t)&fire_range_factor, 0,
314 "Scale normal firing ranges by this amount"},
315 {"sect_mob_neg_factor", intset, (caddr_t)§_mob_neg_factor, 0,
316 "Amount of negative mobility a sector has after takeover (ETU / x) (MOB_ACCESS)"},
317 {"mission_mob_cost", doubleset, (caddr_t)&mission_mob_cost, 0,
318 "Cost to put something on a mission (percentage of max mob)"},
320 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Populace"},
321 {"uwbrate", doubleset, (caddr_t)&uwbrate, 0,
322 "Birth rate for uw's"},
323 {"money_civ", doubleset, (caddr_t)&money_civ, 0,
324 "Money gained from taxes on a civilian in one ETU"},
325 {"money_mil", doubleset, (caddr_t)&money_mil, 0,
326 "Money gained from taxes on an active soldier in one ETU"},
327 {"money_res", doubleset, (caddr_t)&money_res, 0,
328 "Money gained from taxes on a soldier on active reserve in one ETU"},
329 {"money_uw", doubleset, (caddr_t)&money_uw, 0,
330 "Money gained from taxes on an uncompensated worker in one ETU"},
331 {"babyeat", doubleset, (caddr_t)&babyeat, 0,
332 "Amount of food to mature 1 baby into a civilian"},
333 {"bankint", doubleset, (caddr_t)&bankint, 0,
334 "Bank dollar gain (per bar per etu)"},
335 {"eatrate", doubleset, (caddr_t)&eatrate, 0,
336 "Food eating rate for mature people"},
337 {"fcrate", doubleset, (caddr_t)&fcrate, 0,
338 "Food cultivation rate (* workforce in sector)"},
339 {"fgrate", doubleset, (caddr_t)&fgrate, 0,
340 "Food growth rate (* fertility of sector)"},
341 {"obrate", doubleset, (caddr_t)&obrate, 0,
342 "Civilian birth rate"},
344 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Nukes"},
345 {"decay_per_etu", doubleset, (caddr_t)&decay_per_etu, 0,
346 "Decay of fallout per ETU"},
347 {"fallout_spread", doubleset, (caddr_t)&fallout_spread, 0,
348 "Amount of fallout that leaks into surrounding sectors"},
349 {"drnuke_const", floatset, (caddr_t)&drnuke_const, 0,
350 "Amount of research to tech needed to build a nuke (if DR_NUKE is on)"},
352 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Market/Trade"},
353 {"MARK_DELAY", intset, (caddr_t)&MARK_DELAY, 0,
354 "Number of seconds commodities stay on the market for bidding"},
355 {"TRADE_DELAY", intset, (caddr_t)&TRADE_DELAY, 0,
356 "Number of seconds ships, planes, and units stay on the market for bidding"},
357 {"maxmult", doubleset, (caddr_t)&maxmult, 0,
358 "Maximum trade multiple (used for mult command)"},
359 {"minmult", doubleset, (caddr_t)&minmult, 0,
360 "Minimum trade multiple (used for mult command)"},
361 {"buytax", doubleset, (caddr_t)&buytax, 0,
362 "Tax (in percentage points) charged to the buyer on market purchases"},
363 {"tradetax", doubleset, (caddr_t)&tradetax, 0,
364 "Amount of a trade transaction the seller makes (the rest is tax)"},
366 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Trade ships"},
367 {"trade_1_dist", intset, (caddr_t)&trade_1_dist, 0,
368 "Less than this distance no money for cashing in"},
369 {"trade_2_dist", intset, (caddr_t)&trade_2_dist, 0,
370 "Less than this distance gets trade_1 money for cashing in"},
371 {"trade_3_dist", intset, (caddr_t)&trade_3_dist, 0,
372 "Less than this distance gets trade_2 money for cashing in (>= gets trade_3"},
373 {"trade_1", floatset, (caddr_t)&trade_1, 0,
374 "Return per sector on trade_1 distance amount"},
375 {"trade_2", floatset, (caddr_t)&trade_2, 0,
376 "Return per sector on trade_2 distance amount"},
377 {"trade_3", floatset, (caddr_t)&trade_3, 0,
378 "Return per sector on trade_3 distance amount"},
379 {"trade_ally_bonus", floatset, (caddr_t)&trade_ally_bonus, 0,
380 "Bonus you get for cashing in with an ally"},
381 {"trade_ally_cut", floatset, (caddr_t)&trade_ally_cut, 0,
382 "Bonus your ally gets for you cashing in with them"},
384 {"", intset, (caddr_t)&emp_config_dummy, 0, "\n\n### Misc."},
385 {"fuel_mult", intset, (caddr_t)&fuel_mult, 0,
386 "Multiplier for fuel to mobility calculation"},
387 {"lost_items_timeout", intset, (caddr_t)&lost_items_timeout, 0,
388 "Seconds before a lost item is timed out of the database"},
389 {"last_demand_update", longset, (caddr_t)&last_demand_update, 0,
390 "When was the last demand update occured"},
392 {NULL, NULL, (caddr_t)0, 0, NULL}
395 static void fixup_files _PROTO((void));
396 static struct keymatch *keylookup
397 _PROTO((s_char *key, struct keymatch tbl[]));
401 * read in empire configuration
404 emp_config(char *file)
407 s_char scanspace[1024];
412 if (file == NULL || (fp = fopen(file, "r")) == NULL) {
416 while (fgets(buf, sizeof buf, fp) != NULL) {
417 if (buf[0] == '#' || buf[0] == '\n')
419 if (parse(buf, av, 0, scanspace, 0) < 0) {
420 fprintf(stderr, "Can't parse line %s", buf);
423 if ((kp = keylookup(av[0], configkeys)) != NULL) {
424 (*kp->km_func) (kp, av + 1);
426 fprintf(stderr, "Unknown config key %s\n", av[0]);
440 extern s_char *upfil, *downfil, *disablefil, *banfil, *authfil;
441 extern s_char *commfil, *annfil, *telfil, *teldir, *timestampfil;
443 /* list of other well known files... -maybe tailor these oneday
444 * anyway - meantime they are all relative to datadir */
445 static struct otherfiles ofiles[] = {
448 {&disablefil, "disable"},
453 {×tampfil, "timestamp"},
456 {&telfil, "tel/tel"},
458 {&telfil, "tel\\tel"},
463 /* fix up the empfile struct to reference full path names */
468 struct otherfiles *op;
471 for (ep = empfile; ep < &empfile[EF_MAX]; ep++) {
473 sprintf(buf, "%s/%s", datadir, ep->name);
475 sprintf(buf, "%s\\%s", datadir, ep->name);
477 ep->file = strdup(buf);
480 for (op = ofiles; op->files; op++) {
482 sprintf(buf, "%s/%s", datadir, op->name);
484 sprintf(buf, "%s\\%s", datadir, op->name);
486 *op->files = strdup(buf);
490 /* find the key in the table */
491 static struct keymatch *
492 keylookup(register s_char *command, struct keymatch *tbl)
494 register struct keymatch *kp;
496 if (command == 0 || *command == 0)
498 for (kp = tbl; kp->km_key != 0; kp++) {
499 if (strcmp(kp->km_key, command) == 0)
505 /* worldx int setting function */
507 worldxset(struct keymatch *kp, s_char **av)
509 int *intptr = (int *)kp->km_data;
511 if (*av == NULL || intptr == NULL)
514 if (!((*intptr % 2) == 0)) {
515 /* Must be div / 2, so subtract one */
516 *intptr = *intptr - 1;
520 /* generic int setting function */
522 intset(struct keymatch *kp, s_char **av)
524 int *intptr = (int *)kp->km_data;
526 if (*av == NULL || intptr == NULL)
531 /* generic float set function */
533 floatset(struct keymatch *kp, s_char **av)
535 float *floatptr = (float *)kp->km_data;
537 if (*av == NULL || floatptr == NULL)
539 *floatptr = atof(*av);
544 /* generic string set function */
546 optstrset(struct keymatch *kp, s_char **av)
548 s_char **confstrp = (s_char **)kp->km_data;
550 if (*av == NULL || confstrp == NULL)
552 if (kp->km_flags & KM_ALLOC)
554 *confstrp = strdup(*av);
555 kp->km_flags |= KM_ALLOC;
558 /* generic double set function */
560 doubleset(struct keymatch *kp, s_char **av)
562 double *doublep = (double *)kp->km_data;
564 if (*av == NULL || doublep == NULL)
566 *doublep = atof(*av);
569 /* generic long set function */
571 longset(struct keymatch *kp, s_char **av)
573 long int *longp = (long int *)kp->km_data;
575 if (*av == NULL || longp == NULL)
581 print_config(FILE * fp)
584 struct otherfiles *op;
587 fprintf(fp, "# Empire Configuration File:\n");
588 for (kp = configkeys; kp->km_key; kp++) {
589 /* We print a few special things here */
590 if (kp->km_comment) {
591 if (kp->km_comment[0]) {
592 if (kp->km_comment[0] != '\n')
594 fprintf(fp, "%s\n", kp->km_comment);
599 if (kp->km_func == optstrset) {
600 fprintf(fp, "%s \"%s\"\n", kp->km_key,
601 *(s_char **)kp->km_data);
602 } else if (kp->km_func == intset) {
603 fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
604 } else if (kp->km_func == worldxset) {
605 fprintf(fp, "%s %d\n", kp->km_key, *(int *)kp->km_data);
606 } else if (kp->km_func == floatset) {
607 fprintf(fp, "%s %g\n", kp->km_key, *(float *)kp->km_data);
608 } else if (kp->km_func == doubleset) {
609 fprintf(fp, "%s %g\n", kp->km_key, *(double *)kp->km_data);
610 } else if (kp->km_func == longset) {
611 fprintf(fp, "%s %ld\n", kp->km_key, *(long *)kp->km_data);
612 } else if (kp->km_func == optionset) {
613 struct option_list *op;
615 for (op = Options; op->opt_key; op++) {
617 fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
619 } else if (kp->km_func == optiondel) {
620 struct option_list *op;
622 for (op = Options; op->opt_key; op++) {
623 if (*op->opt_valuep == 0)
624 fprintf(fp, "%s %s\n", kp->km_key, op->opt_key);
627 fprintf(fp, "# Unknown format %s\n", kp->km_key);
631 for (ep = empfile; ep < &empfile[EF_MAX]; ep++)
632 fprintf(fp, "# File %s -> %s\n", ep->name, ep->file);
633 for (op = ofiles; op->files; op++)
634 fprintf(fp, "# File %s -> %s\n", op->name, *(op->files));
639 /* add an option to the list */
641 set_option(const char *s)
643 struct option_list *op;
645 for (op = Options; op->opt_key; op++) {
646 if (strcmp(op->opt_key, s) == 0)
651 /* delete an option from the list */
653 delete_option(const char *s)
655 struct option_list *op;
657 for (op = Options; op->opt_key; op++) {
658 if (strcmp(op->opt_key, s) == 0)
663 /* config interface */
665 optionset(struct keymatch *kp, s_char **av)
666 /* unused - we have a well known global */
670 for (cpp = (char **)av; *cpp; cpp++)
674 /* config interface */
676 optiondel(struct keymatch *kp, s_char **av)
677 /* unused - we have a well known global */
681 for (cpp = (char **)av; *cpp; cpp++)