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

unix.superglobalmegacorp.com

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