home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / DEVBBS.ZIP / CONIO.C < prev    next >
Text File  |  1992-07-20  |  39KB  |  1,607 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1991 by Wayne Bell
  5.  
  6. *****************************************************************************/
  7.  
  8. #include "vars.h"
  9. #pragma hdrstop
  10. #include <mem.h>
  11. #include <conio.h>
  12. #define TWO_WAY
  13. #define SCROLL_UP(t,b,l) \
  14.   _CH=t;\
  15.   _DH=b;\
  16.   _BH=curatr;\
  17.   _AL=l;\
  18.   _CL=0;\
  19.   _DL=79;\
  20.   _AH=6;\
  21.   my_video_int();
  22.  
  23. #define GLOBAL_SIZE 256
  24.  
  25. static char global_buf[GLOBAL_SIZE];
  26. static int global_ptr;
  27.  
  28. void my_video_int()
  29. {
  30. #if __TURBOC__ >= 0x0200
  31.   /* TC 2.0 or TC++ here */
  32.   static unsigned short sav_bp;
  33.  
  34.   __emit__(0x56, 0x57); /* push si, push di */
  35.   sav_bp = _BP;
  36.   geninterrupt(0x10);
  37.   _BP = sav_bp;
  38.   __emit__(0x5f, 0x5e); /* pop di, pop si */
  39. #else
  40.   /* TC 1.5 here */
  41.   _VideoInt();
  42. #endif
  43. }
  44.  
  45. void set_global_handle(int i)
  46. {
  47.   char s[81];
  48.  
  49.   if (i) {
  50.     if (!global_handle) {
  51.       sprintf(s,"%sGLOBAL.TXT",syscfg.gfilesdir);
  52.       global_handle=open(s,O_RDWR | O_APPEND | O_BINARY | O_CREAT,
  53.                            S_IREAD | S_IWRITE);
  54.       if (global_handle<0)
  55.         global_handle=0;
  56.       global_ptr=0;
  57.     }
  58.   } else {
  59.     if (global_handle) {
  60.       write(global_handle,global_buf,global_ptr);
  61.       close(global_handle);
  62.       global_handle=0;
  63.     }
  64.   }
  65. }
  66.  
  67. void global_char(char ch)
  68. {
  69.   global_buf[global_ptr++]=ch;
  70.   if (global_ptr==GLOBAL_SIZE) {
  71.     write(global_handle,global_buf,global_ptr);
  72.     global_ptr=0;
  73.   }
  74. }
  75.  
  76. void movecsr(int x,int y)
  77. /* This, obviously, moves the cursor to the location specified, offset from
  78.  * the protected dispaly at the top of the screen
  79.  */
  80. {
  81.   if (x<0)
  82.     x=0;
  83.   if (x>79)
  84.     x=79;
  85.   if (y<0)
  86.     y=0;
  87.   y+=topline;
  88.   if (y>screenbottom)
  89.     y=screenbottom;
  90.  
  91.   _BH=0x00;
  92.   _DH=y;
  93.   _DL=x;
  94.   _AH=0x02;
  95.   my_video_int();
  96. }
  97.  
  98. int wherex()
  99. /* This function returns the current X cursor position, as the number of
  100.  * characters from the left hand side of the screen.  An X position of zero
  101.  * means the cursor is at the left-most position
  102.  */
  103. {
  104.   _BH=0x00;
  105.   _AH=0x03;
  106.   my_video_int();
  107.   tempio=_DL;
  108.   return(tempio);
  109. }
  110.  
  111. int wherey()
  112. /* This function returns the Y cursor position, as the line number from
  113.  * the top of the logical window.  The offset due to the protected top
  114.  * of the screen display is taken into account.  A wherey() of zero means
  115.  * the cursor is at the top-most position it can be at.
  116.  */
  117. {
  118.   _BH=0x00;
  119.   _AH=0x03;
  120.   my_video_int();
  121.   tempio=_DH;
  122.   return(tempio-topline);
  123. }
  124.  
  125. void lf()
  126. /* This function performs a linefeed to the screen (but not remotely) by
  127.  * either moving the cursor down one line, or scrolling the logical screen
  128.  * up one line.
  129.  */
  130. {
  131.   _BH=0x00;
  132.   _AH=0x03;
  133.   my_video_int();
  134.   tempio=_DL;
  135.   if (_DH==screenbottom) {
  136.     SCROLL_UP(topline,screenbottom,1);
  137.     _DL=tempio;
  138.     _DH=screenbottom;
  139.     _BH=0;
  140.     _AH=0x02;
  141.     my_video_int();
  142.   } else {
  143.     tempio=_DH+1;
  144.     _DH=tempio;
  145.     _AH=0x02;
  146.     my_video_int();
  147.   }
  148. }
  149.  
  150. void cr()
  151. /* This short function returns the local cursor to the left-most position
  152.  * on the screen.
  153.  */
  154. {
  155.   _BH=0x00;
  156.   _AH=0x03;
  157.   my_video_int();
  158.   _DL=0x00;
  159.   _AH=2;
  160.   my_video_int();
  161. }
  162.  
  163. void clrscrb()
  164. /* This clears the local logical screen */
  165. {
  166.   SCROLL_UP(topline,screenbottom,0);
  167.   movecsr(0,0);
  168.   lines_listed=0;
  169. }
  170.  
  171. void bs()
  172. /* This function moves the cursor one position to the left, or if the cursor
  173.  * is currently at its left-most position, the cursor is moved to the end of
  174.  * the previous line, except if it is on the top line, in which case nothing
  175.  * happens.
  176.  */
  177. {
  178.   _BH=0;
  179.   _AH=3;
  180.   my_video_int();
  181.   if (_DL==0) {
  182.     if (_DH != topline) {
  183.       _DL=79;
  184.       tempio=_DH-1;
  185.       _DH=tempio;
  186.       _AH=2;
  187.       my_video_int();
  188.     }
  189.   } else {
  190.     _DL--;
  191.     _AH=2;
  192.     my_video_int();
  193.   }
  194. }
  195.  
  196. void out1chx(unsigned char ch)
  197. /* This function outputs one character to the screen, then updates the
  198.  * cursor position accordingly, scolling the screen if necessary.  Not that
  199.  * this function performs no commands such as a C/R or L/F.  If a value of
  200.  * 8, 7, 13, 10, 12 (backspace, beep, C/R, L/F, TOF), or any other command-
  201.  * type characters are passed, the appropriate corresponding "graphics"
  202.  * symbol will be output to the screen as a normal character.
  203.  */
  204. {
  205.   _BL=curatr;
  206.   _BH=0x00;
  207.   _CX=0x01;
  208.   _AL=ch;
  209.   _AH=0x09;
  210.   my_video_int();
  211.   _BH=0x00;
  212.   _AH=0x03;
  213.   my_video_int();
  214.   ++_DL;
  215.   if (_DL==80) {
  216.     _DL=0;
  217.     if (_DH==screenbottom) {
  218.       SCROLL_UP(topline,screenbottom,1);
  219.       _DH=screenbottom;
  220.       _DL=0;
  221.       _BH=0;
  222.       _AH=0x02;
  223.       my_video_int();
  224.     } else {
  225.       tempio=_DH+1;
  226.       _DH=tempio;
  227.       _AH=0x02;
  228.       my_video_int();
  229.     }
  230.   } else {
  231.     _AH=0x02;
  232.     my_video_int();
  233.   }
  234. }
  235.  
  236. void out1ch(unsigned char ch)
  237. /* This function outputs one character to the local screen.  C/R, L/F, TOF,
  238.  * BS, and BELL are interpreted as commands instead of characters.
  239.  */
  240. {
  241.   if (ch>31)
  242.     out1chx(ch);
  243.   else
  244.     if (ch==13)
  245.       cr();
  246.     else
  247.       if (ch==10)
  248.         lf();
  249.       else
  250.         if (ch==12)
  251.           clrscrb();
  252.         else
  253.           if (ch==8)
  254.             bs();
  255.           else
  256.             if (ch==7)
  257.               if (outcom==0) {
  258.                 setbeep(1);
  259.                 wait1(4);
  260.                 setbeep(0);
  261.               }
  262. }
  263.  
  264. void outs(char *s)
  265. /* This (obviously) outputs a string TO THE SCREEN ONLY */
  266. {
  267.   int i;
  268.   char ch;
  269.  
  270.   for (i=0; s[i]!=0; i++) {
  271.     ch=s[i];
  272.     out1ch(ch);
  273.   }
  274. }
  275.  
  276. void pr_wait(int i1)
  277. {
  278.   int i;
  279.  
  280.   if (i1) {
  281.     if (okansi()) {
  282.       i=curatr;
  283.       setc((thisuser.sysstatus & sysstatus_color) ? thisuser.colors[3] :
  284.             thisuser.bwcolors[3]);
  285.       outstr("[Stimpy Working]\x1b[16D");
  286.       setc(i);
  287.     } else {
  288.       outstr("[Stimpy Working]");
  289.     }
  290.   } else {
  291.     if (okansi()) {
  292.       outstr("                \x1b[16D");
  293.     } else {
  294.       for (i=0; i<16; i++)
  295.         backspace();
  296.     }
  297.   }
  298. }
  299.  
  300. void set_protect(int l)
  301. /* set_protect sets the number of lines protected at the top of the screen. */
  302. {
  303.   if (l!=topline) {
  304.     if (l>topline) {
  305.       if ((wherey()+topline-l) < 0) {
  306.         _CH=topline;
  307.         _DH=screenbottom+1;
  308.         _AL=l-topline;
  309.         _CL=0;
  310.         _DL=79;
  311.         _BH=0x07;
  312.         _AH=7;
  313.         my_video_int();
  314.         movecsr(wherex(),wherey()+l-topline);
  315.       } else {
  316.         oldy += (topline-l);
  317.       }
  318.     } else {
  319.       SCROLL_UP(l,topline-1,0);
  320.       oldy += (topline-l);
  321.     }
  322.   }
  323.   topline=l;
  324.   if (using_modem)
  325.     screenlinest=thisuser.screenlines;
  326.   else
  327.     screenlinest=defscreenbottom+1-topline;
  328. }
  329.  
  330. void savescreen(screentype *s)
  331. {
  332.   memmove(s->scrn1,scrn,screenlen);
  333.   s->x1=wherex();
  334.   s->y1=wherey();
  335.   s->topline1=topline;
  336.   s->curatr1=curatr;
  337. }
  338.  
  339. void restorescreen(screentype far *s)
  340. /* restorescreen restores a screen previously saved with savescreen */
  341. {
  342.   memmove(scrn,s->scrn1,screenlen);
  343.   topline=s->topline1;
  344.   curatr=s->curatr1;
  345.   movecsr(s->x1,s->y1);
  346. }
  347.  
  348. void makewindow(int x, int y, int xlen, int ylen)
  349. /* makewindow makes a window with the upper-left hand corner at (x,y), and the
  350.    lower-right corner at (x+xlen,y+ylen) */
  351. {
  352.   int i,xx,yy;
  353.   unsigned char s[81];
  354.  
  355.   if (xlen>80)
  356.     xlen=80;
  357.   if (ylen>(screenbottom+1-topline))
  358.     ylen=(screenbottom+1-topline);
  359.   if ((x+xlen)>80)
  360.     x=80-xlen;
  361.   if ((y+ylen)>screenbottom+1)
  362.     y=screenbottom+1-ylen;
  363.   xx=wherex();
  364.   yy=wherey();
  365.   for (i=1; i<xlen-1; i++)
  366.     s[i]=196;
  367.   s[0]=218;
  368.   s[xlen-1]=191;
  369.   s[xlen]=0;
  370.   movecsr(x,y);
  371.   outs(s);
  372.   s[0]=192;
  373.   s[xlen-1]=217;
  374.   movecsr(x,y+ylen-1);
  375.   outs(s);
  376.   for (i=1; i<xlen-1; i++)
  377.     s[i]=32;
  378.   s[0]=179;
  379.   s[xlen-1]=179;
  380.   for (i=1; i<ylen-1; i++) {
  381.     movecsr(x,i+y);
  382.     outs(s);
  383.   }
  384.   movecsr(xx,yy);
  385. }
  386.  
  387. void editline(char *s, int len, int status, int *returncode, char *ss)
  388. /* editline edits a string, doing I/O to the screen only. */
  389. {
  390.   int i,j,k,oldatr,cx,cy,pos,ch,done,insert,i1;
  391.  
  392.   oldatr=curatr;
  393.   cx=wherex();
  394.   cy=wherey();
  395.   for (i=strlen(s); i<len; i++)
  396.     s[i]=32;
  397.   s[len]=0;
  398.   curatr=0x70;
  399.   outs(s);
  400.   movecsr(cx,cy);
  401.   done=0;
  402.   pos=0;
  403.   insert=0;
  404.   do {
  405.     ch=getchd();
  406.     if (ch==0) {
  407.       ch=getchd();
  408.       switch (ch) {
  409.         case 59:
  410.           done=1;
  411.           *returncode=DONE;
  412.           break;
  413.         case 71: pos=0; movecsr(cx,cy); break;
  414.         case 79: pos=len; movecsr(cx+pos,cy); break;
  415.         case 77: if (pos<len) {
  416.             pos++;
  417.             movecsr(cx+pos,cy);
  418.           }
  419.           break;
  420.         case 75: if (pos>0) {
  421.             pos--;
  422.             movecsr(cx+pos,cy);
  423.           }
  424.           break;
  425.         case 72:
  426.         case 15:
  427.           done=1;
  428.           *returncode=PREV;
  429.           break;
  430.         case 80:
  431.           done=1;
  432.           *returncode=NEXT;
  433.           break;
  434.         case 82:
  435.           if (status!=SET) {
  436.             if (insert)
  437.               insert=0;
  438.             else
  439.               insert=1;
  440.           }
  441.           break;
  442.         case 83:
  443.           if (status!=SET) {
  444.             for (i=pos; i<len; i++)
  445.               s[i]=s[i+1];
  446.             s[len-1]=32;
  447.             movecsr(cx,cy);
  448.             outs(s);
  449.             movecsr(cx+pos,cy);
  450.           }
  451.           break;
  452.       }
  453.     } else {
  454.       if (ch>31) {
  455.         if (status==UPPER_ONLY)
  456.           ch=upcase(ch);
  457.     if (status==SET) {
  458.       ch=upcase(ch);
  459.       if (ch!=' ') {
  460.         i1=1;
  461.             for (i=0; i<len; i++)
  462.           if ((ch==ss[i]) && (i1)) {
  463.         i1=0;
  464.         pos=i;
  465.         movecsr(cx+pos,cy);
  466.         if (s[pos]==' ')
  467.           ch=ss[pos];
  468.         else
  469.           ch=' ';
  470.           }
  471.         if (i1)
  472.           ch=ss[pos];
  473.       }
  474.     }
  475.         if ((pos<len)&&((status==ALL) || (status==UPPER_ONLY) || (status==SET) ||
  476.             ((status==NUM_ONLY) && (((ch>='0') && (ch<='9')) || (ch==' '))))) {
  477.           if (insert) {
  478.             for (i=len-1; i>pos; i--)
  479.               s[i]=s[i-1];
  480.             s[pos++]=ch;
  481.             movecsr(cx,cy);
  482.             outs(s);
  483.             movecsr(cx+pos,cy);
  484.           } else {
  485.             s[pos++]=ch;
  486.             out1ch(ch);
  487.           }
  488.         }
  489.       } else {
  490.     ch=ch;
  491.         switch(ch) {
  492.       case 13:
  493.           case 9:
  494.             done=1;
  495.             *returncode=NEXT;
  496.             break;
  497.           case 27:
  498.             done=1;
  499.             *returncode=DONE;
  500.             break;
  501.           case 8:
  502.             if (pos>0) {
  503.               if (insert) {
  504.                 for (i=pos-1; i<len; i++)
  505.                   s[i]=s[i+1];
  506.                 s[len-1]=32;
  507.                 pos--;
  508.                 movecsr(cx,cy);
  509.                 outs(s);
  510.                 movecsr(cx+pos,cy);
  511.               } else {
  512.                 pos--;
  513.                 movecsr(cx+pos,cy);
  514.               }
  515.             }
  516.             break;
  517.         }
  518.       }
  519.     }
  520.   } while (done==0);
  521.   movecsr(cx,cy);
  522.   curatr=oldatr;
  523.   outs(s);
  524.   movecsr(cx,cy);
  525. }
  526.  
  527. void val_cur_user()
  528. /* val_cur_user allows the sysop at the keyboard to validate the current user,
  529.    chaning sl, dsl, ar, dar, sysop sub, exemptions, restrictions, and user
  530.    note
  531.  */
  532. {
  533.   char sl[4],dsl[4],exempt[4],sysopsub[4],ar[17],dar[17],restrict[17],rst[17],
  534.        tl[50];
  535.   int cp,i,done,rc,wx,wy;
  536.  
  537.   pr_wait(1);
  538.   savescreen(&screensave);
  539.   curatr=7;
  540.   wx=15;
  541.   wy=4;
  542.   makewindow(wx,wy,50,7);
  543.   itoa((int)thisuser.sl,sl,10);
  544.   itoa((int)thisuser.dsl,dsl,10);
  545.   itoa((int)thisuser.exempt,exempt,10);
  546.   itoa((int)thisuser.sysopsub,sysopsub,10);
  547.   strcpy(rst,restrict_string);
  548.   for (i=0; i<=15; i++) {
  549.     if (thisuser.ar & (1 << i))
  550.       ar[i]='A'+i;
  551.     else
  552.       ar[i]=32;
  553.     if (thisuser.dar & (1 << i))
  554.       dar[i]='A'+i;
  555.     else
  556.       dar[i]=32;
  557.     if (thisuser.restrict & (1 << i))
  558.       restrict[i]=rst[i];
  559.     else
  560.       restrict[i]=32;
  561.   }
  562.   dar[16]=0;
  563.   ar[16]=0;
  564.   restrict[16]=0;
  565.   cp=0;
  566.   done=0;
  567.   movecsr(wx+2,wy+1); sprintf(tl,"SL  : %s",sl); outs(tl);
  568.   movecsr(wx+26,wy+1); sprintf(tl,"AR  : %s",ar); outs(tl);
  569.   movecsr(wx+2,wy+2); sprintf(tl,"DSL : %s",dsl); outs(tl);
  570.   movecsr(wx+26,wy+2); sprintf(tl,"DAR : %s",dar); outs(tl);
  571.   movecsr(wx+2,wy+3); sprintf(tl,"EXMT: %s",exempt); outs(tl);
  572.   movecsr(wx+26,wy+3); sprintf(tl,"RSTR: %s",restrict); outs(tl);
  573.   movecsr(wx+2,wy+4); sprintf(tl,"SYSOPSUB: %s",sysopsub); outs(tl);
  574.   movecsr(wx+2,wy+5); sprintf(tl,"NOTE: %s",thisuser.note); outs(tl);
  575.   while (done==0) {
  576.     switch(cp) {
  577.       case 0:
  578.         movecsr(wx+8,wy+1);
  579.         editline(sl,3,NUM_ONLY,&rc,"");
  580.         thisuser.sl=(char) atoi(sl);
  581.         itoa((int)thisuser.sl,sl,10);
  582.         sprintf(tl,"%-3s",sl); outs(tl);
  583.         break;
  584.       case 1:
  585.         movecsr(wx+32,wy+1);
  586.         editline(ar,16,SET,&rc,"ABCDEFGHIJKLMNOP ");
  587.         thisuser.ar=0;
  588.         for (i=0; i<=15; i++)
  589.           if (ar[i]!=32)
  590.             thisuser.ar |= (1 << i);
  591.         break;
  592.       case 2:
  593.         movecsr(wx+8,wy+2);
  594.         editline(dsl,3,NUM_ONLY,&rc,"");
  595.         thisuser.dsl=(char) atoi(dsl);
  596.         itoa((int)thisuser.dsl,dsl,10);
  597.         sprintf(tl,"%-3s",dsl); outs(tl);
  598.         break;
  599.       case 3:
  600.         movecsr(wx+32,wy+2);
  601.         editline(dar,16,SET,&rc,"ABCDEFGHIJKLMNOP ");
  602.         thisuser.dar=0;
  603.         for (i=0; i<=15; i++)
  604.           if (dar[i]!=32)
  605.             thisuser.dar |= (1 << i);
  606.         break;
  607.       case 4:
  608.         movecsr(wx+8,wy+3);
  609.         editline(exempt,3,NUM_ONLY,&rc,"");
  610.         thisuser.exempt=(char) atoi(exempt);
  611.         itoa((int)thisuser.exempt,exempt,10);
  612.         sprintf(tl,"%-3s",exempt); outs(tl);
  613.         break;
  614.       case 5:
  615.         movecsr(wx+32,wy+3);
  616.         editline(restrict,16,SET,&rc,rst);
  617.         thisuser.restrict=0;
  618.         for (i=0; i<=15; i++)
  619.           if (restrict[i]!=32)
  620.             thisuser.restrict |= (1 << i);
  621.         break;
  622.       case 6:
  623.         movecsr(wx+12,wy+4);
  624.         editline(sysopsub,3,NUM_ONLY,&rc,"");
  625.         thisuser.sysopsub=(char) atoi(sysopsub);
  626.         itoa((int)thisuser.sysopsub,sysopsub,10);
  627.         sprintf(tl,"%-3s",sysopsub); outs(tl);
  628.         break;
  629.       case 7:
  630.         movecsr(wx+8,wy+5);
  631.         editline(thisuser.note,40,ALL,&rc,"");
  632.         break;
  633.     }
  634.     switch(rc) {
  635.       case DONE: done=1; break;
  636.       case NEXT: cp=(cp+1) % 8; break;
  637.       case PREV: cp--; if (cp==-1) cp=7;  break;
  638.     }
  639.   }
  640.   restorescreen(&screensave);
  641.   reset_act_sl();
  642.   changedsl();
  643.   pr_wait(0);
  644. }
  645.  
  646. void temp_cmd(char *s, int ccc)
  647. {
  648.   int i;
  649.  
  650.   pr_wait(1);
  651.   savescreen(&screensave);
  652.   i=topline;
  653.   topline=0;
  654.   curatr=0x07;
  655.   clrscrb();
  656.   do_remote(s, ccc);
  657.   restorescreen(&screensave);
  658.   topline=i;
  659.   pr_wait(0);
  660. }
  661.  
  662. char xlate[] = {
  663.   'Q','W','E','R','T','Y','U','I','O','P',0,0,0,0,
  664.   'A','S','D','F','G','H','J','K','L',0,0,0,0,0,
  665.   'Z','X','C','V','B','N','M',
  666. };
  667.  
  668. char scan_to_char(unsigned char ch)
  669. {
  670.   if ((ch>=16) && (ch<=50))
  671.     return(xlate[ch-16]);
  672.   else
  673.     return(0);
  674. }
  675.  
  676. void alt_key(unsigned char ch)
  677. {
  678.   char ch1;
  679.   char *ss, *ss1,s[81],cmd[128];
  680.   int f,l;
  681.  
  682.   cmd[0]=0;
  683.   ch1=scan_to_char(ch);
  684.   if (ch1) {
  685.     sprintf(s,"%sMACROS.TXT",syscfg.datadir);
  686.     f=open(s,O_RDONLY | O_BINARY);
  687.     if (f>0) {
  688.       l=filelength(f);
  689.       ss=farmalloc(l+10);
  690.       if (ss) {
  691.         read(f,ss,l);
  692.         close(f);
  693.     ss[l]=0;
  694.     ss1=strtok(ss,"\r\n");
  695.     while (ss1) {
  696.       if (toupper(*ss1)==ch1) {
  697.         strtok(ss1," \t");
  698.         ss1=strtok(NULL,"\r\n");
  699.         if (ss1)
  700.           strcpy(cmd,ss1);
  701.         ss1=NULL;
  702.       } else
  703.         ss1=strtok(NULL,"\r\n");
  704.     }
  705.     farfree(ss);
  706.       } else
  707.         close(f);
  708.       if (cmd[0]) {
  709.         temp_cmd(cmd,1);
  710.       }
  711.     }
  712.   }
  713. }
  714.  
  715. void skey(char ch)
  716. /* skey handles all f-keys and the like hit FROM THE KEYBOARD ONLY */
  717. {
  718.   int i,i1;
  719.  
  720.   if (((syscfg.sysconfig & sysconfig_no_local) ==0) && (okskey)) {
  721.     if ((ch>=104) && (ch<=113)) {
  722.       set_autoval(ch-104);
  723.     } else
  724.       switch ((unsigned char) ch) {
  725.         case 59: /* F1 */
  726.       val_cur_user();
  727.       break;
  728.         case 60: /* F2 */
  729.           topdata+=1;
  730.           if (topdata==3)
  731.             topdata=0;
  732.           topscreen();
  733.           break;
  734.     case 61: /* F3 */
  735.       if (using_modem) {
  736.         incom=(!incom);
  737.         dump();
  738.             tleft(0);
  739.       }
  740.       break;
  741.         case 62: /* F4 */
  742.           chatcall=0;
  743.           topscreen();
  744.           break;
  745.         case 63: /* F5 */
  746.           hangup=1;
  747.       dtr(0);
  748.       break;
  749.     case 64: /* F6 */
  750.       sysop_alert=!sysop_alert;
  751.           tleft(0);
  752.       break;
  753.         case 65: /* F7 */
  754.           thisuser.extratime-=5.0*60.0;
  755.           tleft(0);
  756.           break;
  757.         case 66: /* F8 */
  758.           thisuser.extratime+=5.0*60.0;
  759.           tleft(0);
  760.           break;
  761.         case 67: /* F9 */
  762.           if (thisuser.sl!=255) {
  763.             if (actsl!=255)
  764.               actsl=255;
  765.             else
  766.               reset_act_sl();
  767.             changedsl();
  768.             tleft(0);
  769.           }
  770.           break;
  771.         case 68: /* F10 */
  772.           if (chatting==0) {
  773.             if (syscfg.sysconfig & sysconfig_2_way)
  774.               chat1("",1);
  775.             else
  776.               chat1("",0);
  777.           } else
  778.             chatting=0;
  779.           break;
  780.     case 71: /* HOME */
  781.       if (chatting) {
  782.         if (chat_file)
  783.           chat_file=0;
  784.         else
  785.           chat_file=1;
  786.       }
  787.       break;
  788.     case 88: /* Shift-F5 */
  789.       i1=(rand() % 20) + 10;
  790.       for (i=0; i<i1; i++)
  791.         outchr(rand() % 256);
  792.           hangup=1;
  793.       dtr(0);
  794.       break;
  795.     case 98: /* Ctrl-F5 */
  796.       nl();
  797.       pl("fCall back later when you are there.");
  798.       nl();
  799.       hangup=1;
  800.       dtr(0);
  801.       break;
  802.         case 103: /* Ctrl-F10 */
  803.           if (chatting==0)
  804.             chat1("",0);
  805.           else
  806.             chatting=0;
  807.           break;
  808.         case 84: /* Shift-F1 */
  809.           set_global_handle(!global_handle);
  810.           topscreen();
  811.           break;
  812.         case 93: /* Shift-F10 */
  813.           temp_cmd(getenv("COMSPEC"),0);
  814.           break;
  815.         default:
  816.           alt_key((unsigned char) ch);
  817.           break;
  818.       }
  819.   }
  820. }
  821.  
  822. void tleft(int x)
  823. {
  824.   int cx,cy,ctl,cc,ln,i;
  825.   double nsln;
  826.   char tl[30];
  827.  
  828.   cx=wherex();
  829.   cy=wherey();
  830.   ctl=topline;
  831.   cc=curatr;
  832.   if (crttype==7)
  833.     curatr=0x07;
  834.   else
  835.     curatr=0x0e;
  836.   topline=0;
  837.   nsln=nsl();
  838.   if (chatcall && (topdata==2))
  839.     ln=5;
  840.   else
  841.     ln=4;
  842.   if (topdata) {
  843.     if ((using_modem) && (!incom)) {
  844.       movecsr(1,ln);
  845.       outs("═════Comm Disabled═");
  846.       for (i=19; i<strlen(curspeed); i++)
  847.         out1ch('═');
  848.     } else {
  849.       movecsr(1,ln);
  850.       outs(curspeed);
  851.     }
  852.     if ((thisuser.sl!=255) && (actsl==255)) {
  853.       movecsr(23,ln);
  854.       outs("═Temp Sysop═");
  855.     }
  856.     if (global_handle) {
  857.       movecsr(40,ln);
  858.       outs("═Capture═");
  859.     }
  860.     movecsr(54,ln);
  861.     if (sysop_alert) {
  862.       outs("═Alert═");
  863.     } else {
  864.       outs("═══════");
  865.     }
  866.     movecsr(64,ln);
  867.     if (sysop1()) {
  868.       outs("═Available═");
  869.     } else {
  870.       outs("═══════════");
  871.     }
  872.   }
  873.   switch (topdata)
  874.     {
  875.     case 1:
  876.       if (useron) {
  877.         movecsr(18,3);
  878.         sprintf(tl,"T-%6.2f",nsln/60.0);
  879.         outs(tl);
  880.       }
  881.       break;
  882.     case 2:
  883.       movecsr(64,3);
  884.       if (useron)
  885.         sprintf(tl,"T-%6.2f",nsln/60.0);
  886.       else
  887.         strcpy(tl,thisuser.pw);
  888.       outs(tl);
  889.       break;
  890.   }
  891.   topline=ctl;
  892.   curatr=cc;
  893.   movecsr(cx,cy);
  894.   if ((x) && (useron))
  895.     if (nsln==0.0) {
  896.       outstr("\r\nTime expired.\r\n");
  897.       hangup=1;
  898.     }
  899. }
  900.  
  901. void topscreen()
  902. {
  903.   int cc,cx,cy,ctl,i;
  904.   char sl[81],ar[17],dar[17],restrict[17],rst[17],lo[90],ol[190],calls[20];
  905.  
  906.   switch(topdata) {
  907.     case 0:
  908.       set_protect(0);
  909.       break;
  910.     case 1:
  911.       set_protect(5);
  912.       break;
  913.     case 2:
  914.       if (chatcall)
  915.         set_protect(6);
  916.       else {
  917.         if (topline==6)
  918.           set_protect(0);
  919.         set_protect(5);
  920.       }
  921.       break;
  922.   }
  923.   cx=wherex();
  924.   cy=wherey();
  925.   ctl=topline;
  926.   cc=curatr;
  927.   if (crttype==7)
  928.     curatr=0x07;
  929.   else
  930.     curatr=0x0e;
  931.   topline=0;
  932.   for (i=0; i<80; i++)
  933.     sl[i]=205;
  934.   sl[80]=0;
  935.   switch (topdata) {
  936.     case 0:
  937.       break;
  938.     case 1:
  939.       movecsr(0,0);
  940.       sprintf(ol,"%-50s  Activity for %8s:      ",
  941.           syscfg.systemname,status.date1);
  942.       outs(ol);
  943.       movecsr(0,1);
  944.       sprintf(ol,"Users: %4d       Total Calls: %5ld      Calls Today: %4d    Posted      :%3d ",
  945.           status.users,status.callernum1,status.callstoday,status.msgposttoday);
  946.       outs(ol);
  947.       movecsr(0,2);
  948.       sprintf(ol,"%-36s      %-4d min   /  %2d%%    E-mail sent :%3d ",
  949.           nam(&thisuser,usernum),status.activetoday,
  950.           (int) (10*status.activetoday/144),status.emailtoday);
  951.       outs(ol);
  952.       movecsr(0,3);
  953.       sprintf(ol,"SL=%3d   DL=%3d               FW=%3d      Uploaded:%2d files    Feedback    :%3d ",
  954.           thisuser.sl,thisuser.dsl,fwaiting,status.uptoday,status.fbacktoday);
  955.       outs(ol);
  956.       break;
  957.     case 2:
  958.       strcpy(rst,restrict_string);
  959.       for (i=0; i<=15; i++) {
  960.         if (thisuser.ar & (1 << i))
  961.           ar[i]='A'+i;
  962.         else
  963.           ar[i]=32;
  964.         if (thisuser.dar & (1 << i))
  965.           dar[i]='A'+i;
  966.         else
  967.           dar[i]=32;
  968.         if (thisuser.restrict & (1 << i))
  969.           restrict[i]=rst[i];
  970.         else
  971.           restrict[i]=32;
  972.       }
  973.       dar[16]=0;
  974.       ar[16]=0;
  975.       restrict[16]=0;
  976.       if (strcmp(thisuser.laston,date()))
  977.         strcpy(lo,thisuser.laston);
  978.       else
  979.         sprintf(lo,"Today:%2d",thisuser.ontoday);
  980.       movecsr(0,0);
  981.       sprintf(ol,"%-36s W=%2d UL=%4d/%6ld SL=%3d LO=%5d PO=%4d",
  982.           nam(&thisuser,usernum),thisuser.waiting,thisuser.uploaded,
  983.           thisuser.uk,thisuser.sl,thisuser.logons,thisuser.msgpost);
  984.       outs(ol);
  985.       movecsr(0,1);
  986.       if (thisuser.wwiv_regnum)
  987.         sprintf(calls,"%lu",thisuser.wwiv_regnum);
  988.       else
  989.     strcpy(calls,thisuser.zipcode);
  990.       sprintf(ol,"%-20s %12s  %-6s DL=%4d/%6ld DL=%3d TO=%5.0ld ES=%4d",
  991.           thisuser.realname,thisuser.phone,calls,
  992.           thisuser.downloaded,thisuser.dk,thisuser.dsl,
  993.           ((long) ((thisuser.timeon+timer()-timeon)/60.0)),
  994.           thisuser.emailsent+thisuser.emailnet);
  995.       outs(ol);
  996.       movecsr(0,2);
  997.       sprintf(ol,"ARs=%-16s/%-16s R=%-16s EX=%3d %-8s FS=%4d",
  998.           ar,dar,restrict,thisuser.exempt,lo,thisuser.feedbacksent);
  999.       outs(ol);
  1000.       movecsr(0,3);
  1001.       sprintf(ol,"%-40s %c %2d %-17s          FW= %3d",
  1002.           thisuser.note,thisuser.sex,thisuser.age,
  1003.           ctypes[thisuser.comp_type],fwaiting);
  1004.       outs(ol);
  1005.       if (chatcall) {
  1006.         movecsr(0,4);
  1007.         outs(chatreason);
  1008.       }
  1009.       break;
  1010.   }
  1011.   if (ctl!=0) {
  1012.     movecsr(0,ctl-1);
  1013.     outs(sl);
  1014.   }
  1015.   topline=ctl;
  1016.   movecsr(cx,cy);
  1017.   curatr=cc;
  1018.   tleft(0);
  1019. }
  1020. /****************************************************************************/
  1021.  
  1022. #ifdef TWO_WAY
  1023.  
  1024. int x1,y1,x2,y2,cp0,cp1;
  1025.  
  1026. void two_way_chat(char *s, char *rollover, int maxlen, int crend)
  1027. {
  1028.   char s2[100], temp1[50], side0[12] [80], side1[12] [80];
  1029.   int side, cnt, cnt2, cntr;
  1030.   int i,i1,done,cm,begx;
  1031.   char s1[255];
  1032.   unsigned char ch;
  1033.  
  1034.   cm=chatting;
  1035.   begx=wherex();
  1036.   if (rollover[0]!=0) {
  1037.     if (charbufferpointer) {
  1038.       strcpy(s1,rollover);
  1039.       strcat(s1,&charbuffer[charbufferpointer]);
  1040.       strcpy(&charbuffer[1],s1);
  1041.       charbufferpointer=1;
  1042.     } else {
  1043.       strcpy(&charbuffer[1],rollover);
  1044.       charbufferpointer=1;
  1045.     }
  1046.     rollover[0]=0;
  1047.   }
  1048.   done=0;
  1049.   side = 0;
  1050.   do {
  1051.     ch=getkey();
  1052.       if (lastcon)
  1053.         {
  1054.           if (wherey() == 11)
  1055.             {
  1056.               outstr("\x1b[12;1H");
  1057.               ansic(3);
  1058.                 for(cnt=0;cnt<=thisuser.screenchars;cnt++)
  1059.                     s2[cnt]=205;
  1060.           strcpy(temp1,"4 Two Way Chat 3");
  1061.           cnt=(((thisuser.screenchars-strlen(temp1)) /2));
  1062.           strncpy(&s2[cnt+1],temp1,(strlen(temp1)));
  1063.           s2[thisuser.screenchars]=0;
  1064.           outstr(s2);
  1065.           s2[0]=0;
  1066.           temp1[0]=0;
  1067.                 for(cntr=1;cntr<12;cntr++)
  1068.                   {
  1069.                     sprintf(s2,"\x1b[%d;%dH",cntr,1);
  1070.                     outstr(s2);
  1071.                       if ((cntr >=0) && (cntr <5))
  1072.                         {
  1073.                           ansic(1);
  1074.                           outstr(side0[cntr+6]);
  1075.                          }
  1076.                     outstr("\x1b[K");
  1077.                     s2[0]=0;
  1078.                   }
  1079.               sprintf(s2,"\x1b[%d;%dH",5,1);
  1080.               outstr(s2);
  1081.               s2[0]=0;
  1082.             }
  1083.           else
  1084.             if (wherey() > 11)
  1085.               {
  1086.                 x2=(wherex()+1);
  1087.                 y2=(wherey()+1);
  1088.                 sprintf(s2,"\x1b[%d;%dH",y1,x1);
  1089.                 outstr(s2);
  1090.                 s2[0]=0;
  1091.               }
  1092.           side = 0;
  1093.           ansic(1);
  1094.         }
  1095.       else
  1096.         {
  1097.           if (wherey() >= 23)
  1098.             {
  1099.               for(cntr=13;cntr<25;cntr++)
  1100.                 {
  1101.                   sprintf(s2,"\x1b[%d;%dH",cntr,1);
  1102.                   outstr(s2);
  1103.                     if ((cntr >= 13) && (cntr <17))
  1104.                       {
  1105.                         ansic(5);
  1106.                         outstr(side1[cntr-7]);
  1107.                       }
  1108.                   outstr("\x1b[K");
  1109.                   s2[0]=0;
  1110.                 }
  1111.               sprintf(s2,"\x1b[%d;%dH",17,1);
  1112.               outstr(s2);
  1113.               s2[0]=0;
  1114.             }
  1115.           else
  1116.             if ((wherey() < 12) && (side == 0))
  1117.               {
  1118.                 x1=(wherex()+1);
  1119.                 y1=(wherey()+1);
  1120.                 sprintf(s2,"\x1b[%d;%dH",y2,x2);
  1121.                 outstr(s2);
  1122.                 s2[0]=0;
  1123.               }
  1124.           side=1;
  1125.           ansic(5);
  1126.         }
  1127.     if (cm)
  1128.       if (chatting==0)
  1129.         ch=13;
  1130.     if ((ch>=32)) {
  1131.       if (side==0)
  1132.        {
  1133.          if ((wherex()<(thisuser.screenchars-1)) && (cp0<maxlen))
  1134.            {
  1135.              if (wherey() < 11)
  1136.                {
  1137.                  side0[wherey()][cp0++]=ch;
  1138.                  outchr(ch);
  1139.                }
  1140.              else
  1141.               {
  1142.               side0[wherey()][cp0++]=ch;
  1143.               side0[wherey()][cp0]=0;
  1144.               for(cntr=0;cntr<12;cntr++)
  1145.                 {
  1146.                   sprintf(s2,"\x1b[%d;%dH",cntr,1);
  1147.                   outstr(s2);
  1148.                   if ((cntr >=0) && (cntr <6))
  1149.                     {
  1150.                       ansic(1);
  1151.                       outstr(side0[cntr+6]);
  1152.                       y1=wherey()+1;
  1153.                       x1=wherex()+1;
  1154.                     }
  1155.                   outstr("\x1b[K");
  1156.                   s2[0]=0;
  1157.                 }
  1158.               sprintf(s2,"\x1b[%d;%dH",y1,x1);
  1159.               outstr(s2);
  1160.               s2[0]=0;
  1161.             }
  1162.         if (wherex()==(thisuser.screenchars-1))
  1163.             done=1;
  1164.       } else {
  1165.         if (wherex()>=(thisuser.screenchars-1))
  1166.             done=1;
  1167.       }
  1168.       }
  1169.       else
  1170.        {
  1171.          if ((wherex()<(thisuser.screenchars-1)) && (cp1<maxlen) )
  1172.            {
  1173.               if (wherey() < 23)
  1174.                 {
  1175.                   side1[wherey()-13][cp1++]=ch;
  1176.                   outchr(ch);
  1177.                 }
  1178.              else
  1179.               {
  1180.                 side1[wherey()-13][cp1++]=ch;
  1181.                 side1[wherey()-13][cp1]=0;
  1182.                   for(cntr=13;cntr<25;cntr++)
  1183.                     {
  1184.                       sprintf(s2,"\x1b[%d;%dH",cntr,1);
  1185.                       outstr(s2);
  1186.                         if ((cntr >=13) && (cntr <18))
  1187.                           {
  1188.                             ansic(5);
  1189.                             outstr(side1[cntr-7]);
  1190.                             y2=wherey()+1;
  1191.                             x2=wherex()+1;
  1192.                           }
  1193.                        outstr("\x1b[K");
  1194.                        s2[0]=0;
  1195.                      }
  1196.               sprintf(s2,"\x1b[%d;%dH",y2,x2);
  1197.               outstr(s2);
  1198.               s2[0]=0;
  1199.             }
  1200.         if (wherex()==(thisuser.screenchars-1))
  1201.             done=1;
  1202.       } else {
  1203.         if (wherex()>=(thisuser.screenchars-1))
  1204.             done=1;
  1205.       }
  1206.       }
  1207.     } else
  1208.         switch(ch) {
  1209.       case 7:
  1210.         if ((chatting) && (outcom))
  1211.           outcomch(7);
  1212.         break;
  1213.           case 13: /* C/R */
  1214.               if (side == 0)
  1215.                 side0[wherey()][cp0]=0;
  1216.               else
  1217.                 side1[wherey()-13][cp1]=0;
  1218.             done=1;
  1219.             break;
  1220.           case 8:  /* Backspace */
  1221.             if (side==0)
  1222.               {
  1223.                 if (cp0)
  1224.                   {
  1225.                     if (side0[wherey()][cp0-2]==3)
  1226.                       {
  1227.                         cp0-=2;
  1228.                         ansic(0);
  1229.                       }
  1230.                     else
  1231.                       if (side0[wherey()][cp0-1]==8)
  1232.                         {
  1233.                           cp0--;
  1234.                           outchr(32);
  1235.                         }
  1236.                       else
  1237.                         {
  1238.                           cp0--;
  1239.                           backspace();
  1240.                         }
  1241.                   }
  1242.               }
  1243.             else
  1244.               if (cp1)
  1245.                 {
  1246.                   if (side1[wherey()-13][cp1-2]==3)
  1247.                     {
  1248.                       cp1-=2;
  1249.                       ansic(0);
  1250.                     }
  1251.                   else
  1252.                     if (side1[wherey()-13][cp1-1]==8)
  1253.                       {
  1254.                         cp1--;
  1255.                         outchr(32);
  1256.                       }
  1257.                     else
  1258.                       {
  1259.                         cp1--;
  1260.                         backspace();
  1261.                       }
  1262.                 }
  1263.             break;
  1264.           case 24: /* Ctrl-X */
  1265.             while (wherex()>begx) {
  1266.               backspace();
  1267.                 if (side==0)
  1268.                   cp0=0;
  1269.                 else
  1270.                   cp1=0;
  1271.             }
  1272.             ansic(0);
  1273.             break;
  1274.           case 23: /* Ctrl-W */
  1275.             if (side==0)
  1276.               {
  1277.               if (cp0) {
  1278.               do {
  1279.                 if (side0[wherey()][cp0-2]==3) {
  1280.                   cp0-=2;
  1281.                   ansic(0);
  1282.                 } else
  1283.                   if (side0[wherey()][cp0-1]==8) {
  1284.                     cp0--;
  1285.                     outchr(32);
  1286.                   } else {
  1287.                     cp0--;
  1288.                     backspace();
  1289.                   }
  1290.               } while ((cp0) && (side0[wherey()][cp0-1]!=32) &&
  1291.                        (side0[wherey()][cp0-1]!=8) &&
  1292.                        (side0[wherey()][cp0-2]!=3));
  1293.               }
  1294.               }
  1295.             else
  1296.               {
  1297.               if (cp1) {
  1298.               do {
  1299.                 if (side1[wherey()-13][cp1-2]==3) {
  1300.                   cp1-=2;
  1301.                   ansic(0);
  1302.                 } else
  1303.                   if (side1[wherey()-13][cp1-1]==8) {
  1304.                     cp1--;
  1305.                     outchr(32);
  1306.                   } else {
  1307.                     cp1--;
  1308.                     backspace();
  1309.                   }
  1310.               } while ((cp1) && (side1[wherey()-13][cp1-1]!=32) &&
  1311.                        (side1[wherey()-13][cp1-1]!=8) &&
  1312.                        (side1[wherey()-13][cp1-2]));
  1313.               }
  1314.             }
  1315.             break;
  1316.           case 14: /* Ctrl-N */
  1317.                 if (side == 0)
  1318.                   {
  1319.                     if ((wherex()) && (cp0<maxlen))
  1320.                       {
  1321.                         outchr(8);
  1322.                         side0[wherey()][cp0++]=8;
  1323.                       }
  1324.                   }
  1325.                 else
  1326.                   if ((wherex()) && (cp1<maxlen))
  1327.                     {
  1328.                       outchr(8);
  1329.                       side1[wherey()-13][cp1++]=8;
  1330.                     }
  1331.         break;
  1332.       case 16: /* Ctrl-P */
  1333.         if (side==0)
  1334.         {
  1335.           if (cp0<maxlen-1)
  1336.           {
  1337.         ch=getkey();
  1338.         if ((ch>='0') && (ch<='9'))
  1339.         {
  1340.           side0[wherey()][cp0++]=3;
  1341.           side0[wherey()][cp0++]=ch;
  1342.           ansic(ch-'0');
  1343.         }
  1344.         else if ((ch>='A') && (ch<='F'))
  1345.         {
  1346.           side0[wherey()][cp0++]=3;
  1347.           side0[wherey()][cp0++]=ch;
  1348.           ansic(ch-'A'+10);
  1349.         }
  1350.         else if ((ch>='a') && (ch<='f'))
  1351.         {
  1352.           side0[wherey()][cp0++]=3;
  1353.           side0[wherey()][cp0++]=ch;
  1354.           ansic(ch-'a'+10);
  1355.         }
  1356.           }
  1357.         }
  1358.         else
  1359.         {
  1360.           if (cp1<maxlen-1)
  1361.           {
  1362.         ch=getkey();
  1363.         if ((ch>='0') && (ch<='9'))
  1364.         {
  1365.           side1[wherey()-13][cp1++]=3;
  1366.           side1[wherey()-13][cp1++]=ch;
  1367.           ansic(ch-'0');
  1368.         }
  1369.         else if ((ch>='A') && (ch<='F'))
  1370.         {
  1371.           side1[wherey()-13][cp1++]=3;
  1372.           side1[wherey()-13][cp1++]=ch;
  1373.           ansic(ch-'A'+10);
  1374.         }
  1375.         else if ((ch>='a') && (ch<='f'))
  1376.         {
  1377.           side1[wherey()-13][cp1++]=3;
  1378.           side1[wherey()-13][cp1++]=ch;
  1379.           ansic(ch-'a'+10);
  1380.         }
  1381.           }
  1382.         }
  1383.         break;
  1384.       case 9:  /* Tab */
  1385.         if (side==0)
  1386.               {
  1387.                 i=5-(cp0 % 5);
  1388.                   if (((cp0+i)<maxlen) && ((wherex()+i)<thisuser.screenchars))
  1389.                     {
  1390.                       i=5-((wherex()+1) % 5);
  1391.                         for (i1=0; i1<i; i1++)
  1392.                           {
  1393.                             side0[wherey()][cp0++]=32;
  1394.                             outchr(32);
  1395.                           }
  1396.                     }
  1397.               }
  1398.             else
  1399.               {
  1400.                 i=5-(cp1 % 5);
  1401.                   if (((cp1+i)<maxlen) && ((wherex()+i)<thisuser.screenchars))
  1402.                     {
  1403.                       i=5-((wherex()+1) % 5);
  1404.                         for (i1=0; i1<i; i1++)
  1405.                           {
  1406.                             side1[wherey()-13][cp1++]=32;
  1407.                             outchr(32);
  1408.                           }
  1409.                     }
  1410.               }
  1411.             break;
  1412.         }
  1413.   } while ((done==0) && (hangup==0));
  1414.   if (ch!=13)
  1415.   {
  1416.     if (side==0)
  1417.       {
  1418.         i=cp0-1;
  1419.           while ((i>0) && (side0[wherey()][i]!=32) &&
  1420.                  (side0[wherey()][i]!=8) || (side0[wherey()][i-1]==3))
  1421.             i--;
  1422.               if ((i>(wherex()/2)) && (i!=(cp0-1)))
  1423.                 {
  1424.                   i1=cp0-i-1;
  1425.                     for (i=0; i<i1; i++)
  1426.                       outchr(8);
  1427.                     for (i=0; i<i1; i++)
  1428.                       outchr(32);
  1429.                     for (i=0; i<i1; i++)
  1430.                       rollover[i]=side0[wherey()][cp0-i1+i];
  1431.                   rollover[i1]=0;
  1432.                   cp0 -= i1;
  1433.                 }
  1434.           side0[wherey()][cp0]=0;
  1435.       }
  1436.   else
  1437.       {
  1438.         i=cp1-1;
  1439.           while ((i>0) && (side1[wherey()-13][i]!=32) &&
  1440.                  (side1[wherey()-13][i]!=8) || (side1[wherey()-13][i-1]==3))
  1441.             i--;
  1442.               if ((i>(wherex()/2)) && (i!=(cp1-1)))
  1443.                 {
  1444.                   i1=cp1-i-1;
  1445.                     for (i=0; i<i1; i++)
  1446.                       outchr(8);
  1447.                     for (i=0; i<i1; i++)
  1448.                       outchr(32);
  1449.                     for (i=0; i<i1; i++)
  1450.                       rollover[i]=side1[wherey()-13][cp1-i1+i];
  1451.                   rollover[i1]=0;
  1452.                   cp1 -= i1;
  1453.                 }
  1454.           side1[wherey()-13][cp1]=0;
  1455.       }
  1456.   }
  1457.   if ((crend) && (wherey() != 11) && (wherey()<23))
  1458.     nl();
  1459.   if (side == 0)
  1460.     cp0=0;
  1461.   else
  1462.     cp1=0;
  1463.  s[0]=0;
  1464. }
  1465.  
  1466. #endif
  1467.  
  1468. void chat1(char *chatline, int two_way)
  1469. {
  1470.  
  1471.   int tempdata, cnt;
  1472.   char cl[81],xl[81],s[161],s1[161],atr[81],s2[81],cc;
  1473.   int i,i1,cf,oe;
  1474.   double tc;
  1475.  
  1476.   chatcall=0;
  1477.     chatting=1;
  1478.   tc=timer();
  1479.   cf=0;
  1480.  
  1481.   savel(cl,atr,xl,&cc);
  1482.   s1[0]=0;
  1483.  
  1484.   oe=echo;
  1485.   echo=1;
  1486.   nl();
  1487.   nl();
  1488.   tempdata=topdata;
  1489.   if (!okansi())
  1490.     two_way=0;
  1491.   if (modem_speed==300)
  1492.     two_way=0;
  1493.  
  1494. #ifndef TWO_WAY
  1495.   two_way=0;
  1496. #endif
  1497.  
  1498.   if (syscfg.sysconfig & sysconfig_two_color)
  1499.     two_color=1;
  1500. #ifdef TWO_WAY
  1501.   if (two_way) {
  1502.     clrscrb();
  1503.     cp0=0;
  1504.     cp1=0;
  1505.     if (defscreenbottom==24) {
  1506.       topdata=0;
  1507.       topscreen();
  1508.     }
  1509.     outstr("\x1b[2J");
  1510.     x2=1;
  1511.     y2=13;
  1512.     outstr("\x1b[1;1H");
  1513.     x1=wherex();
  1514.     y1=wherey();
  1515.     outstr("\x1b[12;1H");
  1516.     ansic(3);
  1517.     for(cnt=0;cnt<thisuser.screenchars;cnt++)
  1518.       outchr(205);
  1519.     strcpy(s,syscfg.sysopname);
  1520.     strcat(s," chatting with ");
  1521.     strcat(s,thisuser.name);
  1522.     cnt=((thisuser.screenchars-strlen(s))/2);
  1523.     sprintf(s1,"\x1b[12;%dH",cnt);
  1524.     outstr(s1);
  1525.     ansic(4);
  1526.     outstr(s);
  1527.     outstr("\x1b[1;1H");
  1528.     s[0]=0;
  1529.     s1[0]=0;
  1530.     s2[0]=0;
  1531.   }
  1532. #endif
  1533.   ansic(7);
  1534.   sprintf(s,"%s's here...",syscfg.sysopname);
  1535.   outstr(s);
  1536.   nl();
  1537.   nl();
  1538.   strcpy(s1,chatline);
  1539.   do {
  1540. #ifdef TWO_WAY
  1541.     if (two_way)
  1542.       two_way_chat(s,s1,160,1);
  1543.     else
  1544. #endif
  1545.       inli(s,s1,160,1);
  1546.     if ((chat_file) && (!two_way)) {
  1547.       if (cf==0) {
  1548.         if (!two_way)
  1549.           outs("-] Chat file opened.\r\n");
  1550.         sprintf(s2,"%sCHAT.TXT",syscfg.gfilesdir);
  1551.         cf=open(s2,O_RDWR | O_BINARY | O_CREAT, S_IREAD | S_IWRITE);
  1552.         lseek(cf,0L,SEEK_END);
  1553.         sprintf(s2,"\r\n\r\nChat file opened %s %s\r\n",date(),times());
  1554.         write(cf,(void *)s2,strlen(s2));
  1555.         strcpy(s2,"----------------------------------\r\n\r\n");
  1556.         write(cf,(void *)s2,strlen(s2));
  1557.       }
  1558.       strcat(s,"\r\n");
  1559.       write(cf,(void *)s,strlen(s));
  1560.     } else
  1561.       if (cf) {
  1562.     close(cf);
  1563.     cf=0;
  1564.         if (!two_way)
  1565.           outs("-] Chat file closed.\r\n");
  1566.       }
  1567.     if (hangup)
  1568.       chatting=0;
  1569.   } while (chatting);
  1570.   if (chat_file) {
  1571.     close(cf);
  1572.     chat_file=0;
  1573.   }
  1574.   ansic(0);
  1575.   two_color=0;
  1576.   if (two_way)
  1577.     outstr("\x1b[2J");
  1578.   nl();
  1579.   ansic(7);
  1580.   pl("Chat mode over...");
  1581.   nl();
  1582.   chatting=0;
  1583.   tc=timer()-tc;
  1584.   if (tc<0)
  1585.     tc += 86400.0;
  1586.   extratimecall += tc;
  1587.   topdata=tempdata;
  1588.   if (useron)
  1589.     topscreen();
  1590.   echo=oe;
  1591.   restorel(cl,atr,xl,&cc);
  1592. }
  1593.  
  1594. void set_autoval(int n)
  1595. {
  1596.   valrec v;
  1597.  
  1598.   v=syscfg.autoval[n];
  1599.   thisuser.sl=v.sl;
  1600.   thisuser.dsl=v.dsl;
  1601.   thisuser.ar=v.ar;
  1602.   thisuser.dar=v.dar;
  1603.   thisuser.restrict=v.restrict;
  1604.   reset_act_sl();
  1605.   changedsl();
  1606. }
  1607.