Annotation of sbbs/src/sbbs3/node.c, revision 1.1.1.2

1.1       root        1: /* node.c */
                      2: 
                      3: /* Synchronet BBS Node control program */
                      4: 
1.1.1.2 ! root        5: /* $Id: node.c,v 1.22 2009/10/25 02:58:06 rswindell Exp $ */
1.1       root        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:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       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: /* Platform-specific headers */
                     39: #ifdef _WIN32
                     40:        #include <io.h>                 /* open/close */
                     41:        #include <windows.h>
                     42: #endif
                     43: 
                     44: #include <stdio.h>
                     45: #include <stdlib.h>
                     46: #include <fcntl.h>
                     47: #include <string.h>
                     48: #include <errno.h>
                     49: #include <ctype.h>             /* isdigit */
                     50: 
                     51: /* Synchronet-specific */
                     52: #include "sbbsdefs.h"
                     53: #include "genwrap.h"   /* stricmp */
                     54: #include "filewrap.h"  /* lock/unlock/sopen */
                     55: 
                     56: enum {
                     57:         MODE_LIST
                     58:        ,MODE_ANON
                     59:        ,MODE_LOCK
                     60:        ,MODE_INTR
                     61:        ,MODE_RRUN
                     62:        ,MODE_DOWN
                     63:        ,MODE_EVENT
                     64:        ,MODE_NOPAGE
                     65:        ,MODE_NOALERTS
                     66:        ,MODE_STATUS
                     67:        ,MODE_USERON
                     68:        ,MODE_ACTION
                     69:        ,MODE_ERRORS
                     70:        ,MODE_MISC
                     71:        ,MODE_CONN
                     72:        ,MODE_AUX
                     73:        ,MODE_EXTAUX
                     74:        };
                     75: 
                     76: char tmp[256];
                     77: int nodefile;
                     78: 
                     79: #if defined(_WIN32)    /* Microsoft-supplied cls() routine - ugh! */
                     80: 
                     81: /* Standard error macro for reporting API errors */
                     82: #define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \
                     83:     on line %d\n", __FILE__, GetLastError(), api, __LINE__);}
                     84: 
                     85: void cls(void)
                     86: {
                     87:     COORD coordScreen = { 0, 0 };    /* here's where we'll home the
                     88:                                         cursor */
                     89:     BOOL bSuccess;
                     90:     DWORD cCharsWritten;
                     91:     CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
                     92:     DWORD dwConSize;                 /* number of character cells in
                     93:                                         the current buffer */
                     94:        HANDLE hConsole;
                     95: 
                     96:        hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
                     97: 
                     98:     /* get the number of character cells in the current buffer */
                     99: 
                    100:     bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
                    101:     PERR( bSuccess, "GetConsoleScreenBufferInfo" );
                    102:     dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
                    103: 
                    104:     /* fill the entire screen with blanks */
                    105: 
                    106:     bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
                    107:        dwConSize, coordScreen, &cCharsWritten );
                    108:     PERR( bSuccess, "FillConsoleOutputCharacter" );
                    109: 
                    110:     /* get the current text attribute */
                    111: 
                    112:     bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
                    113:     PERR( bSuccess, "ConsoleScreenBufferInfo" );
                    114: 
                    115:     /* now set the buffer's attributes accordingly */
                    116: 
                    117:     bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
                    118:        dwConSize, coordScreen, &cCharsWritten );
                    119:     PERR( bSuccess, "FillConsoleOutputAttribute" );
                    120: 
                    121:     /* put the cursor at (0, 0) */
                    122: 
                    123:     bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
                    124:     PERR( bSuccess, "SetConsoleCursorPosition" );
                    125:     return;
                    126: }
                    127: #else /* !_WIN32 */
                    128: 
                    129: #define cls()
                    130: 
                    131: #endif
                    132: 
                    133: #if !defined _MSC_VER && !defined __BORLANDC__
                    134: char* itoa(int val, char* str, int radix)
                    135: {
                    136:        switch(radix) {
                    137:                case 8:
                    138:                        sprintf(str,"%o",val);
                    139:                        break;
                    140:                case 10:
                    141:                        sprintf(str,"%u",val);
                    142:                        break;
                    143:                case 16:
                    144:                        sprintf(str,"%x",val);
                    145:                        break;
                    146:                default:
                    147:                        sprintf(str,"bad radix: %d",radix);
                    148:                        break;
                    149:        }
                    150:        return(str);
                    151: }
                    152: #endif
                    153: 
                    154: /****************************************************************************/
                    155: /* Reads the data for node number 'number' into the structure 'node'        */
                    156: /* from NODE.DAB                                                                                                                       */
                    157: /* if lockit is non-zero, locks this node's record. putnodedat() unlocks it */
                    158: /****************************************************************************/
                    159: void getnodedat(int number, node_t *node, int lockit)
                    160: {
                    161:        int count;
                    162: 
                    163:        number--;       /* make zero based */
                    164:        for(count=0;count<LOOP_NODEDAB;count++) {
                    165:                if(count)
                    166:                        SLEEP(100);
                    167:                lseek(nodefile,(long)number*sizeof(node_t),SEEK_SET);
                    168:                if(lockit
                    169:                        && lock(nodefile,(long)number*sizeof(node_t),sizeof(node_t))==-1) 
                    170:                        continue; 
                    171:                if(read(nodefile,node,sizeof(node_t))==sizeof(node_t))
                    172:                        break;
                    173:        }
                    174:        if(count>=(LOOP_NODEDAB/2))
                    175:                printf("NODE.DAB (node %d) COLLISION (READ) - Count: %d\n"
                    176:                        ,number+1, count);
                    177:        else if(count==LOOP_NODEDAB) {
                    178:                printf("!Error reading nodefile for node %d\n",number+1);
                    179:        }
                    180: }
                    181: 
                    182: /****************************************************************************/
                    183: /* Write the data from the structure 'node' into NODE.DAB                                      */
                    184: /* getnodedat(num,&node,1); must have been called before calling this func  */
                    185: /*          NOTE: ------^   the indicates the node record has been locked   */
                    186: /****************************************************************************/
                    187: void putnodedat(int number, node_t node)
                    188: {
                    189:        number--;       /* make zero based */
                    190:        lseek(nodefile,(long)number*sizeof(node_t),SEEK_SET);
                    191:        if(write(nodefile,&node,sizeof(node_t))!=sizeof(node_t)) {
                    192:                unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t));
                    193:                printf("Error writing to nodefile for node %d\n",number+1);
                    194:                return; }
                    195:        unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t));
                    196: }
                    197: 
                    198: /****************************************************************************/
                    199: /* Unpacks the password 'pass' from the 5bit ASCII inside node_t. 32bits in */
                    200: /* node.extaux, and the other 8bits in the upper byte of node.aux                      */
                    201: /****************************************************************************/
                    202: char *unpackchatpass(char *pass, node_t node)
                    203: {
                    204:        char    bits;
                    205:        int     i;
                    206: 
                    207:        pass[0]=(node.aux&0x1f00)>>8;
                    208:        pass[1]=(char)(((node.aux&0xe000)>>13)|((node.extaux&0x3)<<3));
                    209:        bits=2;
                    210:        for(i=2;i<8;i++) {
                    211:                pass[i]=(char)((node.extaux>>bits)&0x1f);
                    212:                bits+=5; }
                    213:        pass[8]=0;
                    214:        for(i=0;i<8;i++)
                    215:                if(pass[i])
                    216:                        pass[i]+=64;
                    217:        return(pass);
                    218: }
                    219: 
