Annotation of sbbs/src/sbbs3/atcodes.cpp, revision 1.1.1.2

1.1       root        1: /* atcodes.cpp */
                      2: 
                      3: /* Synchronet "@code" functions */
                      4: 
1.1.1.2 ! root        5: /* $Id: atcodes.cpp,v 1.60 2011/08/25 19:22:44 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 2011 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: #include "sbbs.h"
                     39: #include "cmdshell.h"
                     40: 
                     41: #if defined(_WINSOCKAPI_)
                     42:        extern WSADATA WSAData;
                     43:        #define SOCKLIB_DESC WSAData.szDescription
                     44: #else
                     45:        #define SOCKLIB_DESC NULL
                     46: #endif
                     47: 
                     48: /****************************************************************************/
                     49: /* Returns 0 if invalid @ code. Returns length of @ code if valid.          */
                     50: /****************************************************************************/
1.1.1.2 ! root       51: int sbbs_t::show_atcode(const char *instr)
1.1       root       52: {
1.1.1.2 ! root       53:        char    str[128],str2[128],*tp,*sp,*p;
1.1       root       54:     int     len;
                     55:        int             disp_len;
                     56:        bool    padded_left=false;
                     57:        bool    padded_right=false;
1.1.1.2 ! root       58:        const char *cp;
1.1       root       59: 
1.1.1.2 ! root       60:        SAFECOPY(str,instr);
1.1       root       61:        tp=strchr(str+1,'@');
                     62:        if(!tp)                 /* no terminating @ */
                     63:                return(0);
                     64:        sp=strchr(str+1,' ');
                     65:        if(sp && sp<tp)         /* space before terminating @ */
                     66:                return(0);
                     67:        len=(tp-str)+1;
                     68:        (*tp)=0;
                     69:        sp=(str+1);
                     70: 
                     71:        disp_len=len;
                     72:        if((p=strstr(sp,"-L"))!=NULL)
                     73:                padded_left=true;
                     74:        else if((p=strstr(sp,"-R"))!=NULL)
                     75:                padded_right=true;
                     76:        if(p!=NULL) {
                     77:                if(*(p+2) && isdigit(*(p+2)))
                     78:                        disp_len=atoi(p+2);
                     79:                *p=0;
                     80:        }
                     81: 
1.1.1.2 ! root       82:        cp=atcode(sp,str2,sizeof(str2));
        !            83:        if(cp==NULL)
1.1       root       84:                return(0);
                     85: 
                     86:        if(padded_left)
1.1.1.2 ! root       87:                bprintf("%-*.*s",disp_len,disp_len,cp);
1.1       root       88:        else if(padded_right)
1.1.1.2 ! root       89:                bprintf("%*.*s",disp_len,disp_len,cp);
1.1       root       90:        else
1.1.1.2 ! root       91:                bputs(cp);
1.1       root       92: 
                     93:        return(len);
                     94: }
                     95: 
