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