Exemple #1
0
int main()
{
	pthread_t threads[2];
	int retVal[2];
	retVal[0] = pthread_create(&threads[0], NULL, objectDetect, NULL);
	errorDisp(retVal[0]);
	retVal[1] = pthread_create(&threads[1], NULL, objectSearch, NULL);
	errorDisp(retVal[1]);
	pthread_exit(NULL);
	return 0;
}
Exemple #2
0
static void errorAndQuit(const char* errorStr){
	errorConf error;

	errorInit(&error, ERROR_TEXT, CFG_LANGUAGE_EN);
	errorText(&error, errorStr);
	errorDisp(&error);
	exit(0);
}
Exemple #3
0
void TERMWINDOWMEMBER purgeuserlog(void)
	{
	Bool done = FALSE;

	for (l_slot i = (l_slot) (cfg.MAXLOGTAB - 1); i >= 0 && !done; i--)
		{
		if (LTab(i).IsInuse())
			{
			label UserName;
			LTab(i).GetName(UserName, sizeof(UserName));

			if (!loggedIn || !CurrentUser->IsSameName(UserName))
				{
				char prompt[256];

				sprintf(prompt, getsysmsg(57), cfg.Luser_nym, UserName);

				const int response = getYesNo(prompt, 3);

				if (response == 1)
					{
					LogEntry1 Log1;

					Log1.Clear();

					if (Log1.Save(LTab(i).GetLogIndex()))
						{
                        if(!read_tr_messages())
                            {
                            errorDisp(getmsg(172));
                            done = TRUE;
                            return;
                            }
#ifdef WINCIT
                        trap(T_SYSOP, WindowCaption, gettrmsg(16), UserName);
#else
                        trap(T_SYSOP, gettrmsg(16), UserName);
#endif
                        dump_tr_messages();
						}
					}
				else if (response == 2)
					{
					done = TRUE;
					}
				}
			}
		}
	}
Exemple #4
0
Bool TERMWINDOWMEMBER killuser(const char *name)
	{
	label who;
	l_slot logno;
	char line[80];

	if (!name)
		{
		SetDoWhat(SYSKUSER);
		}

	if (name)
		{
		CopyStringToBuffer(who, name);
		}
	else
		{
		getNormStr(cfg.Luser_nym, who, LABELSIZE);
		}

	if (!*who)
		{
		return (FALSE);
		}

	logno = FindPersonByPartialName(who);

	if (logno == CERROR)
		{
		if (!name)
			{
			mPrintfCR(getmsg(595), who);
			}

		return (FALSE);
		}

	LTab(logno).GetName(who, sizeof(who));

	if (loggedIn && CurrentUser->IsSameName(who))
		{
		if (!name)
			{
			mPrintfCR(getsysmsg(83));
			}

		return (FALSE);
		}

	sprintf(line, getsysmsg(84), cfg.Luser_nym, who);

	if (!name && !getYesNo(line, 0))
		{
		return (FALSE);
		}
	else
		{
		LogEntry1 Log1;

		if (!name)
			{
			CRmPrintfCR(getsysmsg(85), who);
			}

		Log1.Clear();
		if (Log1.Save(LTab(logno).GetLogIndex()))
			{
            if(!(read_tr_messages()))
                {
                errorDisp(getmsg(172));
                return(FALSE);
                }

#ifdef WINCIT
            trap(T_SYSOP, WindowCaption, gettrmsg(16), who);
#else
            trap(T_SYSOP, gettrmsg(16), who);
#endif
            dump_tr_messages();
			}

		return (TRUE);
		}
	}
