/* * getLog() * * This loads requested log record into the specified RAM buffer. */ void getLog(logBuffer *lBuf, int n) { long int s, r; if (lBuf == &logBuf) thisLog = n; r = LB_TOTAL_SIZE; /* To get away from overflows */ s = n * r; /* This should be offset */ n *= 3; fseek(logfl, s, 0); if (fread(lBuf, LB_SIZE, 1, logfl) != 1) { crashout("?getLog-read fail//EOF detected (1)!"); } crypte(lBuf, LB_SIZE, n); /* decode buffer */ if (fread(lBuf->lbrgen, GEN_BULK, 1, logfl) != 1) { crashout("?getLog-read fail//EOF detected (2)!"); } if (fread(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) { crashout("?getLog-read fail//EOF detected (3)!"); } if (fread(lBuf->lastvisit, RM_BULK, 1, logfl) != 1) { crashout("?getLog-read fail//EOF detected (4)!"); } }
/* * putLog() * * This function stores the given log record into ctdllog.sys. */ void putLog(logBuffer *lBuf, int n) { long int s, r; r = LB_TOTAL_SIZE; s = n * r; n *= 3; crypte(lBuf, LB_SIZE, n); /* encode buffer */ fseek(logfl, s, 0); if (fwrite(lBuf, LB_SIZE, 1, logfl) != 1) { crashout("?putLog-write fail (1)!"); } if (fwrite(lBuf->lbrgen, GEN_BULK, 1, logfl) != 1) { crashout("?putLog-write fail (2)!"); } if (fwrite(lBuf->lbMail, MAIL_BULK, 1, logfl) != 1) { crashout("?putLog-write fail (3)!"); } if (fwrite(lBuf->lastvisit, RM_BULK, 1, logfl) != 1) { crashout("?putLog-write fail (4)!"); } crypte(lBuf, LB_SIZE, n); /* encode buffer */ fflush(logfl); }
void allocateTables(void) { logTab = _fcalloc(cfg.MAXLOGTAB+1, sizeof(struct lTable)); if (logTab == NULL) crashout("Error allocating logTab \n"); #ifdef NEWMSGTAB createMsgTab(); #else msgTab_mtmsgflags = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtmsgflags)); msgTab_mtmsgLocLO = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtmsgLocLO)); msgTab_mtmsgLocHI = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtmsgLocHI)); msgTab_mtroomno = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtroomno)); msgTab_mttohash = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mttohash)); msgTab_mtauthhash = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtauthhash)); msgTab_mtomesg = _fcalloc(cfg.nmessages+1, sizeof(*msgTab_mtomesg)); if (msgTab_mtmsgflags == NULL || msgTab_mtmsgLocLO == NULL || msgTab_mtmsgLocHI == NULL || msgTab_mtroomno == NULL || msgTab_mttohash == NULL || msgTab_mtauthhash == NULL || msgTab_mtomesg == NULL ) crashout("Error allocating msgTab \n"); #endif if ( ((lBuf2 = _fcalloc(1, sizeof(struct logBuffer ))) == NULL) || ((talleyBuf=_fcalloc(1, sizeof(struct talleyBuffer))) == NULL) || ((doors = _fcalloc(MAXDOORS, sizeof(struct ext_door ))) == NULL) || ((edit = _fcalloc(MAXEXTERN, sizeof(struct ext_editor))) == NULL) || ((hallBuf = _fcalloc(1, sizeof(struct hallBuffer))) == NULL) || ((extrn = _fcalloc(MAXEXTERN, sizeof(struct ext_prot ))) == NULL) || ((roomTab = _fcalloc(MAXROOMS, sizeof(struct rTable ))) == NULL) || ((msgBuf = _fcalloc(1, sizeof(struct msgB ))) == NULL) || ((msgBuf2 = _fcalloc(1, sizeof(struct msgB ))) == NULL) #ifdef NEWMSGTAB || ((roomPos = _fcalloc(MAXROOMS, 2 )) == NULL) #else || ((roomPos = _fcalloc(MAXROOMS, 1 )) == NULL) #endif ) { crashout("Can not allocate space for tables"); } }
void putLog(struct logBuffer *lBuf, int n) { long int s; int i; s = (long)n * (long)(sizeof(struct logBuffer)); fseek(logfl, s, 0); if (fwrite(lBuf, sizeof logBuf, 1, logfl) != 1) { crashout("putLog-write fail!"); } fflush(logfl); for ( i = 0; i < cfg.MAXLOGTAB; i++) { if (n == logTab[i].ltlogSlot) { log2tab(&logTab[i], lBuf); logTab[i].ltlogSlot = n; break; } } }
/* -------------------------------------------------------------------- */ static BOOL alias_route(char *str, const char *srch) { FILE *fBuf; char line[90]; char *words[256]; char path[80]; sprintf(path, "%s\\route.cit", cfg.homepath); if ((fBuf = fopen(path, "r")) == NULL) /* ASCII mode */ { crashout("Can't find route.cit!"); } while (fgets(line, 90, fBuf) != NULL) { if (line[0] != '#') continue; if (strnicmp(line, srch, 5) != SAMESTRING) continue; parse_it( words, line); if (strcmpi(srch, words[0]) == SAMESTRING) { if (strcmpi(str, words[1]) == SAMESTRING) { fclose(fBuf); strcpy(str, words[2]); return TRUE; } } } fclose(fBuf); return FALSE; }
void putHall(void) { fseek(hallfl, 0L, 0); if ( fwrite(hallBuf, sizeof (struct hallBuffer), 1, hallfl) != 1) { crashout("putHall-write fail!"); } if ( fwrite(roomPos, MAXROOMS, 1, hallfl) != 1) { crashout("putHall-write fail!"); } fflush(hallfl); }
void getHall(void) { int i; fseek(hallfl, 0L, 0); if (fread(hallBuf, sizeof (struct hallBuffer), 1, hallfl) != 1) { crashout("getHall-EOF detected!"); } #ifdef NEWMSGTAB if (fread(roomPos, MAXROOMS, 2, hallfl) != 2) #else if (fread(roomPos, MAXROOMS, 1, hallfl) != 1) #endif { cPrintf("\nCreating room position table.\n"); for (i=0; i<MAXROOMS; i++) roomPos[i] = i; putHall(); } }
/* -------------------------------------------------------------------- */ void amPrintf(char *fmt,...) { va_list ap; char *temp; if((temp = calloc(90, sizeof(char))) == NULL) { return; } flipFileLan(cfg->temppath,1); /* no message in progress? */ if (aideFl == NULL) { sprintf(temp, "%s\\%s", cfg->temppath, "aidemsg.tmp"); unlink(temp); if ((aideFl = fopen(temp, "w")) == NULL) { crashout("Can not open AIDEMSG.TMP!"); } } free(temp); flipFileLan(cfg->temppath,0); va_start(ap, fmt); vfprintf(aideFl, fmt, ap); va_end(ap); }
/* -------------------------------------------------------------------- */ void openFile(char *filename, FILE ** fd) { /* open message file */ if ((*fd = fopen(filename, "r+b")) == NULL) { crashout(".DAT file missing!"); } }
/* * getMsgChar() * * This function returns sequential chars from CtdlMsg.Sys. */ int getMsgChar() { long work; int toReturn; if (GMCCache) { /* someone did an unGetMsgChar() --return it */ toReturn= GMCCache; GMCCache= '\0'; return (toReturn & 0xFF); } mFile1.oldChar = mFile1.thisChar; mFile1.oldSector = mFile1.thisSector; toReturn = mFile1.sectBuf[mFile1.thisChar]; toReturn &= 0xFF; /* Only want the lower 8 bits */ mFile1.thisChar = ++mFile1.thisChar % MSG_SECT_SIZE; if (mFile1.thisChar == 0) { /* time to read next sector in: */ mFile1.thisSector = ++mFile1.thisSector % cfg.maxMSector; work = mFile1.thisSector; work *= MSG_SECT_SIZE; fseek(msgfl, work, 0); if (fread(mFile1.sectBuf, MSG_SECT_SIZE, 1, msgfl) != 1) { crashout("?nextMsgChar-read fail"); } crypte(mFile1.sectBuf, MSG_SECT_SIZE, 0); } return(toReturn); }
void getRoom(int rm) { long int s; /* load room #rm into memory starting at buf */ thisRoom = rm; s = (long)rm * (long)sizeof roomBuf; fseek(roomfl, s, 0); if (fread(&roomBuf, sizeof roomBuf, 1, roomfl) != 1) { crashout("getRoom-EOF detected!"); } #ifdef GOODBYE if (roomBuf.rbflags.MSDOSDIR) { if (changedir(roomBuf.rbdirname) == -1) { roomBuf.rbflags.MSDOSDIR = FALSE; roomBuf.rbflags.DOWNONLY = FALSE; noteRoom(); putRoom(rm); sprintf(msgBuf->mbtext, "%s>'s directory unfound.\n Directory: %s\n", roomBuf.rbname, roomBuf.rbdirname); aideMessage(); } } #endif }
/* ------------------------------------------------------------------------ */ static int directory_l(char *str) { FILE *fBuf; char line[90]; char *words[256]; char path[80]; sprintf(path, "%s\\external.cit", cfg.homepath); if ((fBuf = fopen(path, "r")) == NULL) /* ASCII mode */ { crashout("Can't find route.cit!"); } while (fgets(line, 90, fBuf) != NULL) { if (line[0] != '#') continue; if (strnicmp(line, "#DIRE", 5) != SAMESTRING) continue; parse_it( words, line); if (strcmpi(words[0], "#DIRECTORY") == SAMESTRING) { if (u_match(str, words[1])) { fclose(fBuf); return TRUE; } } } fclose(fBuf); return FALSE; }
void getGroup(void) { fseek(grpfl, 0L, 0); if (fread(&grpBuf, sizeof grpBuf, 1, grpfl) != 1) { crashout("getGroup-EOF detected!"); } }
void putGroup(void) { fseek(grpfl, 0L, 0); if (fwrite(&grpBuf, sizeof grpBuf, 1, grpfl) != 1) { crashout("putGroup-write fail!"); } fflush(grpfl); }
void writeTables(void) { FILE *fd; changedir(etcpath); if ((fd = fopen("etc.dat" , "wb")) == NULL) { crashout("Can't make Etc.dat"); } /* write out Etc.dat */ fwrite(&cfg, sizeof cfg, 1, fd); fclose(fd); changedir(cfg.homepath); if ((fd = fopen("log.tab" , "wb")) == NULL) { crashout("Can't make Log.tab"); } /* write out Log.tab */ fwrite(logTab, sizeof(struct lTable), cfg.MAXLOGTAB, fd); fclose(fd); writeMsgTab(); if ((fd = fopen("room.tab", "wb")) == NULL) { crashout("Can't make Room.tab"); } /* write out Room.tab */ fwrite(roomTab, sizeof(struct rTable), MAXROOMS, fd); fclose(fd); /* new cron.tab stuff */ writeCrontab(); /* end of new cron.tab stuff */ changedir(etcpath); }
void writeTables(void) { FILE *fd; int i; changedir(etcpath); if ((fd = fopen("etc.dat" , "wb")) == NULL) { crashout("Can't make ETC.DAT"); } /* write out ETC.DAT */ fwrite(&cfg, sizeof cfg, 1, fd); fclose(fd); changedir(cfg.homepath); if ((fd = fopen("log.tab" , "wb")) == NULL) { crashout("Can't make LOG.TAB"); } /* write out LOG.TAB */ fwrite(logTab, sizeof(struct lTable), cfg.MAXLOGTAB, fd); fclose(fd); writeMsgTab(); if ((fd = fopen("room.tab", "wb")) == NULL) { crashout("Can't make ROOM.TAB"); } /* write out ROOM.TAB */ fwrite(roomTab, sizeof(struct rTable), MAXROOMS, fd); fclose(fd); #ifdef CRON writecrontab(); #endif changedir(etcpath); }
void putHall(void) { fseek(hallfl, 0L, 0); if ( fwrite(hallBuf, sizeof (struct hallBuffer), 1, hallfl) != 1) { crashout("putHall-write fail!"); } #ifdef NEWMSGTAB if ( fwrite(roomPos, MAXROOMS, 2, hallfl) != 2) #else if ( fwrite(roomPos, MAXROOMS, 1, hallfl) != 1) #endif { crashout("putHall-write fail!"); } fflush(hallfl); }
void putRoom(int rm) { long int s; s = (long)rm * (long)sizeof roomBuf; fseek(roomfl, s, 0); if (fwrite(&roomBuf, sizeof roomBuf, 1, roomfl) != 1) { crashout("putRoom-write failed!"); } fflush(roomfl); }
void getLog(struct logBuffer *lBuf, int n) { long int s; if (lBuf == &logBuf) thisLog = n; s = (long)n * (long)sizeof logBuf; fseek(logfl, s, 0); if (fread(lBuf, sizeof logBuf, 1, logfl) != 1) { crashout("getLog-EOF detected!"); } }
/* -------------------------------------------------------------------- */ void SaveAideMess(void) { char *temp; FILE *fd; if((temp = calloc(90, sizeof(char))) == NULL) { return; } flipFileLan(cfg->temppath,1); sprintf(temp, "%s\\%s", cfg->temppath, "aidemsg.tmp"); if (aideFl == NULL) { flipFileLan(cfg->temppath,0); return; } fclose(aideFl); if ((fd = fopen(temp, "rb")) == NULL) { crashout("AIDEMSG.TMP file not found during aide message save!"); } clearmsgbuf(); GetStr(fd, msgBuf->mbtext, cfg->maxtext); fclose(fd); unlink(temp); aideFl = NULL; free(temp); flipFileLan(cfg->temppath,0); if (strlen(msgBuf->mbtext) < 10) return; strcpy(msgBuf->mbauth, cfg->nodeTitle); msgBuf->mbroomno = AIDEROOM; putMessage(); noteMessage(); }
/* * startAt() * * This function sets the location to begin reading a message from. This is * usually only the sector, since byte offset within the sector is not * saved. */ void startAt(FILE *whichmsg, struct mBuf *mFile, SECTOR_ID sect, int byt) { long temp; GMCCache = '\0'; /* cache to unGetMsgChar() into */ if (sect >= cfg.maxMSector) { printf("?startAt s=%u,b=%d", sect, byt); return ; /* Don't crash anymore, just skip the msg */ } mFile->thisChar = byt; mFile->thisSector = sect; temp = sect; temp *= MSG_SECT_SIZE; fseek(whichmsg, temp, 0); if (fread(mFile->sectBuf, MSG_SECT_SIZE, 1, whichmsg) != 1) { crashout("?startAt read fail"); } crypte(mFile->sectBuf, MSG_SECT_SIZE, 0); }
void saveNewReality (struct messNode *nodeArray, char *room, int iTopNode) { int hInFile, hOutFile, i ; char buf[256], originalBuf[256], *words[16], *curnode = NULL ; BOOL shouldBePresent, present ; sprintf (buf, "%s\\NODES.CIT", cfg.homepath) ; hInFile = sopen (buf, O_TEXT | O_RDONLY, SH_DENYNO) ; sprintf (buf, "%s\\NODES.!!!", cfg.homepath) ; unlink (buf) ; hOutFile = sopen (buf, O_CREAT | O_TEXT | O_WRONLY, SH_DENYNO, S_IREAD | S_IWRITE) ; if (-1 == hInFile) crashout ("Problem opening NODES.CIT. Snorp.") ; if (-1 == hOutFile) crashout ("Problem opening NODES.!!!. Foom.") ; /* When we identify a #NODE, a BOOL tells us whether that #NODE shares */ /* room. If not, and the room is found, it's not passed through to */ /* the temporary file. If so, and the roomname ISN'T found before the */ /* next #NODE, it is ADDED just before the next #NODE (or EOF). */ originalBuf[0] = '\0' ; while ( !eof(hInFile) ) { /* In every loop, the first thing we do is write the line from the */ /* PREVIOUS loop around. */ write (hOutFile, originalBuf, strlen (originalBuf)) ; if (!sfgets (buf, 255, hInFile)) break ; /* Error reading file. */ strcpy (originalBuf, buf) ; if ('#' != buf[0]) /* It's not a keyword. */ continue ; parse_it (words, buf) ; /* We are only concerned about #NODE and #ROOM. If we're reading */ /* #NODE line, first check whether a #ROOM line needs to be added */ /* for the previous node. */ if (SAMESTRING == stricmp (words[0], "#NODE")) { addRoomIfShould (curnode, shouldBePresent, present, room, hOutFile) ; /* In any event, find the node's memory bro and fill in BOOLs. */ for (i = 0; i <= iTopNode; i++) if (SAMESTRING == stricmp (nodeArray[i].nodeName, words[1])) break ; if (i > iTopNode) /* Couldn't find node in memory. */ { curnode = NULL ; continue ; } present = FALSE ; shouldBePresent = nodeArray[i].fShared ; curnode = nodeArray[i].nodeName ; } /* If present is TRUE, we don't need to worry about parsing the */ /* rest of the #ROOMs, but instead will sit around until another */ /* #NODE comes along. But if present is false, is this line the */ /* room we're looking for? And should we remove it? */ if (present) continue ; if (SAMESTRING == stricmp (words[0], "#ROOM")) if (SAMESTRING == stricmp (words[1], room)) { present = TRUE ; /* If we've found it and wished we hadn't, nuke the buffer */ /* and end, so nothing gets written. */ if (!shouldBePresent) originalBuf[0] = '\0' ; } } /* Now that we're out of the file, we need to call addRoomIfShould */ /* once more to add a #ROOM line to the last node in the nodes file, */ /* if necessary. And finally, write the last line of the file */ addRoomIfShould (curnode, shouldBePresent, present, room, hOutFile) ; write (hOutFile, originalBuf, strlen (originalBuf)) ; close (hInFile) ; if (0 == close (hOutFile)) /* SUccessful close. Rename... */ { sprintf (buf, "%s\\NODES.CIT", cfg.homepath) ; sprintf (originalBuf, "%s\\NODES.!!!", cfg.homepath) ; unlink (buf) ; rename (originalBuf, buf) ; } else cPrintf ("Unable to close NODES.!!! Spork.") ; }
// -------------------------------------------------------------------------- // resizemsgfile(): Resizes message file. void MessageDatC::Resize(long NewSizeInBytes) { Lock(); Message *Msg = new Message; if (Msg) { char MsgFilePath2[128]; FILE *oldmsg; FILE *newmsg; const char *msgTmp = getcfgmsg(219); sprintf(MsgFilePath2, sbs, cfg.msgpath, msgTmp); if (MsgDat) { fclose(MsgDat); MsgDat = NULL; } if (!citOpen(MsgFilePath2, CO_WPB, &MsgDat)) { illegal(getmsg(8), getcfgmsg(192)); } InitializeMessageFile(NewSizeInBytes); catLoc = 0l; fclose(MsgDat); MsgDat = NULL; // open first message file if (!citOpen(MsgFilePath, CO_RPB, &oldmsg)) { msgDisp(getmsg(78), MsgFilePath); doccr(); delete Msg; Unlock(); return; } // open temp message file if (!citOpen(MsgFilePath2, CO_RPB, &newmsg)) { msgDisp(getmsg(78), MsgFilePath2); doccr(); fclose(oldmsg); delete Msg; Unlock(); return; } for (m_index ID = OldestMessageInTable(); ID <= NewestMessage(); ID++) { MsgDat = oldmsg; if (LoadAll(ID, Msg) != RMS_OK) { continue; } const m_index here = atol(Msg->GetLocalID()); if (here != ID) { continue; } msgDisp(getcfgmsg(193), cfg.Lmsg_nym, ltoac(here)); cPrintfDOS(br); MsgDat = newmsg; ResizeStore(Msg); } doccr(); doccr(); fclose(oldmsg); fclose(newmsg); MsgDat = NULL; int result = unlink(MsgFilePath); if (result == -1) { msgDisp(getcfgmsg(187), msgDat); doccr(); } result = rename(MsgFilePath2, MsgFilePath); if (result == -1) { msgDisp(getcfgmsg(188), msgTmp); doccr(); } delete Msg; if (!OpenMessageFile(cfg.msgpath)) { illegal(getmsg(78), MsgFilePath); } } else { crashout(getmsg(188), getcfgmsg(172)); } #ifdef WINCIT msgDisp(NULL); // msgCaption(ns); #endif Unlock(); }
readTables() { FILE *fd; getcwd(etcpath, 64); /* * ETC.DAT */ if ((fd = fopen("etc.dat" , "rb")) == NULL) return(FALSE); if (!fread(&cfg, sizeof cfg, 1, fd)) { fclose(fd); return FALSE; } fclose(fd); unlink("etc.dat"); changedir(cfg.homepath); allocateTables(); if (logTab == NULL) crashout("Error allocating logTab \n"); if (msgTab1 == NULL || msgTab2 == NULL || /* msgTab3 == NULL || */ msgTab4 == NULL || msgTab5 == NULL || msgTab6 == NULL || msgTab7 == NULL || msgTab8 == NULL /*|| msgTab9 == NULL */) crashout("Error allocating msgTab \n"); /* * LOG.TAB */ if ((fd = fopen("log.tab" , "rb")) == NULL) return(FALSE); if (!fread(logTab, sizeof(struct lTable), cfg.MAXLOGTAB, fd)) { fclose(fd); return FALSE; } fclose(fd); unlink("log.tab" ); /* * MSG.TAB */ if (readMsgTab() == FALSE) return FALSE; /* * ROOM.TAB */ if ((fd = fopen("room.tab", "rb")) == NULL) return(FALSE); if (!fread(roomTab, sizeof(struct rTable), MAXROOMS, fd)) { fclose(fd); return FALSE; } fclose(fd); unlink("room.tab"); return(TRUE); }
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); }
void startUp(int argc, const char *argv[]) { #if __BORLANDC__ >= 1106 set_new_handler(0); #endif strcpy(fullExePath, argv[0]); #ifndef WINCIT fseek(stdin, 0, SEEK_CUR); // Borland says to fseek() before setbuf() setbuf(stdin, NULL); #endif #ifndef WINCIT #ifdef MULTI if (!initTaskInfo(&ti)) #else cfg.maxrooms = 0 ; if (!initFakeTaskInfo()) #endif { printf("Could not create initial task information structure.\n"); exit(200); } #endif tzset(); critical(TRUE); #ifndef WINCIT if (checkDataVer() != NumericVer) { printf("CTDL.DAT is version %d; version %d needed.\n", checkDataVer(), NumericVer); critical(FALSE); exit(200); } if (!read_messages()) { printf("Could not read messages from CTDL.DAT\n"); critical(FALSE); exit(200); } InitializeTimer(); #else if (checkDataVer() != NumericVer) { char bbb[100]; sprintf(bbb, "CTDL.DAT is version %d; version %d needed.", checkDataVer(), NumericVer); MessageBox(NULL, bbb, NULL, MB_ICONSTOP | MB_OK); exit(200); } if (!read_messages()) { MessageBox(NULL, "Could not read messages from CTDL.DAT.", NULL, MB_ICONSTOP | MB_OK); exit(200); } WNDCLASS wndclass; // define and register the main window class wndclass.style = 0; // CS_HREDRAW | CS_VREDRAW wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, "CITADEL"); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // define and register the logo window class wndclass.lpszMenuName = NULL; wndclass.lpfnWndProc = logoWndProc; wndclass.lpszClassName = "Citadel Logo"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register logo window", NULL, MB_ICONSTOP | MB_OK); exit(200); } #ifdef NAHERROR // define and register the error window class wndclass.style = CS_VREDRAW; wndclass.lpfnWndProc = errorWndProc; wndclass.lpszClassName = "Citadel Error"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register error window", NULL, MB_ICONSTOP | MB_OK); exit(200); } // define and register the msg window class wndclass.lpfnWndProc = msgWndProc; wndclass.lpszClassName = "Citadel Message"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register msg window", NULL, MB_ICONSTOP | MB_OK); exit(200); } #endif #endif // initialize all drivers to internal functions #ifdef WINCIT // com // initrs = (void (cdecl *)(int,int,int,int,int,int)) nullFunc; // deinitrs = nullFunc; // ringstatrs = (int (cdecl *)(void)) nullFunc; // carrstatrs = (int (cdecl *)(void)) nullFunc; // statrs = (int (cdecl *)(void)) nullFunc; // flushrs = nullFunc; // getrs = (int (cdecl *)(void)) nullFunc; // putrs = (void (cdecl *)(char)) nullFunc; // dtrrs = (void (cdecl *)(int)) nullFunc; // flushoutrs = nullFunc; #else // Start using BIOS charattr = bioschar; stringattr = biosstring; // com initrs = InitRS; deinitrs = DeInitRS; ringstatrs = RingStatRS; carrstatrs = CarrStatRS; statrs = StatRS; flushrs = FlushRS; getrs = GetRS; putrs = PutRS; dtrrs = DtrRS; flushoutrs = nullFunc; // ups initups = nullFunc; deinitups = nullFunc; statups = NULL; // kbd initkbd = nullFunc; deinitkbd = nullFunc; statcon = StatCON; getcon = GetCON; sp_press = special_pressed; // snd init_sound = (int (cdecl *)(void)) nullFunc; close_sound = (int (cdecl *)(void)) nullFunc; get_version = (int (cdecl *)(void)) nullFunc; query_drivers = (int (cdecl *)(void)) nullFunc; query_status = (int (cdecl *)(void)) nullFunc; start_snd_src = (int (cdecl *)(int, const void *)) nullFunc; play_sound = (int (cdecl *)(int)) nullFunc; stop_sound = (int (cdecl *)(int)) nullFunc; pause_sound = (int (cdecl *)(int)) nullFunc; resume_sound = (int (cdecl *)(int)) nullFunc; read_snd_stat = (int (cdecl *)(int)) nullFunc; set_midi_map = (int (cdecl *)(int)) nullFunc; get_src_vol = (int (cdecl *)(int)) nullFunc; set_src_vol = (int (cdecl *)(int, int)) nullFunc; set_fade_pan = (int (cdecl *)(void *)) nullFunc; strt_fade_pan = (int (cdecl *)(void)) nullFunc; stop_fade_pan = (int (cdecl *)(int)) nullFunc; pse_fade_pan = (int (cdecl *)(void)) nullFunc; res_fade_pan = (int (cdecl *)(void)) nullFunc; read_fade_pan = (int (cdecl *)(int)) nullFunc; get_pan_pos = (int (cdecl *)(int)) nullFunc; set_pan_pos = (int (cdecl *)(int, int)) nullFunc; say_ascii = (int (cdecl *)(const char *, int)) nullFunc; #endif parseArgs(argc, argv); #ifndef WINCIT if (!cfg.bios) { charattr = directchar; stringattr = directstring; } #endif #ifndef WINCIT if (!cmdLine[1]) { uchar *ptr = (uchar *) MK_FP(_psp, 128); if (ptr[0]) { memcpy(cmdLine, ptr + 1, max(128, ptr[0])); cmdLine[ptr[0]] = 0; } } OC.whichIO = CONSOLE; #endif if (!initCitadel()) { #ifndef WINCIT DeinitializeTimer(); #endif critical(FALSE); exit(200); } #ifndef WINCIT ScreenSaver.Update(); #endif if (BoardNameHash && hash(cfg.nodeTitle) != BoardNameHash) { crashout(getmsg(681)); } #ifndef WINCIT // Set system to a known state OC.Echo = BOTH; OC.SetOutFlag(IMPERVIOUS); modStat = FALSE; OC.whichIO = CONSOLE; OC.setio(); if (!(login_pw || login_user || (slv_door && cfg.forcelogin))) { CommPort->FlushInput(); greeting(); } Cron.ResetTimer(); if (slv_net) { doccr(); if(read_tr_messages()) { cPrintf(gettrmsg(49), slv_node); dump_tr_messages(); } if (net_callout(slv_node)) { did_net(slv_node); } ExitToMsdos = TRUE; } if (slv_door) // set according to carrier { // set baud rate even if carrier not present if (slv_baud != PS_ERROR) { CommPort->SetSpeed(slv_baud); } else { CommPort->SetSpeed(cfg.initbaud); } for (ModemSpeedE i = MS_300; i < MS_NUM; i = (ModemSpeedE) (i +1)) { if (connectbauds[i] == bauds[CommPort->GetSpeed()]) { CommPort->SetModemSpeed(i); break; } } if (CommPort->HaveConnection()) { CarrierJustFound(); OC.whichIO = MODEM; OC.setio(); } else { OC.whichIO = CONSOLE; OC.setio(); } } setdefaultTerm(TT_ANSI); StatusLine.Toggle(); // Turns it on (starts life off). ScreenSaver.SetMayTurnOn(TRUE); time(&LastActiveTime); TimeoutChecking = TRUE; if (*cmd_script) { #ifdef WINCIT runScript(cmd_script, NULL); #else runScript(cmd_script); #endif } doEvent(EVT_STARTUP); #endif }
void resizegrpfile(void) { int i; const char *File2; FILE *oldfile; FILE *newfile; #ifdef WINCIT LogEntry *CurrentUser = new LogEntry(cfg.maxrooms, cfg.maxgroups, cfg.maxjumpback); if (!CurrentUser) { illegal("no memory."); } #endif /////////////////////////////////////// msgDisp(getcfgmsg(191), cfg.Ugroups_nym); doccr(); chdir(cfg.homepath); File2 = getcfgmsg(217); msgDisp(getcfgmsg(185), grpDat); cPrintfDOS(br); unlink(File2); GroupData.Resize(newmaxgroups); zapGrpFile(File2, TRUE); Bool Success = FALSE; if ((oldfile = fopen(grpDat, FO_RB)) != NULL) { if ((newfile = fopen(File2, FO_RPB)) != NULL) { fseek(oldfile, sizeof(long), SEEK_SET); fseek(newfile, sizeof(long), SEEK_SET); for (g_slot GroupSlot = 0; (GroupSlot < cfg.maxgroups) && (GroupSlot < newmaxgroups); GroupSlot++) { GroupEntry TempEntry; if (!TempEntry.Load(oldfile)) { crashout(getcfgmsg(281), getcfgmsg(240)); } if (!TempEntry.Save(newfile)) { crashout(getcfgmsg(283), getcfgmsg(240)); } } Success = TRUE; fclose(newfile); } fclose(oldfile); } if (!Success) { crashout(getcfgmsg(218), grpDat); } // log2.dat Success = FALSE; File2 = getcfgmsg(157); msgDisp(getcfgmsg(185), log2Dat); cPrintfDOS(br); unlink(File2); if ((oldfile = fopen(log2Dat, FO_RB)) != NULL) { if ((newfile = fopen(File2, FO_WB)) != NULL) { for (l_index LogIndex = 0; LogIndex < cfg.MAXLOGTAB; LogIndex++) { char ch; for (i = 0; i < cfg.maxgroups / 8 && i < newmaxgroups / 8; i++) { fread(&ch, sizeof(ch), 1, oldfile); fwrite(&ch, sizeof(ch), 1, newfile); } ch = 0; for (; i < newmaxgroups / 8; i++) { fwrite(&ch, sizeof(ch), 1, newfile); } for (; i < cfg.maxgroups / 8; i++) { fread(&ch, sizeof(ch), 1, oldfile); } } Success = TRUE; fclose(newfile); } fclose(oldfile); } if (!Success) { crashout(getcfgmsg(218), log2Dat); } unlink(grpDat); rename(getcfgmsg(217), grpDat); unlink(log2Dat); rename(File2, log2Dat); cfg.maxgroups = newmaxgroups; CurrentUser->LogEntry2::Resize(cfg.maxgroups); if (!GroupData.IsValid() || !CurrentUser->IsValid()) { crashout(getcfgmsg(107)); } doccr(); msgDisp(getcfgmsg(190)); doccr(); doccr(); #ifdef WINCIT msgDisp(NULL); // msgCaption(ns); delete CurrentUser; #endif }
void messWithShareList (uchar bUsage, label roomname) { struct messNode nodeArray[MAXDIRECT] ; int i, j, iNode, iTopNode, iOn ; uchar fKeyFound, fAnyPrinted, fQuit, fDisplayMenu ; char ch, oldEcho, path[255], buf[255], *lpch, *lpstr, aHotKeys[] = "BCDEFGHIJKLMNOPQRTUVWXYZ1234567890!#$%&*(", *words[256]; int hFile ; /* Initialize the array. */ for (i = 0; i < MAXDIRECT; i++) { strcpy (nodeArray[i].nodeName, '\0') ; nodeArray[i].fShared = FALSE ; nodeArray[i].bHotKey = (uchar) 0 ; nodeArray[i].bHotKeyPos = (uchar) 0 ; } /* In one single pass, we're going to read the NODES file and fill out */ /* our array based on all the information we find there! */ sprintf (path, "%s\\NODES.CIT", cfg.homepath) ; hFile = sopen (path, O_TEXT | O_RDONLY, SH_DENYNO) ; if (-1 == hFile) crashout ("Problem opening NODES.CIT.") ; iTopNode = -1 ; while ( !eof(hFile) ) { if (!sfgets (buf, 255, hFile)) break ; /* Error reading file. */ if ('#' != buf[0]) /* It's not a keyword. */ continue ; if (strnicmp (buf, "#NODE", 5) == SAMESTRING) { parse_it (words, buf) ; if (words[1] == NULL) /* Invalid #NODE entry. */ continue ; /* We have a new node and its name! */ ++iTopNode ; strcpy (nodeArray[iTopNode].nodeName, words[1]) ; } else { if (strnicmp (buf, "#ROOM", 5) != SAMESTRING) continue ; if (-1 == iTopNode) /* We don't have a node yet. */ continue ; parse_it (words, buf) ; if (stricmp (words[1], roomname) == SAMESTRING) nodeArray[iTopNode].fShared = TRUE ; } } close (hFile) ; /* For the short, non-interactive output, just spew it out and quit. */ if (SHORT_SEE_NO_MODIFY == bUsage) { if (-1 == iTopNode) mPrintf ("(No nodes in NODES.CIT.)") ; else { iOn = 0 ; fAnyPrinted = FALSE ; while (iOn <= iTopNode) { if (TRUE == nodeArray[iOn].fShared) { if (fAnyPrinted) mPrintf ("3, 0%s", nodeArray[iOn].nodeName) ; else { mPrintf ("%s", nodeArray[iOn].nodeName) ; fAnyPrinted = TRUE ; } } ++iOn ; } if (fAnyPrinted) mPrintf ("3.0") ; } return ; } if (SEE_WITH_MODIFY == bUsage) { /* If we found more nodes than we can hotkey, say so and abort. */ if (iTopNode >= (int) strlen (aHotKeys)) { mPrintf ("Uh-oh! There are too many nodes in the userlog to use this function.") ; doCR() ; return ; } /* Hotkeys are determined by a priority system. First, we try to */ /* get the first character of the node name. Second, we try for */ /* the first character following every space in the name. Third, */ /* we try every character in the name. Last, we scan the entire */ /* hotkey string until we find an unused key. */ for (iNode = 0; iNode <= iTopNode; iNode++) { fKeyFound = FALSE ; /* PLAN ONE: Try for the first character. */ ch = (char) toupper (*nodeArray[iNode].nodeName) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* If char = valid hotkey... */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = 0 ; *lpch = FILLED ; /* Ptr into aHotKeys */ continue ; /* Do the next node. */ } /* PLAN TWO: Try for the first letter of every word. Since i */ /* starts at one, it's ok to check the previous character for */ /* a space. */ lpstr = nodeArray[iNode].nodeName ; i = 1 ; while (lpstr[i]) /* While we're not on the final NULL... */ { if ( ' ' == lpstr[i-1] ) /* Is the prev char a space? */ { ch = (char) toupper (lpstr[i]) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* Valid chr? */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = (uchar) i ; *lpch = FILLED ; /* Ptr into aHotKeys */ fKeyFound = TRUE ; /* Signal release from for iter.*/ break ; /* Releases from while loop. */ } } ++i ; } /* If the above loop found a key, move on to the next node. */ if (fKeyFound) continue ; /* PLAN THREE: Check every single character in the string for */ /* a valid hot key. */ i = 0 ; while (lpstr[i]) /* While we're not on the final NULL... */ { ch = (char) toupper (lpstr[i]) ; lpch = strchr (aHotKeys, ch) ; if (lpch) /* Valid chr? */ { nodeArray[iNode].bHotKey = *lpch ; nodeArray[iNode].bHotKeyPos = (uchar) i ; *lpch = FILLED ; /* Ptr into aHotKeys */ fKeyFound = TRUE ; /* Signal release from for iter. */ break ; /* Releases from while loop. */ } ++i ; } /* If the above loop found a key, move on to the next node. */ if (fKeyFound) continue ; /* PLAN FOUR: Give the node the first available hot key. */ /* Checking done previously assures that we'll get one. */ i = 0 ; while (FILLED == aHotKeys[i]) ++i ; nodeArray[iNode].bHotKey = aHotKeys[i] ; nodeArray[iNode].bHotKeyPos = NOT_IN_STRING ; aHotKeys[i] = FILLED ; } fDisplayMenu = TRUE ; fQuit = FALSE ; for (;;) { if (fDisplayMenu) { doCR () ; for (iNode = 0; iNode <= iTopNode; iNode++) { strcpy (buf, ".........................") ; lpstr = nodeArray[iNode].nodeName ; i = j = 0 ; while (lpstr[i] != '\0') /* Doesn't copy the NULL */ { if ( i == (int) nodeArray[iNode].bHotKeyPos) /* Turn on bold */ { buf[j] = '' ; buf[j+1] = '3' ; buf[j+2] = lpstr[i] ; buf[j+3] = '' ; buf[j+4] = '0' ; j += 5 ; } else { buf[j] = lpstr[i] ; ++j ; } ++i ; } mPrintf ("<3%c0> %s %s", nodeArray[iNode].bHotKey, buf, nodeArray[iNode].fShared ? "YES" : "No") ; doCR() ; } } /* Take user input. */ doCR() ; mPrintf("<3S0> to save, <3A0> to abort."); doCR(); fDisplayMenu = (BOOL)(!expert) ; outFlag = IMPERVIOUS; doCR(); mPrintf("2Add/Drop:0 "); oldEcho = echo; echo = NEITHER; ch = (char) iChar(); echo = oldEcho; if (!((whichIO == CONSOLE) || gotCarrier())) return; switch(toupper(ch)) { case 'A': mPrintf("Abort"); doCR(); if (getYesNo("Abort", TRUE)) return; break; case 'S': mPrintf("Save"); doCR(); if (getYesNo("Save", TRUE)) { saveNewReality(nodeArray, roomname, iTopNode) ; return ; } break ; case '\r': case '\n': case '?' : mPrintf("Menu"); doCR(); fDisplayMenu = TRUE; break; default: /* Check if for hotkey and toggle right entry. */ for (i = 0; i <= iTopNode; i++) if (toupper(ch) == nodeArray[i].bHotKey) { nodeArray[i].fShared = (uchar) !nodeArray[i].fShared ; mPrintf ("%s %s", nodeArray[i].nodeName, nodeArray[i].fShared ? "added." : "dropped.") ; doCR() ; break ; } /* If it fails to break above, it's not valid input. */ if (i > iTopNode) { mPrintf("%c ? for help", ch); doCR(); break ; } } } /* This is in the right place. */ } }
void resizelogfile(void) { #ifdef WINCIT LogEntry *CurrentUser = new LogEntry(cfg.maxrooms, cfg.maxgroups, cfg.maxjumpback); l_slot *LogOrder = new l_slot[cfg.MAXLOGTAB]; if (!LogOrder || !CurrentUser) { illegal("no memory"); } for (l_slot slot = 0; slot < cfg.MAXLOGTAB; slot++) { LogOrder[slot] = slot; } LogTab.Sort(&LogOrder); #endif chdir(cfg.homepath); // get rid of any log?.tmp files unlink(getcfgmsg(156)); unlink(getcfgmsg(157)); unlink(getcfgmsg(158)); unlink(getcfgmsg(159)); unlink(getcfgmsg(160)); unlink(getcfgmsg(161)); // and the LE*.TMP files changedir(cfg.logextdir); ambigUnlink(getcfgmsg(215)); changedir(cfg.homepath); // create new log?.tmp files with new size l_slot i = cfg.MAXLOGTAB; cfg.MAXLOGTAB = newmaxlogtab; zapLogFile(TRUE, TRUE); cfg.MAXLOGTAB = i; for (i = 0; (i < cfg.MAXLOGTAB) && (i < newmaxlogtab); i++) { msgDisp(getcfgmsg(183), ltoac(LTab(i).GetLogIndex())); #ifndef WINCIT cPrintf(getcfgmsg(282), br); #endif // Load from old files (the .DAT ones) CurrentUser->LogEntry1::ResetFileName(); CurrentUser->LogEntry2::ResetFileName(); CurrentUser->LogEntry3::ResetFileName(); CurrentUser->LogEntry4::ResetFileName(); CurrentUser->LogEntry5::ResetFileName(); CurrentUser->LogEntry6::ResetFileName(); CurrentUser->LogExtensions::ResetFileExtension(); if (!CurrentUser->Load(LTab(i).GetLogIndex())) { crashout(getcfgmsg(281), getcfgmsg(155)); } // And save to the new files (the .TMP ones) CurrentUser->LogEntry1::SetFileName(getcfgmsg(156)); CurrentUser->LogEntry2::SetFileName(getcfgmsg(157)); CurrentUser->LogEntry3::SetFileName(getcfgmsg(158)); CurrentUser->LogEntry4::SetFileName(getcfgmsg(159)); CurrentUser->LogEntry5::SetFileName(getcfgmsg(160)); CurrentUser->LogEntry6::SetFileName(getcfgmsg(161)); CurrentUser->LogExtensions::SetFileExtension(getcfgmsg(230)); if (!CurrentUser->Save(i, CurrentUser->GetMessageRoom())) { crashout(getcfgmsg(283), getcfgmsg(155)); } } doccr(); doccr(); // Back to using the .DAT files CurrentUser->LogEntry1::ResetFileName(); CurrentUser->LogEntry2::ResetFileName(); CurrentUser->LogEntry3::ResetFileName(); CurrentUser->LogEntry4::ResetFileName(); CurrentUser->LogEntry5::ResetFileName(); CurrentUser->LogEntry6::ResetFileName(); CurrentUser->LogExtensions::ResetFileExtension(); // clear RAM buffer out CurrentUser->Clear(); // Then clean up - .TMP to .DAT unlink(logDat); unlink(log2Dat); unlink(log3Dat); unlink(log4Dat); unlink(log5Dat); unlink(log6Dat); rename(getcfgmsg(156), logDat); rename(getcfgmsg(157), log2Dat); rename(getcfgmsg(158), log3Dat); rename(getcfgmsg(159), log4Dat); rename(getcfgmsg(160), log5Dat); rename(getcfgmsg(161), log6Dat); changedir(cfg.logextdir); ambigUnlink(getcfgmsg(211)); FindFileC FF; if (FF.FindFirst(getcfgmsg(215))) { do { if (FF.IsNormalFile()) { label newname; CopyStringToBuffer(newname, FF.GetShortName()); strcpy(strchr(newname, '.'), getcfgmsg(285)); rename(FF.GetShortName(), newname); } } while (FF.FindNext()); } changedir(cfg.homepath); #ifdef WINCIT msgDisp(NULL); // msgCaption(ns); delete CurrentUser; delete [] LogOrder; #endif }
static void autoConvert(const char *fname, long size) { FILE *fl; long l; if ((fl = fopen(fname, FO_RPB)) != NULL) { fread(&l, sizeof(l), 1, fl); if (l != size) { FILE *fl2; const char *tmp = getcfgmsg(137); if ((fl2 = fopen(tmp, FO_WPB)) != NULL) { char *buf; size_t bufsize = (size_t) max(l, size); buf = new char[bufsize]; if (buf) { int cnt = 0; fwrite(&size, sizeof(size), 1, fl2); while (!feof(fl)) { memset(buf, 0, bufsize); if (fread(buf, 1, (size_t) l, fl) == (size_t) l) { #ifndef WINCIT cPrintf(br); cPrintf(getcfgmsg(138), fname, ltoac(++cnt)); #endif fwrite(buf, 1, (size_t) size, fl2); } } #ifndef WINCIT doccr(); doccr(); #endif delete [] buf; } else { crashout(getmsg(188), getcfgmsg(203)); } fclose(fl2); fclose(fl); unlink(fname); rename(tmp, fname); unlink(tmp); return; // avoid the fclose down there } else { crashout(getmsg(8), tmp); } } fclose(fl); } }