skylib_mudos_v1/
skylib_mudos_v1/bin/
skylib_mudos_v1/bin/db/
skylib_mudos_v1/mudlib/banish/a/
skylib_mudos_v1/mudlib/banish/b/
skylib_mudos_v1/mudlib/banish/c/
skylib_mudos_v1/mudlib/banish/d/
skylib_mudos_v1/mudlib/banish/e/
skylib_mudos_v1/mudlib/banish/f/
skylib_mudos_v1/mudlib/banish/g/
skylib_mudos_v1/mudlib/banish/h/
skylib_mudos_v1/mudlib/banish/j/
skylib_mudos_v1/mudlib/banish/l/
skylib_mudos_v1/mudlib/banish/m/
skylib_mudos_v1/mudlib/banish/n/
skylib_mudos_v1/mudlib/banish/o/
skylib_mudos_v1/mudlib/banish/p/
skylib_mudos_v1/mudlib/banish/r/
skylib_mudos_v1/mudlib/banish/s/
skylib_mudos_v1/mudlib/banish/t/
skylib_mudos_v1/mudlib/banish/u/
skylib_mudos_v1/mudlib/banish/w/
skylib_mudos_v1/mudlib/cmds/
skylib_mudos_v1/mudlib/cmds/admin/
skylib_mudos_v1/mudlib/cmds/guild-race/
skylib_mudos_v1/mudlib/cmds/guild-race/crafts/
skylib_mudos_v1/mudlib/cmds/guild-race/magic/
skylib_mudos_v1/mudlib/cmds/guild-race/other/
skylib_mudos_v1/mudlib/cmds/living/broken/
skylib_mudos_v1/mudlib/cmds/player/group_cmds/
skylib_mudos_v1/mudlib/d/admin/
skylib_mudos_v1/mudlib/d/admin/room/
skylib_mudos_v1/mudlib/d/admin/room/we_care/
skylib_mudos_v1/mudlib/d/admin/save/
skylib_mudos_v1/mudlib/d/admin/text/
skylib_mudos_v1/mudlib/d/learning/TinyTown/buildings/
skylib_mudos_v1/mudlib/d/learning/TinyTown/map/
skylib_mudos_v1/mudlib/d/learning/TinyTown/roads/
skylib_mudos_v1/mudlib/d/learning/chars/
skylib_mudos_v1/mudlib/d/learning/functions/
skylib_mudos_v1/mudlib/d/learning/handlers/
skylib_mudos_v1/mudlib/d/learning/help_topics/
skylib_mudos_v1/mudlib/d/learning/help_topics/npcs/
skylib_mudos_v1/mudlib/d/learning/help_topics/objects/
skylib_mudos_v1/mudlib/d/learning/help_topics/rcs_demo/
skylib_mudos_v1/mudlib/d/learning/help_topics/rcs_demo/RCS/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/crowd/
skylib_mudos_v1/mudlib/d/learning/help_topics/rooms/situations/
skylib_mudos_v1/mudlib/d/learning/save/
skylib_mudos_v1/mudlib/d/learning/school/
skylib_mudos_v1/mudlib/d/learning/school/add_sc/
skylib_mudos_v1/mudlib/d/learning/school/characters/
skylib_mudos_v1/mudlib/d/learning/school/general/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/basic_commands/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/edtutor/
skylib_mudos_v1/mudlib/d/learning/school/getting-started/unix_tutor/
skylib_mudos_v1/mudlib/d/learning/school/items/
skylib_mudos_v1/mudlib/d/learning/school/npc_school/
skylib_mudos_v1/mudlib/d/learning/school/room_school/
skylib_mudos_v1/mudlib/d/learning/school/room_school/room_basic/
skylib_mudos_v1/mudlib/d/learning/school/room_school/situations/
skylib_mudos_v1/mudlib/d/learning/school/room_school/terrain_tutor/
skylib_mudos_v1/mudlib/d/learning/text/
skylib_mudos_v1/mudlib/d/liaison/
skylib_mudos_v1/mudlib/d/mudlib/
skylib_mudos_v1/mudlib/d/mudlib/changes/
skylib_mudos_v1/mudlib/d/playtesters/
skylib_mudos_v1/mudlib/d/playtesters/effects/
skylib_mudos_v1/mudlib/d/playtesters/handlers/
skylib_mudos_v1/mudlib/d/playtesters/items/
skylib_mudos_v1/mudlib/d/sage/
skylib_mudos_v1/mudlib/doc/
skylib_mudos_v1/mudlib/doc/creator/
skylib_mudos_v1/mudlib/doc/driver/
skylib_mudos_v1/mudlib/doc/driver/efuns/arrays/
skylib_mudos_v1/mudlib/doc/driver/efuns/buffers/
skylib_mudos_v1/mudlib/doc/driver/efuns/compile/
skylib_mudos_v1/mudlib/doc/driver/efuns/filesystem/
skylib_mudos_v1/mudlib/doc/driver/efuns/floats/
skylib_mudos_v1/mudlib/doc/driver/efuns/functions/
skylib_mudos_v1/mudlib/doc/driver/efuns/general/
skylib_mudos_v1/mudlib/doc/driver/efuns/mappings/
skylib_mudos_v1/mudlib/doc/driver/efuns/mixed/
skylib_mudos_v1/mudlib/doc/driver/efuns/mudlib/
skylib_mudos_v1/mudlib/doc/driver/efuns/numbers/
skylib_mudos_v1/mudlib/doc/driver/efuns/parsing/
skylib_mudos_v1/mudlib/doc/known_command/
skylib_mudos_v1/mudlib/doc/login/
skylib_mudos_v1/mudlib/doc/lpc/basic_manual/
skylib_mudos_v1/mudlib/doc/lpc/intermediate/
skylib_mudos_v1/mudlib/doc/new/add_command/
skylib_mudos_v1/mudlib/doc/new/events/
skylib_mudos_v1/mudlib/doc/new/handlers/
skylib_mudos_v1/mudlib/doc/new/living/race/
skylib_mudos_v1/mudlib/doc/new/living/spells/
skylib_mudos_v1/mudlib/doc/new/object/
skylib_mudos_v1/mudlib/doc/new/player/
skylib_mudos_v1/mudlib/doc/new/room/guild/
skylib_mudos_v1/mudlib/doc/new/room/outside/
skylib_mudos_v1/mudlib/doc/new/room/storeroom/
skylib_mudos_v1/mudlib/doc/object/
skylib_mudos_v1/mudlib/doc/playtesters/
skylib_mudos_v1/mudlib/doc/policy/
skylib_mudos_v1/mudlib/doc/weapons/
skylib_mudos_v1/mudlib/global/
skylib_mudos_v1/mudlib/global/creator/
skylib_mudos_v1/mudlib/global/handlers/
skylib_mudos_v1/mudlib/global/virtual/setup_compiler/
skylib_mudos_v1/mudlib/include/cmds/
skylib_mudos_v1/mudlib/include/effects/
skylib_mudos_v1/mudlib/include/npc/
skylib_mudos_v1/mudlib/include/room/
skylib_mudos_v1/mudlib/include/shops/
skylib_mudos_v1/mudlib/net/daemon/
skylib_mudos_v1/mudlib/net/daemon/chars/
skylib_mudos_v1/mudlib/net/inherit/
skylib_mudos_v1/mudlib/net/obj/
skylib_mudos_v1/mudlib/obj/amulets/
skylib_mudos_v1/mudlib/obj/b_day/
skylib_mudos_v1/mudlib/obj/clothes/
skylib_mudos_v1/mudlib/obj/dwarmours/plate/
skylib_mudos_v1/mudlib/obj/dwclothes/transport/horse/
skylib_mudos_v1/mudlib/obj/dwscabbards/
skylib_mudos_v1/mudlib/obj/dwweapons/axes/
skylib_mudos_v1/mudlib/obj/dwweapons/chains/
skylib_mudos_v1/mudlib/obj/faith/symbols/
skylib_mudos_v1/mudlib/obj/fungi/
skylib_mudos_v1/mudlib/obj/gatherables/
skylib_mudos_v1/mudlib/obj/instruments/
skylib_mudos_v1/mudlib/obj/magic/
skylib_mudos_v1/mudlib/obj/media/
skylib_mudos_v1/mudlib/obj/misc/player_shop/
skylib_mudos_v1/mudlib/obj/monster/godmother/
skylib_mudos_v1/mudlib/obj/monster/transport/
skylib_mudos_v1/mudlib/obj/rings/
skylib_mudos_v1/mudlib/obj/spells/
skylib_mudos_v1/mudlib/obj/stationery/
skylib_mudos_v1/mudlib/obj/stationery/envelopes/
skylib_mudos_v1/mudlib/obj/stationery/papers/
skylib_mudos_v1/mudlib/obj/toys/
skylib_mudos_v1/mudlib/obj/vessels/
skylib_mudos_v1/mudlib/obj/weapons/swords/
skylib_mudos_v1/mudlib/save/autodoc/
skylib_mudos_v1/mudlib/save/leaflets/
skylib_mudos_v1/mudlib/save/mail/
skylib_mudos_v1/mudlib/save/new_soul/data/
skylib_mudos_v1/mudlib/save/parcels/
skylib_mudos_v1/mudlib/save/playerinfo/
skylib_mudos_v1/mudlib/save/players/d/
skylib_mudos_v1/mudlib/save/random_names/
skylib_mudos_v1/mudlib/save/random_names/data/
skylib_mudos_v1/mudlib/save/terrains/
skylib_mudos_v1/mudlib/save/terrains/tutorial_desert/
skylib_mudos_v1/mudlib/save/terrains/tutorial_grassy_field/
skylib_mudos_v1/mudlib/save/terrains/tutorial_mountain/
skylib_mudos_v1/mudlib/save/todo_lists/
skylib_mudos_v1/mudlib/secure/
skylib_mudos_v1/mudlib/secure/cmds/admin/
skylib_mudos_v1/mudlib/secure/cmds/lord/
skylib_mudos_v1/mudlib/secure/config/
skylib_mudos_v1/mudlib/secure/handlers/autodoc/
skylib_mudos_v1/mudlib/secure/handlers/intermud/
skylib_mudos_v1/mudlib/secure/include/global/
skylib_mudos_v1/mudlib/secure/save/
skylib_mudos_v1/mudlib/secure/save/handlers/
skylib_mudos_v1/mudlib/secure/std/classes/
skylib_mudos_v1/mudlib/secure/std/modules/
skylib_mudos_v1/mudlib/std/commands/
skylib_mudos_v1/mudlib/std/commands/shadows/
skylib_mudos_v1/mudlib/std/creator/
skylib_mudos_v1/mudlib/std/dom/
skylib_mudos_v1/mudlib/std/effects/
skylib_mudos_v1/mudlib/std/effects/external/
skylib_mudos_v1/mudlib/std/effects/fighting/
skylib_mudos_v1/mudlib/std/effects/priest/
skylib_mudos_v1/mudlib/std/effects/room/
skylib_mudos_v1/mudlib/std/environ/
skylib_mudos_v1/mudlib/std/guilds/
skylib_mudos_v1/mudlib/std/guilds/old/
skylib_mudos_v1/mudlib/std/languages/
skylib_mudos_v1/mudlib/std/languages/BACKUPS/
skylib_mudos_v1/mudlib/std/liquids/
skylib_mudos_v1/mudlib/std/npc/
skylib_mudos_v1/mudlib/std/npc/goals/
skylib_mudos_v1/mudlib/std/npc/goals/basic/
skylib_mudos_v1/mudlib/std/npc/goals/misc/
skylib_mudos_v1/mudlib/std/npc/plans/
skylib_mudos_v1/mudlib/std/npc/plans/basic/
skylib_mudos_v1/mudlib/std/npc/types/
skylib_mudos_v1/mudlib/std/npc/types/helper/
skylib_mudos_v1/mudlib/std/npcs/
skylib_mudos_v1/mudlib/std/outsides/
skylib_mudos_v1/mudlib/std/races/shadows/
skylib_mudos_v1/mudlib/std/room/basic/topography/
skylib_mudos_v1/mudlib/std/room/controller/
skylib_mudos_v1/mudlib/std/room/inherit/topography/
skylib_mudos_v1/mudlib/std/room/topography/area/
skylib_mudos_v1/mudlib/std/room/topography/iroom/
skylib_mudos_v1/mudlib/std/room/topography/milestone/
skylib_mudos_v1/mudlib/std/shadows/curses/
skylib_mudos_v1/mudlib/std/shadows/disease/
skylib_mudos_v1/mudlib/std/shadows/fighting/
skylib_mudos_v1/mudlib/std/shadows/healing/
skylib_mudos_v1/mudlib/std/shadows/magic/
skylib_mudos_v1/mudlib/std/shadows/poison/
skylib_mudos_v1/mudlib/std/shadows/rituals/
skylib_mudos_v1/mudlib/std/shadows/room/
skylib_mudos_v1/mudlib/std/shops/controllers/
skylib_mudos_v1/mudlib/std/shops/objs/
skylib_mudos_v1/mudlib/std/shops/player_shop/
skylib_mudos_v1/mudlib/std/socket/
skylib_mudos_v1/mudlib/std/soul/
skylib_mudos_v1/mudlib/std/soul/d/
skylib_mudos_v1/mudlib/std/soul/e/
skylib_mudos_v1/mudlib/std/soul/i/
skylib_mudos_v1/mudlib/std/soul/j/
skylib_mudos_v1/mudlib/std/soul/k/
skylib_mudos_v1/mudlib/std/soul/l/
skylib_mudos_v1/mudlib/std/soul/n/
skylib_mudos_v1/mudlib/std/soul/o/
skylib_mudos_v1/mudlib/std/soul/q/
skylib_mudos_v1/mudlib/std/soul/u/
skylib_mudos_v1/mudlib/std/soul/v/
skylib_mudos_v1/mudlib/std/soul/y/
skylib_mudos_v1/mudlib/std/soul/z/
skylib_mudos_v1/mudlib/std/stationery/
skylib_mudos_v1/mudlib/w/
skylib_mudos_v1/mudlib/w/default/
skylib_mudos_v1/mudlib/w/default/armour/
skylib_mudos_v1/mudlib/w/default/clothes/
skylib_mudos_v1/mudlib/w/default/item/
skylib_mudos_v1/mudlib/w/default/npc/
skylib_mudos_v1/mudlib/w/default/room/
skylib_mudos_v1/mudlib/w/default/weapon/
skylib_mudos_v1/mudlib/www/
skylib_mudos_v1/mudlib/www/download/
skylib_mudos_v1/mudlib/www/java/
skylib_mudos_v1/mudlib/www/secure/
skylib_mudos_v1/mudlib/www/secure/lpc/advanced/
skylib_mudos_v1/mudlib/www/secure/lpc/intermediate/
skylib_mudos_v1/v22.2b14-DSv10/
skylib_mudos_v1/v22.2b14-DSv10/ChangeLog.old/
skylib_mudos_v1/v22.2b14-DSv10/Win32/
skylib_mudos_v1/v22.2b14-DSv10/compat/
skylib_mudos_v1/v22.2b14-DSv10/compat/simuls/
skylib_mudos_v1/v22.2b14-DSv10/include/
skylib_mudos_v1/v22.2b14-DSv10/mudlib/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/clone/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/command/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/data/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/etc/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/include/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/inherit/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/inherit/master/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/log/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/compiler/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/efuns/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/single/tests/operators/
skylib_mudos_v1/v22.2b14-DSv10/testsuite/u/
skylib_mudos_v1/v22.2b14-DSv10/tmp/
skylib_mudos_v1/v22.2b14-DSv10/windows/
/*
 * rc.c
 * description: runtime configuration for lpmud
 * author: erikkay@mit.edu
 * last modified: July 4, 1994 [robo]
 * Mar 26, 1995: edited heavily by Beek
 * Aug 29, 1998: modified by Gorta
 */