Exemple #5
0
static void initfiles(Bool *grpZap, Bool *hallZap, Bool *msgZap, Bool *logZap, Bool *log2Zap, Bool *log3Zap,
		Bool *log4Zap, Bool *log5Zap, Bool *log6Zap, Bool *roomZap, Bool *roomposZap)
	{
	FILE *aFile;

	changedir(cfg.homepath);

	if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\')
		{
		cfg.msgpath[(strlen(cfg.msgpath) - 1)] = 0;
		}

	autoConvert(grpDat, ((GroupEntry *) NULL)->SizeOfDiskRecord());
	autoConvert(logDat, LogDatRecordSize(*(LogDatStructure *) NULL));
	autoConvert(hallDat, ((HallEntry1 *) NULL)->SizeOfDiskRecord());
	autoConvert(roomDat, RoomC::GetDiskRecordSize());

	checkresize();

	// check group file
	if (!citOpen(grpDat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), grpDat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
		doccr();
#endif
		*grpZap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// check hall file
	if (!citOpen(hallDat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), hallDat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
		doccr();
#endif
		*hallZap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// check room pos file
	if (!citOpen(roomposDat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), roomposDat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
		doccr();
#endif
		*roomposZap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log file
	if (!citOpen(logDat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), logDat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*logZap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log2 file
	if (!citOpen(log2Dat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), log2Dat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*log2Zap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log3 file
	if (!citOpen(log3Dat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), log3Dat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*log3Zap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log4 file
	if (!citOpen(log4Dat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), log4Dat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*log4Zap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log5 file
	if (!citOpen(log5Dat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), log5Dat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*log5Zap = TRUE;
		}
	else
		{
		fclose(aFile);
		}

	// open log6 file
	if (!citOpen(log6Dat, CO_RPB, &aFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), log6Dat);
#endif
#ifndef WINCIT
		doccr();
#endif
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#endif
#ifndef WINCIT
		doccr();
#endif
		*log6Zap = TRUE;
		}
	else
		{
		fclose(aFile);
		}


#ifndef WINCIT
	if (logZap || log2Zap || log3Zap || log4Zap || log5Zap || log6Zap)
		{
		doccr();
		}
#endif

	// open message file
	if (!MessageDat.OpenMessageFile(cfg.msgpath))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), MessageDat.GetFilename());
#endif
#ifndef WINCIT
		doccr();
#endif

		if (!MessageDat.CreateMessageFile(cfg.msgpath))
			{
			illegal(getmsg(8), MessageDat.GetFilename());
			}
#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#else
        printf("problem with msg.dat\n");
#endif
#ifndef WINCIT
		doccr();
		doccr();
#endif
		*msgZap = TRUE;
		}

	// open room file
	if (!citOpen(roomDat, CO_RPB, &RoomFile))
		{
#ifdef WINCIT
		errorDisp(getcfgmsg(140), roomDat);
#endif
#ifndef WINCIT
		doccr();
#endif

		if (!citOpen(roomDat, CO_WPB, &RoomFile))
			{
			illegal(getmsg(8), roomDat);
			}

#ifdef WINCIT
		errorDisp(getcfgmsg(141));
#else
        printf("problem with room.dat\n");
#endif
#ifndef WINCIT
		doccr();
		doccr();
#endif
		*roomZap = TRUE;
		}
	}
Exemple #6
0
static void checkresize(void)
	{
	int fh;
	long result;
    char MsgFilePath[128];
	// save old values for later
	newmessagek = cfg.MsgDatSizeInK;
	newmaxrooms = cfg.maxrooms;
	newmaxhalls = cfg.maxhalls;
	newmaxlogtab = cfg.MAXLOGTAB;
	newmaxgroups = cfg.maxgroups;

	// check message file
	sprintf(MsgFilePath, sbs, cfg.msgpath, msgDat);
	fh = open(MsgFilePath, O_RDONLY);
	if (fh != -1)
		{
		if ((result = filelength(fh)) == 0)
			{
			close(fh);
			unlink(MsgFilePath);
			}
		else if (result != ((long) cfg.MsgDatSizeInK * 1024l))
			{
			resizeMsg = TRUE;
#ifdef WINCIT
			errorDisp(getcfgmsg(139), msgDat);
#endif
#ifndef WINCIT
			doccr();
#endif

			// set messagek to actual value
			cfg.MsgDatSizeInK = result / 1024l;
			close(fh);
			}
		else
			{
			close(fh);
			}
		}

	// check log file
	fh = open(logDat, O_RDONLY);
	if (fh != -1)
		{
		if ((result = filelength(fh)) == 0)
			{
			close(fh);
			unlink(logDat);
			unlink(log2Dat);
			unlink(log3Dat);
			unlink(log4Dat);
			unlink(log5Dat);
			unlink(log6Dat);
			}
		else if (result != ((long) cfg.MAXLOGTAB * (long) LogDatRecordSize(*(LogDatStructure *) NULL)) + (long) sizeof(long))
			{
			resizeLog = TRUE;
#ifdef WINCIT
			errorDisp(getcfgmsg(139), logDat);
#endif
#ifndef WINCIT
			doccr();
#endif

			// set MAXLOGTAB to actual value
			cfg.MAXLOGTAB = (l_slot) ((result - sizeof(long)) / (long) LogDatRecordSize(*(LogDatStructure *) NULL));
			close(fh);
			}
		else
			{
			close(fh);
			}
		}

	// check group file
	fh = open(grpDat, O_RDONLY);
	if (fh != -1)
		{
		if ((result = filelength(fh)) == 0)
			{
			close(fh);
			unlink(grpDat);
			}
		else if (result != ((long) cfg.maxgroups * (long) ((GroupEntry *) NULL)->SizeOfDiskRecord()) + (long) sizeof(long))
			{
			resizeGrp = TRUE;
#ifdef WINCIT
			errorDisp(getcfgmsg(139), grpDat);
#endif
#ifndef WINCIT
			doccr();
#endif

			// set maxgroups to actual value
			cfg.maxgroups = (g_slot) ((result - sizeof(long)) / (long) sizeof(GroupEntry));
			close(fh);
			}
		else
			{
			close(fh);
			}
		}

	// check room file
	fh = open(roomDat, O_RDONLY);
	if (fh != -1)
		{
		if ((result = filelength(fh)) == 0)
			{
			close(fh);
			unlink(roomDat);
			}
		else if (result != ((long) cfg.maxrooms * (long) RoomC::GetDiskRecordSize()) + (long) sizeof(long))
			{
			resizeRoom = TRUE;
#ifdef WINCIT
			errorDisp(getcfgmsg(139), roomDat);
#endif
#ifndef WINCIT
			doccr();
#endif

			// set maxrooms to actual value
			cfg.maxrooms = (r_slot) ((result - sizeof(long)) /
					(long) RoomC::GetDiskRecordSize());
			close(fh);
			}
		else
			{
			close(fh);
			}
		}

	// check hall file
	fh = open(hallDat, O_RDONLY);
	if (fh != -1)
		{
		if ((result = filelength(fh)) == 0)
			{
			close(fh);
			unlink(hallDat);
			unlink(hall2Dat);
			}
		else if (result != (long) cfg.maxhalls *  (long) ((HallEntry1 *) NULL)->SizeOfDiskRecord() + (long) sizeof(long))
			{
			resizeHall = TRUE;
#ifdef WINCIT
			errorDisp(getcfgmsg(139), hallDat);
#endif
#ifndef WINCIT
			doccr();
#endif

			// set maxhalls to actual value
			cfg.maxhalls = (h_slot) ((result - sizeof(long)) /
					(long) ((HallEntry1 *) NULL)->SizeOfDiskRecord());
			close(fh);
			}
		else
			{
			close(fh);
			}
		}

	if (resizeMsg || resizeLog || resizeRoom || resizeGrp || resizeHall)
		{
#ifndef WINCIT
		doccr();
#endif
		pause(200);
		}
	}
Exemple #7
0
static Bool initCitadel(void)
    {
    if (!read_cfg_messages())
        {
#ifdef WINCIT
        char Buffer[128];
        sprintf(Buffer, getmsg(188), getmsg(671));
        MessageBox(NULL, Buffer, NULL, MB_ICONSTOP | MB_OK);
#else
        printf(getmsg(188), getmsg(671));
#endif
        return (FALSE);
        }

    checkfiles();

    initExtDrivers();

    get_os();

	cfg.battr = 0xff;
    setscreen();

    logo(TRUE); // no go for debug version; td32 go crash crash

    init_internal_sound();

	// some mouse initialization technology!!!!
    initMouseHandler();
    hideCounter = 1;

    if (time(NULL) < 700000000L)
        {
#ifdef WINCIT
        MessageBox(NULL, getcfgmsg(119), NULL, MB_ICONSTOP | MB_OK);
#else
        doccr();
        doccr();
        cPrintf(getcfgmsg(119));
        doccr();
#endif
        dump_cfg_messages();
        return (FALSE);
        }


    static char prompt[92];
    static char citadel[92];
    char *envprompt;
    char *citprompt;

    envprompt = getenv(getcfgmsg(120));
    citprompt = getenv(getcfgmsg(121));
    if (citprompt)
        {
        sprintf(prompt, getcfgmsg(122), citprompt);
        }
    else if (envprompt)
        {
        sprintf(prompt, getcfgmsg(123), envprompt);
        }
    else
        {
        strcpy(prompt, getcfgmsg(124));
        }
    putenv(prompt);

    sprintf(citadel, getcfgmsg(125), programName, version);
    putenv(citadel);


#ifndef WINCIT
    OC.whichIO = CONSOLE;
    OC.SetOutFlag(OUTOK);
    OC.Echo = BOTH;
    OC.setio();
#endif

    VerifyHeap(1);

    // If we aren't reconfiguring, load the tables...
    if (!reconfig)
        {
        // Start by reading ETC.TAB
        getcwd(etcpath, 64);

        FILE *fd;
        if ((fd = fopen(etcTab, FO_RB)) != NULL)
            {
            if (filelength(fileno(fd)) != (long) sizeof(config) ||
					fread(&cfg, 1, sizeof(config), fd) != (long) sizeof(config))
                {
                memset(&cfg, 0, sizeof(cfg));
                reconfig = TRUE;
                }

            fclose(fd);
            unlink(etcTab);


            // If ETC.TAB could be loaded, load the rest
            if (!reconfig)
                {
                changedir(cfg.homepath);

                allocateTables();

                if (!LogTab.Load() || !MessageDat.LoadTable() || !RoomTab.Load())
                    {
                    reconfig = TRUE;
                    }

                Cron.ReadTable(WC_TWpn);
                }
            }
        else
            {
            if (!batchmode)
                {
#ifdef WINCIT
                MessageBox(NULL, "No ETC.TAB.", NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();

                discardable *d;

                if ((d = readData(6)) != NULL)
                    {
                    int i;

                    for (i = 0; ((char **) d->next->aux)[i][0] != '#'; i++)
                        {
                        cPrintf(pcts, ((char **) d->next->aux)[i]);
                        doccr();
                        }

                    doccr();

                    discardData(d);
                    }
                else
                    {
                    cOutOfMemory(28);
                    }

                DeinitializeTimer();
                critical(FALSE);
#endif
                exit(1);
                }

            reconfig = TRUE;
            }
        }



    if (reconfig)
        {
        cfg.attr = 7;

#ifndef WINCIT
        pause(200);
        cls(SCROLL_SAVE);

        cCPrintf(getcfgmsg(126));
        doccr();
#endif


        if (!configcit())
            {
#ifdef WINCIT
            MessageBox(NULL, getcfgmsg(127), NULL, MB_ICONSTOP | MB_OK);
#else
            doccr();
            doccr();
            cPrintf(getcfgmsg(127));
            doccr();
#endif
            dump_cfg_messages();
            return (FALSE);
            }


#ifndef WINCIT
        setdefaultTerm(TT_ANSI);
        CurrentUser->SetWidth(80);
#endif

        Cron.ReadCronCit(WC_TWpn);
        }
    else
        {
#ifndef WINCIT
        if (!CreateScrollBackBuffer())
            {
            cPrintf(getcfgmsg(60));
            doccr();
            }
#endif


        if (readconfigcit)  // forced to read in config.cit
            {
            if (!readconfig(NULL, 1))
                {
#ifdef WINCIT
                MessageBox(NULL, getcfgmsg(129), NULL, MB_ICONSTOP | MB_OK);
#else
                doccr();
                doccr();
                cPrintf(getcfgmsg(129));
                doccr();
#endif
                dump_cfg_messages();
                return (FALSE);
                }
            }
        }

    VerifyHeap(1);

    makeBorders();
    readBordersDat();

    if (cmd_nobells)
        {
        cfg.noBells = 2;
        }

    if (cmd_nochat)
        {
        cfg.noChat = TRUE;
        }

    if (cmd_mdata != CERROR)
        {
        cfg.mdata = cmd_mdata;
        }

    if (*cfg.f6pass)
        {
        if (SameString(cfg.f6pass, getmsg(670)))
            {
            ConsoleLock.LockF6();
            }
        else
            {
            ConsoleLock.Lock();
            }
        }


#ifndef WINCIT
    if (cfg.ovrEms)
        {
        if (_OvrInitEms(0, 0, 0))
            {
            cPrintf(getcfgmsg(130));
            doccr();
            pause(200);
            }
        }

    if (cfg.ovrExt)
        {
        if (_OvrInitExt(0, 0))
            {
            cPrintf(getcfgmsg(131));
            doccr();
            pause(200);
            }
        }

    CommPort->Init();
    setscreen();
#endif

    logo(TRUE); // no go for debug version; td32 go crash crash

#ifndef WINCIT
    StatusLine.Update(WC_TWp);
#endif

    if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\')
        {
        cfg.msgpath[(strlen(cfg.msgpath) - 1)] = '\0';
        }

    // move to home path
    changedir(cfg.homepath);
    char FileName[128];

    ReIndexFileInfo();  // keep fileinfo.dat nice and pretty

    // open message file
    if (!MessageDat.OpenMessageFile(cfg.msgpath))
		{
		illegal(getmsg(78), MessageDat.GetFilename());
		}

    // Then room file
    sprintf(FileName, sbs, cfg.homepath, roomDat);
    openFile(FileName, &RoomFile);

    citOpen(cfg.trapfile, CO_A, &TrapFile);
    initMenus();
    dump_cfg_messages();

    if(!read_tr_messages())
        {
        errorDisp(getmsg(172));
        }
    else
        {
#ifdef WINCIT
    trap(T_SYSOP, "", gettrmsg(37));
#else
    trap(T_SYSOP, gettrmsg(37));
#endif
        dump_tr_messages();
        }

        read_cfg_messages();            // uh-oh!

    if (!GroupData.Load())
        {
        return (FALSE);
        }

    if (!HallData.Load())
        {
        return (FALSE);
        }

    getRoomPos();

    if (cfg.accounting)
        {
        ReadGrpdataCit(WC_TWpn);
        }

    ReadExternalCit(WC_TWpn);
    ReadProtocolCit(WC_TWpn);
    ReadMdmresltCit(WC_TWpn);
    ReadCommandsCit(WC_TWpn);


#ifndef WINCIT
    ReadMCICit(FALSE);

    CurrentRoom->Load(LOBBY);
    thisRoom = LOBBY;
    checkdir();

    if (!slv_door)
        {
        CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19));

        Initport();
        Initport();

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }
    else
        {
        CommPort->Enable();
        }

    OC.whichIO = MODEM;
    OC.setio();
#endif


    // record when we put system up
    time(&uptimestamp);

#ifndef WINCIT
    setdefaultconfig(FALSE);
    Talley->Fill();
#endif
    logo(FALSE);

    VerifyHeap(1);

    dump_cfg_messages();
    compactMemory(1);

    return (TRUE);
    }
Exemple #8
0
void TERMWINDOWMEMBER terminate(Bool discon)
    {
    char dtstr[80];
    Bool initport = FALSE;

    if (!altF3Timeout && (cfg.chatmail == 2 && chatReq) || (cfg.chatmail == 3) || (cfg.chatmail == 4))
        {
        if (cfg.chatmail == 2)
            {
            dispBlb(B_CHATTED);
            }

        Message *Msg = new Message;

        if (Msg)
            {
            msgtosysop(Msg);
            delete Msg;
            }
        else
            {
            OutOfMemory(41);
            }
        }

    if (loggedIn && onConsole)
        {
        last_console_login_callno = cfg.callno;
        }

    chatReq = FALSE;
    const Bool doStore = HaveConnectionToUser();

    if (discon || !doStore)
        {
        sysopNew = FALSE;
        }

    const long balance = CurrentUser->GetCredits();

    OC.SetOutFlag(OUTOK);

    if ((doStore && (MRO.Verbose == 2)) || CurrentUser->IsAutoVerbose() || CurrentUser->IsVerboseLogOut() ||
            CurrentUser->IsNode())
        {
        if (CurrentUser->IsNode())
            {
            OC.SetOutFlag(IMPERVIOUS);  // no carrier
            }

        CRmPrintfCR(getmsg(119), ltoac(cfg.callno));
        if (loggedIn)
           {
           mPrintfCR(getmsg(118), diffstamp(logtimestamp));
           }
        label Entered, L;
        CopyStringToBuffer(Entered, ltoac(MS.Entered));
        mPrintfCR(getmsg(117), Entered, MS.Entered == 1 ? cfg.Lmsg_nym : cfg.Lmsgs_nym, ltoac(MS.Read));

        if (cfg.accounting && CurrentUser->IsAccounting())
            {
            long C = (CurrentUserAccount->GetBalanceAtLogin() - balance) / 60;

            mPrintfCR(getmsg(116), ltoac(C), (C == 1) ? cfg.Lcredit_nym : cfg.Lcredits_nym, L);

            C = balance / 60;

            mPrintfCR(getmsg(115), ltoac(C), (C == 1) ? cfg.Lcredit_nym : cfg.Lcredits_nym);
            }

        char Buffer[64];
        strftime(dtstr, 79, (loggedIn) ? CurrentUser->GetVerboseDateStamp(Buffer, sizeof(Buffer)) : cfg.vdatestamp, 0l);
        }

    if (doStore && MRO.Verbose)
        {
        goodbye();
        }

    OC.SetOutFlag(IMPERVIOUS);

    label Buffer;
    if (loggedIn)
        {
        if ((MRO.Verbose == 2) || CurrentUser->IsAutoVerbose() || CurrentUser->IsVerboseLogOut() || CurrentUser->IsNode())
            {
            CRmPrintfCR(getmsg(614), CurrentUser->GetName(Buffer, sizeof(Buffer)), dtstr);
            }
        else
            {
            CRmPrintfCR(getmsg(114), CurrentUser->GetName(Buffer, sizeof(Buffer)));
            }
        }

    // Go back to the default hall
    thisHall = HallData.GetDefault();

    if (discon)
        {
#ifdef WINCIT
        switch(CommPort->GetType())
            {
            case CT_SERIAL:
                {
                initport = TRUE;
                break;
                }

            case CT_TELNET:
                {
                initport = FALSE;
                break;
                }

            default:
                {
                initport = FALSE;
                break;
                }
            }
#endif

        if (CommPort->HaveConnection())
            {
            CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(82));

            Hangup();

            if (w)
                {
                destroyCitWindow(w, FALSE);
                }
            }

        //OC.whichIO = MODEM; // I really don't know
        //OC.setio();
        }

    if (!slv_door && !CommPort->HaveConnection())
        {
        CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(19));

#ifdef WINCIT
        if(initport)
#endif
            {
            Initport();
            }

        if (w)
            {
            destroyCitWindow(w, FALSE);
            }
        }

    CurrentUser->SetInRoom(thisRoom, TRUE);

    if (!doStore) // if carrier dropped
        {
        if(!read_tr_messages())
            {
            errorDisp(getmsg(172));
            }

#ifdef WINCIT
        trap(T_CARRIER, WindowCaption, gettrmsg(19), WindowCaption);
#else
        trap(T_CARRIER, gettrmsg(19));
#endif
        dump_tr_messages();
        }

    // update new pointer only if carrier not dropped
    if (loggedIn && doStore)
        {
        CurrentUser->SetRoomNewPointer(thisRoom, MessageDat.NewestMessage());
        }

    if (loggedIn)
        {
        CurrentUser->SetCallNumber(cfg.callno);
        CurrentUser->SetCallTime(logtimestamp);

        // for the Minibin() function to calculate #new messages
        CurrentUser->SetLastMessage(MessageDat.NewestMessage());

        CurrentUser->SetTotalTime(CurrentUser->GetTotalTime() + (time(NULL) - logtimestamp));

        CurrentUser->SetLogins(CurrentUser->GetLogins() + 1);
        CurrentUser->SetPosted(CurrentUser->GetPosted() + MS.Entered);
        CurrentUser->SetRead(CurrentUser->GetRead() + MS.Read);

        CurrentUser->Save(ThisLog, thisRoom);

        // this stuff puts the current room at the end of jumpback,
        // so J will take you back here.
        jumpback jb;

        jb.hall = thisHall;
        jb.room = thisRoom;
        jb.newpointer = CurrentUser->GetRoomNewPointer(thisRoom);
        jb.bypass = Talley->Bypassed(thisRoom);
        jb.newMsgs = Talley->NewInRoom(thisRoom);

        CurrentUser->JumpbackPush(jb);

#ifdef MULTI
        char LogoffEvent[256];
        label NameBuffer;

        sprintf(LogoffEvent, doStore ? getmsg(665) : getmsg(29), CurrentUser->GetName(NameBuffer, sizeof(NameBuffer)));
        TermWindowCollection.SystemEvent(SE_LOGONOFF, FALSE, NULL, FALSE, LogoffEvent);
#endif

        loggedIn = FALSE;

        if (CurrentUser->IsPrintFile() && OC.Printing)
            {
            OC.Printing = OC.WasPrinting;

            if (!OC.Printing)
                {
                fclose(OC.PrintFile);
                }
            }

        // trap it
        if (CurrentUser->IsNode())
            {
            if (netError)
                {
                Bool OldTrapit = cfg.trapit[T_NETWORK];

                if (node->GetNetFail() > 0)
                    {
                    cfg.trapit[T_NETWORK] = TRUE;
                    }
                else if (node->GetNetFail() < 0)
                    {
                    cfg.trapit[T_NETWORK] = FALSE;
                    }

#ifdef WINCIT
                trap(T_NETWORK, WindowCaption, getmsg(606), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
                trap(T_NETWORK, getmsg(606), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif

                cfg.trapit[T_NETWORK] = OldTrapit;
                }
            else
                {
#ifdef WINCIT
                trap(T_NETWORK, WindowCaption, getmsg(22), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
                trap(T_NETWORK, getmsg(22), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif
                }
            }
        else
            {
            doEvent(EVT_LOGOUT);
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifdef WINCIT
            trap(T_LOGIN, WindowCaption, gettrmsg(24), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#else
            trap(T_LOGIN, gettrmsg(24), CurrentUser->GetName(Buffer, sizeof(Buffer)));
#endif
            dump_tr_messages();
            }

        const TrapKeywords TrapType = CurrentUser->IsNode() ? T_NETWORK : T_ACCOUNT;
        if(!read_tr_messages())
            {
            errorDisp(getmsg(172));
            }
#ifndef WINCIT
        trap(TrapType, gettrmsg(25), MS.Entered);
        trap(TrapType, gettrmsg(26), MS.Read);
#else
        trap(TrapType, WindowCaption, gettrmsg(25), MS.Entered);
        trap(TrapType, WindowCaption, gettrmsg(26), MS.Read);
#endif
        dump_tr_messages();

        if (CurrentUser->IsNode())
            {
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifndef WINCIT
            trap(T_NETWORK, gettrmsg(20), MS.Expired);
            trap(T_NETWORK, gettrmsg(21), MS.Duplicate);
#else
            trap(T_NETWORK, WindowCaption, gettrmsg(20), MS.Expired);
            trap(T_NETWORK, WindowCaption, gettrmsg(21), MS.Duplicate);
#endif
            dump_tr_messages();
            }
        else if (cfg.accounting)    // There's just no accounting for nodes
            {
            if(!read_tr_messages())
                {
                errorDisp(getmsg(172));
                }
#ifdef WINCIT
            trap(T_ACCOUNT, WindowCaption, gettrmsg(27), CurrentUserAccount->GetBalanceAtLogin() - balance);
#else
            trap(T_ACCOUNT, gettrmsg(27), CurrentUserAccount->GetBalanceAtLogin() - balance);
#endif
            dump_tr_messages();
            }

        delete MS.AbortedMessage;
        MS.AbortedMessage = NULL;

#ifdef MULTI
        LoginList.Remove(ThisLog);
#endif
        }

    setdefaultconfig(FALSE);

    if (discon)
        {
        setdefaultTerm(TT_ANSI);
        }
    else
        {
        setdefaultTerm(TT_DUMB);
        }

    CurrentUser->SetCredits(discon ? 0L : cfg.unlogtimeout * 60L);
    StatusLine.Update(WC_TWp);

    Talley->Fill();

    CurrentRoom->Load(LOBBY);
    checkdir();
    thisRoom = LOBBY;

    AideQueueClear();
    clearFileQueue();
    MS.AutoMKC = AM_NONE;
    MS.MarkedID = 0L;

    freeNode(&node);
    netError = FALSE;   // just in case

    Cron.ResetTimer();
    }