home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / XSRC_117.ZIP / XUSERS.C < prev   
Encoding:
C/C++ Source or Header  |  1990-11-02  |  29.9 KB  |  1,090 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*   XBBS SOURCE CODE copyright (c) 1990 by M. Kimes                        */
  4. /*   All Rights Reserved                                                    */
  5. /*                                                                          */
  6. /*    For complete details of the licensing restrictions, please refer      */
  7. /*    to the License agreement, which is published in its entirety in       */
  8. /*    the in the file LICENSE.XBS.                                          */
  9. /*                                                                          */
  10. /*    USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE      */
  11. /*    XBBS LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF            */
  12. /*    THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO       */
  13. /*    NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT M. KIMES         */
  14. /*    AT THE ADDRESS LISTED BELOW.  IN NO EVENT SHOULD YOU PROCEED TO USE   */
  15. /*    THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE XBBS LICENSING     */
  16. /*    AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU ARE ABLE TO REACH WITH      */
  17. /*    M. KIMES                                                              */
  18. /*                                                                          */
  19. /*                                                                          */
  20. /* You can contact M. Kimes at the following address:                       */
  21. /*                                                                          */
  22. /* M. Kimes                         1:380/16.0@FidoNet                      */
  23. /* 542 Merrick                      (318)222-3455 data                      */
  24. /* Shreveport, LA  71104                                                    */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* Please feel free to contact me at any time to share your comments about  */
  28. /* my software and/or licensing policies.                                   */
  29. /*                                                                          */
  30. /*--------------------------------------------------------------------------*/
  31. /*======================================================================*/
  32. /*  XBBS Bulletin Board System.....User routines                        */
  33. /*======================================================================*/
  34.  
  35. #include "msg.h"
  36. #include "xext.h"
  37.  
  38.  
  39.  
  40. void pascal userlist (word type) {
  41.  
  42.  int handlec;
  43.  int handleu;
  44.  char line[82];
  45.  struct _user check;
  46.  struct ffblk f;
  47.  char p[37];
  48.  char pp[39];
  49.  char t;
  50.  char *ptr=NULL;
  51.  word temp;
  52.  register word y;
  53.  register word x;
  54.  
  55.   if (findfirst(searchpath("users.bbs"),&f,0)) return;
  56.   t=conf.numcomps;
  57.   if (t) if (findfirst(searchpath("comtypes.lst"),&filestat,0)) t=0;
  58.   if (!(type & 4) && !(type & 8)) {
  59.     gprintf(0,"\nThere are %lu users.  ",f.ff_fsize/(ulong)sizeof(struct _user));
  60.     printm("Search string? ([Enter] for full list)\n -> ");
  61.     helpnum=534;
  62.     strcpy(p,genin(36,0,0,0,ALPHA));
  63.     helpnum=0;
  64.   }
  65.   else {
  66.     if (!(msg.attr & MSGLOCAL)) {
  67.         say_prompt(395);
  68.         return;
  69.     }
  70.     if (msg.m_attr & MSGANON) {
  71.         say_prompt(396);
  72.         return;
  73.     }
  74.     if (type & 4) strcpy(p,msg.from);
  75.     else strcpy(p,msg.to);
  76.     if (mboard.attr & REAL) type = type | 1;
  77.     else type = type & (~1);
  78.  }
  79.  if (!stricmp(p,"*ANONYMOUS*")) {
  80.     say_prompt(397);
  81.     return;
  82.  }
  83.  if (!strcmp(p,"ALL") || !strcmp(p,"SYSOP")) {
  84.     say_prompt(398);
  85.     return;
  86.  }
  87.  if ((handleu=oopen(searchpath("users.bbs"),O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  88.    gprintf(LOCALONLY,"\n\04Userfile error--%d\n",errno);
  89.  }
  90.  else {
  91.    say_prompt(385);
  92.    if (t) say_prompt(386);
  93.    printm("\n");
  94.    say_prompt(389);
  95.    say_prompt(387);
  96.    if (t) say_prompt(388);
  97.    printm("\n");
  98.  
  99.         ptr=(char *)mmalloc((word)5377);
  100.         if (!ptr) {
  101.             t=0;
  102.         }
  103.         else {
  104.             memset(ptr,0,5376);
  105.             if ((handlec=oopen(searchpath("comtypes.lst"),O_RDONLY | O_TEXT | O_DENYNONE))==-1) {
  106.                 t=0;
  107.             }
  108.             else {
  109.                 strcpy(ptr,"Unknown");
  110.                 for (x=1;x<256;x++) {
  111.                     if (eof(handlec) || !fgetsx(line,81,handlec)) break;
  112.                     stripcr(line);
  113.                     line[20]=0;
  114.                     strcpy(&ptr[x*21],line);
  115.                 }
  116.                 cclose(handlec);
  117.             }
  118.         }
  119.    }
  120.    pauser=1;
  121.    lines=3;
  122.    while (!eof(handleu) && _read(handleu,&check,sizeof(check))>0) {
  123.      if (type & 1) strcpy(check.handle,check.name);
  124.      strcpy(pp,check.handle);
  125.      if (((stristr(check.handle,p)) || (!*p)) && (!check.deleted) && (check.stat[0]>0)) {
  126.        if ((type & 4) || (type & 8)) {
  127.             if (stricmp(check.handle,p)) continue;
  128.        }
  129.        temp=strlen(pp);
  130.        for(y=0;y<(37-temp);y++) strcat(pp,".");
  131.        sprintf(line,"%s%s %s  ",pp,saydate(&check.lastdate),saytime(&check.lasttime));
  132.        if (t) strcat(line,&ptr[check.comptype * 21]);
  133.        strcat(line,"\n");
  134.        if ((printm(line)) || (toupper(inkey())=='S')) break;
  135.        sprintf(line," %s  %s",check.city,check.state);
  136.        sprintf(pp,"%u calls",check.times);
  137.        temp=(strlen(check.city)+strlen(check.state)+3);
  138.        for (y=0;y<(43-temp);y++) strcat(line," ");
  139.        strcat(line,pp);
  140.        strcat(line,"\n");
  141.        if ((printm(line)) || (toupper(inkey())=='S')) break;
  142.        if ((type & 4) || (type & 8)) break;
  143.      }
  144.    }
  145.    pauser=0;
  146.    cclose(handleu);
  147.    if (ptr) ffree (ptr);
  148. }
  149.  
  150.  
  151. void pascal load_lastread (void) {
  152.  
  153.     int fp;
  154.  
  155.     sprintf(buffer,"%sLASTREAD.BBS",messpath);
  156.     if ((fp=oopen(buffer,O_RDONLY | O_BINARY | O_DENYNONE))==-1) return;
  157.     lseek(fp,(long)(userno-1)*(long)(conf.nolmrs)*(long)sizeof(word),SEEK_SET);
  158.     _read(fp,(void far *)lastread,conf.nolmrs*sizeof(word));
  159.     cclose(fp);
  160. }
  161.  
  162.  
  163.  
  164. void pascal save_lastread (void) {
  165.  
  166.     int fp;
  167.  
  168.     sprintf(buffer,"%sLASTREAD.BBS",messpath);
  169.     if ((fp=oopen(buffer,O_RDWR | O_BINARY | O_DENYNONE))==-1)
  170.         if ((fp=ccreat(buffer,S_IWRITE))==-1) return;
  171.     lseek(fp,(long)(userno-1)*(long)(conf.nolmrs)*(long)sizeof(word),SEEK_SET);
  172.     _write(fp,(word far *)lastread,conf.nolmrs*sizeof(word));
  173.     cclose(fp);
  174. }
  175.  
  176.  
  177.  
  178.  
  179. void pascal trashcan (char *name) {
  180.  
  181.  char check[81];
  182.  char test[37];
  183.  char *a;
  184.  char *b;
  185.  int handle;
  186.  
  187.      *check=0;
  188.      strcpy(test,name);
  189.      if ((handle=oopen(searchpath("trashcan.ctl"),O_RDONLY | O_TEXT | O_DENYNONE))==-1) return;
  190.  
  191.      while (!eof(handle)) {
  192.        if(!fgetsx(check,81,handle)) break;
  193.        if (strlen(check)<2) goto skipcheck;
  194.        stripcr(check);
  195.  
  196.       if (!stricmp(name,check)) {
  197. badname:
  198.           cclose(handle);
  199.           user.violations++;
  200.          leaving++;
  201.          readfile("trashcan.xbs",0,0,1);
  202.          say_prompt(337);
  203.          fossil(FLUSHOUT,0);
  204.          fossil(DTR,DOWN);
  205.          logoff();
  206.          userno=0;
  207.          baud=0;
  208.          exit(254);
  209.        }
  210.        a=check;
  211.        if (*a==':') if (stristr(test,++a)) goto badname;
  212.        if (*a==';') {
  213.          b=strtok(test," ");
  214.          b=strtok(0," ");
  215.          if (!(stricmp(test,++a)) || (!stricmp(b,a))) goto badname;
  216.          strcpy(test,name);
  217.        }
  218. skipcheck:
  219. ;
  220.      }
  221.      cclose(handle);
  222. }
  223.  
  224.  
  225.  
  226. void pascal logoff (void) {   /* Update user account */
  227.  
  228.   conf.trace=0;
  229.   if (userno) {
  230.     say_prompt(19);
  231.     user.arq=0;
  232.     user.times++;
  233.     user.callstoday++;
  234.     user.timetoday+=(word)(getxbbstime()/60L);
  235.     if ((user.lastdate.da_day)!=(user.logondate.da_day)) {
  236.       user.callstoday=1;
  237.       timer_off++;
  238.       user.timetoday=(word)(getxbbstime()/60L);
  239.       timer_off=0;
  240.     }
  241.     getdate(&user.lastdate);
  242.     gettime(&user.lasttime);
  243.     user.lastmsgarea=mboard.number;
  244.     update();
  245.     conf.callcount++;
  246.     strcpy(conf.lastcaller,user.name);
  247.     conf.lastusernum=userno;
  248.     conf.lastcall=time(NULL);
  249.     saveconfig();
  250.   }
  251.   fossil(FLUSHOUT,0);
  252.   fossil(DTR,DOWN);
  253. }
  254.  
  255.  
  256.  
  257. void pascal userinfo (word baudrate,char type) {  /* Writes Door exit files */
  258.  
  259.  int handle,handle2;
  260.  char temp[38];
  261.  char tempname[36];
  262.  char *p=NULL;
  263.  word temptime;
  264.  char nodes[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  265.  
  266.     if (!baudrate) baudrate=baud;
  267.     if (type) strcpy(tempname,user.handle);
  268.     else strcpy(tempname,user.name);
  269.  
  270.     temptime=(word)(timelimit-(getxbbstime()/60))-(word)1;
  271.     if (temptime>(word)(timelimit-(getxbbstime()/60)) || timelimit<(word)(getxbbstime()/60)) temptime=0;
  272.  
  273.     if ((handle=ccreat("USERINFO.XBS",S_IWRITE))==-1) {
  274.         gprintf(LOCALONLY,"\n\04Can't create USERINFO.XBS--%d\n",errno);
  275.         goto Next1;
  276.     }
  277.     ffprintf(handle,"%s\r\n%u\r\n",tempname,baudrate);
  278.     ffprintf(handle,"%s\r\n%s\r\n",saydate(&user.lastdate),saytime(&user.lasttime));
  279.     ffprintf(handle,"%s\r\n%s\r\n",saydate(&user.logondate),saytime(&user.logontime));
  280.     ffprintf(handle,"%lu\r\n%u\r\n%u\r\n%hu\r\n%u\r\n%hu\r\n",user.times,(user.graphics),temptime,pages,(word)user.credit,user.length);
  281.     cclose(handle);
  282.  
  283. Next1:
  284.  
  285.     sprintf(temp,"dorinfo%c.def",nodes[nodenumber%36]);
  286.     unlink(temp);
  287.     *temp='q';
  288.     if ((handle=ccreat(temp,S_IWRITE))==-1) {
  289.        gprintf(LOCALONLY,"\n\04%s open error--%d\n",temp,errno);
  290.        goto Next2;
  291.     }
  292.     *temp='r';
  293.     if ((handle2=ccreat(temp,S_IWRITE))==-1) {
  294.         gprintf(LOCALONLY,"\n\04%s open error--%d\n",temp,errno);
  295.         cclose(handle);
  296.         *temp='q';
  297.         unlink(temp);
  298.         goto Next2;
  299.     }
  300.     strcpy(temp,conf.sysop);
  301.     p=split(temp,p);
  302.     ffprintf(handle,"%s\r\n%s\r\n%s",conf.system,temp,p);
  303.     strupr(temp);
  304.     strupr(p);
  305.     ffprintf(handle2,"%s\r\n%s\r\n%s",conf.system,temp,p);
  306.     if (!baud) {
  307.         ffprintf(handle,"\r\nCOM0\r\n");
  308.         ffprintf(handle2,"\r\nCOM0\r\n");
  309.     }
  310.     else {
  311.         ffprintf(handle,"\r\nCOM%u\r\n",conf.commport+1);
  312.         ffprintf(handle2,"\r\nCOM%u\r\n",conf.commport+1);
  313.     }
  314.     strcpy(temp,tempname);
  315.     p=split(temp,p);
  316.     ffprintf(handle,"%u BAUD,N,8,1\r\n0\r\n%s\r\n%s\r\n%s, %s\r\n",baudrate,temp,p,user.city,user.state);
  317.     strupr(temp);
  318.     strupr(p);
  319.     if(!baud) ffprintf(handle2,"9600 BAUD,N,8,1\r\n0\r\n%s\r\n%s\r\n%s, %s\r\n",temp,p,user.city,user.state);
  320.     else ffprintf(handle2,"%u BAUD,N,8,1\r\n0\r\n%s\r\n%s\r\n%s, %s\r\n",baudrate,temp,p,user.city,user.state);
  321.     if(user.graphics) ffprintf(handle2,"2\r\n");
  322.     else if (user.hiok) ffprintf(handle2,"1\r\n");
  323.     else ffprintf(handle2,"0\r\n");
  324.     ffprintf(handle,"%hu\r\n",user.graphics);
  325.     ffprintf(handle,"%u\r\n%u\r\n",user.stat[0],temptime);
  326.     ffprintf(handle2,"%u\r\n%u\r\n",user.stat[0],temptime);
  327.     ffprintf(handle2,"1\r\n");
  328.     cclose(handle);
  329.     cclose(handle2);
  330.     {
  331.         char temp2[38];
  332.  
  333.         sprintf(temp,"dorinfo%c.def",nodes[nodenumber%36]);
  334.         strcpy(temp2,temp);
  335.         if(conf.RBBSorQBBS)*temp2='r';
  336.         else *temp2='q';
  337.         rename(temp2,temp);
  338.     }
  339.  
  340. Next2:
  341.  
  342. if (!strchr(tempname,' ')) strcpy(tempname,user.name);
  343.  
  344.     if ((handle=ccreat("DOOR.SYS",S_IWRITE))==-1) {
  345.        gprintf(LOCALONLY,"\n\04DOOR.SYS open error--%d\n",errno);
  346.        return;
  347.     }
  348.     baud ? ffprintf(handle,"COM%u\r\n",conf.commport+1) : ffprintf(handle,"COM0\r\n");
  349.     ffprintf(handle,"%u\r\n8\r\n%hu\r\nN\r\nY\r\nN\r\n",baudrate,nodenumber);
  350.     conf.sysopin ? ffprintf(handle,"Y") : ffprintf(handle,"N");
  351.     ffprintf(handle,"\r\nN\r\n%s\r\n%s, %s\r\n%s\r\n",tempname,user.city,user.state,user.phone1);
  352.     ffprintf(handle,"%s\r\n%s\r\n%u\r\n%hu\r\n",user.phone2,user.password,user.stat[0],user.times);
  353.     ffprintf(handle,"%s\r\n%lu\r\n%u\r\n",saydate(&user.lastdate),temptime*60,temptime);
  354.     user.graphics ? ffprintf(handle,"GR") : ffprintf(handle,"NG");
  355.     ffprintf(handle,"\r\n%hu\r\n",user.length);
  356.     user.expert ? ffprintf(handle,"Y") : ffprintf(handle,"N");
  357.     ffprintf(handle,"\r\nABCDEFG\r\n%u\r\n01/01/99\r\n%u\r\nZ\r\n",mboard.number,userno);
  358.     ffprintf(handle,"%lu\r\n%lu\r\n%u\r\n%u\r\n999999\r\n",user.upk,user.downk,user.dktoday);
  359.     cclose(handle);
  360.  
  361.   prepare();
  362. }
  363.  
  364.  
  365. void pascal city (void) {
  366.  
  367. char *p=0;
  368.  
  369.    do {
  370.      helpnum=512;
  371.      p=genin(23,0,0,0,NEAT);
  372.      rstrip(p);
  373.      if (strlen(p)<3) printm("\n-> ");
  374.    }
  375.    while (strlen(p)<3);
  376.    strcpy(user.city,p);
  377.    helpnum=0;
  378. }
  379.  
  380. void pascal state (void) {
  381.  
  382. char *p=0;
  383.  
  384.    if (conf.genstatezip==0) {
  385.        do {
  386.          helpnum=513;
  387.          p=genin(2,0,1,0,ALPHA);
  388.          if (strlen(p)!=2) backup(p);
  389.        }
  390.        while (strlen(p)!=2);
  391.        strcpy(user.state,p);
  392.    }
  393.    else {
  394.         helpnum=514;
  395.         p=genin(8,0,0,0,ALPHANUM);
  396.         strcpy(user.state,p);
  397.    }
  398.    helpnum=0;
  399. }
  400.  
  401. void pascal zip (void) {
  402.  
  403. char *p=0;
  404.  
  405.    if (conf.genstatezip) return;
  406.    do {
  407.      helpnum=515;
  408.      p=genin(5,0,0,0,NUM);
  409.      if (strlen(p)!=5) backup(p);
  410.    } while (strlen(p)!=5);
  411.    strcpy(user.zip,p);
  412.    helpnum=0;
  413. }
  414.  
  415.  
  416. void pascal phone1 (void) {
  417.  
  418. char *p=0;
  419.  
  420.    do {
  421.      helpnum=516;
  422.      p=genin(10,0,1,0,PHONE);
  423.      if (strlen(p)!=10) printm("\n-> ");
  424.    } while (strlen(p)!=10 && !conf.genphone);
  425.    strcpy(user.phone1,p);
  426.    helpnum=0;
  427. }
  428.  
  429.  
  430. void pascal phone2 (void) {
  431.  
  432. char *p=0;
  433.  
  434.    do {
  435.      helpnum=517;
  436.      p=genin(10,0,1,0,PHONE);
  437.      if (strlen(p)!=10) printm("\n-> ");
  438.    } while (strlen(p)!=10 && !conf.genphone);
  439.    strcpy(user.phone2,p);
  440.    helpnum=0;
  441. }
  442.  
  443.  
  444. void pascal length (void) {
  445.  
  446. char *p=0;
  447.  
  448.    do {
  449.      helpnum=518;
  450.      p=genin(2,0,1,0,NUM);
  451.      if ((atoi(p)<10) || (atoi(p)>66)) backup(p);
  452.    } while ((atoi(p)<10) || (atoi(p)>66));
  453.    user.length=atoi(p);
  454.    helpnum=0;
  455. }
  456.  
  457.  
  458. void pascal width (void) {
  459.  
  460. char *p=0;
  461.  
  462.    do {
  463.      helpnum=519;
  464.      p=genin(2,0,1,0,NUM);
  465.      if ((atoi(p)<32) || (atoi(p)>80)) backup(p);
  466.    } while ((atoi(p)<32) || (atoi(p)>80));
  467.    user.width=atoi(p);
  468.    helpnum=0;
  469. }
  470.  
  471.  
  472. void pascal usertoggle (word a) {
  473.  
  474.    if (((conf.ansiavail == 'N') || ((baud < conf.ansibaud) && (baud))) && (a==GRAPHICS)) {
  475.         say_prompt(98);
  476.         return;
  477.    }
  478.  
  479.    if (((!user.graphics) || (*conf.edansi==0)) && (a==FULLSCREEN)) {
  480.         say_prompt(98);
  481.         return;
  482.    }
  483.    if (baud) if ((baud<conf.ansibaud) && (a==GRAPHICS)) {
  484.         say_prompt(98);
  485.         return;
  486.    }
  487.    if ((a==DELETED) && (user.nokill)) {
  488.         if (conf.debug) say_prompt(99);
  489.         return;
  490.    }
  491.  
  492.     switch (a) {
  493.       case GRAPHICS:
  494.        user.graphics=1-user.graphics;
  495.        _close(indexhandle);
  496.        _close(prompthandle);
  497.        indexhandle=prompthandle=-1;
  498.        user.graphics ? say_prompt(101) : say_prompt(102);
  499.       break;
  500.       case FULLSCREEN:
  501.        user.fullscreen=1-user.fullscreen;
  502.        user.fullscreen ? say_prompt(104) : say_prompt(105);
  503.       break;
  504.       case SCRNCLR:
  505.        user.scrnclr=1-user.scrnclr;
  506.        user.scrnclr ? say_prompt(107) : say_prompt(108);
  507.       break;
  508.       case EXPERT:
  509.        user.expert=1-user.expert;
  510.        user.expert ? say_prompt(110) : say_prompt(111);
  511.       break;
  512.       case COMMODORE:
  513.        user.commodore=1-user.commodore;
  514.        if (conf.debug) user.commodore ? say_prompt(112) : say_prompt(113);
  515.       break;
  516.       case TWIT:
  517.        user.twit=1-user.twit;
  518.        if (conf.debug) user.twit ? say_prompt(114) : say_prompt(115);
  519.       break;
  520.       case DELETED:
  521.        user.deleted=1-user.deleted;
  522.        if (conf.debug) user.deleted ? say_prompt(116) : say_prompt(117);
  523.       break;
  524.       case IGNOREHRS:
  525.        user.ignorehrs=1-user.ignorehrs;
  526.        if (conf.debug) user.ignorehrs ? say_prompt(118) : say_prompt(119);
  527.       break;
  528.       case IGNORERAT:
  529.        user.ignorerat=1-user.ignorerat;
  530.        if (conf.debug) user.ignorerat ? say_prompt(120) : say_prompt(121);
  531.       break;
  532.       case NOKILL:
  533.        user.nokill=1-user.nokill;
  534.        if (conf.debug) user.nokill ? say_prompt(122) : say_prompt(123);
  535.       break;
  536.       case MORE:
  537.        user.more=1-user.more;
  538.        user.more ? say_prompt(125) : say_prompt(126);
  539.       break;
  540.       case ARQ:
  541.        user.arq=1-user.arq;
  542.        user.arq ? say_prompt(128) : say_prompt(129);
  543.       break;
  544.       case ANSIMENUS:
  545.        user.ansimenus=1-user.ansimenus;
  546.        user.ansimenus ? say_prompt(131) : say_prompt(132);
  547.       break;
  548.       case GEN1:
  549.        user.gen1=1-user.gen1;
  550.        user.gen1 ? say_prompt(133) : say_prompt(134);
  551.        break;
  552.       case GEN2:
  553.        user.gen2=1-user.gen2;
  554.        user.gen2 ? say_prompt(135) : say_prompt(136);
  555.        break;
  556.       case GEN3:
  557.        user.gen3=1-user.gen3;
  558.        user.gen3 ? say_prompt(137) : say_prompt(138);
  559.        break;
  560.     }
  561. }
  562.  
  563.  
  564. void pascal usertoggle2 (word a, char b) {
  565.  
  566.  if(b==16) {
  567.     user.cold=1-user.cold;
  568.     user.cold ? say_prompt(439) : say_prompt(469);
  569.     return;
  570.  }
  571.  if (b==17) {
  572.     user.hiok=1-user.hiok;
  573.     user.hiok ? say_prompt(476) : say_prompt(491);
  574.     return;
  575.  }
  576.  user.attr2 = user.attr2 ^ a;
  577.  if (conf.debug) {
  578.     gprintf(LOCALONLY,"\n\x4#%hu ",b);
  579.     (user.attr2 & a) ? say_prompt(139) : say_prompt(140);
  580.  }
  581. }
  582.  
  583.  
  584. void pascal handler (void) {
  585.  
  586. int handle;
  587. struct _user check;
  588. char exist;
  589. struct ffblk f;
  590. char *r=0;
  591. word register x=0;
  592. char tempsafe;
  593.  
  594.      goto handleonce;
  595.  
  596. handleagain:
  597.  
  598.      say_prompt(141);
  599.      helpnum=520;
  600.      if (*genin(1,0,1,1,YESNO)!='Y') {
  601.        strcpy(user.handle,user.name);
  602.        helpnum=0;
  603.        return;
  604.      }
  605. handleonce:
  606.        r=NULL;
  607.        while ((r==NULL) || (strlen(r)<3)) {
  608.          say_prompt(142);
  609.          helpnum=521;
  610.          r=genin(35,0,0,0,NAME);
  611.          rstrip(r);
  612.          if (!strlen(r)) {
  613.             strcpy(user.handle,user.name);
  614.             helpnum=0;
  615.             return;
  616.          }
  617.        }
  618.        if(!strcmp(r,user.handle) || !strcmp(r,user.name)) {
  619.             strcpy(user.handle,r);
  620.             return;
  621.        }
  622.        say_prompt(143);
  623.        exist=findfirst(searchpath("users.bbs"),&f,0);
  624.        if ((handle=oopen("users.bbs",O_RDONLY | O_BINARY | O_DENYNONE))==-1) {
  625.          say_prompt(144);
  626.          strcpy(user.handle,user.name);
  627.          return;
  628.        }
  629.        tempsafe=safe;
  630.        safe=0;
  631.        if (!exist && f.ff_fsize) {
  632.          while (!eof(handle)) {
  633.            x++;
  634.            if (!(x%50)) printm(".");
  635.            if (_read(handle,&check,sizeof(check))<1) break;
  636.            if (check.deleted) continue;
  637.            if (!strcmp(r,check.handle)) break;
  638.            if (!strcmp(r,check.name)) break;
  639.          }
  640.          cclose(handle);
  641.          safe=tempsafe;
  642.          printm("\n");
  643.          if ((!strcmp(r,check.handle) || !strcmp(r,check.name)) && !check.deleted) {
  644.            say_prompt(145);
  645.            goto handleagain;
  646.          }
  647.        }
  648.        strcpy(user.handle,r);
  649.        trashcan(r);
  650.        update();
  651. }
  652.  
  653.  
  654. void pascal password (void) {
  655.  
  656. char p[13];
  657. char *r;
  658.  
  659. passagain:
  660.  
  661.      say_prompt(146);
  662.      helpnum=522;
  663.      strcpy(p,genin(11,1,0,0,ALPHANUM));
  664.      rstrip(p);
  665.      if (strlen(p)<3) {
  666.                        say_prompt(147);
  667.                        goto passagain;
  668.      }
  669.      say_prompt(148);
  670.      helpnum=523;
  671.      r=genin(11,1,0,0,ALPHANUM);
  672.      rstrip(r);
  673.      if(strcmp(p,r)==0) {
  674.                          strcpy(user.password,p);
  675.                          helpnum=0;
  676.                          return;
  677.      }
  678.      say_prompt(149);
  679.      goto passagain;
  680. }
  681.  
  682.  
  683. void pascal getonline (void) {
  684.  
  685.   int fp;
  686.   char s[90];
  687.   char numnode[4]="";
  688.  
  689.   if (nodenumber!=1) sprintf(numnode,"%hu",nodenumber);
  690.   sprintf(s,"%sonline%s.xbs",conf.homepath,numnode);
  691.   if ((fp=oopen(s,O_RDONLY | O_BINARY | O_DENYNONE))==-1)
  692.     gprintf(LOCALONLY | LOGONLY,"Can't open %s!--%d",s,errno);
  693.   else {
  694.       _read(fp,&user,sizeof(struct _user));
  695.       _read(fp,&userno,sizeof(userno));
  696.       _read(fp,&timelimit,sizeof(timelimit));
  697.       _read(fp,&timeon,sizeof(timeon));
  698.       _read(fp,&starter,sizeof(starter));
  699.       _read(fp,&baud,sizeof(baud));
  700.       _read(fp,&pages,sizeof(pages));
  701.       _read(fp,&age,sizeof(age));
  702.       _read(fp,&timer_off,sizeof(timer_off));
  703.       _read(fp,&hold_time,sizeof(hold_time));
  704.       _read(fp,variable,(sizeof(variable[0])*10));
  705.       _read(fp,&mboard,sizeof(mboard));
  706.       _read(fp,&fboard,sizeof(fboard));
  707.       if (_read(fp,event,(sizeof(struct _events)*10))<1) {
  708.         gprintf(LOCALONLY | LOGONLY,"Came up short!");
  709.         goto FatalError;
  710.       }
  711.   }
  712.   if (eof(fp)==-1) {
  713. FatalError:
  714.          cclose(fp);
  715.          say_prompt(150);
  716.          fossil(FLUSHOUT,0);
  717.          fossil(DTR,DOWN);
  718.          baud=0;
  719.          exit(253);
  720.    }
  721.    cclose(fp);
  722.    load_lastread();
  723. }
  724.  
  725.  
  726. char * pascal split (char *a,char *b)    /* a=string to split, b is pointer */
  727.  
  728. {
  729.        if ((b=strchr(a,' '))) {
  730.             *b=0;
  731.             return(++b);
  732.        }
  733.        else return "";
  734. }
  735.  
  736.  
  737.  
  738. void pascal update (void) {   /* Updates entry in users.bbs */
  739.  
  740.     int handle;
  741.  
  742.     if (!userno) return;
  743.     rstrip(user.name);
  744.     rstrip(user.handle);
  745.     rstrip(user.phone1);
  746.     rstrip(user.phone2);
  747.     rstrip(user.city);
  748.     rstrip(user.password);
  749.     rstrip(user.state);
  750.     if ((handle=oopen(searchpath("users.bbs"),O_RDWR | O_BINARY | O_DENYNONE))==-1) {
  751.         if ((handle=ccreat("users.bbs",S_IWRITE))==-1) {
  752.             lprint("\n\04Can't create USERS.BBS\n");
  753.             return;
  754.         }
  755.     }
  756.     if(lseek(handle,(long)sizeof(struct _user)*(long)(userno-1),0)==-1) {
  757.         gprintf(0,"\n\04Seek error USERS.BBS--%d\n",errno);
  758.         return;
  759.     }
  760.     _write(handle,&user,sizeof(struct _user));
  761.     cclose(handle);
  762.     save_lastread();
  763. }
  764.  
  765.  
  766. void pascal comptype (void)         /* Handles changing/setting type of
  767.                                        computer used by user */
  768.  
  769. {
  770.  
  771.   char text[91];
  772.  
  773.   if (!conf.numcomps) {     /* If config set to 0 insult sysop :-) */
  774.         say_prompt(422);
  775.         return;
  776.   }
  777.   user.comptype=0;
  778.   while (!user.comptype) {
  779.        say_prompt(394);
  780.        sprintf(text,"%s%s",conf.menupath,"comtypes.xbs");
  781.        if (!findfirst(text,&filestat,0)) readfile("comtypes.xbs",0,0,1);
  782.        printm("\n -> ");
  783.        helpnum=532;
  784.        user.comptype=(byte)atoi(genin(3,0,0,0,NUM));
  785.        helpnum=0;
  786.        if ((user.comptype<1) || (user.comptype>conf.numcomps)) user.comptype=0;
  787.   }
  788. }
  789.  
  790.  
  791. void pascal user_param (char a) {
  792.  
  793.     char d[48];
  794.     char *cm;
  795.  
  796.    switch (a) {
  797.       case 'f':          /* FIRST NAME */
  798.       if (!strchr(user.handle,' ')) {
  799.         printm(user.handle);
  800.       }
  801.       else {
  802.          strcpy(d,user.handle);
  803.          cm=split(d,cm);
  804.          printm(d);
  805.      }
  806.      break;
  807.      case 'l':          /* LAST NAME */
  808.       if (!strchr(user.handle,' ')) {
  809.         printm(user.handle);
  810.       }
  811.       else {
  812.          strcpy(d,user.handle);
  813.          cm=split(d,cm);
  814.          printm(cm);
  815.        }
  816.        break;
  817.      case 'w':           /* WHOLE NAME */
  818.        printm(user.handle);
  819.        break;
  820.      case 'N':           /* REAL NAME */
  821.        printm(user.name);
  822.        break;
  823.      case 'n':           /* NUMBER OF TOTAL CALLS */
  824.        gprintf(0,"%lu",(user.times+1));
  825.       break;
  826.      case'm':            /* NUMBER OF CALLS TODAY */
  827.        gprintf(0,"%u",(user.callstoday+1));
  828.        break;
  829.      case'o':            /* NUMBER OF CALLS REMAINING */
  830.        gprintf(0,"%u",(user.callsperday-(user.callstoday+1)));
  831.       break;
  832.      case'p':            /* NUMBER OF CALLS PER DAY */
  833.        gprintf(0,"%u",(user.callsperday));
  834.       break;
  835.      case'c':            /* TIME PER CALL */
  836.        gprintf(0,"%u",(user.timepercall));
  837.       break;
  838.      case't':            /* TOTAL TIME PER DAY */
  839.        gprintf(0,"%u",(user.totaltime));
  840.       break;
  841.      case's': {          /* LAST CALL DATE */
  842.        printm(saydate(&user.lastdate));
  843.        break;
  844.      }
  845.      case 'a': {         /* LAST CALL TIME */
  846.        printm(saytime(&user.lasttime));
  847.        break;
  848.      }
  849.      case 'F':           /* TIME USED SO FAR TODAY */
  850.        gprintf(0,"%u",(word)(user.timetoday+(getxbbstime()/60L)));
  851.       break;
  852.      case 'u':
  853.        gprintf(0,"%-05u",user.upno);
  854.       break;
  855.      case 'U':
  856.        gprintf(0,"%lu",user.upk);
  857.       break;
  858.      case 'd':
  859.        gprintf(0,"%-05u",user.downno);
  860.       break;
  861.      case 'D':
  862.        gprintf(0,"%lu",user.downk);
  863.       break;
  864.      case 'A':
  865.        gprintf(0,"%hu",age);
  866.       break;
  867.      case 'L':
  868.        if(conf.nolmrs>mboard.number) gprintf(0,"%u",lastread[mboard.number-1]);
  869.        else printm("?");
  870.       break;
  871.      case 'S': printm(user.state);
  872.       break;
  873.      case 'C': printm(user.city);
  874.       break;
  875.      case 'Z': printm(user.zip);
  876.       break;
  877.     }
  878. }
  879.  
  880. char pascal change_parm (char a, word secl, long fsize, long totalbytes, word nofiles, char *b) {
  881.  
  882.    switch (a) {
  883.      case 'A':        /* ANSI menu flag */
  884.       usertoggle(ANSIMENUS);
  885.       break;
  886.      case 'F':        /* Flags 1-16 */
  887.       a=(char)atoi(b);
  888.       if (a<1 || a>18) return 0;   /* & cold/hiok */
  889.       secl=1;
  890.       secl=secl<<(--a);
  891.       usertoggle2(secl,a);
  892.       return 1;
  893.      case 'G':        /* General flags 1-3 */
  894.       a=atoi(b);
  895.       if (a<1 || a>3) return 0;
  896.       secl=1;
  897.       secl=secl<<(12+a);
  898.       usertoggle(secl);
  899.       return 1;
  900.      case 'p':        /* PASSWORD */
  901.       password();
  902.      break;
  903.      case 'h':        /* HANDLE */
  904.       handler();
  905.      break;
  906.      case 'l':        /* LENGTH */
  907.       length();
  908.      break;
  909.      case 'w':        /* WIDTH */
  910.       width();
  911.      break;
  912.      case '1':        /* PHONE1 */
  913.       phone1();
  914.      break;
  915.      case '2':        /* PHONE2 */
  916.       phone2();
  917.      break;
  918.      case 'z':        /* ZIPCODE */
  919.       zip();
  920.      break;
  921.      case 's':        /* STATE */
  922.       state();
  923.      break;
  924.      case 'c':        /* CITY */
  925.       city();
  926.      break;
  927.      case 'g':        /* ANSI */
  928.       usertoggle(GRAPHICS);
  929.      break;
  930.      case 'm':        /* MORE */
  931.       usertoggle(MORE);
  932.      break;
  933.      case 'r':        /* SCRNCLR */
  934.       usertoggle(SCRNCLR);
  935.      break;
  936.      case 'x':        /* EXPERT */
  937.       usertoggle(EXPERT);
  938.      break;
  939.      case 'o':        /* COMMODORE */
  940.       usertoggle(COMMODORE);
  941.      break;
  942.      case 'f':        /* FULLSCREEN */
  943.       usertoggle(FULLSCREEN);
  944.      break;
  945.      case 'u':        /* UPNO */
  946.       user.upno+=secl;
  947.       return 1;
  948.      case 'd':        /* DOWNNO */
  949.       user.downno+=secl;
  950.       return 1;
  951.      case 'U':        /* UPK */
  952.       user.upk+=(fsize/1024L);
  953.       user.uktoday+=(word)(fsize/1024L);
  954.      break;
  955.      case 'D':        /* DOWNK */
  956.       user.downk+=(fsize/1024L);
  957.       user.dktoday+=(word)(fsize/1024L);
  958.      break;
  959.      case 't':        /* TWIT */
  960.       usertoggle(TWIT);
  961.      break;
  962.      case 'M':        /* ARQ  */
  963.       usertoggle(ARQ);
  964.      break;
  965.      case 'k':        /* DELETED */
  966.       usertoggle(DELETED);
  967.      break;
  968.      case 'n':        /* NOKILL */
  969.       usertoggle(NOKILL);
  970.      break;
  971.      case 'R':        /* RATIO */
  972.       usertoggle(IGNORERAT);
  973.      break;
  974.      case 'H':        /* HOURS */
  975.       usertoggle(IGNOREHRS);
  976.      break;
  977.      case 'C':        /* COMPUTER TYPE */
  978.       comptype();
  979.       return 1;
  980.      case 'K':        /* Add total file len to user downk */
  981.       user.downk+=(totalbytes/1024L);
  982.       user.dktoday+=(word)(totalbytes/1024L);
  983.       break;
  984.      case 'L':        /* Add total files to user downno */
  985.       user.downno+=(word)(nofiles);
  986.     }
  987.     return 0;
  988. }
  989.  
  990.  
  991. char pascal system_parms (char a, char b) {
  992.  
  993.     char d[133];
  994.  
  995.    switch (a) {
  996.      case 'l':
  997.       if (!stricmp(conf.lastcaller,user.handle)) printm("you");
  998.       else printm(conf.lastcaller);
  999.      break;
  1000.      case 's':
  1001.       if (conf.sysopin) say_prompt(390);
  1002.       else say_prompt(391);
  1003.      break;
  1004.      case 'n':
  1005.       printm(conf.system);
  1006.      break;
  1007.      case '#': {
  1008.          struct ffblk f;
  1009.        sprintf(d,"%sXDATA.%03x",messpath,mboard.number);
  1010.        if (findfirst(d,&f,0)) printm("0");
  1011.        else gprintf(0,"%01lu",f.ff_fsize/(long)sizeof(struct _msg));
  1012.       break;
  1013.      }
  1014.      case 'c':
  1015.       gprintf(0,"%01lu",conf.callcount);
  1016.      break;
  1017.      case 'd': {
  1018.  
  1019.         struct dfree drivefree;
  1020.  
  1021.       if (b<'A' || b>'Z') break;
  1022.       getdfree((b-'@'),&drivefree);
  1023.       gprintf(0,"%lu",(long)drivefree.df_avail*(drivefree.df_bsec*drivefree.df_sclus));
  1024.       return 1;
  1025.      }
  1026.      case 'M':
  1027.         printm(mboard.name);
  1028.         break;
  1029.      case 'F':
  1030.         printm(fboard.name);
  1031.         break;
  1032.    }
  1033.    return 0;
  1034. }
  1035.  
  1036.  
  1037. void pascal chat (void) {   /* Ultra-cheap chat mode */
  1038.  
  1039.     char a;
  1040.     char temp;
  1041.     char last=0;
  1042.  
  1043.      if (readfile("chaton.xbs",0,0,1)==2) say_prompt(190);
  1044.      adjust_time(0);
  1045.      printg("\x1b[0;1;33m");
  1046.      {
  1047.         int p;
  1048.  
  1049.         if(user.graphics) {
  1050.             for(p=wherey();p<(int)(user.length+1);p++) {
  1051.                 if(p<24) printm("\x1b[K");
  1052.                 else mprint("\x1b[K");
  1053.                 if(p<23) printm("\n");
  1054.                 else mprint("\x1b[K");
  1055.             }
  1056.             if(user.length<23) {
  1057.                 for(p=(int)user.length;p<24;p++) {
  1058.                     lprint("\x1b[K");
  1059.                     if(p<23) lprint("\n");
  1060.                 }
  1061.             }
  1062.         }
  1063.         else for(p=wherey();p<23;p++) fputs("\n\x1b[K",stdout);
  1064.         gotoxy(1,23);
  1065.      }
  1066.      while (chatting) {
  1067.        a=inkey();
  1068.        if(!a) continue;
  1069.        if (chatting) {
  1070.          r.h.ah=3;
  1071.          r.h.bh=0;
  1072.          int86(16,&r,&r);
  1073.          temp=r.h.dl;
  1074.          if(whotyped!=last) {
  1075.             if(!whotyped) printg("\x1b[0;1;33m");
  1076.             else printg("\x1b[0;1;36m");
  1077.             last=whotyped;
  1078.          }
  1079.          if (a==13) printm("\n");
  1080.          if (a==13 || (a==' ' && temp>70)) printm("\n");
  1081.          else gprintf(0,"%c",a);
  1082.        }
  1083.       }
  1084.  
  1085.      if (readfile("chatoff.xbs",0,0,1)==2) say_prompt(191);
  1086.      chatted++;
  1087.      adjust_time(1);
  1088. }
  1089.  
  1090.