Example #1
0
int
main(int argc, char *argv[])
{
	char *p;
	const char *last_component;
	char *outfile = NULL;
	int pflag, ch, eflag, uflag, fflag;

	pflag = eflag = uflag = fflag = 0;
	while ((ch = getopt(argc, argv, "egpfb:s:o:u")) != -1) {
		switch (ch) {

		case 'o':
			outfile = optarg;
			break;
		case 'u':
			uflag = 1;
			break;
		case 'f':
			fflag = 1;
			break;

		case 'e':
			eflag = 1;
			if (!isatty(STDIN_FILENO))
				verbose = 1;
			break;

		case 'g':
			/*
			 * In addition to DEBUG, you probably wanted to
			 * set "options KGDB" and maybe others.  We could
			 * do that for you, but you really should just
			 * put them in the config file.
			 */
			(void)fputs(
			    "-g is obsolete (use makeoptions DEBUG=\"-g\")\n",
			    stderr);
			usage();

		case 'p':
			/*
			 * Essentially the same as makeoptions PROF="-pg",
			 * but also changes the path from ../../compile/FOO
			 * to ../../compile/FOO.PROF; i.e., compile a
			 * profiling kernel based on a typical "regular"
			 * kernel.
			 *
			 * Note that if you always want profiling, you
			 * can (and should) use a "makeoptions" line.
			 */
			pflag = 1;
			break;

		case 'b':
			builddir = optarg;
			break;

		case 's':
			srcdir = optarg;
			break;

		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;
	if (argc > 1 || (eflag && argv[0] == NULL))
		usage();

	if (eflag) {
#ifdef MAKE_BOOTSTRAP
		fprintf(stderr, "config: UKC not available in this binary\n");
		exit(1);
#else
		return (ukc(argv[0], outfile, uflag, fflag));
#endif
	}

	conffile = (argc == 1) ? argv[0] : "CONFIG";
	if (firstfile(conffile)) {
		(void)fprintf(stderr, "config: cannot read %s: %s\n",
		    conffile, strerror(errno));
		exit(2);
	}

	/*
	 * Init variables.
	 */
	minmaxusers = 1;
	maxmaxusers = 10000;
	initintern();
	initfiles();
	initsem();
	devbasetab = ht_new();
	devatab = ht_new();
	selecttab = ht_new();
	needcnttab = ht_new();
	opttab = ht_new();
	mkopttab = ht_new();
	defopttab = ht_new();
	nextopt = &options;
	nextmkopt = &mkoptions;
	nextdefopt = &defoptions;

	/*
	 * Handle profiling (must do this before we try to create any
	 * files).
	 */
	last_component = strrchr(conffile, '/');
	last_component = (last_component) ? last_component + 1 : conffile;
	if (pflag) {
		int len = strlen(last_component) + 17;
		p = emalloc(len);
		(void)snprintf(p, len, "../compile/%s.PROF", last_component);
		(void)addmkoption(intern("PROF"), "-pg");
		(void)addoption(intern("GPROF"), NULL);
	} else {
		int len = strlen(last_component) + 12;
		p = emalloc(len);
		(void)snprintf(p, len, "../compile/%s", last_component);
	}
	defbuilddir = (argc == 0) ? "." : p;

	/*
	 * Parse config file (including machine definitions).
	 */
	if (yyparse())
		stop();

	/*
	 * Fix (as in `set firmly in place') files.
	 */
	if (fixfiles())
		stop();

	/*
	 * Fix objects and libraries.
	 */
	if (fixobjects())
		stop();

	/*
	 * Perform cross-checking.
	 */
	if (maxusers == 0) {
		if (defmaxusers) {
			(void)printf("maxusers not specified; %d assumed\n",
			    defmaxusers);
			maxusers = defmaxusers;
		} else {
			(void)fprintf(stderr,
			    "config: need \"maxusers\" line\n");
			errors++;
		}
	}
	if (crosscheck() || errors)
		stop();

	/*
	 * Squeeze things down and finish cross-checks (STAR checks must
	 * run after packing).
	 */
	pack();
	if (badstar())
		stop();

	/*
	 * Ready to go.  Build all the various files.
	 */
	if (mksymlinks() || mkmakefile() || mkheaders() || mkswap() ||
	    mkioconf())
		stop();
	optiondelta();
	exit(0);
}
Example #2
0
static Bool configcit(void)
    {
    Bool oldresizelog = FALSE, oldresizemsg = FALSE;

    CitadelIsConfiguring = TRUE;

    VerifyHeap();

#ifndef WINCIT
    if (OC.PrintFile)
        {
        fclose(OC.PrintFile);
        OC.PrintFile = NULL;
        }

    if (journalfl)
        {
        fclose(journalfl);
        journalfl = NULL;
        }
#endif

    if (TrapFile)
        {
        fclose(TrapFile);
        TrapFile = NULL;
        }

    if (RoomFile)
        {
        fclose(RoomFile);
        RoomFile = NULL;
        }


    // read CONFIG.CIT
    if (!readconfig(NULL, 0))
        {
        return (FALSE);
        }


	Bool grpZap = FALSE, hallZap = FALSE, msgZap = FALSE, logZap = FALSE, log2Zap = FALSE, log3Zap = FALSE,
			log4Zap = FALSE, log5Zap = FALSE, log6Zap = FALSE, roomZap = FALSE, roomposZap = FALSE;

    initfiles(&grpZap, &hallZap, &msgZap, &logZap, &log2Zap, &log3Zap, &log4Zap, &log5Zap, &log6Zap, &roomZap, &roomposZap);

    VerifyHeap();

    // if we are about to make a new system, make default .CIT files.
    if (msgZap && roomZap && logZap && grpZap && hallZap && roomposZap)
        {
        CreateConfigurationFile(C_EXTERNAL_CIT, 0, TRUE);
        CreateConfigurationFile(C_NODES_CIT, 1, TRUE);
        CreateConfigurationFile(C_GRPDATA_CIT, 2, TRUE);
        CreateConfigurationFile(C_CRON_CIT, 3, TRUE);
        CreateConfigurationFile(C_MDMRESLT_CIT, 4, TRUE);
        CreateConfigurationFile(C_PROTOCOL_CIT, 5, TRUE);
        CreateConfigurationFile(C_TERMCAP_CIT, 6, TRUE);
        CreateConfigurationFile(C_COMMANDS_CIT, 7, TRUE);
        }

    VerifyHeap(1);

    // allocate tables here so readconfig() can be called from sysop menu
    allocateTables();

#ifndef WINCIT
    setdefaultTerm(TT_ANSI);
    termCap(TERM_NORMAL);
#endif

    VerifyHeap(1);

#ifdef WINCIT
    if (msgZap || roomZap || logZap || grpZap || hallZap || roomposZap)
        {
        hCreateDlg = CreateDialog(hInstance, "CREATEDATAFILES", NULL, (DLGPROC) EmptyDlgProc);
        }
#endif

    if (msgZap)
        {
        MessageDat.InitializeMessageFile(cfg.MsgDatSizeInK * 1024l);
        }

    if (roomZap)    zapRoomFile();
    if (logZap)     zapLogFile(FALSE, TRUE);
    if (grpZap)     zapGrpFile(NULL, TRUE);
    if (hallZap)    zapHallFile();
    if (roomposZap) zapRoomPosFile(TRUE);

    if (roomZap && !msgZap) roomBuild = TRUE;
    if (hallZap && !msgZap) hallBuild = TRUE;

    if (!logZap)
        {
        if (log2Zap)    zapLog2();
        if (log3Zap)    zapLog3();
        if (log4Zap)    zapLog4();
        if (log5Zap)    zapLog5();
        if (log6Zap)    zapLog6();
        }

#ifdef WINCIT
    if (hCreateDlg)
        {
        DestroyWindow(hCreateDlg);
        hCreateDlg = NULL;
        }

// no go for debug version; td32 go crash crash
    hConfigDlg = CreateDialog(hInstance, "CONFIGURE", NULL, (DLGPROC) EmptyDlgProc);
#endif

    VerifyHeap(1);

    logInit();

    VerifyHeap(1);

	MessageDat.BuildTable();

    VerifyHeap(1);

    RoomTabBld();

    VerifyHeap(1);

#ifdef WINCIT
    if (hConfigDlg)
        {
        DestroyWindow(hConfigDlg);
        hConfigDlg = NULL;
        }
#endif

    if (hallBuild)
        {
        buildhalls();
        VerifyHeap(1);
        }

    if (resizeRoom)
        {
        resizeroomfile();
        VerifyHeap(1);
        }

    if (resizeGrp)
        {
        resizegrpfile();
        VerifyHeap(1);
        }

    if (resizeHall)
        {
        resizehallfile();
        VerifyHeap(1);
        }

    if (resizeLog)
        {
        resizelogfile();
        VerifyHeap(1);
        }

    if (resizeMsg)
        {
        MessageDat.Resize(newmessagek * 1024l);	// bibnewmsg
        VerifyHeap(1);
        }

    if (resizeLog || resizeMsg || resizeRoom || resizeGrp)
        {
        oldresizelog = resizeLog;
        oldresizemsg = resizeMsg;
        resizeLog = FALSE;
        resizeMsg = FALSE;

        MessageDat.CloseMessageFile();

#ifndef MINGW
        fcloseall();
#endif

        cfg.MsgDatSizeInK = newmessagek;
        cfg.MAXLOGTAB = newmaxlogtab;

        initfiles(&grpZap, &hallZap, &msgZap, &logZap, &log2Zap, &log3Zap, &log4Zap, &log5Zap, &log6Zap, &roomZap, &roomposZap);
        }

    VerifyHeap(1);

#ifdef WINCIT
    if (oldresizelog || oldresizemsg)
        {
        hConfigDlg = CreateDialog(hInstance, "CONFIGURE", NULL, (DLGPROC) EmptyDlgProc);
        }
#endif

    if (oldresizelog)
        {
        if (!LogTab.Resize(cfg.MAXLOGTAB))
            {
            crashout(getcfgmsg(116));
            }

        VerifyHeap(1);

        logInit();

        VerifyHeap(1);
        }

	if (oldresizemsg)	// bibnewmsg - required?
        {
        MessageDat.SetTableSize(cfg.nmessages);

        VerifyHeap(1);

        MessageDat.BuildTable();

        VerifyHeap(1);
        }

#ifdef WINCIT
    if (hConfigDlg)
        {
        DestroyWindow(hConfigDlg);
        hConfigDlg = NULL;
        }
#else
    doccr();
    cPrintf(getcfgmsg(135));
    doccr();
    pause(200);
#endif

	MessageDat.CloseMessageFile();

#ifndef WINCIT
    if (OC.PrintFile)
        {
        fclose(OC.PrintFile);
        OC.PrintFile = NULL;
        }

    if (journalfl)
        {
        fclose(journalfl);
        journalfl = NULL;
        }
#endif

    if (TrapFile)
        {
        fclose(TrapFile);
        TrapFile = NULL;
        }

    if (RoomFile)
        {
        fclose(RoomFile);
        RoomFile = NULL;
        }

    VerifyHeap(1);

    CitadelIsConfiguring = FALSE;

    return (TRUE);
    }