1.1.1.2 ! root       96: const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
1.1       root       97: {
                     98:        char*   tp;
                     99:        uint    i;
                    100:        uint    ugrp;
                    101:        uint    usub;
                    102:        long    l;
                    103:     stats_t stats;
                    104:     node_t  node;
                    105:        struct  tm tm;
                    106: 
                    107:        str[0]=0;
                    108: 
                    109:        if(!strcmp(sp,"VER"))
                    110:                return(VERSION);
                    111: 
                    112:        if(!strcmp(sp,"REV")) {
                    113:                safe_snprintf(str,maxlen,"%c",REVISION);
                    114:                return(str);
                    115:        }
                    116: 
                    117:        if(!strcmp(sp,"FULL_VER")) {
                    118:                safe_snprintf(str,maxlen,"%s%c%s",VERSION,REVISION,beta_version);
                    119:                truncsp(str);
                    120: #if defined(_DEBUG)
                    121:                strcat(str," Debug");
                    122: #endif
                    123:                return(str);
                    124:        }
                    125: 
                    126:        if(!strcmp(sp,"VER_NOTICE"))
                    127:                return(VERSION_NOTICE);
                    128: 
                    129:        if(!strcmp(sp,"OS_VER"))
                    130:                return(os_version(str));
                    131: 
                    132: #ifdef JAVASCRIPT
                    133:        if(!strcmp(sp,"JS_VER"))
                    134:                return((char *)JS_GetImplementationVersion());
                    135: #endif
                    136: 
                    137:        if(!strcmp(sp,"PLATFORM"))
                    138:                return(PLATFORM_DESC);
                    139: 
                    140:        if(!strcmp(sp,"COPYRIGHT"))
                    141:                return(COPYRIGHT_NOTICE);
                    142: 
                    143:        if(!strcmp(sp,"COMPILER")) {
                    144:                DESCRIBE_COMPILER(str);
                    145:                return(str);
                    146:        }
                    147: 
                    148:        if(!strcmp(sp,"UPTIME")) {
1.1.1.2 ! root      149:                extern volatile time_t uptime;
1.1       root      150:                time_t up=time(NULL)-uptime;
                    151:                if(up<0)
                    152:                        up=0;
                    153:                char   days[64]="";
                    154:                if((up/(24*60*60))>=2) {
                    155:                sprintf(days,"%lu days ",(ulong)(up/(24L*60L*60L)));
                    156:                        up%=(24*60*60);
                    157:                }
                    158:                safe_snprintf(str,maxlen,"%s%lu:%02lu"
                    159:                ,days
                    160:                        ,(ulong)(up/(60L*60L))
                    161:                        ,(ulong)((up/60L)%60L)
                    162:                        );
                    163:                return(str);
                    164:        }
                    165: 
                    166:        if(!strcmp(sp,"SERVED")) {
1.1.1.2 ! root      167:                extern volatile ulong served;
1.1       root      168:                safe_snprintf(str,maxlen,"%lu",served);
                    169:                return(str);
                    170:        }
                    171: 
                    172:        if(!strcmp(sp,"SOCKET_LIB"))
                    173:                return(socklib_version(str,SOCKLIB_DESC));
                    174: 
                    175:        if(!strcmp(sp,"MSG_LIB")) {
                    176:                safe_snprintf(str,maxlen,"SMBLIB %s",smb_lib_ver());
                    177:                return(str);
                    178:        }
                    179: 
                    180:        if(!strcmp(sp,"BBS") || !strcmp(sp,"BOARDNAME"))
                    181:                return(cfg.sys_name);
                    182: 
                    183:        if(!strcmp(sp,"BAUD") || !strcmp(sp,"BPS")) {
                    184:                safe_snprintf(str,maxlen,"%lu",cur_rate);
                    185:                return(str);
                    186:        }
                    187: 
                    188:        if(!strcmp(sp,"CONN"))
                    189:                return(connection);
                    190: 
                    191:        if(!strcmp(sp,"SYSOP"))
                    192:                return(cfg.sys_op);
                    193: 
                    194:        if(!strcmp(sp,"LOCATION"))
                    195:                return(cfg.sys_location);
                    196: 
                    197:        if(!strcmp(sp,"NODE")) {
                    198:                safe_snprintf(str,maxlen,"%u",cfg.node_num);
                    199:                return(str);
                    200:        }
                    201: 
                    202:        if(!strcmp(sp,"TNODE")) {
                    203:                safe_snprintf(str,maxlen,"%u",cfg.sys_nodes);
                    204:                return(str);
                    205:        }
                    206: 
                    207:        if(!strcmp(sp,"INETADDR"))
                    208:                return(cfg.sys_inetaddr);
                    209: 
                    210:        if(!strcmp(sp,"HOSTNAME"))
                    211:                return(startup->host_name);
                    212: 
                    213:        if(!strcmp(sp,"FIDOADDR")) {
                    214:                if(cfg.total_faddrs)
                    215:                        return(smb_faddrtoa(&cfg.faddr[0],str));
                    216:                return(nulstr);
                    217:        }
                    218: 
                    219:        if(!strcmp(sp,"EMAILADDR"))
                    220:                return(usermailaddr(&cfg, str
                    221:                        ,cfg.inetmail_misc&NMAIL_ALIAS ? useron.alias : useron.name));
                    222: 
                    223:        if(!strcmp(sp,"QWKID"))
                    224:                return(cfg.sys_id);
                    225: 
                    226:        if(!strcmp(sp,"TIME") || !strcmp(sp,"SYSTIME")) {
                    227:                now=time(NULL);
                    228:                memset(&tm,0,sizeof(tm));
                    229:                localtime_r(&now,&tm);
                    230:                if(cfg.sys_misc&SM_MILITARY)
                    231:                        safe_snprintf(str,maxlen,"%02d:%02d"
                    232:                                ,tm.tm_hour,tm.tm_min);
                    233:                else
                    234:                        safe_snprintf(str,maxlen,"%02d:%02d %s"
                    235:                                ,tm.tm_hour==0 ? 12
                    236:                                : tm.tm_hour>12 ? tm.tm_hour-12
                    237:                                : tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
                    238:                return(str);
                    239:        }
                    240: 
1.1.1.2 ! root      241:        if(!strcmp(sp,"TIMEZONE"))
        !           242:                return(smb_zonestr(sys_timezone(&cfg),str));
        !           243: 
1.1       root      244:        if(!strcmp(sp,"DATE") || !strcmp(sp,"SYSDATE")) {
                    245:                now=time(NULL);
                    246:                return(unixtodstr(&cfg,now,str));
                    247:        }
                    248: 
1.1.1.2 ! root      249:        if(!strcmp(sp,"DATETIME"))
        !           250:                return(timestr(time(NULL)));
        !           251: 
1.1       root      252:        if(!strcmp(sp,"TMSG")) {
                    253:                l=0;
                    254:                for(i=0;i<cfg.total_subs;i++)
                    255:                        l+=getposts(&cfg,i);            /* l=total posts */
                    256:                safe_snprintf(str,maxlen,"%lu",l);
                    257:                return(str);
                    258:        }
                    259: 
                    260:        if(!strcmp(sp,"TUSER")) {
                    261:                safe_snprintf(str,maxlen,"%u",total_users(&cfg));
                    262:                return(str);
                    263:        }
                    264: 
                    265:        if(!strcmp(sp,"TFILE")) {
                    266:                l=0;
                    267:                for(i=0;i<cfg.total_dirs;i++)
                    268:                        l+=getfiles(&cfg,i);
                    269:                safe_snprintf(str,maxlen,"%lu",l);
                    270:                return(str);
                    271:        }
                    272: 
                    273:        if(!strcmp(sp,"TCALLS") || !strcmp(sp,"NUMCALLS")) {
                    274:                getstats(&cfg,0,&stats);
                    275:                safe_snprintf(str,maxlen,"%lu",stats.logons);
                    276:                return(str);
                    277:        }
                    278: 
                    279:        if(!strcmp(sp,"PREVON") || !strcmp(sp,"LASTCALLERNODE")
                    280:                || !strcmp(sp,"LASTCALLERSYSTEM"))
                    281:                return(lastuseron);
                    282: 
                    283:        if(!strcmp(sp,"CLS")) {
                    284:                CLS;
                    285:                return(nulstr);
                    286:        }
                    287: 
                    288:        if(!strcmp(sp,"PAUSE") || !strcmp(sp,"MORE")) {
                    289:                pause();
                    290:                return(nulstr);
                    291:        }
                    292: 
                    293:        if(!strcmp(sp,"RESETPAUSE")) {
                    294:                lncntr=0;
                    295:                return(nulstr);
                    296:        }
                    297: 
                    298:        if(!strcmp(sp,"NOPAUSE") || !strcmp(sp,"POFF")) {
                    299:                sys_status^=SS_PAUSEOFF;
                    300:                return(nulstr);
                    301:        }
                    302: 
                    303:        if(!strcmp(sp,"PON") || !strcmp(sp,"AUTOMORE")) {
                    304:                sys_status^=SS_PAUSEON;
                    305:                return(nulstr);
                    306:        }
                    307: 
                    308:        /* NOSTOP */
                    309: 
                    310:        /* STOP */
                    311: 
                    312:        if(!strcmp(sp,"BELL") || !strcmp(sp,"BEEP"))
                    313:                return("\a");
                    314: 
                    315:        if(!strcmp(sp,"EVENT")) {
                    316:                if(event_time==0)
                    317:                        return("<none>");
1.1.1.2 ! root      318:                return(timestr(event_time));
1.1       root      319:        }
                    320: 
                    321:        /* LASTCALL */
                    322: 
                    323:        if(!strncmp(sp,"NODE",4)) {
                    324:                i=atoi(sp+4);
                    325:                if(i && i<=cfg.sys_nodes) {
                    326:                        getnodedat(i,&node,0);
                    327:                        printnodedat(i,&node);
                    328:                }
                    329:                return(nulstr);
                    330:        }
                    331: 
                    332:        if(!strcmp(sp,"WHO")) {
                    333:                whos_online(true);
                    334:                return(nulstr);
                    335:        }
                    336: 
                    337:        /* User Codes */
                    338: 
                    339:        if(!strcmp(sp,"USER") || !strcmp(sp,"ALIAS") || !strcmp(sp,"NAME"))
                    340:                return(useron.alias);
                    341: 
                    342:        if(!strcmp(sp,"FIRST")) {
                    343:                safe_snprintf(str,maxlen,"%s",useron.alias);
                    344:                tp=strchr(str,' ');
                    345:                if(tp) *tp=0;
                    346:                return(str);
                    347:        }
                    348: 
                    349:        if(!strcmp(sp,"USERNUM")) {
                    350:                safe_snprintf(str,maxlen,"%u",useron.number);
                    351:                return(str);
                    352:        }
                    353: 
                    354:        if(!strcmp(sp,"PHONE") || !strcmp(sp,"HOMEPHONE")
                    355:                || !strcmp(sp,"DATAPHONE") || !strcmp(sp,"DATA"))
                    356:                return(useron.phone);
                    357: 
                    358:        if(!strcmp(sp,"ADDR1"))
                    359:                return(useron.address);
                    360: 
                    361:        if(!strcmp(sp,"FROM"))
                    362:                return(useron.location);
                    363: 
                    364:        if(!strcmp(sp,"CITY")) {
                    365:                safe_snprintf(str,maxlen,"%s",useron.location);
                    366:                char* p=strchr(str,',');
                    367:                if(p) {
                    368:                        *p=0;
                    369:                        return(str);
                    370:                }
                    371:                return(nulstr);
                    372:        }
                    373: 
                    374:        if(!strcmp(sp,"STATE")) {
                    375:                char* p=strchr(useron.location,',');
                    376:                if(p) {
                    377:                        p++;
                    378:                        if(*p==' ')
                    379:                                p++;
                    380:                        return(p);
                    381:                }
                    382:                return(nulstr);
                    383:        }
                    384: 
                    385:        if(!strcmp(sp,"CPU"))
                    386:                return(useron.comp);
                    387: 
                    388:        if(!strcmp(sp,"HOST"))
                    389:                return(client_name);
                    390: 
                    391:        if(!strcmp(sp,"BDATE"))
                    392:                return(useron.birth);
                    393: 
                    394:        if(!strcmp(sp,"AGE")) {
                    395:                safe_snprintf(str,maxlen,"%u",getage(&cfg,useron.birth));
                    396:                return(str);
                    397:        }
                    398: 
                    399:        if(!strcmp(sp,"CALLS") || !strcmp(sp,"NUMTIMESON")) {
                    400:                safe_snprintf(str,maxlen,"%u",useron.logons);
                    401:                return(str);
                    402:        }
                    403: 
                    404:        if(!strcmp(sp,"MEMO"))
                    405:                return(unixtodstr(&cfg,useron.pwmod,str));
                    406: 
                    407:        if(!strcmp(sp,"SEC") || !strcmp(sp,"SECURITY")) {
                    408:                safe_snprintf(str,maxlen,"%u",useron.level);
                    409:                return(str);
                    410:        }
                    411: 
                    412:        if(!strcmp(sp,"SINCE"))
                    413:                return(unixtodstr(&cfg,useron.firston,str));
                    414: 
                    415:        if(!strcmp(sp,"TIMEON") || !strcmp(sp,"TIMEUSED")) {
                    416:                now=time(NULL);
                    417:                safe_snprintf(str,maxlen,"%lu",(ulong)(now-logontime)/60L);
                    418:                return(str);
                    419:        }
                    420: 
                    421:        if(!strcmp(sp,"TUSED")) {              /* Synchronet only */
                    422:                now=time(NULL);
                    423:                return(sectostr(now-logontime,str)+1);
                    424:        }
                    425: 
                    426:        if(!strcmp(sp,"TLEFT")) {              /* Synchronet only */
                    427:                gettimeleft();
                    428:                return(sectostr(timeleft,str)+1);
                    429:        }
                    430: 
                    431:        if(!strcmp(sp,"TPERD"))                /* Synchronet only */
                    432:                return(sectostr(cfg.level_timeperday[useron.level],str)+1);
                    433: 
                    434:        if(!strcmp(sp,"TPERC"))                /* Synchronet only */
                    435:                return(sectostr(cfg.level_timepercall[useron.level],str)+1);
                    436: 
                    437:        if(!strcmp(sp,"TIMELIMIT")) {
                    438:                safe_snprintf(str,maxlen,"%u",cfg.level_timepercall[useron.level]);
                    439:                return(str);
                    440:        }
                    441: 
                    442:        if(!strcmp(sp,"MINLEFT") || !strcmp(sp,"LEFT") || !strcmp(sp,"TIMELEFT")) {
                    443:                gettimeleft();
                    444:                safe_snprintf(str,maxlen,"%lu",timeleft/60);
                    445:                return(str);
                    446:        }
                    447: 
                    448:        if(!strcmp(sp,"LASTON"))
1.1.1.2 ! root      449:                return(timestr(useron.laston));
1.1       root      450: 
                    451:        if(!strcmp(sp,"LASTDATEON"))
                    452:                return(unixtodstr(&cfg,useron.laston,str));
                    453: 
                    454:        if(!strcmp(sp,"LASTTIMEON")) {
                    455:                memset(&tm,0,sizeof(tm));
                    456:                localtime_r(&useron.laston,&tm);
                    457:                safe_snprintf(str,maxlen,"%02d:%02d %s"
                    458:                        ,tm.tm_hour==0 ? 12
                    459:                        : tm.tm_hour>12 ? tm.tm_hour-12
                    460:                        : tm.tm_hour, tm.tm_min, tm.tm_hour>11 ? "pm":"am");
                    461:                return(str);
                    462:        }
                    463: 
                    464:        if(!strcmp(sp,"MSGLEFT") || !strcmp(sp,"MSGSLEFT")) {
                    465:                safe_snprintf(str,maxlen,"%u",useron.posts);
                    466:                return(str);
                    467:        }
                    468: 
                    469:        if(!strcmp(sp,"MSGREAD")) {
                    470:                safe_snprintf(str,maxlen,"%lu",posts_read);
                    471:                return(str);
                    472:        }
                    473: 
                    474:        if(!strcmp(sp,"FREESPACE")) {
                    475:                safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,0));
                    476:                return(str);
                    477:        }
                    478: 
                    479:        if(!strcmp(sp,"FREESPACEK")) {
                    480:                safe_snprintf(str,maxlen,"%lu",getfreediskspace(cfg.temp_dir,1024));
                    481:                return(str);
                    482:        }
                    483: 
                    484:        if(!strcmp(sp,"UPBYTES")) {
                    485:                safe_snprintf(str,maxlen,"%lu",useron.ulb);
                    486:                return(str);
                    487:        }
                    488: 
                    489:        if(!strcmp(sp,"UPK")) {
                    490:                safe_snprintf(str,maxlen,"%lu",useron.ulb/1024L);
                    491:                return(str);
                    492:        }
                    493: 
                    494:        if(!strcmp(sp,"UPS") || !strcmp(sp,"UPFILES")) {
                    495:                safe_snprintf(str,maxlen,"%u",useron.uls);
                    496:                return(str);
                    497:        }
                    498: 
                    499:        if(!strcmp(sp,"DLBYTES")) {
                    500:                safe_snprintf(str,maxlen,"%lu",useron.dlb);
                    501:                return(str);
                    502:        }
                    503: 
                    504:        if(!strcmp(sp,"DOWNK")) {
                    505:                safe_snprintf(str,maxlen,"%lu",useron.dlb/1024L);
                    506:                return(str);
                    507:        }
                    508: 
                    509:        if(!strcmp(sp,"DOWNS") || !strcmp(sp,"DLFILES")) {
                    510:                safe_snprintf(str,maxlen,"%u",useron.dls);
                    511:                return(str);
                    512:        }
                    513: 
                    514:        if(!strcmp(sp,"LASTNEW"))
                    515:                return(unixtodstr(&cfg,ns_time,str));
                    516: 
                    517:        if(!strcmp(sp,"NEWFILETIME"))