#include "std.h"
#include "rc.h"
#include "include/runtime_config.h"
#include "main.h"

#define MAX_LINE_LENGTH 120

char *config_str[NUM_CONFIG_STRS];
int config_int[NUM_CONFIG_INTS];

static char *buff;
static int buff_size;

static void read_config_file PROT((FILE *));
static int scan_config_line PROT((char *, void *, int));
static void config_init PROT((void)); /* don't ask */

static void config_init() {
    int i;

    for (i = 0; i < NUM_CONFIG_INTS; i++) {
	config_int[i] = 0;
    }
    for (i = 0; i < NUM_CONFIG_STRS; i++) {
	config_str[i] = 0;
    }
    
}

static void read_config_file P1(FILE *, file)
{
    char str[MAX_LINE_LENGTH * 4];
    int size = 2, len, tmp;
    char *p;

    buff_size = MAX_LINE_LENGTH * (NUM_CONFIG_INTS + 1) * (NUM_CONFIG_STRS + 1);
    p = buff = CALLOCATE(buff_size, char, TAG_CONFIG, "read_config_file: 1");
    *p++ = '\n';

    while (1) {
	if (fgets(str, MAX_LINE_LENGTH * 4, file) == NULL)
	    break;
	if (!str)
	    break;
	len = strlen(str); /* ACK! */
	if (len > MAX_LINE_LENGTH) {
	    fprintf(stderr, "*Error in config file: line too long:\n%s...\n", str);
	    exit(-1);
	}
	if (str[0] != '#' && str[0] != '\n') {
	    size += len + 1;
	    if (size > buff_size) {
		tmp = p - buff;
		buff = RESIZE(buff, buff_size *= 2, char, 
			      TAG_CONFIG, "read_config_file: 2");
		p = buff + tmp;
	    }
	    strncpy(p, str, len);
	    p += len;
	    *p++ = '\n';
	}
    }
    *p = 0;
}