1.1.1.2 ! root      220: static char* node_connection_desc(ushort conn, char* str)
        !           221: {
        !           222:        switch(conn) {
        !           223:                case NODE_CONNECTION_LOCAL:
        !           224:                        strcpy(str,"Locally");
        !           225:                        break;
        !           226:                case NODE_CONNECTION_TELNET:
        !           227:                        strcpy(str,"via telnet");
        !           228:                        break;
        !           229:                case NODE_CONNECTION_RLOGIN:
        !           230:                        strcpy(str,"via rlogin");
        !           231:                        break;
        !           232:                case NODE_CONNECTION_SSH:
        !           233:                        strcpy(str,"via ssh");
        !           234:                        break;
        !           235:                default:
        !           236:                        sprintf(str,"at %ubps",conn);
        !           237:                        break;
        !           238:        }
        !           239: 
        !           240:        return str;
        !           241: }
        !           242: 
1.1       root      243: /****************************************************************************/
                    244: /* Displays the information for node number 'number' contained in 'node'    */
                    245: /****************************************************************************/
                    246: void printnodedat(int number, node_t node)
                    247: {
                    248:     char hour,mer[3];
1.1.1.2 ! root      249:        char tmp[128];
1.1       root      250: 
                    251:        printf("Node %2d: ",number);
                    252:        switch(node.status) {
                    253:                case NODE_WFC:
1.1.1.2 ! root      254:                        printf("Waiting for connection");
1.1       root      255:                        break;
                    256:                case NODE_OFFLINE:
                    257:                        printf("Offline");
                    258:                        break;
                    259:                case NODE_NETTING:
                    260:                        printf("Networking");
                    261:                        break;
                    262:                case NODE_LOGON:
                    263:                        printf("At logon prompt");
                    264:                        break;
                    265:                case NODE_EVENT_WAITING:
                    266:                        printf("Waiting for all nodes to become inactive");
                    267:                        break;
                    268:                case NODE_EVENT_LIMBO:
                    269:                        printf("Waiting for node %d to finish external event",node.aux);
                    270:                        break;
                    271:                case NODE_EVENT_RUNNING:
                    272:                        printf("Running external event");
                    273:                        break;
                    274:                case NODE_NEWUSER:
                    275:                        printf("New user");
                    276:                        printf(" applying for access ");
1.1.1.2 ! root      277:                        printf("%s",node_connection_desc(node.connection,tmp));
1.1       root      278:                        break;
                    279:                case NODE_QUIET:
                    280:                case NODE_INUSE:
                    281:                        printf("User #%d",node.useron);
                    282:                        printf(" ");
                    283:                        switch(node.action) {
                    284:                                case NODE_MAIN:
                    285:                                        printf("at main menu");
                    286:                                        break;
                    287:                                case NODE_RMSG:
                    288:                                        printf("reading messages");
                    289:                                        break;
                    290:                                case NODE_RMAL:
                    291:                                        printf("reading mail");
                    292:                                        break;
                    293:                                case NODE_RSML:
                    294:                                        printf("reading sent mail");
                    295:                                        break;
                    296:                                case NODE_RTXT:
                    297:                                        printf("reading text files");
                    298:                                        break;
                    299:                                case NODE_PMSG:
                    300:                                        printf("posting message");
                    301:                                        break;
                    302:                                case NODE_SMAL:
                    303:                                        printf("sending mail");
                    304:                                        break;
                    305:                                case NODE_AMSG:
                    306:                                        printf("posting auto-message");
                    307:                                        break;
                    308:                                case NODE_XTRN:
                    309:                                        if(!node.aux)
                    310:                                                printf("at external program menu");
                    311:                                        else
                    312:                                                printf("running external program #%d",node.aux);
                    313:                                        break;
                    314:                                case NODE_DFLT:
                    315:                                        printf("changing defaults");
                    316:                                        break;
                    317:                                case NODE_XFER:
                    318:                                        printf("at transfer menu");
                    319:                                        break;
                    320:                                case NODE_RFSD:
                    321:                                        printf("retrieving from device #%d",node.aux);
                    322:                                        break;
                    323:                                case NODE_DLNG:
                    324:                                        printf("downloading");
                    325:                                        break;
                    326:                                case NODE_ULNG:
                    327:                                        printf("uploading");
                    328:                                        break;
                    329:                                case NODE_BXFR:
                    330:                                        printf("transferring bidirectional");
                    331:                                        break;
                    332:                                case NODE_LFIL:
                    333:                                        printf("listing files");
                    334:                                        break;
                    335:                                case NODE_LOGN:
                    336:                                        printf("logging on");
                    337:                                        break;
                    338:                                case NODE_LCHT:
                    339:                                        printf("in local chat with sysop");
                    340:                                        break;
                    341:                                case NODE_MCHT:
                    342:                                        if(node.aux) {
                    343:                                                printf("in multinode chat channel %d",node.aux&0xff);
                    344:                                                if(node.aux&0x1f00) { /* password */
                    345:                                                        putchar('*');
                    346:                                                        printf(" %s",unpackchatpass(tmp,node)); } }
                    347:                                        else
                    348:                                                printf("in multinode global chat channel");
                    349:                                        break;
                    350:                                case NODE_PAGE:
                    351:                                        printf("paging node %u for private chat",node.aux);
                    352:                                        break;
                    353:                                case NODE_PCHT:
                    354:                                        printf("in private chat with node %u",node.aux);
                    355:                                        break;
                    356:                                case NODE_GCHT:
                    357:                                        printf("chatting with The Guru");
                    358:                                        break;
                    359:                                case NODE_CHAT:
                    360:                                        printf("in chat section");
                    361:                                        break;
                    362:                                case NODE_TQWK:
                    363:                                        printf("transferring QWK packet");
                    364:                                        break;
                    365:                                case NODE_SYSP:
                    366:                                        printf("performing sysop activities");
                    367:                                        break;
                    368:                                default:
                    369:                                        printf(itoa(node.action,tmp,10));
                    370:                                        break;  }
1.1.1.2 ! root      371:                        printf(" %s",node_connection_desc(node.connection,tmp));
1.1       root      372:                        if(node.action==NODE_DLNG) {
                    373:                                if((node.aux/60)>=12) {
                    374:                                        if(node.aux/60==12)
                    375:                                                hour=12;
                    376:                                        else
                    377:                                                hour=(node.aux/60)-12;
                    378:                                        strcpy(mer,"pm"); }
                    379:                                else {
                    380:                                        if((node.aux/60)==0)    /* 12 midnite */
                    381:                                                hour=12;
                    382:                                        else hour=node.aux/60;
                    383:                                        strcpy(mer,"am"); }
                    384:                                printf(" ETA %02d:%02d %s"
                    385:                                        ,hour,node.aux-((node.aux/60)*60),mer); }
                    386:                        break; }
                    387:        if(node.misc&(NODE_LOCK|NODE_POFF|NODE_AOFF|NODE_MSGW|NODE_NMSG)) {
                    388:                printf(" (");
                    389:                if(node.misc&NODE_AOFF)
                    390:                        putchar('A');
                    391:                if(node.misc&NODE_LOCK)
                    392:                        putchar('L');
                    393:                if(node.misc&(NODE_MSGW|NODE_NMSG))
                    394:                        putchar('M');
                    395:                if(node.misc&NODE_POFF)
                    396:                        putchar('P');
                    397:                putchar(')'); }
                    398:        if(((node.misc
                    399:                &(NODE_ANON|NODE_UDAT|NODE_INTR|NODE_RRUN|NODE_EVENT|NODE_DOWN))
                    400:                || node.status==NODE_QUIET)) {
                    401:                printf(" [");
                    402:                if(node.misc&NODE_ANON)
                    403:                        putchar('A');
                    404:                if(node.misc&NODE_INTR)
                    405:                        putchar('I');
                    406:                if(node.misc&NODE_RRUN)
                    407:                        putchar('R');
                    408:                if(node.misc&NODE_UDAT)
                    409:                        putchar('U');
                    410:                if(node.status==NODE_QUIET)
                    411:                        putchar('Q');
                    412:                if(node.misc&NODE_EVENT)
                    413:                        putchar('E');
                    414:                if(node.misc&NODE_DOWN)
                    415:                        putchar('D');
                    416:                if(node.misc&NODE_LCHAT)
                    417:                        putchar('C');
                    418:                putchar(']'); }
                    419:        if(node.errors)
                    420:                printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' );
                    421:        printf("\n");
                    422: }
                    423: 
                    424: 
                    425: /****************************/
                    426: /* Main program entry point */
                    427: /****************************/
                    428: int main(int argc, char **argv)
                    429: {
                    430:        char str[256],ctrl_dir[41],*p,debug=0;
                    431:        int sys_nodes,node_num=0,onoff=0;
                    432:        int i,j,mode=0,misc;
                    433:        int     modify=0;
                    434:        int loop=0;
                    435:        int pause=0;
                    436:        long value=0;
                    437:        node_t node;
                    438: 
                    439:        char            revision[16];
                    440: 
1.1.1.2 ! root      441:        sscanf("$Revision: 1.22 $", "%*s %s", revision);
1.1       root      442: 
                    443:        printf("\nSynchronet Node Display/Control Utility v%s\n\n", revision);
                    444: 
                    445:        if(sizeof(node_t)!=SIZEOF_NODE_T) {
                    446:                printf("COMPILER ERROR: sizeof(node_t)=%d instead of %d\n"
                    447:                        ,sizeof(node_t),SIZEOF_NODE_T);
                    448:                return(-1);
                    449:        }
                    450: 
                    451:        if(argc<2) {
1.1.1.2 ! root      452:                printf("usage: node [-debug] [action [on|off]] [node numbers] [...]"
1.1       root      453:                        "\n\n");
                    454:                printf("actions (default is list):\n\n");
                    455:                printf("list        = list status\n");
                    456:                printf("anon        = anonymous user\n");
                    457:                printf("lock        = locked\n");
                    458:                printf("intr        = interrupt\n");
                    459:                printf("down        = shut-down\n");
                    460:                printf("rerun       = rerun\n");
                    461:                printf("event       = run event\n");
                    462:                printf("nopage      = page disable\n");
                    463:                printf("noalerts    = activity alerts disable\n");
                    464:                printf("status=#    = set status value\n");
                    465:                printf("useron=#    = set useron number\n");
                    466:                printf("action=#    = set action value\n");
                    467:                printf("errors=#    = set error counter\n");
                    468:                printf("conn=#      = set connection value\n");
                    469:                printf("misc=#      = set misc value\n");
                    470:                printf("aux=#       = set aux value\n");
                    471:                printf("extaux=#    = set extended aux value\n");
                    472:                exit(0); }
                    473: 
                    474:        p=getenv("SBBSCTRL");
                    475:        if(p==NULL) {
                    476:                printf("\7\nSBBSCTRL environment variable is not set.\n");
                    477:                printf("This environment variable must be set to your CTRL directory.");
                    478:                printf("\nExample: SET SBBSCTRL=/sbbs/ctrl\n");
                    479:                exit(1); }
                    480:        sprintf(ctrl_dir,"%.40s",p);
                    481:        if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
                    482:                && ctrl_dir[strlen(ctrl_dir)-1]!='/')
                    483:                strcat(ctrl_dir,"/");
                    484: 
                    485:        sprintf(str,"%snode.dab",ctrl_dir);
                    486:        if((nodefile=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
                    487:                printf("\7\nError %d opening %s.\n",errno,str);
                    488:                exit(1); }
                    489: 
                    490:        sys_nodes=filelength(nodefile)/sizeof(node_t);
                    491:        if(!sys_nodes) {
                    492:                printf("%s reflects 0 nodes!\n",str);
                    493:                exit(1); }
                    494: 
                    495:        for(i=1;i<argc;i++) {
                    496:                if(isdigit(argv[i][0]))
                    497:                        node_num=atoi(argv[i]);
                    498:                else {
                    499:                        node_num=onoff=value=0;
                    500:                        if(!stricmp(argv[i],"-DEBUG"))
                    501:                                debug=1;
                    502:                        if(!stricmp(argv[i],"-LOOP"))
                    503:                                loop=1;
                    504:                        if(!stricmp(argv[i],"-PAUSE"))
                    505:                                pause=1;
                    506: 
                    507:                        else if(!stricmp(argv[i],"LOCK"))
                    508:                                mode=MODE_LOCK;
                    509:                        else if(!stricmp(argv[i],"ANON"))
                    510:                                mode=MODE_ANON;
                    511:                        else if(!stricmp(argv[i],"INTR"))
                    512:                                mode=MODE_INTR;
                    513:                        else if(!stricmp(argv[i],"DOWN"))
                    514:                                mode=MODE_DOWN;
                    515:                        else if(!stricmp(argv[i],"RERUN"))
                    516:                                mode=MODE_RRUN;
                    517:                        else if(!stricmp(argv[i],"EVENT"))
                    518:                                mode=MODE_EVENT;
                    519:                        else if(!stricmp(argv[i],"NOPAGE"))
                    520:                                mode=MODE_NOPAGE;
                    521:                        else if(!stricmp(argv[i],"NOALERTS"))
                    522:                                mode=MODE_NOALERTS;
                    523:                        else if(!stricmp(argv[i],"ON"))
                    524:                                onoff=1;
                    525:                        else if(!stricmp(argv[i],"OFF"))
                    526:                                onoff=2;
                    527:                        else if(!strnicmp(argv[i],"STATUS=",7)) {
                    528:                                mode=MODE_STATUS;
                    529:                                value=atoi(argv[i]+7); }
                    530:                        else if(!strnicmp(argv[i],"ERRORS=",7)) {
                    531:                                mode=MODE_ERRORS;
                    532:                                value=atoi(argv[i]+7); }
                    533:                        else if(!strnicmp(argv[i],"USERON=",7)) {
                    534:                                mode=MODE_USERON;
                    535:                                value=atoi(argv[i]+7); }
                    536:                        else if(!strnicmp(argv[i],"ACTION=",7)) {
                    537:                                mode=MODE_ACTION;
                    538:                                value=atoi(argv[i]+7); }
                    539:                        else if(!strnicmp(argv[i],"CONN=",5)) {
                    540:                                mode=MODE_CONN;
                    541:                                value=atoi(argv[i]+5); }
                    542:                        else if(!strnicmp(argv[i],"MISC=",5)) {
                    543:                                mode=MODE_MISC;
                    544:                                value=atoi(argv[i]+5); }
                    545:                        else if(!strnicmp(argv[i],"AUX=",4)) {
                    546:                                mode=MODE_AUX;
                    547:                                value=atoi(argv[i]+4); }
                    548:                        else if(!strnicmp(argv[i],"EXTAUX=",7)) {
                    549:                                mode=MODE_EXTAUX;
                    550:                                value=atoi(argv[i]+7); }
                    551:                        }
                    552:                if(mode!=MODE_LIST)
                    553:                        modify=1;
                    554: 
                    555:                if((mode && node_num) || i+1==argc)
                    556:                        while(1) {
                    557:                                for(j=1;j<=sys_nodes;j++)
                    558:                                        if(!node_num || j==node_num) {
                    559:                                                getnodedat(j,&node,modify);
                    560:                                                misc=0;
                    561:                                                switch(mode) {
                    562:                                                        case MODE_ANON:
                    563:                                                                misc=NODE_ANON;
                    564:                                                                break;
                    565:                                                        case MODE_LOCK:
                    566:                                                                misc=NODE_LOCK;
                    567:                                                                break;
                    568:                                                        case MODE_INTR:
                    569:                                                                misc=NODE_INTR;
                    570:                                                                break;
                    571:                                                        case MODE_DOWN:
                    572:                                                    if(node.status==NODE_WFC)
                    573:                                                        node.status=NODE_OFFLINE;
                    574:                                                                else
                    575:                                                                        misc=NODE_DOWN;
                    576:                                                                break;
                    577:                                                        case MODE_RRUN:
                    578:                                                                misc=NODE_RRUN;
                    579:                                                                break;
                    580:                                                        case MODE_EVENT:
                    581:                                                                misc=NODE_EVENT;
                    582:                                                                break;
                    583:                                                        case MODE_NOPAGE:
                    584:                                                                misc=NODE_POFF;
                    585:                                                                break;
                    586:                                                        case MODE_NOALERTS:
                    587:                                                                misc=NODE_AOFF;
                    588:                                                                break;
                    589:                                                        case MODE_STATUS:
                    590:                                                                node.status=(uchar)value;
                    591:                                                                break;
                    592:                                                        case MODE_ERRORS:
                    593:                                                                node.errors=(uchar)value;
                    594:                                                                break;
                    595:                                                        case MODE_ACTION:
                    596:                                                                node.action=(uchar)value;
                    597:                                                                break;
                    598:                                                        case MODE_USERON:
                    599:                                                                node.useron=(uchar)value;
                    600:                                                                break;
                    601:                                                        case MODE_MISC:
                    602:                                                                node.misc=(uchar)value;
                    603:                                                                break;
                    604:                                                        case MODE_CONN:
                    605:                                                                node.connection=(uchar)value;
                    606:                                                                break;
                    607:                                                        case MODE_AUX:
                    608:                                                                node.aux=(uchar)value;
                    609:                                                                break;
                    610:                                                        case MODE_EXTAUX:
                    611:                                                                node.extaux=value;
                    612:                                                                break; }
                    613:                                                if(misc) {
                    614:                                                        if(onoff==0)
                    615:                                                                node.misc^=misc;
                    616:                                                        else if(onoff==1)
                    617:                                                                node.misc|=misc;
                    618:                                                        else if(onoff==2)
                    619:                                                                node.misc&=~misc; }
                    620:                                                if(modify)
                    621:                                                        putnodedat(j,node);
                    622:                                                printnodedat(j,node);
                    623:                                                if(debug) {
                    624:                                                        printf("status=%u\n",node.status);
                    625:                                                        printf("errors=%u\n",node.errors);
                    626:                                                        printf("action=%d\n",node.action);
                    627:                                                        printf("useron=%u\n",node.useron);
                    628:                                                        printf("conn=%u\n",node.connection);
                    629:                                                        printf("misc=%u\n",node.misc);
                    630:                                                        printf("aux=%u\n",node.aux);
                    631:                                                        printf("extaux=%lu\n",node.extaux); 
                    632:                                                }  /* debug */
                    633: 
                    634:                                                if(pause) {
                    635:                                                        printf("Hit enter...");
                    636:                                                        getchar();
                    637:                                                        printf("\n");
                    638:                                                }
                    639: 
                    640:                                        } /* if(!node_num) */
                    641: 
                    642:                                if(!loop)
                    643:                                        break;
                    644:                                SLEEP(1000);
                    645:                                cls();
                    646:                        } /* while(1) */
                    647: 
                    648:        } /* for i<argc */
                    649: 
                    650:        close(nodefile);
                    651:        return(0);
                    652: }

unix.superglobalmegacorp.com

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