1.1.1.2 ! root      518:                return(timestr(ns_time));
1.1       root      519: 
                    520:        /* MAXDL */
                    521: 
                    522:        if(!strcmp(sp,"MAXDK") || !strcmp(sp,"DLKLIMIT") || !strcmp(sp,"KBLIMIT")) {
                    523:                safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]/1024L);
                    524:                return(str);
                    525:        }
                    526: 
                    527:        if(!strcmp(sp,"DAYBYTES")) {    /* amt of free cdts used today */
                    528:                safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]-useron.freecdt);
                    529:                return(str);
                    530:        }
                    531: 
                    532:        if(!strcmp(sp,"BYTELIMIT")) {
                    533:                safe_snprintf(str,maxlen,"%lu",cfg.level_freecdtperday[useron.level]);
                    534:                return(str);
                    535:        }
                    536: 
                    537:        if(!strcmp(sp,"KBLEFT")) {
                    538:                safe_snprintf(str,maxlen,"%lu",(useron.cdt+useron.freecdt)/1024L);
                    539:                return(str);
                    540:        }
                    541: 
                    542:        if(!strcmp(sp,"BYTESLEFT")) {
                    543:                safe_snprintf(str,maxlen,"%lu",useron.cdt+useron.freecdt);
                    544:                return(str);
                    545:        }
                    546: 
                    547:        if(!strcmp(sp,"CONF")) {
                    548:                safe_snprintf(str,maxlen,"%s %s"
                    549:                        ,usrgrps ? cfg.grp[usrgrp[curgrp]]->sname :nulstr
                    550:                        ,usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
                    551:                return(str);
                    552:        }
                    553: 
                    554:        if(!strcmp(sp,"CONFNUM")) {
                    555:                safe_snprintf(str,maxlen,"%u %u",curgrp+1,cursub[curgrp]+1);
                    556:                return(str);
                    557:        }
                    558: 
                    559:        if(!strcmp(sp,"NUMDIR")) {
                    560:                safe_snprintf(str,maxlen,"%u %u",usrlibs ? curlib+1 : 0,usrlibs ? curdir[curlib]+1 : 0);
                    561:                return(str);
                    562:        }
                    563: 
                    564:        if(!strcmp(sp,"EXDATE") || !strcmp(sp,"EXPDATE"))
                    565:                return(unixtodstr(&cfg,useron.expire,str));
                    566: 
                    567:        if(!strcmp(sp,"EXPDAYS")) {
                    568:                now=time(NULL);
                    569:                l=useron.expire-now;
                    570:                if(l<0)
                    571:                        l=0;
                    572:                safe_snprintf(str,maxlen,"%lu",l/(1440L*60L));
                    573:                return(str);
                    574:        }
                    575: 
                    576:        if(!strcmp(sp,"MEMO1"))
                    577:                return(useron.note);
                    578: 
                    579:        if(!strcmp(sp,"MEMO2") || !strcmp(sp,"COMPANY"))
                    580:                return(useron.name);
                    581: 
                    582:        if(!strcmp(sp,"ZIP"))
                    583:                return(useron.zipcode);
                    584: 
                    585:        if(!strcmp(sp,"HANGUP")) {
                    586:                hangup();
                    587:                return(nulstr);
                    588:        }
                    589: 
                    590:        /* Synchronet Specific */
                    591: 
                    592:        if(!strncmp(sp,"SETSTR:",7)) {
                    593:                strcpy(main_csi.str,sp+7);
                    594:                return(nulstr);
                    595:        }
                    596: 
                    597:        if(!strncmp(sp,"EXEC:",5)) {
                    598:                exec_bin(sp+5,&main_csi);
                    599:                return(nulstr);
                    600:        }
                    601: 
1.1.1.2 ! root      602:        if(!strncmp(sp,"EXEC_XTRN:",10)) {
        !           603:                for(i=0;i<cfg.total_xtrns;i++)
        !           604:                        if(!stricmp(cfg.xtrn[i]->code,sp+10))
        !           605:                                break;
        !           606:                if(i<cfg.total_xtrns)
        !           607:                        exec_xtrn(i);
        !           608:                return(nulstr);
        !           609:        }
        !           610: 
1.1       root      611:        if(!strncmp(sp,"MENU:",5)) {
                    612:                menu(sp+5);
                    613:                return(nulstr);
                    614:        }
                    615: 
                    616:        if(!strncmp(sp,"TYPE:",5)) {
                    617:                printfile(cmdstr(sp+5,nulstr,nulstr,str),0);
                    618:                return(nulstr);
                    619:        }
                    620: 
1.1.1.2 ! root      621:        if(!strncmp(sp,"INCLUDE:",8)) {
1.1       root      622:                printfile(cmdstr(sp+8,nulstr,nulstr,str),P_NOCRLF|P_SAVEATR);
                    623:                return(nulstr);
                    624:        }
                    625: 
                    626:        if(!strcmp(sp,"QUESTION"))
                    627:                return(question);
                    628: 
                    629:        if(!strcmp(sp,"HANDLE"))
                    630:                return(useron.handle);
                    631: 
                    632:        if(!strcmp(sp,"CID") || !strcmp(sp,"IP"))
                    633:                return(cid);
                    634: 
                    635:        if(!strcmp(sp,"LOCAL-IP")) {
                    636:                struct in_addr in_addr;
                    637:                in_addr.s_addr=local_addr;
                    638:                return(inet_ntoa(in_addr));
                    639:        }
                    640: 
                    641:        if(!strcmp(sp,"CRLF"))
                    642:                return("\r\n");
                    643: 
                    644:        if(!strcmp(sp,"PUSHXY")) {
1.1.1.2 ! root      645:                ansi_save();
1.1       root      646:                return(nulstr);
                    647:        }
                    648: 
                    649:        if(!strcmp(sp,"POPXY")) {
1.1.1.2 ! root      650:                ansi_restore();
1.1       root      651:                return(nulstr);
                    652:        }
                    653: 
                    654:        if(!strncmp(sp,"UP:",3)) {
1.1.1.2 ! root      655:                cursor_up(atoi(sp+3));
1.1       root      656:                return(str);
                    657:        }
                    658: 
                    659:        if(!strncmp(sp,"DOWN:",5)) {
1.1.1.2 ! root      660:                cursor_down(atoi(sp+5));
1.1       root      661:                return(str);
                    662:        }
                    663: 
                    664:        if(!strncmp(sp,"LEFT:",5)) {
1.1.1.2 ! root      665:                cursor_left(atoi(sp+5));
1.1       root      666:                return(str);
                    667:        }
                    668: 
                    669:        if(!strncmp(sp,"RIGHT:",6)) {
1.1.1.2 ! root      670:                cursor_right(atoi(sp+6));
1.1       root      671:                return(str);
                    672:        }
                    673: 
                    674:        if(!strncmp(sp,"GOTOXY:",7)) {
                    675:                tp=strchr(sp,',');
                    676:                if(tp!=NULL) {
                    677:                        tp++;
1.1.1.2 ! root      678:                        ansi_gotoxy(atoi(sp+7),atoi(tp));
1.1       root      679:                }
                    680:                return(nulstr);
                    681:        }
                    682: 
                    683:        if(!strcmp(sp,"GRP")) {
                    684:                if(SMB_IS_OPEN(&smb)) {
                    685:                        if(smb.subnum==INVALID_SUB)
                    686:                                return("Local");
                    687:                        if(smb.subnum<cfg.total_subs)
                    688:                                return(cfg.grp[cfg.sub[smb.subnum]->grp]->sname);
                    689:                }
                    690:                return(usrgrps ? cfg.grp[usrgrp[curgrp]]->sname : nulstr);
                    691:        }
                    692: 
                    693:        if(!strcmp(sp,"GRPL")) {
                    694:                if(SMB_IS_OPEN(&smb)) {
                    695:                        if(smb.subnum==INVALID_SUB)
                    696:                                return("Local");
                    697:                        if(smb.subnum<cfg.total_subs)
                    698:                                return(cfg.grp[cfg.sub[smb.subnum]->grp]->lname);
                    699:                }
                    700:                return(usrgrps ? cfg.grp[usrgrp[curgrp]]->lname : nulstr);
                    701:        }
                    702: 
                    703:        if(!strcmp(sp,"GN")) {
                    704:                if(SMB_IS_OPEN(&smb))
                    705:                        ugrp=getusrgrp(smb.subnum);
                    706:                else
                    707:                        ugrp=usrgrps ? curgrp+1 : 0;
                    708:                safe_snprintf(str,maxlen,"%u",ugrp);
                    709:                return(str);
                    710:        }
                    711: 
                    712:        if(!strcmp(sp,"GL")) {
                    713:                if(SMB_IS_OPEN(&smb))
                    714:                        ugrp=getusrgrp(smb.subnum);
                    715:                else
                    716:                        ugrp=usrgrps ? curgrp+1 : 0;
                    717:                safe_snprintf(str,maxlen,"%-4u",ugrp);
                    718:                return(str);
                    719:        }
                    720: 
                    721:        if(!strcmp(sp,"GR")) {
                    722:                if(SMB_IS_OPEN(&smb))
                    723:                        ugrp=getusrgrp(smb.subnum);
                    724:                else
                    725:                        ugrp=usrgrps ? curgrp+1 : 0;
                    726:                safe_snprintf(str,maxlen,"%4u",ugrp);
                    727:                return(str);
                    728:        }
                    729: 
                    730:        if(!strcmp(sp,"SUB")) {
                    731:                if(SMB_IS_OPEN(&smb)) {
                    732:                        if(smb.subnum==INVALID_SUB)
                    733:                                return("Mail");
                    734:                        else if(smb.subnum<cfg.total_subs)
                    735:                                return(cfg.sub[smb.subnum]->sname);
                    736:                }
                    737:                return(usrgrps ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->sname : nulstr);
                    738:        }
                    739: 
                    740:        if(!strcmp(sp,"SUBL")) {
                    741:                if(SMB_IS_OPEN(&smb)) {
                    742:                        if(smb.subnum==INVALID_SUB)
                    743:                                return("Mail");
                    744:                        else if(smb.subnum<cfg.total_subs)
                    745:                                return(cfg.sub[smb.subnum]->lname);
                    746:                }
                    747:                return(usrgrps  ? cfg.sub[usrsub[curgrp][cursub[curgrp]]]->lname : nulstr);
                    748:        }
                    749: 
                    750:        if(!strcmp(sp,"SN")) {
                    751:                if(SMB_IS_OPEN(&smb))
                    752:                        usub=getusrsub(smb.subnum);
                    753:                else
                    754:                        usub=usrgrps ? cursub[curgrp]+1 : 0;
                    755:                safe_snprintf(str,maxlen,"%u",usub);
                    756:                return(str);
                    757:        }
                    758: 
                    759:        if(!strcmp(sp,"SL")) {
                    760:                if(SMB_IS_OPEN(&smb))
                    761:                        usub=getusrsub(smb.subnum);
                    762:                else
                    763:                        usub=usrgrps ? cursub[curgrp]+1 : 0;
                    764:                safe_snprintf(str,maxlen,"%-4u",usub);
                    765:                return(str);
                    766:        }
                    767: 
                    768:        if(!strcmp(sp,"SR")) {
                    769:                if(SMB_IS_OPEN(&smb))
                    770:                        usub=getusrsub(smb.subnum);
                    771:                else
                    772:                        usub=usrgrps ? cursub[curgrp]+1 : 0;
                    773:                safe_snprintf(str,maxlen,"%4u",usub);
                    774:                return(str);
                    775:        }
                    776: 
                    777:        if(!strcmp(sp,"LIB"))
                    778:                return(usrlibs ? cfg.lib[usrlib[curlib]]->sname : nulstr);
                    779: 
                    780:        if(!strcmp(sp,"LIBL"))
                    781:                return(usrlibs ? cfg.lib[usrlib[curlib]]->lname : nulstr);
                    782: 
                    783:        if(!strcmp(sp,"LN")) {
                    784:                safe_snprintf(str,maxlen,"%u",usrlibs ? curlib+1 : 0);
                    785:                return(str);
                    786:        }
                    787: 
                    788:        if(!strcmp(sp,"LL")) {
                    789:                safe_snprintf(str,maxlen,"%-4u",usrlibs ? curlib+1 : 0);
                    790:                return(str);
                    791:        }
                    792: 
                    793:        if(!strcmp(sp,"LR")) {
                    794:                safe_snprintf(str,maxlen,"%4u",usrlibs  ? curlib+1 : 0);
                    795:                return(str);
                    796:        }
                    797: 
                    798:        if(!strcmp(sp,"DIR"))
                    799:                return(usrlibs ? cfg.dir[usrdir[curlib][curdir[curlib]]]->sname :nulstr);
                    800: 
                    801:        if(!strcmp(sp,"DIRL"))
                    802:                return(usrlibs ? cfg.dir[usrdir[curlib][curdir[curlib]]]->lname : nulstr);
                    803: 
                    804:        if(!strcmp(sp,"DN")) {
                    805:                safe_snprintf(str,maxlen,"%u",usrlibs ? curdir[curlib]+1 : 0);
                    806:                return(str);
                    807:        }
                    808: 
                    809:        if(!strcmp(sp,"DL")) {
                    810:                safe_snprintf(str,maxlen,"%-4u",usrlibs ? curdir[curlib]+1 : 0);
                    811:                return(str);
                    812:        }
                    813: 
                    814:        if(!strcmp(sp,"DR")) {
                    815:                safe_snprintf(str,maxlen,"%4u",usrlibs ? curdir[curlib]+1 : 0);
                    816:                return(str);
                    817:        }
                    818: 
                    819:        if(!strcmp(sp,"NOACCESS")) {
                    820:                if(noaccess_str==text[NoAccessTime])
                    821:                        safe_snprintf(str,maxlen,noaccess_str,noaccess_val/60,noaccess_val%60);
                    822:                else if(noaccess_str==text[NoAccessDay])
                    823:                        safe_snprintf(str,maxlen,noaccess_str,wday[noaccess_val]);
                    824:                else
                    825:                        safe_snprintf(str,maxlen,noaccess_str,noaccess_val);
                    826:                return(str);
                    827:        }
                    828: 
                    829:        if(!strcmp(sp,"LAST")) {
                    830:                tp=strrchr(useron.alias,' ');
                    831:                if(tp) tp++;
                    832:                else tp=useron.alias;
                    833:                return(tp);
                    834:        }
                    835: 
                    836:        if(!strcmp(sp,"REAL") || !strcmp(sp,"FIRSTREAL")) {
                    837:                safe_snprintf(str,maxlen,"%s",useron.name);
                    838:                tp=strchr(str,' ');
                    839:                if(tp) *tp=0;
                    840:                return(str);
                    841:        }
                    842: 
                    843:        if(!strcmp(sp,"LASTREAL")) {
                    844:                tp=strrchr(useron.name,' ');
                    845:                if(tp) tp++;
                    846:                else tp=useron.name;
                    847:                return(tp);
                    848:        }
                    849: 
                    850:        if(!strcmp(sp,"MAILW")) {
                    851:                safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number,0));
                    852:                return(str);
                    853:        }
                    854: 
                    855:        if(!strcmp(sp,"MAILP")) {
                    856:                safe_snprintf(str,maxlen,"%u",getmail(&cfg,useron.number,1));
                    857:                return(str);
                    858:        }
                    859: 
                    860:        if(!strncmp(sp,"MAILW:",6)) {
                    861:                safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6),0));
                    862:                return(str);
                    863:        }
                    864: 
                    865:        if(!strncmp(sp,"MAILP:",6)) {
                    866:                safe_snprintf(str,maxlen,"%u",getmail(&cfg,atoi(sp+6),1));
                    867:                return(str);
                    868:        }
                    869: 
                    870:        if(!strcmp(sp,"MSGREPLY")) {
                    871:                safe_snprintf(str,maxlen,"%c",cfg.sys_misc&SM_RA_EMU ? 'R' : 'A');
                    872:                return(str);
                    873:        }
                    874: 
                    875:        if(!strcmp(sp,"MSGREREAD")) {
                    876:                safe_snprintf(str,maxlen,"%c",cfg.sys_misc&SM_RA_EMU ? 'A' : 'R');
                    877:                return(str);
                    878:        }
                    879: 
                    880:        if(!strncmp(sp,"STATS.",6)) {
                    881:                getstats(&cfg,0,&stats);
                    882:                sp+=6;
                    883:                if(!strcmp(sp,"LOGONS"))
                    884:                        safe_snprintf(str,maxlen,"%lu",stats.logons);
                    885:                else if(!strcmp(sp,"LTODAY"))
                    886:                        safe_snprintf(str,maxlen,"%lu",stats.ltoday);
                    887:                else if(!strcmp(sp,"TIMEON"))
                    888:                        safe_snprintf(str,maxlen,"%lu",stats.timeon);
                    889:                else if(!strcmp(sp,"TTODAY"))
                    890:                        safe_snprintf(str,maxlen,"%lu",stats.ttoday);
                    891:                else if(!strcmp(sp,"ULS"))
                    892:                        safe_snprintf(str,maxlen,"%lu",stats.uls);
                    893:                else if(!strcmp(sp,"ULB"))
                    894:                        safe_snprintf(str,maxlen,"%lu",stats.ulb);
                    895:                else if(!strcmp(sp,"DLS"))
                    896:                        safe_snprintf(str,maxlen,"%lu",stats.dls);
                    897:                else if(!strcmp(sp,"DLB"))
                    898:                        safe_snprintf(str,maxlen,"%lu",stats.dlb);
                    899:                else if(!strcmp(sp,"PTODAY"))
                    900:                        safe_snprintf(str,maxlen,"%lu",stats.ptoday);
                    901:                else if(!strcmp(sp,"ETODAY"))
                    902:                        safe_snprintf(str,maxlen,"%lu",stats.etoday);
                    903:                else if(!strcmp(sp,"FTODAY"))
                    904:                        safe_snprintf(str,maxlen,"%lu",stats.ftoday);
                    905:                else if(!strcmp(sp,"NUSERS"))
                    906:                        safe_snprintf(str,maxlen,"%u",stats.nusers);
                    907:                return(str);
                    908:        }
                    909: 
                    910:        /* Message header codes */
                    911:        if(!strcmp(sp,"MSG_TO") && current_msg!=NULL) {
                    912:                if(current_msg->to==NULL)
                    913:                        return(nulstr);
                    914:                if(current_msg->to_ext!=NULL)
                    915:                        safe_snprintf(str,maxlen,"%s #%s",current_msg->to,current_msg->to_ext);
1.1.1.2 ! root      916:                else if(current_msg->to_net.type!=NET_NONE) {
        !           917:                        char tmp[128];
1.1       root      918:                        safe_snprintf(str,maxlen,"%s (%s)",current_msg->to
1.1.1.2 ! root      919:                                ,smb_netaddrstr(&current_msg->to_net,tmp));
        !           920:                } else
1.1       root      921:                        return(current_msg->to);
                    922:                return(str);
                    923:        }
                    924:        if(!strcmp(sp,"MSG_TO_NAME") && current_msg!=NULL)
                    925:                return(current_msg->to==NULL ? nulstr : current_msg->to);
                    926:        if(!strcmp(sp,"MSG_TO_EXT") && current_msg!=NULL) {
                    927:                if(current_msg->to_ext==NULL)
                    928:                        return(nulstr);
                    929:                return(current_msg->to_ext);
                    930:        }
                    931:        if(!strcmp(sp,"MSG_TO_NET") && current_msg!=NULL)