/*
 * If the required flag is 0, it will only give a warning if the line is
 * missing from the config file.  Otherwise, it will give an error and exit
 * if the line isn't there.
 */
/* required:
      1  : Must have
      0  : optional
      -1 : warn if missing */
static int scan_config_line P3(char *, fmt, void *, dest, int, required)
{
    char *tmp, *end;
    char missing_line[MAX_LINE_LENGTH];

    /* zero the destination.  It is either a pointer to an int or a char
       buffer, so this will work */
    *((int *)dest) = 0;
    tmp = buff;
    while (tmp) {
	while ((tmp = (char *) strchr(tmp, '\n'))) {
	    if (*(++tmp) == fmt[0]) break;
	}
	/* don't allow sscanf() to scan to next line for blank entries */
	end = (tmp ? strchr(tmp, '\n') : 0);
	if (end) *end = '\0';
	if (tmp && sscanf(tmp, fmt, dest) == 1) {
	    if (end) *end = '\n';
	    break;
	}
	if (end) *end = '\n';
    }
    if (!tmp) {
	strcpy(missing_line, fmt);
	tmp = (char *) strchr(missing_line, ':');
	*tmp = '\0';
	if (required == -1) {
	    fprintf(stderr, "*Warning: Missing line in config file:\n\t%s\n",
			  missing_line);
	    return 0;
	}
	if (!required) return 0;
	fprintf(stderr, "*Error in config file.  Missing line:\n\t%s\n",
		missing_line);
	exit(-1);
    }
    return 1;
}

