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

  1. /***************************************************************************
  2.  *                                                                         *
  3.  *   MJRTLC.C                                                              *
  4.  *                                                                         *
  5.  *   Copyright (C) 1987-1989 GALACTICOMM, Inc.    All Rights Reserved.     *
  6.  *                                                                         *
  7.  *   This is the Major BBS default teleconference handler.                 *
  8.  *                                                                         *
  9.  *                                            - T. Stryker 6/29/86         *
  10.  *                                                                         *
  11.  ***************************************************************************/
  12.  
  13. #include "stdio.h"
  14. #include "majorbbs.h"
  15. #include "usracc.h"
  16. #include "mjrtlc.h"
  17. #include "portable.h"
  18.  
  19. int initlc(),telecn(),dfsthn(),tlchup(),clstlc();
  20.  
  21. #define TLCSTT      01        /* teleconferencing state               */
  22. struct module module01={      /* module interface block               */
  23.      '*',                     /*    main menu select character (config'able) */
  24.      "",                      /*    description for main menu  (config'able) */
  25.      initlc,                  /*    system initialization routine     */
  26.      NULL,                    /*    user logon supplemental routine   */
  27.      telecn,                  /*    input routine if selected         */
  28.      dfsthn,                  /*    status-input routine if selected  */
  29.      tlchup,                  /*    hangup (lost carrier) routine     */
  30.      NULL,                    /*    midnight cleanup routine          */
  31.      NULL,                    /*    delete-account routine            */
  32.      clstlc                   /*    finish-up (sys shutdown) routine  */
  33. };
  34.  
  35. #define TPCSIZ 41             /* max size of teleconf channel topic        */
  36.  
  37. static
  38. FILE *tlcmb;                  /* teleconf named-message file block pointer */
  39. static
  40. struct tlc {                  /* teleconference per-user volatile data     */
  41.      int flags;               /*   telecon user "flag" bits                */
  42.      long sqlflg[2];          /*   "squelch" flags by modem number         */
  43.      int paged;               /*   intervals-since-last-paged counter      */
  44.      int blinkc;              /*   intervals-since-paged-Sysop counter     */
  45.      int swchan;              /*   # of times switched chans in interval   */
  46.      unsigned channel;        /*   teleconference channel number in use    */
  47.      unsigned modchn;         /*   channel moderated by telecon user       */
  48.      char topic[TPCSIZ];      /*   channel topic as set by moderator       */
  49.      int inpcnt;              /*   input message counter for freeloaders   */
  50.      int reqcha;              /*   intervals-since-last-chat-request ctr.  */
  51.      int chatch;              /*   channel of other user being chatted with*/
  52.      int retstt;              /*   return state number when XTOOTH         */
  53.      int retsub;              /*   return sub-state number when XTOOTH     */
  54. } *tlclst,                    /* one to a customer (dynamic array)         */
  55.   *tlcptr,*tptr;              /* handy pointers for speed                  */
  56.  
  57.                               /* definition of telecon user bit "flags"    */
  58. #define NOPAGE 1              /*   user page-flag set to "off"             */
  59. #define SHWCHN 2              /*   user's channel is displayed in scan     */
  60. #define SQUCHD 4              /*   this guy has been "squelched" by modera */
  61. #define LUISSU 8              /*   list or unlist command has been issued  */
  62. #define JUSTEX 16             /*   user "just exited" during current intvl */
  63. #define OKPAGE 32             /*   user doesn't mind being paged to death  */
  64. #define XTOOTH 64             /*   exit to "caller" module when finished   */
  65. #define CCHVLD 128            /*   chat-channel value is valid             */
  66.  
  67. #define SQLFLS(u) sqlflg[(u) > 31] /* squelch flags bank, as func of user# */
  68. #define SQLBIT(u) (1<<((u)&0x1F))
  69.  
  70.  
  71. /*--- OPTIONS FROM MJRTLC.MSG ---*/
  72.  
  73. int npaymx,                   /* max times can talk per session if no pay  */
  74.     nswchx,                   /* max times can switch chans or on-off/15sec*/
  75.     pagint,                   /* minimum interval between paging a user    */
  76.     reqint,                   /* minimum interval bewteen requesting a user*/
  77.     tinpsz;                   /* allowable input size for teleconference   */
  78. unsigned maxfre;              /* top freeloader telecon channel            */
  79.  
  80. initlc()                           /* initialize teleconference module     */
  81. {
  82.      int tlctck();
  83.      long lngopt();
  84.      int n;
  85.  
  86.      tlcmb=opnmsg("mjrtlc.mcv");
  87.      tlclst=(struct tlc *)alcmem(n=nterms*sizeof(struct tlc));
  88.      setmem(tlclst,n,0);
  89.      npaymx=numopt(NPAYMX,0,32767);
  90.      nswchx=numopt(NSWCHX,1,32767);
  91.      maxfre=(unsigned)lngopt(MAXFRE,1L,65535L);
  92.      pagint=numopt(PAGINT,0,32767);
  93.      reqint=numopt(REQINT,0,32767);
  94.      tinpsz=numopt(TINPSZ,1,255);
  95.      inimid(TLCSTT,TLCSEL,TLCMNU);
  96.      rtkick(10,tlctck);
  97. }
  98.  
  99. joint(chan)                        /* join teleconference from other module*/
  100. unsigned chan;
  101. {
  102.      tlcptr=&tlclst[usrnum];
  103.      tlcptr->retstt=usrptr->state;
  104.      tlcptr->retsub=usrptr->substt;
  105.      tlcptr->flags|=XTOOTH;
  106.      tlcptr->channel=chan;
  107.      usrptr->state=TLCSTT;
  108.      usrptr->substt=0;
  109.      telecn();
  110. }
  111.  
  112. telecn()                           /* main teleconferencing input handler  */
  113. {
  114.      long actchn;
  115.      struct tlc *tp;
  116.  
  117.      setmbk(tlcmb);
  118.      tlcptr=&tlclst[usrnum];
  119.      switch (usrptr->substt) {
  120.      case 0:
  121.           usrptr->substt=1;
  122.           btumil(usrnum,tinpsz);
  123.           btuxnf(usrnum,0,19);
  124.           prfmsg(ENTTLC,usaptr->userid);
  125.           outtlc();
  126.           prfmsg(INTRO,bbsttl);
  127.           tlcctx();
  128.           btupmt(usrnum,':');
  129.           break;
  130.      case 1:
  131.           if (margc == 0) {
  132.                tlcctx();
  133.                break;
  134.           }
  135.           if (margc == 1) {
  136.                if (sameas(margv[0],"?")
  137.                 || sameas(margv[0],"'?'")
  138.                 || sameas(margv[0],"\"?\"")
  139.                 || sameas(margv[0],"help")) {
  140.                     prfmsg(TLCHLP,(pagint+30)/60);
  141.                     break;
  142.                }
  143.                if (sameas(margv[0],"nopage")) {
  144.                     tlcptr->flags|=NOPAGE;
  145.                     prfmsg(PAGTOF);
  146.                     break;
  147.                }
  148.                if (sameas(margv[0],"exit") || sameas(margv[0],"x")) {
  149.                     if ((tlcptr->flags&JUSTEX) && !(usrptr->flags&OPCHAT)) {
  150.                          prfmsg(NANNOY);
  151.                          break;
  152.                     }
  153.                     tlcptr->flags|=JUSTEX;
  154.                     prfmsg(LVITLC,usaptr->userid);
  155.                     outtlc();
  156.                     prfmsg(EXITLC);
  157.                     rstrxf();
  158.                     btupmt(usrnum,0);
  159.                     if (tlcptr->flags&XTOOTH) {
  160.                          tlcptr->flags&=~XTOOTH;
  161.                          usrptr->state=tlcptr->retstt;
  162.                          usrptr->substt=tlcptr->retsub;
  163.                          injacr();
  164.                          return(1);
  165.                     }
  166.                     return(0);
  167.                }
  168.                if (sameas(margv[0],"scan")) {
  169.                     prf("USER-ID ..... CHANNEL ... TOPIC\r");
  170.                     for (tp=tlclst,othusn=0 ; othusn < nterms ; tp++,othusn++) {
  171.                          if (user[othusn].state == TLCSTT) {
  172.                               prf("%-10s... ",usracc[othusn].userid);
  173.                               if (user[othusn].substt == 2) {
  174.                                    prf("(Chat)\r");
  175.                               }
  176.                               else {
  177.                                    if ((tp->flags&SHWCHN) || (usrptr->flags&ISYSOP)
  178.                                      || tp->channel == 0
  179.                                      || *sigtpc(tp->channel) != '\0'
  180.                                      || (!(tp->flags&LUISSU)
  181.                                          && tp->modchn == tp->channel)) {
  182.                                         prf("%5u",tp->channel+1);
  183.                                         ckmodr(tp,"     ");
  184.                                    }
  185.                                    else {
  186.                                         prf("(Unlisted)");
  187.                                         ckmodr(tp,"");
  188.                                    }
  189.                               }
  190.                          }
  191.                     }
  192.                     break;
  193.                }
  194.                if (sameas(margv[0],"unlist")) {
  195.                     tlcptr->flags&=~SHWCHN;
  196.                     tlcptr->flags|=LUISSU;
  197.                     prfmsg(UNLSTC);
  198.                     break;
  199.                }
  200.                if (sameas(margv[0],"list")) {
  201.                     tlcptr->flags|=(SHWCHN+LUISSU);
  202.                     prfmsg(LSTCHN);
  203.                     break;
  204.                }
  205.           }
  206.           if (margc == 2) {
  207.                if (sameas(margv[0],"squelch")) {
  208.                     squsqu(1);
  209.                     break;
  210.                }
  211.                if (sameas(margv[0],"unsquelch")) {
  212.                     squsqu(0);
  213.                     break;
  214.                }
  215.           }
  216.           if (margc <= 2) {
  217.                if (sameas(margv[0],"appoint")) {
  218.                     xfrcon();
  219.                     break;
  220.                }
  221.                if (sameas(margv[0],"chat")) {
  222.                     chat();
  223.                     break;
  224.                }
  225.                if (sameas(margv[0],"channel")) {
  226.                     if (margc == 1) {
  227.                          prfmsg(WHATCH,tlcptr->channel+1);
  228.                     }
  229.                     else if (strlen(margv[1]) > 5
  230.                       || (actchn=atol(margv[1])) > 65535L || actchn <= 0L) {
  231.                          prfmsg(OUTORG);
  232.                     }
  233.                     else if (actchn == tlcptr->channel+1) {
  234.                          prfmsg(YOURCH);
  235.                     }
  236.                     else if (actchn > maxfre && usrptr->class < PAYING) {
  237.                          prfmsg(PAYONL,maxfre);
  238.                     }
  239.                     else if (tlcptr->swchan++ >= nswchx) {
  240.                          prfmsg(NANNOY);
  241.                     }
  242.                     else {
  243.                          prfmsg(LEFTCH,usaptr->userid);
  244.                          outtlc();
  245.                          tlcptr->flags&=~SQUCHD;
  246.                          tlcptr->channel=(unsigned)actchn-1;
  247.                          ck4sql();
  248.                          prfmsg(CAMEIN,usaptr->userid);
  249.                          outtlc();
  250.                          tlcctx();
  251.                     }
  252.                     break;
  253.                }
  254.           }
  255.           if (usrptr->pfnacc > MAXPFN) {
  256.                btuinj(usrnum,RING);
  257.                return(1);
  258.           }
  259.           if (pfnlvl >= 2 && usrptr->pfnacc > WRNPFN) {
  260.                prfmsg(RAUNCH);
  261.                break;
  262.           }
  263.           if (pfnlvl > 2) {
  264.                prfmsg(PFNWRD);
  265.                break;
  266.           }
  267.           if (sameas(margv[0],"page")) {
  268.                page();
  269.                break;
  270.           }
  271.           if (sameas(margv[0],"moderate")) {
  272.                if (margc == 1) {
  273.                     xfrcon();
  274.                }
  275.                else if (tlcptr->channel == 0) {
  276.                     prfmsg(NOMCH1);
  277.                }
  278.                else if (*sigtpc(tlcptr->channel) != '\0') {
  279.                     prfmsg(NOOVRS);
  280.                }
  281.                else if (ck4mod()) {
  282.                     prfmsg(ANOMOD,usracc[othusn].userid);
  283.                }
  284.                else if (usrptr->class < PAYING) {
  285.                     prfmsg(MODLIV);
  286.                }
  287.                else {
  288.                     rstrin();
  289.                     *(margv[1]+TPCSIZ-1)='\0';
  290.                     strcpy(tlcptr->topic,margv[1]);
  291.                     tlcptr->modchn=tlcptr->channel;
  292.                     prfmsg(BGNCON,usaptr->userid,tlcptr->topic);
  293.                     outtlc();
  294.                     prfmsg(BMODER,tlcptr->topic);
  295.                }
  296.                break;
  297.           }
  298.           if (tlcptr->flags&SQUCHD) {
  299.                prfmsg(TLKSQU);
  300.                break;
  301.           }
  302.           if (usrptr->class < PAYING && (tlcptr->inpcnt)++ >= npaymx) {
  303.                prfmsg(NPAYXC,npaymx);
  304.                break;
  305.           }
  306.           if (sameas(margv[0],"whisper")) {
  307.                if (margc < 4) {
  308.                     prfmsg(WHSFMT);
  309.                }
  310.                else {
  311.                     whisper(margv[2],margv[3]);
  312.                }
  313.                break;
  314.           }
  315.           if (margv[0][0] == '/') {
  316.                if (margc < 2 || margv[0][1] == '\0') {
  317.                     prfmsg(WHSFMT);
  318.                }
  319.                else {
  320.                     whisper(margv[0]+1,margv[1]);
  321.                }
  322.                break;
  323.           }
  324.           rstrin();
  325.           prf("***\rFrom %s: %s\r",usaptr->userid,input);
  326.           outtlc();
  327.           if (chncnt() == 1) {
  328.                prfmsg(BYSELF,tlcptr->channel+1);
  329.           }
  330.           else {
  331.                prf("-- Message sent --\r");
  332.           }
  333.           break;
  334.      case 2:
  335.           if (margc == 1 && sameas(margv[0],"x")) {
  336.                tlcptr->flags&=~CCHVLD;
  337.                tlcptr->reqcha=0;
  338.                btuchi(usrnum,NULL);
  339.                btuchi(tlcptr->chatch,NULL);
  340.                btucli(usrnum);
  341.                btumil(usrnum,tinpsz);
  342.                prfmsg(ENTTLC,usaptr->userid);
  343.                outtlc();
  344.                usrptr->substt=1;
  345.                prfmsg(EXICHA);
  346.                tlcctx();
  347.                btupmt(usrnum,':');
  348.           }
  349.           else {
  350.                return(1);
  351.           }
  352.           break;
  353.      }
  354.      outprf(usrnum);
  355.      return(1);
  356. }
  357.  
  358. char
  359. tlchat(chan,c)                /* bypass routine for btuchi() for chat */
  360. int chan;
  361. char c;
  362. {
  363.      int oth;
  364.  
  365.      oth=tlclst[chan].chatch;
  366.      c&=eurmsk;
  367.      switch (c) {
  368.      case '\r':
  369.           chiinp(oth,c);
  370.           chiout(oth,c);
  371.           chiout(oth,'\n');
  372.           return(c);
  373.      case '\b':
  374.           chiinp(oth,c);
  375.           chiout(oth,c);
  376.           chiout(oth,' ');
  377.           chiout(oth,c);
  378.           return(c);
  379.      default:
  380.           if (c >= 32) {
  381.                chiinp(oth,c);
  382.                chiout(oth,c);
  383.                return(c);
  384.           }
  385.      }
  386.      return(0);
  387. }
  388.  
  389. ck4sql()                           /* check to see if a user is squelched  */
  390. {
  391.      for (tptr=tlclst,othusn=0 ; othusn < nterms ; tptr++,othusn++) {
  392.           if (tptr->modchn != 0 && tptr->modchn == tlcptr->channel
  393.            && (tptr->SQLFLS(usrnum)&SQLBIT(usrnum))) {
  394.                tlclst[usrnum].flags|=SQUCHD;
  395.           }
  396.      }
  397. }
  398.  
  399. ck4mod()                           /* check for a channel moderator        */
  400. {
  401.      for (tptr=tlclst,othusn=0 ; othusn < nterms ; tptr++,othusn++) {
  402.           if (tptr->modchn == tlcptr->channel && othusn != usrnum) {
  403.                if (tptr->modchn != 0) {
  404.                     return(1);
  405.                }
  406.           }
  407.      }
  408.      return(0);
  409. }
  410.  
  411. squsqu(squel)                      /* squelch/unsquelch user utility       */
  412. int squel;
  413. {
  414.      if ((tlcptr->modchn != 0 && tlcptr->channel == tlcptr->modchn)
  415.       || (usrptr->flags&ISYSOP)) {
  416.           if (instat(margv[1],TLCSTT) && othusp->substt == 1
  417.            && tlclst[othusn].channel == tlcptr->channel) {
  418.                if (squel) {
  419.                     tlcptr->SQLFLS(othusn)|=SQLBIT(othusn);
  420.                     tlclst[othusn].flags|=SQUCHD;
  421.                     prfmsg(YOUSQU);
  422.                     outprf(othusn);
  423.                     prfmsg(CHIMSQ,othuap->userid);
  424.                     outbt2(othusn);
  425.                     prfmsg(HESSQU,othuap->userid);
  426.                }
  427.                else {
  428.                     tlcptr->SQLFLS(othusn)&=~SQLBIT(othusn);
  429.                     tlclst[othusn].flags&=~SQUCHD;
  430.                     prfmsg(YOUUSQ);
  431.                     outprf(othusn);
  432.                     prfmsg(CHEUSQ,othuap->userid);
  433.                     outbt2(othusn);
  434.                     prfmsg(HESUSQ,othuap->userid);
  435.                }
  436.           }
  437.           else {
  438.                prfmsg(WHSNHR,margv[1]);
  439.           }
  440.      }
  441.      else {
  442.           prfmsg(NOTMOD,(ck4mod() ? usracc[othusn].userid : "nobody"));
  443.      }
  444. }
  445.  
  446. xfrcon()                           /* transfer of channel moderatorship    */
  447. {
  448.      struct tlc *otptr;
  449.  
  450.      if (tlcptr->channel == tlcptr->modchn && tlcptr->modchn != 0) {
  451.           if (margc == 1) {
  452.                tlcptr->modchn=0;
  453.                prfmsg(ENDCON,usaptr->userid);
  454.                outtlc();
  455.                prfmsg(RESIGN);
  456.           }
  457.           else if (instat(margv[1],TLCSTT) && othusp->substt == 1
  458.            && tlclst[othusn].channel == tlcptr->channel) {
  459.                otptr=&tlclst[othusn];
  460.                if (otptr->modchn != 0) {
  461.                     prfmsg(ALRMOD,otptr->modchn+1);
  462.                }
  463.                else {
  464.                     otptr->flags&=~SQUCHD;
  465.                     otptr->modchn=otptr->channel;
  466.                     strcpy(otptr->topic,tlcptr->topic);
  467.                     tlcptr->modchn=0;
  468.                     prfmsg(UBMODR,usaptr->userid);
  469.                     outprf(othusn);
  470.                     prfmsg(NEWMOD,usaptr->userid,othuap->userid);
  471.                     outbt2(othusn);
  472.                     prfmsg(RESIGN);
  473.                }
  474.           }
  475.           else {
  476.                prfmsg(WHSNHR,margv[1]);
  477.           }
  478.      }
  479.      else {
  480.           prfmsg(NOTMOD,(ck4mod() ? usracc[othusn].userid : "nobody"));
  481.      }
  482. }
  483.  
  484. outbt2(chn)                        /* prf() to all but usrnum and chn      */
  485. unsigned chn;
  486. {
  487.      for (othusn=0,othusp=user ; othusn < nterms ; othusn++,othusp++) {
  488.           if (othusn != usrnum && othusp->state == TLCSTT
  489.             && othusp->substt == 1 && othusn != chn) {
  490.                if (tlclst[usrnum].channel == tlclst[othusn].channel) {
  491.                     outprf(othusn);
  492.                }
  493.           }
  494.      }
  495.      clrprf();
  496. }
  497.  
  498. ckmodr(tp,spcs)                    /* check for/display moderation topic   */
  499. struct tlc *tp;
  500. char *spcs;
  501. {
  502.      char *stp;
  503.  
  504.      if (tp->channel != 0) {
  505.           if (*(stp=sigtpc(tp->channel)) != '\0') {
  506.                prf("%s  %s",spcs,stp);
  507.           }
  508.           else if (tp->channel == tp->modchn) {
  509.                prf("%s  %s",spcs,tp->topic);
  510.           }
  511.      }
  512.      prf("\r");
  513. }
  514.  
  515. tlcctx()                           /* teleconference channel user display  */
  516. {
  517.      char *tlsrui(),*curguy,tmpbuf[16],*stp;
  518.      unsigned chan;
  519.  
  520.      initls();
  521.      chan=tlclst[usrnum].channel+1;
  522.      switch (chncnt()) {
  523.      case 1:
  524.           prfmsg(BYSELF,chan);
  525.           break;
  526.      case 2:
  527.           prfmsg(ONEOTH,tlsrui(),chan);
  528.           break;
  529.      case 3:
  530.           strcpy(tmpbuf,tlsrui());
  531.           prfmsg(TWOOTH,tmpbuf,tlsrui(),chan);
  532.           break;
  533.      default:
  534.           strcpy(tmpbuf,tlsrui());
  535.           while ((curguy=tlsrui()) != NULL) {
  536.                prf("%s, ",tmpbuf);
  537.                strcpy(tmpbuf,curguy);
  538.           }
  539.           prfmsg(SEVOTH,tmpbuf,chan);
  540.      }
  541.      if (ck4mod()) {
  542.           prfmsg(CHNTPC,tptr->topic,usracc[othusn].userid);
  543.      }
  544.      else if (*(stp=sigtpc(tlcptr->channel)) != '\0') {
  545.           prfmsg(STOPIC,stp);
  546.      }
  547.      if (tlcptr->modchn != 0) {
  548.           if (tlcptr->channel == tlcptr->modchn) {
  549.                prfmsg(URMODR,tlcptr->topic);
  550.           }
  551.           else {
  552.                prfmsg(URMODO,tlcptr->modchn+1,tlcptr->topic);
  553.           }
  554.      }
  555.      prfmsg(IROEPI);
  556. }
  557.  
  558. page()                             /* "page" function                      */
  559. {
  560.      char *heshe();
  561.  
  562.      if (margc == 1) {
  563.           prfmsg(PAGFMT);
  564.      }
  565.      else if (!onsys(margv[1])) {
  566.           if (sameas(margv[1],"on")) {
  567.                tlcptr->flags&=~(NOPAGE+OKPAGE);
  568.                prfmsg(PAGTON,(pagint+30)/60);
  569.           }
  570.           else if (sameas(margv[1],"off")) {
  571.                tlcptr->flags|=NOPAGE;
  572.                prfmsg(PAGTOF);
  573.           }
  574.           else if (sameas(margv[1],"ok")) {
  575.                tlcptr->flags|=OKPAGE;
  576.                tlcptr->flags&=~NOPAGE;
  577.                prfmsg(PAGTOK,(pagint+30)/60);
  578.           }
  579.           else if (sameas(margv[1],"Sysop")) {
  580.                prfmsg(PAGEOK,"Sysop (at main console)");
  581.                tlcptr->blinkc=8;
  582.                shochb(usaptr->userid,1);
  583.           }
  584.           else {
  585.                prfmsg(PAGNON,margv[1]);
  586.           }
  587.      }
  588.      else if (tlclst[othusn].flags&NOPAGE) {
  589.           prfmsg(PAGOFF,othuap->userid);
  590.      }
  591.      else if (!(tlclst[othusn].flags&OKPAGE) && tlclst[othusn].paged) {
  592.           prfmsg(PAGL2M,othuap->userid,(pagint+30)/60);
  593.      }
  594.      else if (othusp->state == TLCSTT && othusp->substt == 1 &&
  595.         tlclst[othusn].channel == tlcptr->channel) {
  596.           prfmsg(PAGATC,othuap->userid,heshe(othusn));
  597.      }
  598.      else {
  599.           if (margc == 2) {
  600.                prfmsg(PAGMSG,usaptr->userid,tlcptr->channel+1);
  601.           }
  602.           else {
  603.                rstrin();
  604.                prfmsg(PAGNOT,usaptr->userid,tlcptr->channel+1,margv[2]);
  605.           }
  606.           if (injoth()) {
  607.                tlclst[othusn].paged=(pagint+7)/15;
  608.                prfmsg(PAGEOK,othuap->userid);
  609.           }
  610.           else {
  611.                prfmsg(PAGNPS,othuap->userid);
  612.           }
  613.      }
  614. }
  615.  
  616. chat()                             /* "chat" function                      */
  617. {
  618.      int i;
  619.      char tlchat();
  620.  
  621.      if (margc == 1) {
  622.           prfmsg(CHAFMT);
  623.      }
  624.      else if (!onsys(margv[1])) {
  625.           prfmsg(PAGNON,margv[1]);
  626.      }
  627.      else if (user[othusn].state != TLCSTT) {
  628.           prfmsg(NOLINT,othuap->userid);
  629.      }
  630.      else if (user[othusn].substt == 2) {
  631.           prfmsg(ALRICH,othuap->userid);
  632.      }
  633.      else if (othusn == usrnum) {
  634.           prfmsg(NCHSLF);
  635.      }
  636.      else if ((tlclst[othusn].flags&CCHVLD)
  637.        && usrnum == tlclst[othusn].chatch) {
  638.           tlclst[usrnum].chatch=othusn;
  639.           btumil(othusn,-(othuap->scnwid-1));
  640.           btumil(usrnum,-(usaptr->scnwid-1));
  641.           usrptr->substt=2;
  642.           othusp->substt=2;
  643.           tlcptr=&tlclst[othusn];
  644.           i=usrnum;
  645.           usrnum=othusn;
  646.           prfmsg(GONCHA,othuap->userid);
  647.           outtlc();
  648.           btucli(othusn);
  649.           btuclo(othusn);
  650.           btupmt(othusn,0);
  651.           prfmsg(ACCPCH,usaptr->userid);
  652.           prfmsg(ENTCHA);
  653.           outprf(othusn);
  654.           btuchi(othusn,tlchat);
  655.           usrnum=i;
  656.           btuclo(usrnum);
  657.           btucli(usrnum);
  658.           tlcptr=&tlclst[usrnum];
  659.           prfmsg(GONCHA,usaptr->userid);
  660.           outtlc();
  661.           btupmt(usrnum,0);
  662.           prfmsg(ENTCHA);
  663.           btuchi(usrnum,tlchat);
  664.      }
  665.      else if (tlclst[othusn].flags&NOPAGE) {
  666.           prfmsg(PAGOFF,othuap->userid);
  667.      }
  668.      else if (!(tlclst[othusn].flags&OKPAGE) && tlclst[othusn].reqcha) {
  669.           prfmsg(CHAL2M,othuap->userid,(reqint+30)/60);
  670.      }
  671.      else {
  672.           prfmsg(CHAREQ,usaptr->userid,(usaptr->sex == 'M' ? "him" : "her"),
  673.                usaptr->userid);
  674.           if (injoth()) {
  675.                tlcptr->chatch=othusn;
  676.                tlcptr->flags|=CCHVLD;
  677.                tlclst[othusn].reqcha=(reqint+7)/15;
  678.                prfmsg(CREQOK,othuap->userid);
  679.           }
  680.           else {
  681.                prfmsg(PAGNPS,othuap->userid);
  682.           }
  683.      }
  684. }
  685.  
  686. chncnt()                           /* count number of users on channel     */
  687. {
  688.      int i,cnt;
  689.      unsigned chan;
  690.  
  691.      chan=tlclst[usrnum].channel;
  692.      for (i=0,cnt=0 ; i < nterms ; i++) {
  693.           if (user[i].state == TLCSTT && user[i].substt == 1
  694.             && tlclst[i].channel == chan) {
  695.                cnt+=1;
  696.           }
  697.      }
  698.      return(cnt);
  699. }
  700.  
  701. char *heshe(usr)                   /* returns "he" or "she" for a user     */
  702. int usr;
  703. {
  704.      return(usracc[usr].sex == 'M' ? "he" : "she");
  705. }
  706.  
  707. whisper(whoto,what)                /* "whisper" function                   */
  708. char *whoto,*what;
  709. {
  710.      if (!instat(whoto,TLCSTT) || othusp->substt != 1
  711.        || tlclst[othusn].channel != tlclst[usrnum].channel) {
  712.           prfmsg(WHSNHR,whoto);
  713.      }
  714.      else {
  715.           rstrin();
  716.           prfmsg(WHSTO,usaptr->userid,what);
  717.           outprf(othusn);
  718.           prf("-- Message sent only to %s --\r",othuap->userid);
  719.      }
  720. }
  721.  
  722. outtlc()                           /* prf()s prfbuf to teleconference chan */
  723. {
  724.      int ousn;
  725.      struct user *ousp;
  726.  
  727.      for (ousn=0,ousp=user ; ousn < nterms ; ousn++,ousp++) {
  728.           if (ousn != usrnum && ousp->state == TLCSTT && ousp->substt == 1) {
  729.                if (tlcptr->channel == tlclst[ousn].channel) {
  730.                     outprf(ousn);
  731.                }
  732.           }
  733.      }
  734.      clrprf();
  735. }
  736.  
  737. tlctck()                           /* real-time teleconference kicker      */
  738. {
  739.      struct tlc *tlcptr;
  740.  
  741.      for (usrnum=0,tlcptr=tlclst ; usrnum < nterms ; usrnum++,tlcptr++) {
  742.           if (tlcptr->paged != 0) {
  743.                tlcptr->paged-=1;
  744.           }
  745.           if (tlcptr->blinkc != 0) {
  746.                if ((tlcptr->blinkc-=1) == 0) {
  747.                     shochn(usracc[usrnum].userid);
  748.                }
  749.           }
  750.           if (tlcptr->reqcha != 0) {
  751.                tlcptr->reqcha-=1;
  752.           }
  753.           tlcptr->swchan=0;
  754.           tlcptr->flags&=~JUSTEX;
  755.      }
  756.      rtkick(15,tlctck);
  757. }
  758.  
  759. initls()                           /* initialize teleconferencer list      */
  760. {
  761.      othusn=-1;
  762.      othusp=user-1;
  763.      othuap=usracc-1;
  764.      tptr=tlclst-1;
  765. }
  766.  
  767. char *tlsrui()                     /* teleconferencer list, show next one  */
  768. {
  769.      static char retval[16];
  770.  
  771.      while (othusn < nterms) {
  772.           othusn+=1;
  773.           othusp+=1;
  774.           othuap+=1;
  775.           tptr+=1;
  776.           if (othusp->state == TLCSTT && othusn != usrnum &&
  777.               othusp->substt == 1 && tptr->channel == tlcptr->channel) {
  778.                strcpy(retval,othuap->userid);
  779.                if (tptr->flags&SQUCHD) {
  780.                     strcat(retval," (sq)");
  781.                }
  782.                return(retval);
  783.           }
  784.      }
  785.      return(NULL);
  786. }
  787.  
  788. tlchup()                           /* teleconference hang-up routine       */
  789. {
  790.      int i,othusn;
  791.  
  792.      tlcptr=&tlclst[usrnum];
  793.      if (usrptr->state == TLCSTT) {
  794.           setmbk(tlcmb);
  795.           if (usrptr->substt == 2) {
  796.                othusn=tlcptr->chatch;
  797.                btuchi(usrnum,NULL);
  798.                btuchi(othusn,NULL);
  799.                tlcptr=&tlclst[othusn];
  800.                tlcptr->flags&=~CCHVLD;
  801.                tlcptr->reqcha=0;
  802.                btupmt(othusn,':');
  803.                user[othusn].substt=1;
  804.                prfmsg(ENTTLC,usracc[othusn].userid);
  805.                i=usrnum;
  806.                usrnum=othusn;
  807.                outtlc();
  808.                prfmsg(OCHHUP,usaptr->userid);
  809.                tlcctx();
  810.                outprf(othusn);
  811.                btucli(othusn);
  812.                btumil(othusn,tinpsz);
  813.                usrnum=i;
  814.                tlcptr=&tlclst[usrnum];
  815.           }
  816.           else {
  817.                prfmsg(TLCHUP,usaptr->userid);
  818.                outtlc();
  819.           }
  820.      }
  821.      for (tptr=tlclst,othusn=0 ; othusn < nterms ; tptr++,othusn++) {
  822.           if (tptr->chatch == usrnum) {
  823.                tptr->flags&=~CCHVLD;
  824.           }
  825.           tptr->SQLFLS(usrnum)&=~SQLBIT(usrnum);
  826.      }
  827.      setmem(tlcptr,sizeof(struct tlc),0);
  828. }
  829.  
  830. clstlc()                      /* close teleconference files for shutdown   */
  831. {
  832.      clsmsg(tlcmb);
  833. }
  834.