1.1.1.2 ! root      932:                return(smb_netaddrstr(&current_msg->to_net,str));
1.1       root      933:        if(!strcmp(sp,"MSG_FROM") && current_msg!=NULL) {
                    934:                if(current_msg->from==NULL)
                    935:                        return(nulstr);
                    936:                if(current_msg->hdr.attr&MSG_ANONYMOUS && !SYSOP)
                    937:                        return(text[Anonymous]);
                    938:                if(current_msg->from_ext!=NULL)
                    939:                        safe_snprintf(str,maxlen,"%s #%s",current_msg->from,current_msg->from_ext);
1.1.1.2 ! root      940:                else if(current_msg->from_net.type!=NET_NONE) {
        !           941:                        char tmp[128];
1.1       root      942:                        safe_snprintf(str,maxlen,"%s (%s)",current_msg->from
1.1.1.2 ! root      943:                                ,smb_netaddrstr(&current_msg->from_net,tmp));
        !           944:                } else
1.1       root      945:                        return(current_msg->from);
                    946:                return(str);
                    947:        }
                    948:        if(!strcmp(sp,"MSG_FROM_NAME") && current_msg!=NULL) {
                    949:                if(current_msg->from==NULL)
                    950:                        return(nulstr);
                    951:                if(current_msg->hdr.attr&MSG_ANONYMOUS && !SYSOP)
                    952:                        return(text[Anonymous]);
                    953:                return(current_msg->from);
                    954:        }
                    955:        if(!strcmp(sp,"MSG_FROM_EXT") && current_msg!=NULL) {
                    956:                if(!(current_msg->hdr.attr&MSG_ANONYMOUS) || SYSOP)
                    957:                        if(current_msg->from_ext!=NULL)
                    958:                                return(current_msg->from_ext);
                    959:                return(nulstr);
                    960:        }
                    961:        if(!strcmp(sp,"MSG_FROM_NET") && current_msg!=NULL) {
                    962:                if(current_msg->from_net.type!=NET_NONE
                    963:                        && (!(current_msg->hdr.attr&MSG_ANONYMOUS) || SYSOP))
1.1.1.2 ! root      964:                        return(smb_netaddrstr(&current_msg->from_net,str));
1.1       root      965:                return(nulstr);
                    966:        }
                    967:        if(!strcmp(sp,"MSG_SUBJECT") && current_msg!=NULL)
                    968:                return(current_msg->subj==NULL ? nulstr : current_msg->subj);
                    969:        if(!strcmp(sp,"MSG_DATE") && current_msg!=NULL)
