Annotation of sbbs/sbbs3/umonitor/umonitor.c, revision 1.1

1.1     ! root        1: /* umonitor.c */
        !             2: 
        !             3: /* Synchronet for *nix node activity monitor */
        !             4: 
        !             5: /* $Id: umonitor.c,v 1.66 2004/11/05 01:08:44 deuce Exp $ */
        !             6: 
        !             7: /****************************************************************************
        !             8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
        !             9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
        !            10:  *                                                                                                                                                     *
        !            11:  * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html         *
        !            12:  *                                                                                                                                                     *
        !            13:  * This program is free software; you can redistribute it and/or                       *
        !            14:  * modify it under the terms of the GNU General Public License                         *
        !            15:  * as published by the Free Software Foundation; either version 2                      *
        !            16:  * of the License, or (at your option) any later version.                                      *
        !            17:  * See the GNU General Public License for more details: gpl.txt or                     *
        !            18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
        !            19:  *                                                                                                                                                     *
        !            20:  * Anonymous FTP access to the most recent released source is available at     *
        !            21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
        !            22:  *                                                                                                                                                     *
        !            23:  * Anonymous CVS access to the development source and modification history     *
        !            24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
        !            25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
        !            26:  *     (just hit return, no password is necessary)                                                     *
        !            27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
        !            28:  *                                                                                                                                                     *
        !            29:  * For Synchronet coding style and modification guidelines, see                                *
        !            30:  * http://www.synchro.net/source.html                                                                          *
        !            31:  *                                                                                                                                                     *
        !            32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
        !            33:  * format) via e-mail to [email protected]                                                                      *
        !            34:  *                                                                                                                                                     *
        !            35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
        !            36:  ****************************************************************************/
        !            37: 
        !            38: #include <signal.h>
        !            39: #include <sys/types.h>
        !            40: #include <time.h>
        !            41: #include <sys/time.h>
        !            42: #ifdef __QNX__
        !            43: #include <string.h>
        !            44: #endif
        !            45: #include <stdio.h>
        !            46: #include <unistd.h>
        !            47: 
        !            48: #include "ciolib.h"
        !            49: #include "keys.h"
        !            50: #define __COLORS               /* Disable the colour macros in sbbsdefs.h ToDo */
        !            51: #include "sbbs.h"
        !            52: #include "genwrap.h"
        !            53: #include "uifc.h"
        !            54: #include "sbbsdefs.h"
        !            55: #include "genwrap.h"   /* stricmp */
        !            56: #include "dirwrap.h"   /* lock/unlock/sopen */
        !            57: #include "filewrap.h"  /* lock/unlock/sopen */
        !            58: #include "sbbs_ini.h"  /* INI parsing */
        !            59: #include "scfglib.h"   /* SCFG files */
        !            60: #include "ars_defs.h"  /* needed for SCFG files */
        !            61: #include "userdat.h"   /* getnodedat() */
        !            62: #include "spyon.h"
        !            63: #include "chat.h"
        !            64: 
        !            65: #define CTRL(x) (x&037)
        !            66: 
        !            67: /********************/
        !            68: /* Global Variables */
        !            69: /********************/
        !            70: uifcapi_t uifc; /* User Interface (UIFC) Library API */
        !            71: const char *YesStr="Yes";
        !            72: const char *NoStr="No";
        !            73: 
        !            74: int lprintf(char *fmt, ...)
        !            75: {
        !            76:        va_list argptr;
        !            77:        char sbuf[1024];
        !            78:        int     len;
        !            79: 
        !            80:        va_start(argptr,fmt);
        !            81:        len=vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
        !            82:        sbuf[sizeof(sbuf)-1]=0;
        !            83:        va_end(argptr);
        !            84:        uifc.msg(sbuf);
        !            85:        return(len);
        !            86: }
        !            87: 
        !            88: void bail(int code)
        !            89: {
        !            90:     if(code) {
        !            91:         puts("\nHit a key...");
        !            92:         getch();
        !            93:        }
        !            94:     uifc.bail();
        !            95: 
        !            96:     exit(code);
        !            97: }
        !            98: 
        !            99: void allocfail(uint size)
        !           100: {
        !           101:     printf("\7Error allocating %u bytes of memory.\n",size);
        !           102:     bail(1);
        !           103: }
        !           104: 
        !           105: void freeopt(char** opt)
        !           106: {
        !           107:        int i;
        !           108: 
        !           109:        for(i=0;i<(MAX_OPTS+1);i++)
        !           110:                free(opt[i]);
        !           111: 
        !           112:        free(opt);
        !           113: }
        !           114: 
        !           115: void node_toggles(scfg_t *cfg,int nodenum)  {
        !           116:        int nodefile;
        !           117:        char**  opt;
        !           118:        int             i,j;
        !           119:        node_t  node;
        !           120:        int             save=0;
        !           121: 
        !           122:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           123:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           124:        for(i=0;i<(MAX_OPTS+1);i++)
        !           125:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           126:                        allocfail(MAX_OPLN);
        !           127: 
        !           128:        i=0;
        !           129:        uifc.helpbuf=   "`Node Toggles\n"
        !           130:                        "`------------`\n\n"
        !           131:                                        "`The following are `Yes/No `options.  Hitting Enter toggles between.\n\n"
        !           132:                                        "`Locked for SysOps only : `Locks the node so that only SysOps may \n"
        !           133:                                        "                         logon to them.\n"
        !           134:                                        "`Interrupt (Hangup)     : `The current user will be kicked as soon as it \n"
        !           135:                                        "                         is safe to do so.  A brief message is given\n"
        !           136:                                        "                         to user.\n"
        !           137:                                        "`Re-run on logoff       : `Toggles the system to reload the configuration\n"
        !           138:                                        "                         files when the current user logs off.\n"
        !           139:                                        "`Down node after logoff : `Takes the node offline after current user logs\n"
        !           140:                                        "                         off.\n\n"
        !           141:                                        "`[Note] `These toggles take effect immediately.";
        !           142:        while(save==0) {
        !           143:                if(getnodedat(cfg,nodenum,&node,&nodefile)) {
        !           144:                        uifc.msg("Error reading node data!");
        !           145:                        break;
        !           146:                }
        !           147:                j=0;
        !           148:                sprintf(opt[j++],"%-30s%3s","Locked for SysOps only",node.misc&NODE_LOCK ? YesStr : NoStr);
        !           149:                sprintf(opt[j++],"%-30s%3s","Interrupt (Hangup)",node.misc&NODE_INTR ? YesStr : NoStr);
        !           150:                sprintf(opt[j++],"%-30s%3s","Re-run on logoff",node.misc&NODE_RRUN ? YesStr : NoStr);
        !           151:                sprintf(opt[j++],"%-30s%3s","Down node after logoff"
        !           152:                        ,(node.misc&NODE_DOWN || (node.status==NODE_OFFLINE)) ? YesStr : NoStr);
        !           153:                opt[j][0]=0;
        !           154: 
        !           155:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Node Toggles",opt)) {
        !           156:                        case 0: /* Locked */
        !           157:                                node.misc ^= NODE_LOCK;
        !           158:                                break;
        !           159: 
        !           160:                        case 1: /* Interrupt */
        !           161:                                node.misc ^= NODE_INTR;
        !           162:                                break;
        !           163: 
        !           164:                        case 2: /* Re-run */
        !           165:                                node.misc ^= NODE_RRUN;
        !           166:                                break;
        !           167: 
        !           168:                        case 3: /* Down */
        !           169:                                if(node.status != NODE_WFC && node.status != NODE_OFFLINE)
        !           170:                                        node.misc ^= NODE_DOWN;
        !           171:                                else {
        !           172:                                        if(node.status!=NODE_OFFLINE)
        !           173:                                                node.status=NODE_OFFLINE;
        !           174:                                        else
        !           175:                                                node.status=NODE_WFC;
        !           176:                                }
        !           177:                                break;
        !           178: 
        !           179:                        case -1:
        !           180:                                save=1;
        !           181:                                break;
        !           182: 
        !           183:                        default:
        !           184:                                uifc.msg("Option not implemented");
        !           185:                                continue;
        !           186:                }
        !           187:                putnodedat(cfg,nodenum,&node,nodefile);
        !           188:        }
        !           189:        freeopt(opt);
        !           190: }
        !           191: 
        !           192: int dospy(int nodenum, bbs_startup_t *bbs_startup)  {
        !           193:        char str[80],str2[80];
        !           194:        int i;
        !           195: 
        !           196:        if(bbs_startup->temp_dir[0])
        !           197:        snprintf(str,sizeof(str),"%slocalspy%d.sock", bbs_startup->temp_dir, nodenum);
        !           198:        else
        !           199:                snprintf(str,sizeof(str),"%slocalspy%d.sock", bbs_startup->ctrl_dir, nodenum);
        !           200:        i=spyon(str);
        !           201:        switch(i) {
        !           202:                case SPY_NOSOCKET:
        !           203:                        uifc.msg("Could not create socket");
        !           204:                        return(-1);
        !           205: 
        !           206:                case SPY_NOCONNECT:
        !           207:                        sprintf(str2,"Failed to connect to %s",str);
        !           208:                        uifc.msg(str2);
        !           209:                        return(-1);
        !           210: 
        !           211:                case SPY_SELECTFAILED:
        !           212:                        uifc.msg("select() failed, connection terminated.");
        !           213:                        return(-1);
        !           214: 
        !           215:                case SPY_SOCKETLOST:
        !           216:                        uifc.msg("Spy socket lost");
        !           217:                        return(-1);
        !           218: 
        !           219:                case SPY_STDINLOST:
        !           220:                        uifc.msg("STDIN has gone away... you probably can't close this window.  :-)");
        !           221:                        return(-1);
        !           222: 
        !           223:                case SPY_CLOSED:
        !           224:                        break;
        !           225: 
        !           226:                default:
        !           227:                        sprintf(str,"Unknown return code %d",i);
        !           228:                        uifc.msg(str);
        !           229:                        return(-1);
        !           230:        }
        !           231:        return(0);
        !           232: }
        !           233: 
        !           234: int sendmessage(scfg_t *cfg, int nodenum,node_t *node)  {
        !           235:        char str[80],str2[80];
        !           236: 
        !           237:        uifc.input(WIN_MID|WIN_SAV,0,0,"Telegram",str2,58,K_WRAP|K_MSG);
        !           238:        sprintf(str,"\1n\1y\1hMessage From Sysop:\1w %s\r\n",str2);
        !           239:        if(getnodedat(cfg,nodenum,node,NULL))
        !           240:                return(-1);
        !           241:        if(node->useron==0)
        !           242:                return(-1);
        !           243:        putsmsg(cfg, node->useron, str);
        !           244:        return(0);
        !           245: }
        !           246: 
        !           247: int clearerrors(scfg_t *cfg, int nodenum, node_t *node) {
        !           248:        int nodefile;
        !           249:        if(getnodedat(cfg,nodenum,node,&nodefile)) {
        !           250:                uifc.msg("getnodedat() failed! (Nothing done)");
        !           251:                return(-1);
        !           252:        }
        !           253:        node->errors=0;
        !           254:        putnodedat(cfg,nodenum,node,nodefile);
        !           255:        uifc.msg("Error count cleared for this node.");
        !           256:        return(0);
        !           257: }
        !           258: 
        !           259: /* Assumes a 12 char outstr */
        !           260: char *getsizestr(char *outstr, long size, BOOL bytes) {
        !           261:        if(bytes) {
        !           262:                if(size < 1000) {       /* Bytes */
        !           263:                        snprintf(outstr,12,"%ld bytes",size);
        !           264:                        return(outstr);
        !           265:                }
        !           266:                if(size<10000) {        /* Bytes with comma */
        !           267:                        snprintf(outstr,12,"%ld,%03ld bytes",(size/1000),(size%1000));
        !           268:                        return(outstr);
        !           269:                }
        !           270:                size = size/1024;
        !           271:        }
        !           272:        if(size<1000) { /* KB */
        !           273:                snprintf(outstr,12,"%ld KB",size);
        !           274:                return(outstr);
        !           275:        }
        !           276:        if(size<999999) { /* KB With comma */
        !           277:                snprintf(outstr,12,"%ld,%03ld KB",(size/1000),(size%1000));
        !           278:                return(outstr);
        !           279:        }
        !           280:        size = size/1024;
        !           281:        if(size<1000) { /* MB */
        !           282:                snprintf(outstr,12,"%ld MB",size);
        !           283:                return(outstr);
        !           284:        }
        !           285:        if(size<999999) { /* MB With comma */
        !           286:                snprintf(outstr,12,"%ld,%03ld MB",(size/1000),(size%1000));
        !           287:                return(outstr);
        !           288:        }
        !           289:        size = size/1024;
        !           290:        if(size<1000) { /* GB */
        !           291:                snprintf(outstr,12,"%ld GB",size);
        !           292:                return(outstr);
        !           293:        }
        !           294:        if(size<999999) { /* GB With comma */
        !           295:                snprintf(outstr,12,"%ld,%03ld GB",(size/1000),(size%1000));
        !           296:                return(outstr);
        !           297:        }
        !           298:        size = size/1024;
        !           299:        if(size<1000) { /* TB (Yeah, right) */
        !           300:                snprintf(outstr,12,"%ld TB",size);
        !           301:                return(outstr);
        !           302:        }
        !           303:        sprintf(outstr,"Plenty");
        !           304:        return(outstr);
        !           305: }
        !           306: 
        !           307: /* Assumes a 12 char outstr */
        !           308: char *getnumstr(char *outstr, ulong size) {
        !           309:        if(size < 1000) {
        !           310:                snprintf(outstr,12,"%ld",size);
        !           311:                return(outstr);
        !           312:        }
        !           313:        if(size<1000000) {
        !           314:                snprintf(outstr,12,"%ld,%03ld",(size/1000),(size%1000));
        !           315:                return(outstr);
        !           316:        }
        !           317:        if(size<1000000000) {
        !           318:                snprintf(outstr,12,"%ld,%03ld,%03ld",(size/1000000),((size/1000)%1000),(size%1000));
        !           319:                return(outstr);
        !           320:        }
        !           321:        size=size/1000000;
        !           322:        if(size<1000000) {
        !           323:                snprintf(outstr,12,"%ld,%03ld M",(size/1000),(size%1000));
        !           324:                return(outstr);
        !           325:        }
        !           326:        if(size<10000000) {
        !           327:                snprintf(outstr,12,"%ld,%03ld,%03ld M",(size/1000000),((size/1000)%1000),(size%1000));
        !           328:                return(outstr);
        !           329:        }
        !           330:        sprintf(outstr,"Plenty");
        !           331:        return(outstr);
        !           332: }
        !           333: 
        !           334: int drawstats(scfg_t *cfg, int nodenum, node_t *node, int *curp, int *barp) {
        !           335:        stats_t sstats;
        !           336:        stats_t nstats;
        !           337:        char    statbuf[6*78];          /* Buffer to hold the stats for passing to uifc.showbuf() */
        !           338:        char    str[4][4][12];
        !           339:        char    usrname[128];
        !           340:        ulong   free;
        !           341:        uint    i,l,m;
        !           342:        time_t  t;
        !           343:        int             shownode=1;
        !           344: 
        !           345:        if(getnodedat(cfg,nodenum,node,NULL)) {
        !           346:                shownode=0;
        !           347:        }
        !           348:        else {
        !           349:                getstats(cfg, nodenum, &nstats);
        !           350:        }
        !           351:        username(cfg,node->useron,usrname);
        !           352: 
        !           353:        getstats(cfg, 0, &sstats);
        !           354:        t=time(NULL);
        !           355:        strftime(str[0][0],12,"%b %e",localtime(&t));
        !           356:        free=getfreediskspace(cfg->temp_dir,1024);
        !           357:        if(free<1000) {
        !           358:                free=getfreediskspace(cfg->temp_dir,0);
        !           359:                getsizestr(str[0][1],free,TRUE);
        !           360:        }
        !           361:        else
        !           362:                getsizestr(str[0][1],free,FALSE);
        !           363:        if(shownode) {
        !           364:                snprintf(str[1][0],12,"%s/%s",getnumstr(str[3][2],nstats.ltoday),getnumstr(str[3][3],sstats.ltoday));
        !           365:                getnumstr(str[1][1],sstats.logons);
        !           366:                snprintf(str[1][2],12,"%s/%s",getnumstr(str[3][2],nstats.ttoday),getnumstr(str[3][3],sstats.ttoday));
        !           367:                getnumstr(str[1][3],sstats.timeon);
        !           368:                snprintf(str[2][0],12,"%s/%s",getnumstr(str[3][2],sstats.etoday),getnumstr(str[3][3],getmail(cfg,0,0)));
        !           369:                l=m=0;
        !           370:                for(i=0;i<cfg->total_subs;i++)
        !           371:                        l+=getposts(cfg,i);                     /* l=total posts */
        !           372:                for(i=0;i<cfg->total_dirs;i++)
        !           373:                        m+=getfiles(cfg,i);                     /* m=total files */
        !           374:                snprintf(str[2][1],12,"%s/%s",getnumstr(str[3][2],sstats.ptoday),getnumstr(str[3][3],l));
        !           375:                snprintf(str[2][2],12,"%s/%s",getnumstr(str[3][2],sstats.ftoday),getnumstr(str[3][3],getmail(cfg,1,0)));
        !           376:                snprintf(str[2][3],12,"%s/%s",getnumstr(str[3][2],sstats.nusers),getnumstr(str[3][3],total_users(cfg)));
        !           377:                getsizestr(str[3][0],sstats.ulb,TRUE);
        !           378:                snprintf(str[3][1],12,"%s/%s",getnumstr(str[3][2],sstats.uls),getnumstr(str[3][3],m));
        !           379:                getsizestr(str[3][2],sstats.dlb,TRUE);
        !           380:                getnumstr(str[3][3],sstats.dls);
        !           381:        }
        !           382:        else {
        !           383:                snprintf(str[1][0],12,"%s",getnumstr(str[3][3],sstats.ltoday));
        !           384:                getnumstr(str[1][1],sstats.logons);
        !           385:                snprintf(str[1][2],12,"%s",getnumstr(str[3][3],sstats.ttoday));
        !           386:                getnumstr(str[1][3],sstats.timeon);
        !           387:                snprintf(str[2][0],12,"%s/%s",getnumstr(str[3][2],sstats.etoday),getnumstr(str[3][3],getmail(cfg,0,0)));
        !           388:                l=m=0;
        !           389:                for(i=0;i<cfg->total_subs;i++)
        !           390:                        l+=getposts(cfg,i);                     /* l=total posts */
        !           391:                for(i=0;i<cfg->total_dirs;i++)
        !           392:                        m+=getfiles(cfg,i);                     /* m=total files */
        !           393:                snprintf(str[2][1],12,"%s/%s",getnumstr(str[3][2],sstats.ptoday),getnumstr(str[3][3],l));
        !           394:                snprintf(str[2][2],12,"%s/%s",getnumstr(str[3][2],sstats.ftoday),getnumstr(str[3][3],getmail(cfg,1,0)));
        !           395:                snprintf(str[2][3],12,"%s/%s",getnumstr(str[3][2],sstats.nusers),getnumstr(str[3][3],total_users(cfg)));
        !           396:                getsizestr(str[3][0],sstats.ulb,TRUE);
        !           397:                snprintf(str[3][1],12,"%s/%s",getnumstr(str[3][2],sstats.uls),getnumstr(str[3][3],m));
        !           398:                getsizestr(str[3][2],sstats.dlb,TRUE);
        !           399:                getnumstr(str[3][3],sstats.dls);
        !           400:        }
        !           401:        snprintf(statbuf,sizeof(statbuf),"`Node #`: %-3d %6s  `Space`: %s"
        !           402:                        "\n`Logons`: %-11s `Total`: %-11s `Timeon`: %-11s `Total`: %-11s"
        !           403:                        "\n`Emails`: %-11s `Posts`: %-11s `Fbacks`: %-11s `Users`: %-11s"
        !           404:                        "\n`Uloads`: %-11s `Files`: %-11s `Dloads`: %-11s `Files`: %-11s",
        !           405:                        nodenum,str[0][0],str[0][1],
        !           406:                        str[1][0],str[1][1],str[1][2],str[1][3],
        !           407:                        str[2][0],str[2][1],str[2][2],str[2][3],
        !           408:                        str[3][0],str[3][1],str[3][2],str[3][3]);
        !           409: 
        !           410:        uifc.showbuf(WIN_HLP|WIN_L2R|WIN_DYN|WIN_PACK,1,1,80,6,"Statistics",statbuf,curp,barp);
        !           411: /* Node 5 :    Mar 11  Space: 162,024k
        !           412:    Logons: 23/103      Total: 62,610      Timeon: 322/2430    Total: 5,321,900
        !           413:    Emails: 4/265       Posts: 4/12811     Fbacks: 2/17        Users: 1/592
        !           414:    Uloads: 324k        Files: 1/2195      Dloads: 9,308k      Files: 52 */
        !           415:        return(0);
        !           416: }
        !           417: 
        !           418: int view_log(char *filename, char *title)
        !           419: {
        !           420:        char str[1024];
        !           421:        int buffile;
        !           422:        int j;
        !           423:        char *buf;
        !           424: 
        !           425:        if(fexist(filename)) {
        !           426:                if((buffile=sopen(filename,O_RDONLY,SH_DENYWR))>=0) {
        !           427:                        j=filelength(buffile);
        !           428:                        if((buf=(char *)MALLOC(j+1))!=NULL) {
        !           429:                                read(buffile,buf,j);
        !           430:                                close(buffile);
        !           431:                                *(buf+j)=0;
        !           432:                                uifc.showbuf(WIN_MID,0,0,76,uifc.scrn_len-2,title,buf,NULL,NULL);
        !           433:                                free(buf);
        !           434:                                return(0);
        !           435:                        }
        !           436:                        close(buffile);
        !           437:                        uifc.msg("Error allocating memory for the error log");
        !           438:                        return(3);
        !           439:                }
        !           440:                sprintf(str,"Error opening %s",title);
        !           441:                uifc.msg(str);
        !           442:                return(1);
        !           443:        }
        !           444:        sprintf(str,"%s does not exists",title);
        !           445:        uifc.msg(str);
        !           446:        return(2);
        !           447: }
        !           448: 
        !           449: int view_logs(scfg_t *cfg)
        !           450: {
        !           451:        char**  opt;
        !           452:        int             i;
        !           453:        char    str[1024];
        !           454:        struct tm tm;
        !           455:        struct tm tm_yest;
        !           456:        time_t  now;
        !           457: 
        !           458:        now=time(NULL);
        !           459:        localtime_r(&now,&tm);
        !           460:        now -= 60*60*24;
        !           461:        localtime_r(&now,&tm_yest);
        !           462:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           463:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           464:        for(i=0;i<(MAX_OPTS+1);i++)
        !           465:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           466:                        allocfail(MAX_OPLN);
        !           467: 
        !           468:        i=0;
        !           469:        strcpy(opt[i++],"Today's callers");
        !           470:        strcpy(opt[i++],"Yesterday's callers");
        !           471:        strcpy(opt[i++],"Error log");
        !           472:        strcpy(opt[i++],"Today's log");
        !           473:        strcpy(opt[i++],"Yesterday's log");
        !           474:        strcpy(opt[i++],"Spam log");
        !           475:        strcpy(opt[i++],"SBBSEcho log");
        !           476:        strcpy(opt[i++],"Guru log");
        !           477:        strcpy(opt[i++],"Hack log");
        !           478:        opt[i][0]=0;
        !           479:        i=0;
        !           480:        uifc.helpbuf=   "`View Logs\n"
        !           481:                                        "`---------\n\n"
        !           482:                                        "`Today's callers     : `View a list of Today's callers.\n"
        !           483:                                        "`Yesterday's callers : `View a list of Yesterday's callers.\n"
        !           484:                                        "`Error log           : `View the Error log.\n"
        !           485:                                        "`Today's log         : `View Today's system activity.\n"
        !           486:                                        "`Yesterday's log     : `View Yesterday's system activity.\n"
        !           487:                                        "`Spam log            : `View the log of Spam E-Mail sent to the system.\n"
        !           488:                                        "`SBBSEcho log        : `View the SBBSecho tosser log.\n"
        !           489:                                        "`Guru log            : `View the transcriptions of chats with the Guru.\n"
        !           490:                                        "`Hack log            : `View the Hack attempt log.";
        !           491: 
        !           492:        while(1) {
        !           493:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"View Logs",opt))  {
        !           494:                        case -1:
        !           495:                                freeopt(opt);
        !           496:                                return(0);
        !           497:                        case 0:
        !           498:                                sprintf(str,"%slogs/%2.2d%2.2d%2.2d.lol",cfg->logs_dir,tm.tm_mon+1,tm.tm_mday
        !           499:                                        ,TM_YEAR(tm.tm_year));
        !           500:                                view_log(str,"Todays Callers");
        !           501:                                break;
        !           502:                        case 1:
        !           503:                                sprintf(str,"%slogs/%2.2d%2.2d%2.2d.lol",cfg->logs_dir,tm_yest.tm_mon+1
        !           504:                                        ,tm_yest.tm_mday,TM_YEAR(tm_yest.tm_year));
        !           505:                                view_log(str,"Yesterdays Callers");
        !           506:                                break;
        !           507:                        case 2:
        !           508:                                sprintf(str,"%s/error.log",cfg->logs_dir);
        !           509:                                view_log(str,"Error Log");
        !           510:                                break;
        !           511:                        case 3:
        !           512:                                sprintf(str,"%slogs/%2.2d%2.2d%2.2d.log",cfg->logs_dir,tm.tm_mon+1,tm.tm_mday
        !           513:                                        ,TM_YEAR(tm.tm_year));
        !           514:                                view_log(str,"Todays Log");
        !           515:                                break;
        !           516:                        case 4:
        !           517:                                sprintf(str,"%slogs/%2.2d%2.2d%2.2d.log",cfg->logs_dir,tm_yest.tm_mon+1
        !           518:                                        ,tm_yest.tm_mday,TM_YEAR(tm_yest.tm_year));
        !           519:                                view_log(str,"Yesterdays Log");
        !           520:                                break;
        !           521:                        case 5:
        !           522:                                sprintf(str,"%sspam.log",cfg->logs_dir);
        !           523:                                view_log(str,"SPAM Log");
        !           524:                                break;
        !           525:                        case 6:
        !           526:                                sprintf(str,"%ssbbsecho.log",cfg->logs_dir);
        !           527:                                view_log(str,"SBBSEcho Log");
        !           528:                                break;
        !           529:                        case 7:
        !           530:                                sprintf(str,"%sguru.log",cfg->logs_dir);
        !           531:                                view_log(str,"Guru Log");
        !           532:                                break;
        !           533:                        case 8:
        !           534:                                sprintf(str,"%shack.log",cfg->logs_dir);
        !           535:                                view_log(str,"Hack Log");
        !           536:                                break;
        !           537:                }
        !           538:        }
        !           539: }
        !           540: 
        !           541: int do_cmd(char *cmd)
        !           542: {
        !           543:        int i;
        !           544:        struct text_info ti;
        !           545:        char *p;
        !           546: 
        !           547:        gettextinfo(&ti);
        !           548:        p=malloc(ti.screenheight*ti.screenwidth*2);
        !           549:        gettext(1,1,ti.screenwidth,ti.screenheight,p);
        !           550:        i=system(cmd);
        !           551:        puttext(1,1,ti.screenwidth,ti.screenheight,p);
        !           552:        free(p);
        !           553:        return(i);
        !           554: }
        !           555: 
        !           556: int qwk_callouts(scfg_t *cfg)
        !           557: {
        !           558:        char**  opt;
        !           559:        int             i,j;
        !           560:        char    str[1024];
        !           561: 
        !           562:        if(cfg->total_qhubs<1) {
        !           563:                uifc.msg("No QWK hubs configured!");
        !           564:                return(1);
        !           565:        }
        !           566: 
        !           567:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           568:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           569:        for(i=0;i<(MAX_OPTS+1);i++)
        !           570:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           571:                        allocfail(MAX_OPLN);
        !           572: 
        !           573: 
        !           574:        uifc.helpbuf=   "`QWK Callouts\n"
        !           575:                                        "`------------\n\n"
        !           576:                                        "Select the Hub and press enter to initiate a call out to\n"
        !           577:                                        "the highlighted system.";
        !           578: 
        !           579:        j=0;
        !           580:        while(1) {
        !           581:                for(i=0;i<cfg->total_qhubs;i++) {
        !           582:                        strcpy(opt[i],cfg->qhub[i]->id);
        !           583:                        sprintf(str,"%sqnet/%s.now",cfg->data_dir,cfg->qhub[i]->id);
        !           584:                        if(fexist(str))
        !           585:                                strcat(opt[i]," (pending)");
        !           586:                }
        !           587:                opt[i][0]=0;
        !           588:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"QWK Callouts",opt))  {
        !           589:                        case -1:
        !           590:                                freeopt(opt);
        !           591:                                return(0);
        !           592:                                break;
        !           593:                        default:
        !           594:                                sprintf(str,"%sqnet/%s.now",cfg->data_dir,cfg->qhub[j]->id);
        !           595:                                ftouch(str);
        !           596:                }
        !           597:        }
        !           598:        return(0);
        !           599: }
        !           600: 
        !           601: int run_events(scfg_t *cfg)
        !           602: {
        !           603:        char**  opt;
        !           604:        int             i,j;
        !           605:        char    str[1024];
        !           606: 
        !           607:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           608:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           609:        for(i=0;i<(MAX_OPTS+1);i++)
        !           610:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           611:                        allocfail(MAX_OPLN);
        !           612: 
        !           613:        if(cfg->total_events<1) {
        !           614:                uifc.msg("No events configured!");
        !           615:                return(1);
        !           616:        }
        !           617:        j=0;
        !           618: 
        !           619:        uifc.helpbuf=   "`Run Events\n"
        !           620:                                        "`----------\n\n"
        !           621:                                        "To run and event, highlight it and press Enter";
        !           622: 
        !           623:        while(1) {
        !           624:                for(i=0;i<cfg->total_events;i++) {
        !           625:                        strcpy(opt[i],cfg->event[i]->code);
        !           626:                        sprintf(str,"%s%s.now",cfg->data_dir,cfg->event[i]->code);
        !           627:                        if(fexist(str))
        !           628:                                strcat(opt[i]," (pending)");
        !           629:                }
        !           630:                opt[i][0]=0;
        !           631:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&j,0,"Run Events",opt))  {
        !           632:                        case -1:
        !           633:                                freeopt(opt);
        !           634:                                return(0);
        !           635:                                break;
        !           636:                        default:
        !           637:                                sprintf(str,"%s%s.now",cfg->data_dir,cfg->event[j]->code);
        !           638:                                ftouch(str);
        !           639:                }
        !           640:        }
        !           641:        return(0);
        !           642: }
        !           643: 
        !           644: int recycle_servers(scfg_t *cfg)
        !           645: {
        !           646:        char str[1024];
        !           647:        char **opt;
        !           648:        int i=0;
        !           649: 
        !           650:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           651:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           652:        for(i=0;i<(MAX_OPTS+1);i++)
        !           653:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           654:                        allocfail(MAX_OPLN);
        !           655: 
        !           656:        i=0;
        !           657:        strcpy(opt[i++],"FTP server");
        !           658:        strcpy(opt[i++],"Mail server");
        !           659:        strcpy(opt[i++],"Services");
        !           660:        strcpy(opt[i++],"Telnet server");
        !           661:        strcpy(opt[i++],"Web server");
        !           662:        opt[i][0]=0;
        !           663: 
        !           664:        uifc.helpbuf=   "`Recycle Servers\n"
        !           665:                                        "`---------------\n\n"
        !           666:                                        "To rerun a server, highlight it and press Enter.\n"
        !           667:                                        "This will reload the configuration files for selected\n"
        !           668:                                        "server.";
        !           669: 
        !           670:        i=0;
        !           671:        while(1) {
        !           672:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Recycle Servers",opt))  {
        !           673:                        case -1:
        !           674:                                freeopt(opt);
        !           675:                                return(0);
        !           676:                                break;
        !           677:                        case 0:
        !           678:                                sprintf(str,"%sftpsrvr.rec",cfg->ctrl_dir);
        !           679:                                ftouch(str);
        !           680:                                break;
        !           681:                        case 1:
        !           682:                                sprintf(str,"%smailsrvr.rec",cfg->ctrl_dir);
        !           683:                                ftouch(str);
        !           684:                                break;
        !           685:                        case 2:
        !           686:                                sprintf(str,"%sservices.rec",cfg->ctrl_dir);
        !           687:                                ftouch(str);
        !           688:                                break;
        !           689:                        case 3:
        !           690:                                sprintf(str,"%stelnet.rec",cfg->ctrl_dir);
        !           691:                                ftouch(str);
        !           692:                                break;
        !           693:                        case 4:
        !           694:                                sprintf(str,"%swebsrvr.rec",cfg->ctrl_dir);
        !           695:                                ftouch(str);
        !           696:                                break;
        !           697:                }
        !           698:        }
        !           699:        return(0);
        !           700: }
        !           701: 
        !           702: char *geteditor(char *edit)
        !           703: {
        !           704:        if(getenv("EDITOR")==NULL && (getenv("VISUAL")==NULL || getenv("DISPLAY")==NULL))
        !           705:                strcpy(edit,"vi");
        !           706:        else {
        !           707:                if(getenv("DISPLAY")!=NULL && getenv("VISUAL")!=NULL)
        !           708:                        strcpy(edit,getenv("VISUAL"));
        !           709:                else
        !           710:                        strcpy(edit,getenv("EDITOR"));
        !           711:        }
        !           712:        return(edit);
        !           713: }
        !           714: 
        !           715: 
        !           716: int edit_cfg(scfg_t *cfg)
        !           717: {
        !           718:        char**  opt;
        !           719:        int             i;
        !           720:        char    cmd[1024];
        !           721:        char    editcmd[1024];
        !           722: 
        !           723:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           724:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           725:        for(i=0;i<(MAX_OPTS+1);i++)
        !           726:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           727:                        allocfail(MAX_OPLN);
        !           728: 
        !           729:        i=0;
        !           730:        strcpy(opt[i++],"sbbs.ini");
        !           731:        strcpy(opt[i++],"alias.cfg");
        !           732:        strcpy(opt[i++],"attr.cfg");
        !           733:        strcpy(opt[i++],"dns_blacklist.cfg");
        !           734:        strcpy(opt[i++],"dnsbl_exempt.cfg");
        !           735:        strcpy(opt[i++],"domains.cfg");
        !           736:        strcpy(opt[i++],"mailproc.cfg");
        !           737:        strcpy(opt[i++],"mime_types.cfg");
        !           738:        strcpy(opt[i++],"relay.cfg");
        !           739:        strcpy(opt[i++],"sbbsecho.cfg");
        !           740:        strcpy(opt[i++],"services.cfg");
        !           741:        strcpy(opt[i++],"services.ini");
        !           742:        strcpy(opt[i++],"ftpalias.cfg");
        !           743:        strcpy(opt[i++],"sockopts.cfg");
        !           744:        strcpy(opt[i++],"spambait.cfg");
        !           745:        strcpy(opt[i++],"spamblock.cfg");
        !           746:        strcpy(opt[i++],"twitlist.cfg");
        !           747:        opt[i][0]=0;
        !           748:        uifc.helpbuf= "Highlight desired file and hit Enter to edit it.";
        !           749:        i=0;
        !           750:        while(1) {
        !           751:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"System Options",opt))  {
        !           752:                        case -1:
        !           753:                                freeopt(opt);
        !           754:                                return(0);
        !           755:                                break;
        !           756:                        default:
        !           757:                                sprintf(cmd,"%s %s%s",geteditor(editcmd),cfg->ctrl_dir,opt[i]);
        !           758:                                do_cmd(cmd);
        !           759:                                break;
        !           760:                }
        !           761:        }
        !           762:        return(0);
        !           763: }
        !           764: 
        !           765: int edit_can(scfg_t *cfg)
        !           766: {
        !           767:        char**  opt;
        !           768:        int             i;
        !           769:        char    cmd[1024];
        !           770:        char    editcmd[1024];
        !           771: 
        !           772:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           773:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           774:        for(i=0;i<(MAX_OPTS+1);i++)
        !           775:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           776:                        allocfail(MAX_OPLN);
        !           777: 
        !           778:        i=0;
        !           779:        strcpy(opt[i++],"email.can");
        !           780:        strcpy(opt[i++],"file.can");
        !           781:        strcpy(opt[i++],"host.can");
        !           782:        strcpy(opt[i++],"ip.can");
        !           783:        strcpy(opt[i++],"ip-silent.can");
        !           784:        strcpy(opt[i++],"name.can");
        !           785:        strcpy(opt[i++],"phone.can");
        !           786:        strcpy(opt[i++],"rlogin.can");
        !           787:        strcpy(opt[i++],"subject.can");
        !           788:        opt[i][0]=0;
        !           789:        uifc.helpbuf="Highlight desired file and hit Enter to edit it.";
        !           790:        i=0;
        !           791:        while(1) {
        !           792:                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"System Options",opt))  {
        !           793:                        case -1:
        !           794:                                freeopt(opt);
        !           795:                                return(0);
        !           796:                                break;
        !           797:                        default:
        !           798:                                sprintf(cmd,"%s %s%s",geteditor(editcmd),cfg->text_dir,opt[i]);
        !           799:                                do_cmd(cmd);
        !           800:                                break;
        !           801:                }
        !           802:        }
        !           803:        return(0);
        !           804: }
        !           805: 
        !           806: int main(int argc, char** argv)  {
        !           807: 
        !           808:        char**  opt;
        !           809:        char**  mopt;
        !           810:        int             main_dflt=0;
        !           811:        int             main_bar=0;
        !           812:        char    revision[16];
        !           813:        char    str[256],ctrl_dir[41],*p;
        !           814:        char    title[256];
        !           815:        int             i,j;
        !           816:        node_t  node;
        !           817:        int             nodefile;
        !           818:        box_t   boxch;
        !           819:        scfg_t  cfg;
        !           820:        int             done;
        !           821:        int             ciolib_mode=CIOLIB_MODE_AUTO;
        !           822: 
        !           823:        /******************/
        !           824:        /* Ini file stuff */
        !           825:        /******************/
        !           826:        char    ini_file[MAX_PATH+1];
        !           827:        FILE*                           fp;
        !           828:        bbs_startup_t           bbs_startup;
        !           829: 
        !           830:        sscanf("$Revision: 1.66 $", "%*s %s", revision);
        !           831: 
        !           832:     printf("\nSynchronet UNIX Monitor %s-%s  Copyright 2004 "
        !           833:         "Rob Swindell\n",revision,PLATFORM_DESC);
        !           834: 
        !           835:        p=getenv("SBBSCTRL");
        !           836:        if(p==NULL) {
        !           837:                printf("\7\nSBBSCTRL environment variable is not set.\n");
        !           838:                printf("This environment variable must be set to your CTRL directory.");
        !           839:                printf("\nExample: SET SBBSCTRL=/sbbs/ctrl\n");
        !           840:                exit(1); }
        !           841: 
        !           842:        sprintf(ctrl_dir,"%.40s",p);
        !           843:        if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
        !           844:                && ctrl_dir[strlen(ctrl_dir)-1]!='/')
        !           845:                strcat(ctrl_dir,"/");
        !           846: 
        !           847:        gethostname(str,sizeof(str)-1);
        !           848: 
        !           849:        sbbs_get_ini_fname(ini_file, ctrl_dir, str);
        !           850: 
        !           851:        /* Initialize BBS startup structure */
        !           852:     memset(&bbs_startup,0,sizeof(bbs_startup));
        !           853:     bbs_startup.size=sizeof(bbs_startup);
        !           854:     strcpy(bbs_startup.ctrl_dir,ctrl_dir);
        !           855: 
        !           856:        /* Read .ini file here */
        !           857:        if(ini_file[0]!=0 && (fp=fopen(ini_file,"r"))!=NULL) {
        !           858:                printf("Reading %s\n",ini_file);
        !           859:        }
        !           860:        /* We call this function to set defaults, even if there's no .ini file */
        !           861:        sbbs_read_ini(fp,
        !           862:                NULL,           /* global_startup */
        !           863:                NULL, &bbs_startup,
        !           864:                NULL, NULL, /* ftp_startup */
        !           865:                NULL, NULL, /* web_startup */
        !           866:                NULL, NULL, /* mail_startup */
        !           867:                NULL, NULL  /* services_startup */
        !           868:                );
        !           869: 
        !           870:        /* close .ini file here */
        !           871:        if(fp!=NULL)
        !           872:                fclose(fp);
        !           873: 
        !           874:        chdir(bbs_startup.ctrl_dir);
        !           875: 
        !           876:        /* Read .cfg files here */
        !           877:     memset(&cfg,0,sizeof(cfg));
        !           878:        cfg.size=sizeof(cfg);
        !           879:        SAFECOPY(cfg.ctrl_dir,bbs_startup.ctrl_dir);
        !           880:        if(!load_cfg(&cfg, NULL, TRUE, str)) {
        !           881:                printf("ERROR! %s\n",str);
        !           882:                exit(1);
        !           883:        }
        !           884:        prep_dir(cfg.data_dir, cfg.temp_dir, sizeof(cfg.temp_dir));
        !           885: 
        !           886:     memset(&uifc,0,sizeof(uifc));
        !           887: 
        !           888:        uifc.esc_delay=500;
        !           889: 
        !           890:        boxch.ls=186;
        !           891:        boxch.rs=186;
        !           892:        boxch.ts=205;
        !           893:        boxch.bs=205;
        !           894:        boxch.tl=201;
        !           895:        boxch.tr=187;
        !           896:        boxch.bl=200;
        !           897:        boxch.br=188;
        !           898:        for(i=1;i<argc;i++) {
        !           899:         if(argv[i][0]=='-'
        !           900:             )
        !           901:             switch(toupper(argv[i][1])) {
        !           902:                 case 'C':
        !           903:                                uifc.mode|=UIFC_COLOR;
        !           904:                     break;
        !           905:                 case 'L':
        !           906:                     uifc.scrn_len=atoi(argv[i]+2);
        !           907:                     break;
        !           908:                 case 'E':
        !           909:                     uifc.esc_delay=atoi(argv[i]+2);
        !           910:                     break;
        !           911:                                case 'I':
        !           912:                                        switch(toupper(argv[i][2])) {
        !           913:                                                case 'A':
        !           914:                                                        ciolib_mode=CIOLIB_MODE_ANSI;
        !           915:                                                        break;
        !           916:                                                case 'C':
        !           917:                                                        ciolib_mode=CIOLIB_MODE_CURSES;
        !           918:                                                        break;
        !           919:                                                case 0:
        !           920:                                                        printf("NOTICE: The -i option is depreciated, use -if instead\r\n");
        !           921:                                                        SLEEP(2000);
        !           922:                                                case 'F':
        !           923:                                                        ciolib_mode=CIOLIB_MODE_CURSES_IBM;
        !           924:                                                        break;
        !           925:                                                case 'X':
        !           926:                                                        ciolib_mode=CIOLIB_MODE_X;
        !           927:                                                        break;
        !           928:                                                case 'W':
        !           929:                                                        ciolib_mode=CIOLIB_MODE_CONIO;
        !           930:                                                        break;
        !           931:                                                default:
        !           932:                                                        goto USAGE;
        !           933:                                        }
        !           934:                                        break;
        !           935:                 default:
        !           936:                                        USAGE:
        !           937:                     printf("\nusage: %s [ctrl_dir] [options]"
        !           938:                         "\n\noptions:\n\n"
        !           939:                         "-c  =  force color mode\n"
        !           940:                         "-e# =  set escape delay to #msec\n"
        !           941:                                                "-iX =  set interface mode to X (default=auto) where X is one of:\r\n"
        !           942: #ifdef __unix__
        !           943:                                                "       X = X11 mode\r\n"
        !           944:                                                "       C = Curses mode\r\n"
        !           945:                                                "       F = Curses mode with forced IBM charset\r\n"
        !           946: #else
        !           947:                                                "       W = Win32 native mode\r\n"
        !           948: #endif
        !           949:                                                "       A = ANSI mode\r\n"
        !           950:                         "-l# =  set screen lines to #\n"
        !           951:                                                ,argv[0]
        !           952:                         );
        !           953:                                exit(0);
        !           954:            }
        !           955:     }
        !           956: 
        !           957:        signal(SIGPIPE, SIG_IGN);
        !           958: 
        !           959:        uifc.size=sizeof(uifc);
        !           960:        i=initciolib(ciolib_mode);
        !           961:        if(i!=0) {
        !           962:        printf("ciolib library init returned error %d\n",i);
        !           963:        exit(1);
        !           964:        }
        !           965:        i=uifcini32(&uifc);  /* curses */
        !           966:        if(i!=0) {
        !           967:                printf("uifc library init returned error %d\n",i);
        !           968:                exit(1);
        !           969:        }
        !           970: 
        !           971:        if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
        !           972:                allocfail(sizeof(char *)*(MAX_OPTS+1));
        !           973:        for(i=0;i<(MAX_OPTS+1);i++)
        !           974:                if((opt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           975:                        allocfail(MAX_OPLN);
        !           976: 
        !           977:        if((mopt=(char **)MALLOC(sizeof(char *)*MAX_OPTS))==NULL)
        !           978:                allocfail(sizeof(char *)*MAX_OPTS);
        !           979:        for(i=0;i<MAX_OPTS;i++)
        !           980:                if((mopt[i]=(char *)MALLOC(MAX_OPLN))==NULL)
        !           981:                        allocfail(MAX_OPLN);
        !           982: 
        !           983:        sprintf(title,"Synchronet UNIX Monitor %s-%s",revision,PLATFORM_DESC);
        !           984:        if(uifc.scrn(title)) {
        !           985:                printf(" USCRN (len=%d) failed!\n",uifc.scrn_len+1);
        !           986:                bail(1);
        !           987:        }
        !           988: 
        !           989:        while(1) {
        !           990:                strcpy(mopt[0],"System Options");
        !           991:                for(i=1;i<=cfg.sys_nodes;i++) {
        !           992:                        if((j=getnodedat(&cfg,i,&node,NULL)))
        !           993:                                sprintf(mopt[i],"Error reading node data (%d)!",j);
        !           994:                        else
        !           995:                                sprintf(mopt[i],"%3d: %s",i,nodestatus(&cfg,&node,str,71));
        !           996:                }
        !           997:                mopt[i][0]=0;
        !           998: 
        !           999:                uifc.helpbuf=   "`Synchronet UNIX Monitor\n"
        !          1000:                                "`------------------\n"
        !          1001:                                "Welcome to the Synchronet UNIX Monitor.\n"
        !          1002:                                "Displayed on this screen are the statitics for the BBS\n"
        !          1003:                                "You can scroll through the list starting at \"System Options\" \n"
        !          1004:                                "Pressing Enter on each will give a menu of option to perform.\n"
        !          1005:                                "Additionally these keys are available from this screen:\n\n"
        !          1006:                                                "`CTRL-E : `Displays the error log\n"
        !          1007:                                                "`F12    : `Spys on the currently selected node\n"
        !          1008:                                                "`F11    : `Send message to the currently selected node\n"
        !          1009:                                                "`F10    : `Chats with the user on the currently selected node\n"
        !          1010:                                                "`DEL    : `Clear errors on currently selected node\n"
        !          1011:                                                "`CTRL-L : `Lock node toggle\n"
        !          1012:                                                "`CTRL-R : `Rerun node\n"
        !          1013:                                                "`CTRL-D : `Down node toggle\n"
        !          1014:                                                "`CTRL-I : `Interrupt node\n";
        !          1015: 
        !          1016:                drawstats(&cfg, main_dflt, &node, &main_dflt, &main_bar);
        !          1017: 
        !          1018:                j=uifc.list(WIN_L2R|WIN_ESC|WIN_ACT|WIN_DYN,0,5,70,&main_dflt,&main_bar
        !          1019:                        ,title,mopt);
        !          1020: 
        !          1021:                if(j == -2)
        !          1022:                        continue;
        !          1023: 
        !          1024:                if(j==-7) {     /* CTRL-E */
        !          1025:                        sprintf(str,"%s/error.log",cfg.data_dir);
        !          1026:                        view_log(str,"Error Log");
        !          1027:                        continue;
        !          1028:                }
        !          1029: 
        !          1030:                if(j==0) {
        !          1031:                        /* System Options */
        !          1032:                        i=0;
        !          1033:                        strcpy(opt[i++],"Run SCFG");
        !          1034:                        strcpy(opt[i++],"Run User Editor");
        !          1035:                        strcpy(opt[i++],"Run SyncTERM");
        !          1036:                        strcpy(opt[i++],"View logs");
        !          1037:                        strcpy(opt[i++],"Force QWK Net callout");
        !          1038:                        strcpy(opt[i++],"Run event");
        !          1039:                        strcpy(opt[i++],"Recycle servers");
        !          1040:                        strcpy(opt[i++],"Edit CFG/INI files");
        !          1041:                        strcpy(opt[i++],"Edit trashcan files");
        !          1042:                        opt[i][0]=0;
        !          1043:                        uifc.helpbuf=   "`System Options`\n"
        !          1044:                                        "`------------`\n\n"
        !          1045:                                                        "`Run SCFG              : `Run the Synchronet Configuration Utility.\n"
        !          1046:                                                        "`Run User Editor       : `Call up the User Editor.\n"
        !          1047:                                                        "`Run SynchTERM         : `Run SyncTERM for RLogin.  SyncTERM must be\n"
        !          1048:                                                        "                        in the exec directory.\n"
        !          1049:                                                        "`View logs             : `View the various system logs.\n"
        !          1050:                                                        "`Force QWK Net callout : `Force a callout to QWK Net Hub.  Select which\n"
        !          1051:                                                        "                        Hub from a popup list of configured Hubs.\n"
        !          1052:                                                        "`Run Event             : `Call up a menu of system events that can be\n"
        !          1053:                                                        "                        manually.\n"
        !          1054:                                                        "`Recycle Servers       : `Have the Servers reload their configuration \n"
        !          1055:                                                        "                        files.\n"
        !          1056:                                                        "`Edit trashcan files   : `Edit the various .can files.  i.e.; ip.can";
        !          1057: 
        !          1058:                        done=0;
        !          1059:                        i=0;
        !          1060:                        while(!done) {
        !          1061:                                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"System Options",opt))  {
        !          1062:                                        case -1:
        !          1063:                                                done=1;
        !          1064:                                                break;
        !          1065:                                        case 0:
        !          1066:                                                sprintf(str,"%sscfg ",cfg.exec_dir);
        !          1067:                                                for(j=1; j<argc; j++) {
        !          1068:                                                        strcat(str,"'");
        !          1069:                                                        strcat(str,argv[j]);
        !          1070:                                                        strcat(str,"' ");
        !          1071:                                                }
        !          1072:                                                do_cmd(str);
        !          1073:                                                break;
        !          1074:                                        case 1:
        !          1075:                                                sprintf(str,"%suedit ",cfg.exec_dir);
        !          1076:                                                for(j=1; j<argc; j++) {
        !          1077:                                                        strcat(str,"'");
        !          1078:                                                        strcat(str,argv[j]);
        !          1079:                                                        strcat(str,"' ");
        !          1080:                                                }
        !          1081:                                                do_cmd(str);
        !          1082:                                                break;
        !          1083:                                        case 2:
        !          1084:                                                sprintf(str,"%ssyncterm",cfg.exec_dir);
        !          1085:                                                for(j=1; j<argc; j++) {
        !          1086:                                                        strcat(str,"'");
        !          1087:                                                        strcat(str,argv[j]);
        !          1088:                                                        strcat(str,"' ");
        !          1089:                                                }
        !          1090:                                                do_cmd(str);
        !          1091:                                                break;
        !          1092:                                        case 3:
        !          1093:                                                view_logs(&cfg);
        !          1094:                                                break;
        !          1095:                                        case 4:
        !          1096:                                                qwk_callouts(&cfg);
        !          1097:                                                break;
        !          1098:                                        case 5:
        !          1099:                                                run_events(&cfg);
        !          1100:                                                break;
        !          1101:                                        case 6:
        !          1102:                                                recycle_servers(&cfg);
        !          1103:                                                break;
        !          1104:                                        case 7:
        !          1105:                                                edit_cfg(&cfg);
        !          1106:                                                break;
        !          1107:                                        case 8:
        !          1108:                                                edit_can(&cfg);
        !          1109:                                                break;
        !          1110:                                }
        !          1111:                        }
        !          1112:                        continue;
        !          1113:                }
        !          1114: 
        !          1115:                if(j==-1) {
        !          1116:                        i=0;
        !          1117:                        strcpy(opt[0],YesStr);
        !          1118:                        strcpy(opt[1],NoStr);
        !          1119:                        opt[2][0]=0;
        !          1120:                        uifc.helpbuf=   "`Exit Synchronet UNIX Monitor:`\n"
        !          1121:                                                        "\n"
        !          1122:                                                        "\nIf you want to exit the Synchronet UNIX monitor utility,"
        !          1123:                                                        "\nselect `Yes`. Otherwise, select `No` or hit ~ ESC ~.";
        !          1124:                        i=uifc.list(WIN_MID,0,0,0,&i,0,"Exit Synchronet Monitor",opt);
        !          1125:                        if(!i)
        !          1126:                                bail(0);
        !          1127:                        continue;
        !          1128:                }
        !          1129: 
        !          1130:                /* Everything after this point is invalid for the System Options */
        !          1131:                if(main_dflt==0)
        !          1132:                        continue;
        !          1133: 
        !          1134:                if(j==-2-CIO_KEY_DC) {  /* Clear errors */
        !          1135:                        clearerrors(&cfg, main_dflt,&node);
        !          1136:                        continue;
        !          1137:                }
        !          1138: 
        !          1139:                if(j==-2-CIO_KEY_F(10)) {       /* Chat */
        !          1140:                        if(getnodedat(&cfg,main_dflt,&node,NULL)) {
        !          1141:                                uifc.msg("Error reading node data!");
        !          1142:                                continue;
        !          1143:                        }
        !          1144:                        if((node.status==NODE_INUSE) && node.useron)
        !          1145:                                chat(&cfg,main_dflt,&node,&boxch,NULL);
        !          1146:                        continue;
        !          1147:                }
        !          1148: 
        !          1149:                if(j==-2-CIO_KEY_F(11)) {       /* Send message */
        !          1150:                        sendmessage(&cfg, main_dflt,&node);
        !          1151:                        continue;
        !          1152:                }
        !          1153: 
        !          1154:                if(j==-2-CIO_KEY_F(12)) {       /* Spy */
        !          1155:                        dospy(main_dflt,&bbs_startup);
        !          1156:                        continue;
        !          1157:                }
        !          1158: 
        !          1159:                if(j==-2-CTRL('l')) {   /* Lock node */
        !          1160:                        if(getnodedat(&cfg,main_dflt,&node,&nodefile)) {
        !          1161:                                uifc.msg("Error reading node data!");
        !          1162:                                continue;
        !          1163:                        }
        !          1164:                        node.misc^=NODE_LOCK;
        !          1165:                        putnodedat(&cfg,main_dflt,&node,nodefile);
        !          1166:                        continue;
        !          1167:                }
        !          1168: 
        !          1169:                if(j==-2-CTRL('r')) {   /* Rerun node */
        !          1170:                        if(getnodedat(&cfg,main_dflt,&node,&nodefile)) {
        !          1171:                                uifc.msg("Error reading node data!");
        !          1172:                                continue;
        !          1173:                        }
        !          1174:                        node.misc^=NODE_RRUN;
        !          1175:                        putnodedat(&cfg,main_dflt,&node,nodefile);
        !          1176:                        continue;
        !          1177:                }
        !          1178: 
        !          1179:                if(j==-2-CTRL('d')) {   /* Down node */
        !          1180:                        if(getnodedat(&cfg,main_dflt,&node,&nodefile)) {
        !          1181:                                uifc.msg("Error reading node data!");
        !          1182:                                continue;
        !          1183:                        }
        !          1184:                        if(node.status != NODE_WFC && node.status != NODE_OFFLINE)
        !          1185:                                node.misc ^= NODE_DOWN;
        !          1186:                        else {
        !          1187:                                if(node.status!=NODE_OFFLINE)
        !          1188:                                        node.status=NODE_OFFLINE;
        !          1189:                                else
        !          1190:                                        node.status=NODE_WFC;
        !          1191:                        }
        !          1192:                        putnodedat(&cfg,main_dflt,&node,nodefile);
        !          1193:                        continue;
        !          1194:                }
        !          1195: 
        !          1196:                if(j==-2-CTRL('i')) {   /* Interrupt node */
        !          1197:                        if(getnodedat(&cfg,main_dflt,&node,&nodefile)) {
        !          1198:                                uifc.msg("Error reading node data!");
        !          1199:                                continue;
        !          1200:                        }
        !          1201:                        node.misc^=NODE_INTR;
        !          1202:                        putnodedat(&cfg,main_dflt,&node,nodefile);
        !          1203:                        continue;
        !          1204:                }
        !          1205: 
        !          1206:                if(j <= -2)
        !          1207:                        continue;
        !          1208: 
        !          1209:                if(j<=cfg.sys_nodes && j>0) {
        !          1210:                  if((node.status==NODE_INUSE) && node.useron) {
        !          1211:                i=0;
        !          1212:                        strcpy(opt[i++],"Edit User");
        !          1213:                        strcpy(opt[i++],"Spy on node");
        !          1214:                        strcpy(opt[i++],"Send message to user");
        !          1215:                        strcpy(opt[i++],"Chat with user");
        !          1216:                        strcpy(opt[i++],"Node toggles");
        !          1217:                        strcpy(opt[i++],"Clear Errors");
        !          1218:                        strcpy(opt[i++],"View node log");
        !          1219:                        strcpy(opt[i++],"View crash log");
        !          1220: 
        !          1221:                        opt[i][0]=0;
        !          1222:                        i=0;
        !          1223:                        uifc.helpbuf=   "`Node Options\n"
        !          1224:                                        "`------------\n\n"
        !          1225:                                                        "`Edit User            : `Call up the user editor to edit current user.\n"
        !          1226:                                                        "`Spy on User          : `Spy on current user.\n"
        !          1227:                                                        "`Send message to user : `Send on online message to user.\n"
        !          1228:                                                        "`Chat with user       : `Initiate private split-screen chat wityh user.\n"
        !          1229:                                                        "`Node Toggles         : `Call up Node Toggles menu to set various toggles\n"
        !          1230:                                                        "                       for current node.\n"
        !          1231:                                                        "`Clear Errors         : `Clears the error count for node.\n"
        !          1232:                                                        "`View node log        : `View activity log for current node.\n"
        !          1233:                                                        "`View crash log       : `View the crash log for current node.";
        !          1234:                        done=0;
        !          1235:                        while(!done) {
        !          1236:                                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Node Options",opt))  {
        !          1237: 
        !          1238:                                        case 0:  /* Edit Users */
        !          1239:                                                sprintf(str,"%suedit %d",cfg.exec_dir,node.useron);
        !          1240:                                                for(j=1; j<argc; j++) {
        !          1241:                                                  strcat(str,"'");
        !          1242:                                                  strcat(str,argv[j]);
        !          1243:                                                  strcat(str,"' ");
        !          1244:                                                }
        !          1245:                                                do_cmd(str);
        !          1246:                                                break;
        !          1247: 
        !          1248:                                    case 1:     /* Spy */
        !          1249:                                                dospy(j,&bbs_startup);
        !          1250:                                                break;
        !          1251: 
        !          1252:                                        case 2: /* Send message */
        !          1253:                                                sendmessage(&cfg, j,&node);
        !          1254:                                                break;
        !          1255: 
        !          1256:                                        case 3: /* Chat with User */
        !          1257:                                                chat(&cfg,main_dflt,&node,&boxch,NULL);
        !          1258:                                                break;
        !          1259: 
        !          1260:                                        case 4: /* Node Toggles */
        !          1261:                                                node_toggles(&cfg, j);
        !          1262:                                                break;
        !          1263: 
        !          1264:                                        case 5:
        !          1265:                                                clearerrors(&cfg, j,&node);
        !          1266:                                                break;
        !          1267: 
        !          1268:                                        case 6: /* Node log */
        !          1269:                                                sprintf(str,"%snode.log",cfg.node_path[j-1]);
        !          1270:                                                view_log(str,"Node Log");
        !          1271:                                                break;
        !          1272: 
        !          1273:                                        case 7: /* Crash log */
        !          1274:                                                sprintf(str,"%scrash.log",cfg.node_path[j-1]);
        !          1275:                                                view_log(str,"Crash Log");
        !          1276:                                                break;
        !          1277: 
        !          1278:                                        case -1:
        !          1279:                                                done=1;
        !          1280:                                                break;
        !          1281: 
        !          1282:                                        default:
        !          1283:                                                uifc.msg("Option not implemented");
        !          1284:                                                break;
        !          1285:                                        }
        !          1286:                                }
        !          1287:             }
        !          1288:          }
        !          1289:                if(j<=cfg.sys_nodes && j>0) {
        !          1290:                  if(!((node.status==NODE_INUSE) && node.useron)) {
        !          1291: 
        !          1292:                i=0;
        !          1293:                        strcpy(opt[i++],"Node toggles");
        !          1294:                        strcpy(opt[i++],"Clear Errors");
        !          1295:                        strcpy(opt[i++],"View node log");
        !          1296:                        strcpy(opt[i++],"View crash log");
        !          1297: 
        !          1298:                        opt[i][0]=0;
        !          1299:                        i=0;
        !          1300:                        uifc.helpbuf=   "`Node Options\n"
        !          1301:                                        "`------------\n\n"
        !          1302:                                                        "`Node Toggles   : `Call up Node Toggles menu to set various toggles\n"
        !          1303:                                                        "                 for current node.\n"
        !          1304:                                                        "`Clear Errors   : `Clears the error count for node.\n"
        !          1305:                                                        "`View node log  : `View activity log for current node.\n"
        !          1306:                                                        "`View crash log : `View the crash log for current node.";
        !          1307:                        done=0;
        !          1308:                        while(!done) {
        !          1309:                                switch(uifc.list(WIN_MID|WIN_SAV,0,0,0,&i,0,"Node Options",opt))  {
        !          1310: 
        !          1311:                                        case 0: /* Node Toggles */
        !          1312:                                                node_toggles(&cfg, j);
        !          1313:                                                break;
        !          1314: 
        !          1315:                                        case 1:
        !          1316:                                                clearerrors(&cfg, j,&node);
        !          1317:                                                break;
        !          1318: 
        !          1319:                                        case 2: /* Node log */
        !          1320:                                                sprintf(str,"%snode.log",cfg.node_path[j-1]);
        !          1321:                                                view_log(str,"Node Log");
        !          1322:                                                break;
        !          1323: 
        !          1324:                                        case 3: /* Crash log */
        !          1325:                                                sprintf(str,"%scrash.log",cfg.node_path[j-1]);
        !          1326:                                                view_log(str,"Crash Log");
        !          1327:                                                break;
        !          1328: 
        !          1329:                                case -1:
        !          1330:                                                done=1;
        !          1331:                                                break;
        !          1332: 
        !          1333:                                        default:
        !          1334:                                                uifc.msg("Option not implemented");
        !          1335:                                                break;
        !          1336:                                        }
        !          1337:                                }
        !          1338:             }
        !          1339:                }
        !          1340:        }
        !          1341: }
        !          1342: 
        !          1343: 
        !          1344: 
        !          1345: 
        !          1346: 
        !          1347: 
        !          1348: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.