home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / MJRDEVEL.ARC / UINFED.C < prev    next >
Text File  |  1989-03-01  |  14KB  |  416 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   UINFED.C                                                              *
  4.  *                                                                         *
  5.  *   Copyright (C) 1987-1989 GALACTICOMM, Inc.    All Rights Reserved.     *
  6.  *                                                                         *
  7.  *   This is the Major BBS demo board user-info editor.                    *
  8.  *                                                                         *
  9.  *                                            - T. Stryker 7/13/86         *
  10.  *                                                                         *
  11.  ***************************************************************************/
  12.  
  13. #include "stdio.h"
  14. #include "ctype.h"
  15. #include "majorbbs.h"
  16. #include "usracc.h"
  17. #include "signup.h"
  18. #include "btvstf.h"
  19. #include "portable.h"
  20.  
  21. int iniuin(),uinfed(),uinlon(),dfsthn();
  22.  
  23. #define UEDSTT      12        /* system info requesting state         */
  24. struct module module12={      /* module interface block               */
  25.      '*',                     /*    main menu select character (config'able) */
  26.      "",                      /*    description for main menu  (config'able) */
  27.      iniuin,                  /*    system initialization routine     */
  28.      uinlon,                  /*    user logon supplemental routine   */
  29.      uinfed,                  /*    input routine if selected         */
  30.      dfsthn,                  /*    status-input routine if selected  */
  31.      NULL,                    /*    hangup (lost carrier) routine     */
  32.      NULL,                    /*    midnight cleanup routine          */
  33.      NULL,                    /*    delete-account routine            */
  34.      NULL                     /*    finish-up (sys shutdown) routine  */
  35. };
  36.  
  37. #define MAXTKC 100000000L     /* maximum char count of tick xfer request   */
  38.  
  39. char *sysstg[]={              /* strings corresponding to sys type codes   */
  40.      "(nonstandard)",
  41.      "IBM PC or compatible",
  42.      "Apple Macintosh",
  43.      "Apple other than Mac",
  44.      "Commodore Amiga",
  45.      "Atari",
  46.      "Radio Shack",
  47.      "CP/M system"
  48. };
  49.  
  50. char *ansstg[]= {             /* strings corresponding to ANSI settings    */
  51.      "non-ANSI","ANSI","ANSI OFF","ANSI ON"
  52. };
  53.  
  54. struct xfinfo {               /* credit-transfer info    */
  55.      char tranfid[UIDSIZ];    /*   transferee's User-ID  */
  56.      long tikreq;             /*   amount of the xfer    */
  57. } *xfidat;
  58.  
  59. struct usracc acctmp,*accptr; /* user account temporary holding area & ptr */
  60. int newstt;                   /* new sub-state code                        */
  61.  
  62. extern
  63. BTVFILE *accbb;               /* user accounts btrieve data file           */
  64. extern
  65. FILE *supmb;                  /* uses the signup module's message file     */
  66.  
  67. /*--- OPTIONS FROM SIGNUP.MSG ---*/
  68.  
  69. long mincxf;                  /* minimum number of credits per xfer oper   */
  70.  
  71. iniuin()                           /* initialize user info editor module   */
  72. {
  73.      int n;
  74.      long lngopt();
  75.  
  76.      xfidat=(struct xfinfo *)alcmem(n=nterms*sizeof(struct xfinfo));
  77.      setmem(xfidat,n,0);
  78.      setmbk(supmb);
  79.      mincxf=lngopt(MINCXF,0L,1000000000L);
  80.      inimid(UEDSTT,UEDSEL,UEDMNU);
  81. }
  82.  
  83. uinlon()                           /* supplement log on; shows credits     */
  84. {
  85.      if (usaptr->tckavl != 0) {
  86.           setmbk(supmb);
  87.           prfmsg(LIVLON,city,spr("%ld",usaptr->tckavl));
  88.      }
  89. }
  90.  
  91. uinfed()                           /* user info editor main module         */
  92. {
  93.      int c,intguy;
  94.      static int prmts[]={
  95.           NEWUSN,NEWAD1,NEWAD2,NEWAD3,NEWPHO,
  96.           NEWSYT,NEWSWD,NEWSLN,NEWAGE,NEWSEX,NEWPSW,CREDTR
  97.      };
  98.  
  99.      setmbk(supmb);
  100.      newstt=usrptr->substt;
  101.      if (margc == 0) {
  102.           prfmsg(newstt);
  103.      }
  104.      else if (margc == 1 && sameas(margv[0],"x")) {
  105.           return(0);
  106.      }
  107.      else {
  108.           do {
  109.                bgncnc();
  110.                if (margc == 1 && (sameas(margv[0],"?") || sameas(margv[0],"help"))) {
  111.                     newstt=0;
  112.                }
  113.                switch (newstt) {
  114.                case 0:
  115.                     cncchr();
  116.                     shwusr(usaptr,0);
  117.                     prfmsg(newstt=CHGORX);
  118.                     break;
  119.                case CHGORX:
  120.                     if ((c=cncint()) >= 1 && c <= 12) {
  121.                          if (c == 12) {
  122.                               if (usaptr->tckavl <= mincxf) {
  123.                                    prfmsg(NOCRDX,ltoa(mincxf),chgmin,chgtime,
  124.                                                  company,addres1,addres2);
  125.                                    prfmsg(CHGORX);
  126.                                    cncall();
  127.                               }
  128.                               else if (usaptr->tckpai == 0) {
  129.                                    prfmsg(NOCRFX,chgmin,chgtime,
  130.                                                  company,addres1,addres2);
  131.                                    prfmsg(CHGORX);
  132.                                    cncall();
  133.                               }
  134.                               else {
  135.                                    prfmsg(newstt=CREDTR);
  136.                               }
  137.                          }
  138.                          else {
  139.                               prfmsg(newstt=prmts[c-1]);
  140.                          }
  141.                     }
  142.                     else {
  143.                          prfmsg(ONLERR);
  144.                          prfmsg(CHGORX);
  145.                          cncall();
  146.                     }
  147.                     break;
  148.                case NEWUSN:
  149.                     if (uinfok(NEWUSN,5,NADSIZ,usaptr->usrnam)) {
  150.                          prfmsg(newstt=CHGORX);
  151.                     }
  152.                     cncall();
  153.                     break;
  154.                case NEWAD1:
  155.                     accacct(usaptr,-1);
  156.                     if (uinfok(NEWAD1,0,NADSIZ,usaptr->usrad1)) {
  157.                          prfmsg(newstt=CHGORX);
  158.                     }
  159.                     accacct(usaptr,1);
  160.                     cncall();
  161.                     break;
  162.                case NEWAD2:
  163.                     if (uinfok(NEWAD2,5,NADSIZ,usaptr->usrad2)) {
  164.                          prfmsg(newstt=CHGORX);
  165.                     }
  166.                     cncall();
  167.                     break;
  168.                case NEWAD3:
  169.                     if (uinfok(NEWAD3,5,NADSIZ,usaptr->usrad3)) {
  170.                          prfmsg(newstt=CHGORX);
  171.                     }
  172.                     cncall();
  173.                     break;
  174.                case NEWPHO:
  175.                     if (uinfok(NEWPHO,7,PHOSIZ,usaptr->usrpho)) {
  176.                          prfmsg(newstt=CHGORX);
  177.                     }
  178.                     cncall();
  179.                     break;
  180.                case NEWSYT:
  181.                     accacct(usaptr,-1);
  182.                     if (unumok(NEWSYT,0,7,&intguy)) {
  183.                          usaptr->systyp=intguy;
  184.                          prfmsg(newstt=NEWANS);
  185.                     }
  186.                     accacct(usaptr,1);
  187.                     cncall();
  188.                     break;
  189.                case NEWANS:
  190.                     accacct(usaptr,-1);
  191.                     if (unumok(NEWANS,1,3,&intguy)) {
  192.                          switch (intguy) {
  193.                          case 1:
  194.                               usaptr->ansifl=ANSMAN;
  195.                               break;
  196.                          case 2:
  197.                               usaptr->ansifl=ANSMAN+ANSON;
  198.                               break;
  199.                          case 3:
  200.                               usaptr->ansifl&=~ANSMAN;
  201.                               break;
  202.                          }
  203.                          stansi();
  204.                          prfmsg(newstt=CHGORX);
  205.                     }
  206.                     accacct(usaptr,1);
  207.                     cncall();
  208.                     break;
  209.                case NEWSWD:
  210.                     if (unumok(NEWSWD,20,136,&intguy)) {
  211.                          btutsw(usrnum,usaptr->scnwid=intguy);
  212.                          prfmsg(newstt=CHGORX);
  213.                     }
  214.                     cncall();
  215.                     break;
  216.                case NEWSLN:
  217.                     if (morcnc() == 'C') {
  218.                          usaptr->scnlen=CTNUOS;
  219.                     }
  220.                     else {
  221.                          if (!unumok(NEWSLN,3,254,&intguy)) {
  222.                               cncall();
  223.                               break;
  224.                          }
  225.                          usaptr->scnlen=intguy;
  226.                     }
  227.                     cncall();
  228.                     rstrxf();
  229.                     prfmsg(newstt=CHGORX);
  230.                     break;
  231.                case NEWAGE:
  232.                     accacct(usaptr,-1);
  233.                     if (unumok(NEWAGE,5,99,&usaptr->age)) {
  234.                          prfmsg(newstt=CHGORX);
  235.                     }
  236.                     accacct(usaptr,1);
  237.                     cncall();
  238.                     break;
  239.                case NEWSEX:
  240.                     accacct(usaptr,-1);
  241.                     if (usexok()) {
  242.                          prfmsg(newstt=CHGORX);
  243.                     }
  244.                     accacct(usaptr,1);
  245.                     cncall();
  246.                     break;
  247.                case NEWPSW:
  248.                     if (uinfok(GPSWORD,1,PSWSIZ,usaptr->psword)) {
  249.                          prfmsg(PSWWRN);
  250.                          prfmsg(newstt=CHGORX);
  251.                     }
  252.                     cncall();
  253.                     break;
  254.                case CREDTR:
  255.                     scredtr();
  256.                     break;
  257.                case UIDEN:
  258.                     suiden();
  259.                     break;
  260.                case QUERYN:
  261.                     squeryn();
  262.                     break;
  263.                }
  264.           } while (!endcnc());
  265.      }
  266.      outprf(usrnum);
  267.      usrptr->substt=newstt;
  268.      return(1);
  269. }
  270.  
  271. scredtr()                          /* get number of credits to transfer    */
  272. {
  273.      long num,numeok();
  274.  
  275.      if (usaptr->tckavl <= mincxf) {
  276.           prfmsg(RANOUT);
  277.           prfmsg(newstt=CHGORX);
  278.           cncall();
  279.           return;
  280.      }
  281.      if ((num=numeok()) == -1) {
  282.           prfmsg(NUMBAD,ltoa(mincxf),ltoa(usaptr->tckavl-1));
  283.           prfmsg(CREDTR);
  284.           cncall();
  285.           return;
  286.      }
  287.      if ((xfidat[usrnum].tikreq=num) >= usaptr->tckavl) {
  288.           prfmsg(NOTENO,ltoa(usaptr->tckavl-1));
  289.           prfmsg(CREDTR);
  290.           cncall();
  291.           return;
  292.      }
  293.      prfmsg(newstt=UIDEN);
  294. }
  295.  
  296. suiden()                           /* get userid to transfer credits to    */
  297. {
  298.      char *uidptr;
  299.  
  300.      if (usaptr->tckavl <= mincxf) {
  301.           prfmsg(RANOUT);
  302.           prfmsg(newstt=CHGORX);
  303.           cncall();
  304.           return;
  305.      }
  306.      setbtv(accbb);
  307.      movmem(uidptr=cncuid(),xfidat[usrnum].tranfid,UIDSIZ);
  308.      if (sameas(usaptr->userid,uidptr)) {
  309.           prfmsg(NOTSELF);
  310.           prfmsg(UIDEN);
  311.           cncall();
  312.           return;
  313.      }
  314.      if (!acqbtv(&acctmp,uidptr,0)) {
  315.           prfmsg(UIDBAD);
  316.           prfmsg(UIDEN);
  317.           cncall();
  318.           return;
  319.      }
  320.      if (acctmp.tckpai == 0) {
  321.           prfmsg(WRNNOP,input,input);
  322.      }
  323.      prfmsg(QYNPRE,ltoa(xfidat[usrnum].tikreq),usaptr->userid,uidptr);
  324.      prfmsg(newstt=QUERYN);
  325. }
  326.  
  327. squeryn()                          /* verify transfer of credits           */
  328. {
  329.      int online;
  330.      long treq;
  331.      char *tfid;
  332.  
  333.      if (usaptr->tckavl <= mincxf) {
  334.           prfmsg(RANOUT);
  335.           prfmsg(newstt=CHGORX);
  336.           cncall();
  337.           return;
  338.      }
  339.      if (cncchr() == 'Y') {
  340.           setbtv(accbb);
  341.           tfid=xfidat[usrnum].tranfid;
  342.           if (!acqbtv(&acctmp,tfid,0)) {
  343.                prfmsg(ACCDEL,tfid);
  344.                prfmsg(newstt=CHGORX);
  345.                cncall();
  346.                return;
  347.           }
  348.           treq=xfidat[usrnum].tikreq;
  349.           if (usaptr->tckavl <= treq) {
  350.                treq=usaptr->tckavl-1;
  351.                prfmsg(NOENOT,ltoa(treq));
  352.           }
  353.           accptr=((online=onsys(tfid)) != 0 ? othuap : &acctmp);
  354.           usaptr->tckavl-=treq;
  355.           accptr->tckavl+=treq;
  356.           updbtv(accptr);
  357.           prfmsg(DATATR,ltoa(treq),usaptr->userid,tfid);
  358.           outprf(usrnum);
  359.           if (online && accptr->tckavl > 0) {
  360.                othusp->class=PAYING;
  361.                prfmsg(SENDUS,usaptr->userid,ltoa(treq));
  362.                if (injoth()) {
  363.                     prfmsg(NOTICE,tfid);
  364.                }
  365.           }
  366.           shocst(1,"XF %-9s%9s->%-9s",ltoa(treq),usaptr->userid,tfid);
  367.      }
  368.      else {
  369.           prfmsg(CDXABO);
  370.      }
  371.      prfmsg(newstt=CHGORX);
  372.      cncall();
  373. }
  374.  
  375. shwusr(usaptr,sysop)               /* display's a user's account info      */
  376. struct usracc *usaptr;
  377. int sysop;
  378. {
  379.      FILE *savmb;
  380.      extern FILE *curmbk;
  381.  
  382.      savmb=curmbk;
  383.      setmbk(supmb);
  384.      prfmsg((sysop ? SOPINFN : UINFENI),usaptr->userid,
  385.                   usaptr->credat,
  386.                   usaptr->usedat,
  387.                   usaptr->usrnam,
  388.                   usaptr->usrad1,
  389.                   usaptr->usrad2,
  390.                   usaptr->usrad3,
  391.                   usaptr->usrpho,
  392.                   sysstg[usaptr->systyp],ansstg[usaptr->ansifl],
  393.                   usaptr->scnwid,
  394.                   usaptr->scnlen == CTNUOS ? "(continuous)"
  395.                                            : spr("%d",usaptr->scnlen),
  396.                   usaptr->age,
  397.                   usaptr->sex,
  398.                   (sysop ? usaptr->psword :
  399.                            "<not displayed, for security reasons>"),
  400.                   ltoa(usaptr->tckavl));
  401.      setmbk(savmb);
  402. }
  403.  
  404. long numeok()                      /* is number ok? (for credits to xfer)  */
  405. {
  406.      long retval;
  407.  
  408.      if ((retval=cnclon()) < mincxf) {
  409.           return(-1);
  410.      }
  411.      if (retval > MAXTKC) {
  412.           return(-1);
  413.      }
  414.      return(retval);
  415. }
  416.