/* * citpeek.c - Sneak a peek at Fnordadel datafiles; for privileged eyes only! * * 90Dec05 AA Munged a bit for gcc * 90Aug03 AA Menu mode added; showconfig() filled in * 90Mar25 AA Created. */ #include "ctdl.h" #include "net.h" #include "room.h" #include "log.h" #include "msg.h" #include "floor.h" #include "config.h" #include "citlib.h" /* globals */ char *program = "citpeek"; int logfl; /* log file descriptor */ char echo; char Debug = NO; typedef char BINBUF[33]; /* buffer to hold long (binary) */ int missing[4] = { NO, NO, NO, NO }; #define MSG 0 #define LOG 1 #define NET 2 #define FLR 3 /* stolen from output.c */ char prevchar = 0; char *CRfill = NULL; void (*CRftn)() = NULL; char outFlag = OUTOK; struct logBuffer logBuf; /* FIXME: */ char remoteSysop; extern int PATCHNUM; /* * binary() -- take a long value and turn into a string of ones & zeros */ void binary(long value, char *str) { register long val = value; register int i; strcpy(str,"00000000000000000000000000000000"); for (i=1; i<=32; i++) { str[32-i] = (val&1L) ? '1' : '0'; val = val>>1; } } /* * getnormstr() -- get a string and delete extraneous blanks, etc * returns NO if blank line is input, YES otherwise */ int getnormstr(char *prompt, char *buf, int lim) { int c, i; if (strlen(prompt) > 0) printf("%s: ", prompt); i = 0; while ( (c = getch()) != '\r') { /* handle delete chars: */ if (c == '\b') { if (i > 0) { i--; fputs("\b \b", stdout); } else putchar(BELL); } else if (i < lim) { buf[i++] = c; putchar((c>=32) ? c : '@'); } else putchar(BELL); } putchar('\n'); buf[i] = 0; normalise(buf); return(*buf == '\0' ? NO : YES); } /* * showconfig() -- print information about struct cfg */ void showconfig(void) { int i; printf("showconfig()\n"); printf("maxMSector: %d\tcatChar: %d\tcatSector: %d\n", cfg.maxMSector, cfg.catChar, cfg.catSector); printf("oldest: %ld\tnewest: %ld\n", cfg.oldest, cfg.newest); printf("cryptSeed: %d\tlogsize: %d\tmailslots: %d\tmaxrooms: %d\n", cfg.cryptSeed, cfg.logsize, cfg.mailslots, cfg.maxrooms); printf("sharedrooms: %d\tmaxmsgs: %d\tmaxmailmsgs: %d\tmaxcalls: %d\n", cfg.sharedrooms, cfg.maxmsgs, cfg.maxmailmsgs, cfg.maxcalls); printf("maxtime: %d\tmaxclosecalls: %d\tclosetime: %d\tmincalltime: %d\n", cfg.maxtime, cfg.maxclosecalls, cfg.closetime, cfg.mincalltime); printf("newusermsgs: %d\n", cfg.newusermsgs); printf("flags:\n"); if (cfg.flags.ENTEROK) printf("\tENTEROK"); if (cfg.flags.READOK) printf("\tREADOK"); if (cfg.flags.LOGINOK) printf("\tLOGINOK"); if (cfg.flags.ROOMOK) printf("\tROOMOK"); if (cfg.flags.NOMAIL) printf("\tNOMAIL"); if (cfg.flags.ALLNET) printf("\tALLNET"); if (cfg.flags.GETNAME) printf("\tGETNAME"); if (cfg.flags.KEEPHOLD) printf("\tKEEPHOLD"); if (cfg.flags.AIDE_FORGET) printf("\tAIDE_FORGET"); if (cfg.flags.SHOWRECD) printf("\tSHOWRECD"); if (cfg.flags.NOCHAT) printf("\tNOCHAT"); if (cfg.flags.DISKUSAGE) printf("\tDISKUSAGE"); if (cfg.flags.ARCHIVE_MAIL) printf("\tARCHIVE_MAIL"); if (cfg.flags.SYSOPSLEEP) printf("\tSYSOPSLEEP"); if (cfg.flags.AIDEKILLROOM) printf("\tAIDEKILLROOM"); if (cfg.flags.DEBUG) printf("\tDEBUG"); if (cfg.flags.FZAP) printf("\tFZAP"); if (cfg.flags.FNETLOG) printf("\tFNETLOG"); if (cfg.flags.FNETDEB) printf("\tFNETDEB"); if (cfg.flags.USA) printf("\tUSA"); if (cfg.flags.PATHALIAS) printf("\tPATHALIAS"); if (cfg.flags.FORWARD_MAIL) printf("\tFORWARD_MAIL"); if (cfg.flags.SEARCH_BAUD) printf("\tSEARCH_BAUD"); if (cfg.flags.CONNECTPROMPT) printf("\tCONNECTPROMPT"); if (cfg.flags.MODEMCC) printf("\tMODEMCC"); if (cfg.flags.HAYES) printf("\tHAYES"); if (cfg.flags.ANONNETMAIL) printf("\tANONNETMAIL"); if (cfg.flags.ANONFILEXFER) printf("\tANONFILEXFER"); if (cfg.flags.PURGENET) printf("\tPURGENET"); if (cfg.flags.KEEPDISCARDS) printf("\tKEEPDISCARDS"); printf("\n"); /* codeBuf[] */ printf("nodeName: %s (%d)\n", &cfg.codeBuf[cfg.nodeName], cfg.nodeName); printf("nodeTitle: %s (%d)\n", &cfg.codeBuf[cfg.nodeTitle], cfg.nodeTitle); printf("nodeId: %s (%d)\n", &cfg.codeBuf[cfg.nodeId], cfg.nodeId); printf("shell: %s (%d)\tsysopName: %s (%d)\thub: %s (%d)\n", &cfg.codeBuf[cfg.shell], cfg.shell, &cfg.codeBuf[cfg.sysopName], cfg.sysopName, &cfg.codeBuf[cfg.hub], cfg.hub); printf("organization: %s (%d)\n", &cfg.codeBuf[cfg.organization], cfg.organization); printf("sysdir: %s (%d)\thelpdir: %s (%d)\tmsgdir: %s (%d)\n", &cfg.codeBuf[cfg.sysdir], cfg.sysdir, &cfg.codeBuf[cfg.helpdir], cfg.helpdir, &cfg.codeBuf[cfg.msgdir], cfg.msgdir); printf("netdir: %s (%d)\tauditdir: %s (%d)\n", &cfg.codeBuf[cfg.netdir], cfg.netdir, &cfg.codeBuf[cfg.auditdir], cfg.auditdir); printf("receiptdir: %s (%d)\troomdir: %s (%d)\n", &cfg.codeBuf[cfg.receiptdir], cfg.receiptdir, &cfg.codeBuf[cfg.roomdir], cfg.roomdir); printf("holddir: %s (%d)\n", &cfg.codeBuf[cfg.holddir], cfg.holddir); printf("modemSetup: %s (%d)\n", &cfg.codeBuf[cfg.modemSetup], cfg.modemSetup); for (i=0; i to end)", username, NAMESIZE-1)) { /* get max. 19 characters */ for (i=0; i to end", input, NAMESIZE - 1)) { i = sscanf(input, "%ld %hd", &id, &loc); if (i == 2) { if (findMessage(loc, id)) { getmsgstr(msgBuf.mbtext, MAXTEXT); putheader(0); mformat(msgBuf.mbtext); putchar('\n'); } } else if (i == 1) { for (j = 0; j < cfg.maxMSector; j++) { if (findMessage(j, id)) { printf("Found it in sector %d\n", j); getmsgstr(msgBuf.mbtext, MAXTEXT); putheader(0); mformat(msgBuf.mbtext); putchar('\n'); break; } } } else printf("fargup.\n"); } } /* * shownet() -- examine network nodes from ctdlnet.sys */ void shownet(void) { LABEL nodename; BINBUF binflags, binnets; int i; while (getnormstr("Name of net node to display ( to end)", nodename, NAMESIZE-1)) { /* get max. 19 characters */ for (i=0; i" : netBuf.myPasswd)); printf("\therPasswd:\t%s\n", (netBuf.herPasswd[0] == '\0' ? "" : netBuf.herPasswd)); printf("\tflags:\t\t0x%lx (%s)\n", netBuf.flags, binflags); printf("\tld (pollcount):\t%d\n", netBuf.ld); printf("\tdialer:\t\t%d\n", netBuf.dialer); printf("\tpoll_day:\t0x%x\n", netBuf.poll_day); printf("\twhat_net:\t0x%lx (%s)\n", netBuf.what_net, binnets); printf("\tbaudCode:\t%d\n", netBuf.baudCode); printf("\taccess:\t\t%s\n", (netBuf.access[0] == '\0' ? "" : netBuf.access)); printf("\n"); /* The end */ } else printf("\nNo node by that name.\n\n"); } } /* * showroom() -- print data from roomnnnn.sys */ void showroom(void) { LABEL roomname, floorname; BINBUF binflags; int i, j; while (getnormstr("Name of room to display ( to end)", roomname, NAMESIZE-1)) { /* get 19 character roomnames */ for (i=0; i" : roomBuf.rbdirname)); printf("\tnummsgs:\t%u\n", roomBuf.nummsgs); printf("\n"); /* The end */ } else printf("\nNo room by that name.\n\n"); } } /* * shlogtab() -- print data from the logTab[] */ void shlogtab(void) { register int i; printf("\nContents of logTab[i]:\n\n"); printf(" i ltpwhash ltnmhash ltlogSlot ltnewest\n\n"); for (i=0; i to end)", nodename, NAMESIZE-1)) { /* get max. 19 characters */ for (i=0; i" : roomTab[netTab[i].Tshared[j].NRidx].rtname); printf("\n\tThe End\n"); } else printf("\nNo node by that name.\n\n"); } } /* * shroomtab() -- print data from the roomTab[] */ void shroomtab(void) { register int i; printf("\nContents of roomTab[i]: (* == in use)\n\n"); printf(" i rtgen flags rtname lastNet lastLocal lastMsg \ floorGen\n\n"); for (i=0; i