1.1.1.2 ! root      970:                return(timestr(current_msg->hdr.when_written.time));
1.1       root      971:        if(!strcmp(sp,"MSG_TIMEZONE") && current_msg!=NULL)
                    972:                return(smb_zonestr(current_msg->hdr.when_written.zone,NULL));
                    973:        if(!strcmp(sp,"MSG_ATTR") && current_msg!=NULL) {
1.1.1.2 ! root      974:                safe_snprintf(str,maxlen,"%s%s%s%s%s%s%s%s%s%s%s"
1.1       root      975:                        ,current_msg->hdr.attr&MSG_PRIVATE              ? "Private  "   :nulstr
                    976:                        ,current_msg->hdr.attr&MSG_READ                 ? "Read  "      :nulstr
                    977:                        ,current_msg->hdr.attr&MSG_DELETE               ? "Deleted  "   :nulstr
                    978:                        ,current_msg->hdr.attr&MSG_KILLREAD             ? "Kill  "      :nulstr
                    979:                        ,current_msg->hdr.attr&MSG_ANONYMOUS    ? "Anonymous  " :nulstr
                    980:                        ,current_msg->hdr.attr&MSG_LOCKED               ? "Locked  "    :nulstr
                    981:                        ,current_msg->hdr.attr&MSG_PERMANENT    ? "Permanent  " :nulstr
                    982:                        ,current_msg->hdr.attr&MSG_MODERATED    ? "Moderated  " :nulstr
                    983:                        ,current_msg->hdr.attr&MSG_VALIDATED    ? "Validated  " :nulstr
                    984:                        ,current_msg->hdr.attr&MSG_REPLIED              ? "Replied  "   :nulstr
1.1.1.2 ! root      985:                        ,current_msg->hdr.attr&MSG_NOREPLY              ? "NoReply  "   :nulstr
1.1       root      986:                        );
                    987:                return(str);
                    988:        }
                    989:        if(!strcmp(sp,"MSG_ID") && current_msg!=NULL)
                    990:                return(current_msg->id==NULL ? nulstr : current_msg->id);
                    991:        if(!strcmp(sp,"MSG_REPLY_ID") && current_msg!=NULL)
                    992:                return(current_msg->reply_id==NULL ? nulstr : current_msg->reply_id);
                    993:        if(!strcmp(sp,"MSG_NUM") && current_msg!=NULL) {
                    994:                safe_snprintf(str,maxlen,"%lu",current_msg->hdr.number);
                    995:                return(str);
                    996:        }
                    997: 
                    998:        if(!strcmp(sp,"SMB_AREA")) {
                    999:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1000:                        safe_snprintf(str,maxlen,"%s %s"
                   1001:                                ,cfg.grp[cfg.sub[smb.subnum]->grp]->sname
                   1002:                                ,cfg.sub[smb.subnum]->sname);
                   1003:                return(str);
                   1004:        }
                   1005:        if(!strcmp(sp,"SMB_AREA_DESC")) {
                   1006:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1007:                        safe_snprintf(str,maxlen,"%s %s"
                   1008:                                ,cfg.grp[cfg.sub[smb.subnum]->grp]->lname
                   1009:                                ,cfg.sub[smb.subnum]->lname);
                   1010:                return(str);
                   1011:        }
                   1012:        if(!strcmp(sp,"SMB_GROUP")) {
                   1013:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1014:                        return(cfg.grp[cfg.sub[smb.subnum]->grp]->sname);
                   1015:                return(nulstr);
                   1016:        }
                   1017:        if(!strcmp(sp,"SMB_GROUP_DESC")) {
                   1018:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1019:                        return(cfg.grp[cfg.sub[smb.subnum]->grp]->lname);
                   1020:                return(nulstr);
                   1021:        }
                   1022:        if(!strcmp(sp,"SMB_GROUP_NUM")) {
                   1023:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1024:                        safe_snprintf(str,maxlen,"%u",getusrgrp(smb.subnum));
                   1025:                return(str);
                   1026:        }
                   1027:        if(!strcmp(sp,"SMB_SUB")) {
                   1028:                if(smb.subnum==INVALID_SUB)
                   1029:                        return("Mail");
                   1030:                else if(smb.subnum<cfg.total_subs)
                   1031:                        return(cfg.sub[smb.subnum]->sname);
                   1032:                return(nulstr);
                   1033:        }
                   1034:        if(!strcmp(sp,"SMB_SUB_DESC")) {
                   1035:                if(smb.subnum==INVALID_SUB)
                   1036:                        return("Mail");
                   1037:                else if(smb.subnum<cfg.total_subs)
                   1038:                        return(cfg.sub[smb.subnum]->lname);
                   1039:                return(nulstr);
                   1040:        }
                   1041:        if(!strcmp(sp,"SMB_SUB_CODE")) {
                   1042:                if(smb.subnum==INVALID_SUB)
                   1043:                        return("MAIL");
                   1044:                else if(smb.subnum<cfg.total_subs)
                   1045:                        return(cfg.sub[smb.subnum]->code);
                   1046:                return(nulstr);
                   1047:        }
                   1048:        if(!strcmp(sp,"SMB_SUB_NUM")) {
                   1049:                if(smb.subnum!=INVALID_SUB && smb.subnum<cfg.total_subs)
                   1050:                        safe_snprintf(str,maxlen,"%u",getusrsub(smb.subnum));
                   1051:                return(str);
                   1052:        }
                   1053:        if(!strcmp(sp,"SMB_MSGS")) {
                   1054:                safe_snprintf(str,maxlen,"%ld",smb.msgs);
                   1055:                return(str);
                   1056:        }
                   1057:        if(!strcmp(sp,"SMB_CURMSG")) {
                   1058:                safe_snprintf(str,maxlen,"%ld",smb.curmsg+1);
                   1059:                return(str);
                   1060:        }
                   1061:        if(!strcmp(sp,"SMB_LAST_MSG")) {
                   1062:                safe_snprintf(str,maxlen,"%lu",smb.status.last_msg);
                   1063:                return(str);
                   1064:        }
                   1065:        if(!strcmp(sp,"SMB_MAX_MSGS")) {
                   1066:                safe_snprintf(str,maxlen,"%lu",smb.status.max_msgs);
                   1067:                return(str);
                   1068:        }
                   1069:        if(!strcmp(sp,"SMB_MAX_CRCS")) {
                   1070:                safe_snprintf(str,maxlen,"%lu",smb.status.max_crcs);
                   1071:                return(str);
                   1072:        }
                   1073:        if(!strcmp(sp,"SMB_MAX_AGE")) {
                   1074:                safe_snprintf(str,maxlen,"%hu",smb.status.max_age);
                   1075:                return(str);
                   1076:        }
                   1077:        if(!strcmp(sp,"SMB_TOTAL_MSGS")) {
                   1078:                safe_snprintf(str,maxlen,"%lu",smb.status.total_msgs);
                   1079:                return(str);
                   1080:        }
                   1081: 
                   1082:        return(NULL);
                   1083: }
                   1084: 

unix.superglobalmegacorp.com

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