#if 0
static char *process_config_string(char *str) {
    char *p = str;
    char *q;
    int n;
    
    while (*p && isspace(*p))
	p++;
    n = strlen(p);
    if (!n) return alloc_cstring("", "config_file: blank string");

    q = p + n - 1;
    while (q > p && isspace(*q))
	q--;
    q[1] = 0;
    return alloc_cstring(p, "process_config_string()");
}
#endif

void set_defaults P1(char *, filename)
{
    FILE *def;
    char defaults[SMALL_STRING_SIZE];
    char *p;
    char tmp[MAX_LINE_LENGTH];
    char kind[MAX_LINE_LENGTH];
    int i, port, port_start = 0;

    max_string_length = 120; /* needed for string_copy() below */
    config_init();
    def = fopen(filename, "r");
    if (def) {
	fprintf(stderr, "using config file: %s\n", filename);
    } else {
#ifdef LATTICE
	if (strchr(CONFIG_FILE_DIR, ':'))
	    sprintf(defaults, "%s%s", CONFIG_FILE_DIR, filename);
	else
#endif
	    sprintf(defaults, "%s/%s", CONFIG_FILE_DIR, filename);

	def = fopen(defaults, "r");
	if (def) {
	    fprintf(stderr, "using config file: %s\n", defaults);
	}
    }
    if (!def) {
	fprintf(stderr, "*Error: couldn't find or open config file: '%s'\n", filename);
	exit(-1);
    }
    read_config_file(def);

    scan_config_line("global include file : %[^\n]", tmp, 0);
    p = CONFIG_STR(__GLOBAL_INCLUDE_FILE__) = alloc_cstring(tmp, "config file: gif");

    /* check if the global include file is quoted */
    if (*p && *p != '"' && *p != '<') {
	char *ptr;

	fprintf(stderr, "Missing '\"' or '<' around global include file name; adding quotes.\n");
	for (ptr = p; *ptr; ptr++)
	    ;
	ptr[2] = 0;
	ptr[1] = '"';
	while (ptr > p) {
	    *ptr = ptr[-1];
	    ptr--;
	}
	*p = '"';
    }

    scan_config_line("name : %[^\n]", tmp, 1);
    CONFIG_STR(__MUD_NAME__) = alloc_cstring(tmp, "config file: mn");
    scan_config_line("address server ip : %[^\n]", tmp, 0);
    CONFIG_STR(__ADDR_SERVER_IP__) = alloc_cstring(tmp, "config file: asi");

    scan_config_line("mudlib directory : %[^\n]", tmp, 1);
    CONFIG_STR(__MUD_LIB_DIR__) = alloc_cstring(tmp, "config file: mld");
    scan_config_line("binary directory : %[^\n]", tmp, 1);
    CONFIG_STR(__BIN_DIR__) = alloc_cstring(tmp, "config file: bd");

    scan_config_line("log directory : %[^\n]", tmp, 1);
    CONFIG_STR(__LOG_DIR__) = alloc_cstring(tmp, "config file: ld");
    scan_config_line("include directories : %[^\n]", tmp, 1);
    CONFIG_STR(__INCLUDE_DIRS__) = alloc_cstring(tmp, "config file: id");
#ifdef BINARIES
    scan_config_line("save binaries directory : %[^\n]", tmp, 1);
    CONFIG_STR(__SAVE_BINARIES_DIR__) = alloc_cstring(tmp, "config file: sbd");
#else
    CONFIG_STR(__SAVE_BINARIES_DIR__) = alloc_cstring("", "config file: sbd");
#endif

    scan_config_line("master file : %[^\n]", tmp, 1);
    CONFIG_STR(__MASTER_FILE__) = alloc_cstring(tmp, "config file: mf");
    scan_config_line("simulated efun file : %[^\n]", tmp, 0);
    CONFIG_STR(__SIMUL_EFUN_FILE__) = alloc_cstring(tmp, "config file: sef");
    scan_config_line("swap file : %[^\n]", tmp, 1);
    CONFIG_STR(__SWAP_FILE__) = alloc_cstring(tmp, "config file: sf");
    scan_config_line("debug log file : %[^\n]", tmp, -1);
    CONFIG_STR(__DEBUG_LOG_FILE__) = alloc_cstring(tmp, "config file: dlf");

    scan_config_line("default error message : %[^\n]", tmp, 0);
    CONFIG_STR(__DEFAULT_ERROR_MESSAGE__) = alloc_cstring(tmp, "config file: dem");
    scan_config_line("default fail message : %[^\n]", tmp, 0);
    CONFIG_STR(__DEFAULT_FAIL_MESSAGE__) = alloc_cstring(tmp, "config file: dfm");

    scan_config_line("mud ip : %[^\n]", tmp, 0);
    CONFIG_STR(__MUD_IP__) = alloc_cstring(tmp, "config file: mi");

    if (scan_config_line("fd6 kind : %[^\n]", tmp, 0)) {
	if (!strcasecmp(tmp, "telnet"))
	    FD6_KIND = PORT_TELNET;
	else if (!strcasecmp(tmp, "mud"))
	    FD6_KIND = PORT_MUD;
	else if (!strcasecmp(tmp, "ascii"))
	    FD6_KIND = PORT_ASCII;
	else if (!strcasecmp(tmp, "binary"))
	    FD6_KIND = PORT_BINARY;
	else {
	    fprintf(stderr, "Unknown port type for fd6 kind.  fd6 support disabled.\n");
	    FD6_KIND = PORT_UNDEFINED;
	}
    } else {
	FD6_KIND = PORT_UNDEFINED;
    }

    if (scan_config_line("port number : %d\n", &CONFIG_INT(__MUD_PORT__), 0)) {
	external_port[0].port = PORTNO;
	external_port[0].kind = PORT_TELNET;
	port_start = 1;
    }
    
    scan_config_line("address server port : %d\n",
		     &CONFIG_INT(__ADDR_SERVER_PORT__), 0);

    scan_config_line("fd6 port : %d\n", &CONFIG_INT(__FD6_PORT__), 0);

    scan_config_line("time to clean up : %d\n",
		     &CONFIG_INT(__TIME_TO_CLEAN_UP__), 1);
    scan_config_line("time to reset : %d\n", 
		     &CONFIG_INT(__TIME_TO_RESET__), 1);
    scan_config_line("time to swap : %d\n",
		     &CONFIG_INT(__TIME_TO_SWAP__), 1);

#if 0
    /*
     * not currently used...see options.h
     */
    scan_config_line("evaluator stack size : %d\n", 
		     &CONFIG_INT(__EVALUATOR_STACK_SIZE__), 0);
    scan_config_line("maximum local variables : %d\n",
		     &CONFIG_INT(__MAX_LOCAL_VARIABLES__), 0);
    scan_config_line("maximum call depth : %d\n",
		     &CONFIG_INT(__MAX_CALL_DEPTH__), 0);
    scan_config_line("living hash table size : %d\n",
		     &CONFIG_INT(__LIVING_HASH_TABLE_SIZE__), 0);
#endif

    scan_config_line("inherit chain size : %d\n",
		     &CONFIG_INT(__INHERIT_CHAIN_SIZE__), 1);
    scan_config_line("maximum evaluation cost : %d\n", 
		     &CONFIG_INT(__MAX_EVAL_COST__), 1);

    scan_config_line("maximum array size : %d\n",
		     &CONFIG_INT(__MAX_ARRAY_SIZE__), 1);
#ifndef NO_BUFFER_TYPE
    scan_config_line("maximum buffer size : %d\n", 
		     &CONFIG_INT(__MAX_BUFFER_SIZE__), 1);
#endif
    scan_config_line("maximum mapping size : %d\n", 
		     &CONFIG_INT(__MAX_MAPPING_SIZE__), 1);
    scan_config_line("maximum string length : %d\n",
		     &CONFIG_INT(__MAX_STRING_LENGTH__), 1);
    scan_config_line("maximum bits in a bitfield : %d\n",
		     &CONFIG_INT(__MAX_BITFIELD_BITS__), 1);

    scan_config_line("maximum byte transfer : %d\n", 
		     &CONFIG_INT(__MAX_BYTE_TRANSFER__), 1);
    scan_config_line("maximum read file size : %d\n",
		     &CONFIG_INT(__MAX_READ_FILE_SIZE__), 1);

    scan_config_line("reserved size : %d\n",
		     &CONFIG_INT(__RESERVED_MEM_SIZE__), 0);

    scan_config_line("hash table size : %d\n",
		     &CONFIG_INT(__SHARED_STRING_HASH_TABLE_SIZE__), 1);
    scan_config_line("object table size : %d\n",
		     &CONFIG_INT(__OBJECT_HASH_TABLE_SIZE__), 1);

    /* check for ports */
    if (port_start == 1) {
	if (scan_config_line("external_port_1 : %[^\n]", tmp, 0)) {
	    int port = CONFIG_INT(__MUD_PORT__);
	    fprintf(stderr, "Warning: external_port_1 already defined to be 'telnet %i' by the line\n    'port number : %i'; ignoring the line 'external_port_1 : %s'\n", port, port, tmp);
	}
    }
    for (i = port_start; i < 5; i++) {
	external_port[i].kind = 0;
	external_port[i].fd = -1;
	sprintf(kind, "external_port_%i : %%[^\n]", i + 1);
	if (scan_config_line(kind, tmp, 0)) {
	    if (sscanf(tmp, "%s %d", kind, &port) == 2) {
		external_port[i].port = port;
		if (!strcmp(kind, "telnet")) 
		    external_port[i].kind = PORT_TELNET;
		else
		if (!strcmp(kind, "binary")) {
#ifdef NO_BUFFER_TYPE
		    fprintf(stderr, "binary ports unavailable with NO_BUFFER_TYPE defined.\n");
		    exit(-1);
#endif		    
		    external_port[i].kind = PORT_BINARY;
		} else
		if (!strcmp(kind, "ascii"))
		    external_port[i].kind = PORT_ASCII;
		else
		if (!strcmp(kind, "MUD"))
		    external_port[i].kind = PORT_MUD;
		else
		    {
		    fprintf(stderr, "Unknown kind of external port: %s\n",
				  kind);
		    exit(-1);
		}
	    } else {
		fprintf(stderr, "Syntax error in port specification\n");
		exit(-1);
	    }
	}
    }		    
#ifdef PACKAGE_EXTERNAL
    /* check for commands */
    for (i = 0; i < NUM_EXTERNAL_CMDS; i++) {
	sprintf(kind, "external_cmd_%i : %%[^\n]", i + 1);
	if (scan_config_line(kind, tmp, 0))
	    external_cmd[i] = alloc_cstring(tmp, "external cmd");
	else
	    external_cmd[i] = 0;
    }		    
#endif

    FREE(buff);
    fclose(def);

    /*
     * from options.h
     */
    config_int[__EVALUATOR_STACK_SIZE__ - BASE_CONFIG_INT] = CFG_EVALUATOR_STACK_SIZE;
    config_int[__MAX_LOCAL_VARIABLES__ - BASE_CONFIG_INT] = CFG_MAX_LOCAL_VARIABLES;
    config_int[__MAX_CALL_DEPTH__ - BASE_CONFIG_INT] = CFG_MAX_CALL_DEPTH;
    config_int[__LIVING_HASH_TABLE_SIZE__ - BASE_CONFIG_INT] = CFG_LIVING_HASH_SIZE;
}

int get_config_item P2(svalue_t *, res, svalue_t *, arg)
{
    int num;

    num = arg->u.number;

    if (num < 0 || num >= RUNTIME_CONFIG_NEXT) {
	return 0;
    }
    if (num >= BASE_CONFIG_INT) {
	res->type = T_NUMBER;
	res->u.number = config_int[num - BASE_CONFIG_INT];
    } else {
	res->type = T_STRING;
	res->subtype = STRING_CONSTANT;
	res->u.string = config_str[num];
    }

    return 1;
}