home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / FMD-02B.ZIP / WFC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  22.0 KB  |  795 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1993 by Wayne Bell
  5.  
  6. Distribution of the source code for WWIV, in any form, modified or unmodified,
  7. without PRIOR, WRITTEN APPROVAL by the author, is expressly prohibited.
  8. Distribution of compiled versions of WWIV is limited to copies compiled BY
  9. THE AUTHOR.  Distribution of any copies of WWIV not compiled by the author
  10. is expressly prohibited.
  11.  
  12.  
  13. *****************************************************************************/
  14.  
  15. #include "vars.h"
  16. #pragma hdrstop
  17.  
  18. #include <dir.h>
  19. #include <mem.h>
  20. #include <stdarg.h>
  21. #include "ini.h"
  22.  
  23. /*****************************************************************************/
  24.  
  25. void set_43(void)
  26. /* This function initialize the screen to 80x43 text mode */
  27. {
  28.   union REGS regs;
  29.  
  30.   textmode(C4350);
  31.  
  32.   regs.h.ah=0x12;
  33.   regs.h.bl=0x30;
  34.   regs.h.al=0x01;
  35.   int86(0x10, ®s, ®s);
  36.  
  37.   regs.h.ah=0x00;
  38.   regs.h.al=0x03;
  39.   int86(0x10, ®s, ®s);
  40.  
  41.   regs.h.ah=0x11;
  42.   regs.h.al=0x30;
  43.   regs.h.bh=0x03;
  44.   int86(0x10, ®s, ®s);
  45.  
  46.   regs.h.ah=0x11;
  47.   regs.h.al=0x12;
  48.   regs.h.bl=0x00;
  49.   int86(0x10, ®s, ®s);
  50. }
  51.  
  52. /*****************************************************************************/
  53.  
  54. void set_25(void)
  55. /* This function will reset the screen to 80x25 mode */
  56. {
  57.   union REGS regs;
  58.  
  59.   regs.h.ah=0x12;
  60.   regs.h.bl=0x30;
  61.   regs.h.al=0x02;
  62.   int86(0x10, ®s, ®s);
  63.  
  64.   regs.h.ah=0x00;
  65.   regs.h.al=0x03;
  66.   int86(0x10, ®s, ®s);
  67.  
  68.   regs.h.ah=0x11;
  69.   regs.h.al=0x30;
  70.   regs.h.bh=0x06;
  71.   int86(0x10, ®s, ®s);
  72.  
  73.   regs.h.ah=0x11;
  74.   regs.h.al=0x14;
  75.   regs.h.bl=0x00;
  76.   int86(0x10, ®s, ®s);
  77.  
  78.   textmode(C80);
  79. }
  80. /*****************************************************************************/
  81.  
  82. unsigned char *wfc_string(void)
  83. /* This is the screen displayed in the scrolling bar of the WFC screen */
  84. {
  85.   unsigned char s[512];
  86.   
  87.   sprintf(s, "System is waiting for caller "
  88.   "- You are on instance %d - %s %s (C) 1988-1995 Wayne Bell"
  89.   " - Modification by Nicolas LeBlanc & Martin Bourdages - "
  90.   "All rights reserved - Press ESC to quit - "
  91.   "F1 to start screen saver - F2 to poll statistics - ", instance,
  92.   wwiv_version,(syscfg.wwiv_reg_number)? "Registered": "Unregistered");
  93.   return(s);
  94. }
  95.  
  96. /*****************************************************************************/
  97.  
  98. unsigned char *wfc_menu [] =
  99. {
  100.   "Log On System",
  101.   "Show Network Info",
  102.   "Network Callout",
  103.   "Network Pending",
  104.   "Network Redial",
  105.   "Network DataFiles",
  106.   "Network Log",
  107.   "Activity Log",
  108.   "Yesterday's Log",
  109.   "Today's Log",
  110.   "Read All-Mail",
  111.   "Read Feedback",
  112.   "Send Email",
  113.   "Sub Editor",
  114.   "Dir Editor",
  115.   "Conference Editor",
  116.   "Instance Editor",
  117.   "G-Files Editor",
  118.   "Chain Editor",
  119.   "Vote Editor",
  120.   "Users Editor",
  121.   "Reset Files",
  122.   "Answer Phone",
  123.   "Shell to Dos",
  124.   "Terminal Program",
  125.   "Send Loaded Mail",
  126.   "System Status",
  127.   "Write A File",
  128.   "Show Environment",
  129.   "Help",
  130.   "Quit"
  131. };
  132.  
  133. /*****************************************************************************/
  134.  
  135. void wfc_prlocate(int x, int y, int c, char *fmt, ...)
  136. /* Output a fast string at a given position */
  137. {
  138.   va_list ap;
  139.   char s[512];
  140.  
  141.   va_start(ap, fmt);
  142.   vsprintf(s, fmt, ap);
  143.   va_end(ap);
  144.   gotoxy(x, y);
  145.   curatr=c;
  146.   outfast(stripcolors(s));
  147. }
  148.  
  149. /*****************************************************************************/
  150.  
  151. void display(int type, int pos)
  152. /* This function moves the cursor with the arrow keys */
  153. {
  154.   int i;
  155.   char s[81];
  156.   
  157.   switch (type)
  158.   {
  159.     case 0:
  160.       if (wfcinfo.flags & WFC_FLAGS_MENU_CENTERED)
  161.       {
  162.         i= strlen(wfc_menu[pos-1]);
  163.         sprintf(s, "%s%s", charstr((17-i)/2, 32), wfc_menu[pos-1]);
  164.         wfc_prlocate(3, pos+8, wfcinfo.wfc_high_color, " %-17.17s ", s);
  165.       } else {
  166.         wfc_prlocate(3, pos+8, wfcinfo.wfc_high_color, " %-17s ", wfc_menu[pos - 1]);
  167.       }
  168.     break;
  169.     case 1:
  170.       if (wfcinfo.flags & WFC_FLAGS_MENU_CENTERED)
  171.       {
  172.         i= strlen(wfc_menu[pos-1]);
  173.         sprintf(s, "%s%s", charstr((17-i)/2, 32), wfc_menu[pos-1]);
  174.         wfc_prlocate(3, pos+8, wfcinfo.wfc_low_color, " %-17.17s ", s);
  175.       } else {
  176.         wfc_prlocate(3, pos+8, wfcinfo.wfc_low_color, " %-17s ", wfc_menu[pos - 1]);
  177.       }
  178.     break;
  179.   }
  180. }
  181.  
  182. /*****************************************************************************/
  183.  
  184. void init_wfc(void)
  185. {
  186.   char *ss;
  187.  
  188.   wfcinfo.poll_time=10;
  189.   wfcinfo.scrolling_time=0.25;
  190.   wfcinfo.screen_saver_time=180;
  191.   if (sysinfo.screen_saver_time==0)
  192.     sysinfo.screen_saver_time=180;
  193.   wfcinfo.options=31;
  194.   wfcinfo.wfc_high_color=59;
  195.   wfcinfo.wfc_low_color=113;
  196.   wfcinfo.wfc_prt_color=126;
  197.   wfcinfo.wfc_net_color=15;
  198.   wfcinfo.wfc_bar_color=12;
  199.   wfcinfo.wfc_sbar_color=127;
  200.   wfcinfo.wfc_perc_color=15;
  201.   wfcinfo.screen=C80;
  202.   if (ini_init("WWIV.INI", "WFC", NULL)==0)
  203.   {
  204.     wfcinfo.flags &= ~WFC_FLAGS_EXIT_SAVER;
  205.     wfcinfo.flags |= WFC_FLAGS_SCREEN_SAVER;
  206.     wfcinfo.flags &= ~WFC_FLAGS_MENU_CENTERED;
  207.     wfcinfo.flags &= ~WFC_FLAGS_STARFIELD;
  208.     wfcinfo.flags &= ~WFC_FLAGS_SHOW_PERCENTAGE;
  209.     if ((ss=ini_get("EXIT_SAVER", -1, NULL))!=NULL)
  210.     {
  211.       if (ss[0]==*str_yes)
  212.         wfcinfo.flags |= WFC_FLAGS_EXIT_SAVER;
  213.     }
  214.     if ((ss=ini_get("SCREEN_SAVER", -1, NULL))!=NULL)
  215.     {
  216.       if (ss[0]==*str_yes)
  217.         wfcinfo.flags |= WFC_FLAGS_SCREEN_SAVER;
  218.     }
  219.     if ((ss=ini_get("STARFIELD", -1, NULL))!=NULL)
  220.     {
  221.       if (ss[0]==*str_yes)
  222.         wfcinfo.flags |= WFC_FLAGS_STARFIELD;
  223.     }
  224.     if ((ss=ini_get("SHOW_PERCENTAGE", -1, NULL))!=NULL)
  225.     {
  226.       if (ss[0]==*str_yes)
  227.         wfcinfo.flags |= WFC_FLAGS_SHOW_PERCENTAGE;
  228.     }
  229.     if ((ss=ini_get("EXIT_MENU_CENTERED", -1, NULL))!=NULL)
  230.     {
  231.       if (ss[0]==*str_yes)
  232.         wfcinfo.flags |= WFC_FLAGS_MENU_CENTERED;
  233.     }
  234.     if ((ss=ini_get("SCREEN", -1, NULL))!=NULL)
  235.     {
  236.        if (strcmpi(ss, "C4350")==NULL)
  237.          wfcinfo.screen=C4350;
  238.        else
  239.          wfcinfo.screen=C80;
  240.     }
  241.     if ((ss=ini_get("POLLING_TIME", -1, NULL))!=NULL)
  242.     {
  243.       wfcinfo.poll_time=atoi(ss);
  244.     }
  245.     if ((ss=ini_get("SCROLL_TIME", -1, NULL))!=NULL)
  246.     {
  247.       wfcinfo.scrolling_time=atof(ss);
  248.     }
  249.     if ((ss=ini_get("OPTIONS", -1, NULL))!=NULL)
  250.     {
  251.       wfcinfo.options=atoi(ss);
  252.     }
  253.     if ((ss=ini_get("WFC_PRT_COLOR", -1, NULL))!=NULL)
  254.     {
  255.       wfcinfo.wfc_prt_color=atoi(ss);
  256.     }
  257.     if ((ss=ini_get("WFC_PERC_COLOR", -1, NULL))!=NULL)
  258.     {
  259.       wfcinfo.wfc_perc_color=atoi(ss);
  260.     }
  261.     if ((ss=ini_get("WFC_HIGH_COLOR", -1, NULL))!=NULL)
  262.     {
  263.       wfcinfo.wfc_high_color=atoi(ss);
  264.     }
  265.     if ((ss=ini_get("WFC_LOW_COLOR", -1, NULL))!=NULL)
  266.     {
  267.       wfcinfo.wfc_low_color=atoi(ss);
  268.     }
  269.     if ((ss=ini_get("WFC_NET_COLOR", -1, NULL))!=NULL)
  270.     {
  271.       wfcinfo.wfc_net_color=atoi(ss);
  272.     }
  273.     if ((ss=ini_get("WFC_BAR_COLOR", -1, NULL))!=NULL)
  274.     {
  275.       wfcinfo.wfc_bar_color=atoi(ss);
  276.     }
  277.     if ((ss=ini_get("WFC_SBAR_COLOR", -1, NULL))!=NULL)
  278.     {
  279.       wfcinfo.wfc_sbar_color=atoi(ss);
  280.     }
  281.     ini_done();
  282.   }
  283. }
  284. /*****************************************************************************/
  285.  
  286. void wfc_screen(void)
  287. /* This functions displays the waiting for caller screen */
  288. {
  289.   char s[161], s2[81], s3[81];
  290.   int i1, dv, win, f, os2warp_ver_maj, os2warp_ver_min;
  291.   float i;
  292.   instancerec ir;
  293.   userrec ur;
  294.   struct dfree free;
  295.   long avail;
  296.  
  297.   set_43();
  298.   sprintf(s2, "%sWFC.DAT", syscfg.datadir);
  299.   if (exist(s2)) 
  300.   {
  301.     f= sh_open1(s2, O_RDONLY | O_BINARY);
  302.     sh_read(f, scrn, (2*80*42));
  303.     wfcinfo.wfc_scr= 1;
  304.     sh_close(f);
  305.   } else {
  306.     set_25();
  307.     npr("\r\n\7WFC.DAT NOT FOUND!\r\n");
  308.     npr("Please copy this file to your data directory.\r\n");
  309.     end_bbs(noklevel);
  310.   }
  311.   init_wfc();
  312.   for (i=0; i<wfcinfo.options; i++)
  313.     display(1, i+1);
  314.   write_inst(INST_LOC_WFC, 0, INST_FLAGS_NONE);
  315.   wfc_prlocate(43, 8, wfcinfo.wfc_prt_color, times());
  316.   wfc_prlocate(46, 24, wfcinfo.wfc_prt_color, ctim(timer() - wfcinfo.cur_time));
  317.   if (sysop2()) 
  318.   {
  319.     wfc_prlocate(46, 20, wfcinfo.wfc_prt_color, "Available    ");
  320.   } else {
  321.     wfc_prlocate(46, 20, wfcinfo.wfc_prt_color, "Not Available");
  322.   }
  323.   _setcursortype(_NOCURSOR);
  324.   i= (status.activetoday*49/1440.0);
  325.   sprintf(s, "%s", charstr((int)i, '█'));
  326.   i= i - (int)i;
  327.   if (i>0)
  328.     strcat(s, i>=0.5? "█": "▌");
  329.   if (i) {
  330.     if (i<100)
  331.       sprintf(s3,"%4.1f%%",i);
  332.     else
  333.       sprintf(s3,"99.9%%");
  334.   } else {
  335.     sprintf(s3," 0.0%%");
  336.   }
  337.   wfc_prlocate(28, 40, wfcinfo.wfc_bar_color, s);
  338.   if (wfcinfo.flags & WFC_FLAGS_SHOW_PERCENTAGE)
  339.     wfc_prlocate(49, 40, wfcinfo.wfc_perc_color, s3);
  340.   wfc_prlocate(43, 9, wfcinfo.wfc_prt_color, status.date1);
  341.   wfc_prlocate(43, 10, wfcinfo.wfc_prt_color, "%d", fwaiting);
  342.   wfc_prlocate(43, 11, wfcinfo.wfc_prt_color, "%hu", status.fbacktoday);
  343.   wfc_prlocate(43, 12, wfcinfo.wfc_prt_color, "%hu", status.emailtoday);
  344.   wfc_prlocate(43, 13, wfcinfo.wfc_prt_color, "%hu", status.msgposttoday);
  345.   i1= getdisk();
  346.   getdfree(i1 + 1, &free);
  347.   avail= (long) free.df_avail * (long) free.df_bsec * (long) free.df_sclus;
  348.   wfc_prlocate(43, 14, wfcinfo.wfc_prt_color, "%lu Megs", avail / 1000000);
  349.   wfc_prlocate(43, 15, wfcinfo.wfc_prt_color, "%hu", status.localposts);
  350.   get_inst_info(instance, &ir);
  351.   if ((ir.user<syscfg.maxusers) && (ir.user>0)) 
  352.   {
  353.     read_user(ir.user, &ur);
  354.     wfc_prlocate(46, 23, wfcinfo.wfc_prt_color, "%-30.30s", nam(&ur, ir.user));
  355.   } else
  356.     wfc_prlocate(46, 23, wfcinfo.wfc_prt_color, "%-30.30s", get_string(1410));
  357.   wfc_prlocate(70, 8, wfcinfo.wfc_prt_color, "%hu", status.users);
  358.   wfc_prlocate(70, 9, wfcinfo.wfc_prt_color, "%hu", status.callstoday);
  359.   wfc_prlocate(70, 10, wfcinfo.wfc_prt_color, "%ld", status.callernum1);
  360.   wfc_prlocate(70, 13, wfcinfo.wfc_prt_color, "%hu", status.activetoday);
  361.   wfc_prlocate(70, 14, wfcinfo.wfc_prt_color, "%hu", status.uptoday);
  362. #ifdef __OS2__
  363.   wfc_prlocate(70, 15, wfcinfo.wfc_prt_color, "N/A");
  364. #else
  365.   wfc_prlocate(70, 15, wfcinfo.wfc_prt_color, "%ldk", bytes_to_k(memavail()));
  366. #endif
  367.   if (multitasker)
  368.     switch (multitasker) 
  369.     {
  370.       case 1 :
  371.         dv= get_dv_version();
  372.         wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "DESQView %d.%02d", dv / 256, dv % 256);
  373.       break;
  374.       case 2 :
  375.         win= get_win_version();
  376.         wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "Windows %s%d.%02d",
  377.                 (win%256==4)?"95 ":"", win % 256, win / 256);
  378.       break;
  379.       case 3 :
  380.         win= get_win_version();
  381.         dv= get_dv_version();
  382.         wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "Win %d.%02d and DV %d.%02d",
  383.           win % 256, win / 256, dv / 256, dv % 256);
  384.       break;
  385.       case 4 :
  386.        os2warp_ver_maj=_osmajor/10;
  387.        os2warp_ver_min=_osminor;
  388.        if ((os2warp_ver_maj>=2) && (os2warp_ver_min>=30))
  389.        {
  390.          if (os2warp_ver_min==30)
  391.            wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "OS/2 Warp v%d", os2warp_ver_min/10);
  392.          else
  393.            wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "OS/2 v%d.x", os2warp_ver_min/10);
  394.        } else {
  395.          wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "OS/2 %d.%2.2d", _osmajor / 10, _osminor);
  396.        }
  397.       break;
  398.       default:
  399.         wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, get_string(1170));
  400.     } else
  401.       wfc_prlocate(46, 19, wfcinfo.wfc_prt_color, "None");
  402.   wfc_prlocate(46, 21, wfcinfo.wfc_prt_color, "%.30s", syscfgovr.primaryport?modem_i->name:"Local Node");
  403.   wfc_prlocate(46, 18, wfcinfo.wfc_prt_color, "%5.5s", ctim(syscfg.executetime*60));
  404.   wfc_prlocate(70, 11, wfcinfo.wfc_prt_color, "%u", status.days);
  405.   if (status.days<1)
  406.     status.days=1;
  407.   wfc_prlocate(70, 12, wfcinfo.wfc_prt_color, "%.2f", (status.callernum1 / (status.days*1.0)));
  408.   alternate_pending();
  409.   alternate_instance();
  410.   reset_colors();
  411. }
  412.  
  413. /*****************************************************************************/
  414.  
  415. void alternate_pending(void)
  416. /* This function is doing the alternating network pending */
  417. {
  418.   char s[61][6];
  419.   int net_pendingos[61], ipos[61], nn, i, i1, i2, i3, y, netnum= 0;
  420.   int sn,num_ncn, amount, num_call_sys;
  421.   net_call_out_rec *con;
  422.   net_contact_rec *ncn;
  423.   net_system_list_rec *csne;
  424.   
  425.   if ((net_networks[0].sysnum==0) && (net_num_max==1)) {
  426.     wfc_prlocate(43, 32, wfcinfo.wfc_net_color, "No network detected");
  427.     return;
  428.   }
  429.   for (nn= 0; nn<net_num_max; nn++)
  430.   {
  431.     set_net_num(nn);
  432.     read_call_out_list();
  433.     read_contacts();
  434.     con= net_networks[net_num].con;
  435.     ncn= net_networks[net_num].ncn;
  436.     num_call_sys= net_networks[net_num].num_con;
  437.     num_ncn= net_networks[net_num].num_ncn;
  438.     for (i1= 0; i1<num_call_sys; i1++)
  439.     {
  440.       i2= - 1;
  441.       for (i= 0; i<num_ncn; i++)
  442.       {
  443.         if (con[i1].sysnum==ncn[i].systemnumber)
  444.         {
  445.           i2= i;
  446.           break;
  447.         }
  448.       }
  449.       ipos[netnum]= i2;
  450.       net_pendingos[netnum]= nn;
  451.       sprintf(s[netnum++], "%hu", ncn[i2].systemnumber);
  452.     }
  453.     if (netnum>60)
  454.       break;
  455.   }
  456.   if (netnum<4)
  457.     amount=netnum;
  458.   else
  459.     amount=4;
  460.   for (i3=0; i3<amount; i3++) {
  461.     if (wfcinfo.net_pending+i3<netnum)
  462.       y=wfcinfo.net_pending+i3;
  463.     if (wfcinfo.net_pending+i3==netnum)
  464.       y=0;
  465.     if (wfcinfo.net_pending+i3==netnum+1)
  466.       y=1;
  467.     if (wfcinfo.net_pending+i3==netnum+2)
  468.       y=2;
  469.     sn= atoi(s[y]);
  470.     set_net_num(net_pendingos[y]);
  471.     read_call_out_list();
  472.     read_contacts();
  473.     ncn= net_networks[net_num].ncn;
  474.     csne= next_system(sn);
  475.     wfc_prlocate(28, 31+i3, wfcinfo.wfc_net_color, "@%-5s %-25.25s %-10.10s %4ldk",
  476.       s[y], csne->name, net_name,
  477.       bytes_to_k(ncn[ipos[y]].bytes_waiting));
  478.   }
  479.   wfcinfo.net_pending++;
  480.   if (wfcinfo.net_pending>netnum-1)
  481.     wfcinfo.net_pending= 0;
  482. }
  483.  
  484. /*****************************************************************************/
  485.  
  486. void alternate_instance(void)
  487. /* This function is the alternating instance display */
  488. {
  489.   char s[161],s2[81];
  490.   int i, i1= 0, ch;
  491.   instancerec ir;
  492.   userrec ur;
  493.   
  494.   s[0]= 0;
  495.   get_inst_info(wfcinfo.alt_instance, &ir);
  496.   read_user(ir.user, &ur);
  497.   if (ir.flags & INST_FLAGS_ONLINE)
  498.     wfc_prlocate(46, 26, wfcinfo.wfc_prt_color, "%-25.25s (%d)", nam(&ur, ir.user), wfcinfo.alt_instance);
  499.   else
  500.     wfc_prlocate(46, 26, wfcinfo.wfc_prt_color, "Nobody On Instance %-10d", wfcinfo.alt_instance);
  501.   make_inst_str(wfcinfo.alt_instance, s2);
  502.   for (i=strcspn(s2, ":")+4; ((i<strlen(s2)) && (ch!=13)); i++)
  503.   {
  504.     ch=s2[i];
  505.     if (ch>31)
  506.       s[i1++]=ch;
  507.   }
  508.   s[i1]=0;
  509.   wfc_prlocate(46, 27, wfcinfo.wfc_prt_color, "%-30.25s", s);
  510.   wfcinfo.alt_instance++;
  511.   if (wfcinfo.alt_instance>num_instances())
  512.     wfcinfo.alt_instance= 1;
  513. }
  514.  
  515. /*****************************************************************************/
  516.  
  517. void wfcprt(char *fmt, ...)
  518. /* Print in the bar up in the screen if wfc screen is present */
  519. {
  520.   int i1;
  521.   va_list ap;
  522.   char s[512];
  523.   
  524.   va_start(ap, fmt);
  525.   vsprintf(s, fmt, ap);
  526.   va_end(ap);
  527.  
  528.   if (sysinfo.flags & OP_FLAGS_WFC_SCREEN) 
  529.   {
  530.     if (wfcinfo.wfc_scr==1)
  531.     {
  532.       i1= strlen(stripcolors(s));
  533.       wfc_prlocate(2, 3, wfcinfo.wfc_sbar_color, charstr(76, ' '));
  534.       wfc_prlocate(2+((76-i1)/2), 3, wfcinfo.wfc_sbar_color, s);
  535.     } else {
  536.       outfast(s);
  537.     }
  538.   } else {
  539.     outfast(s);
  540.   }
  541. }
  542.  
  543. /*****************************************************************************/
  544.  
  545. void reset_screen(int mode)
  546. /* Reset the screen to 80x25 or SCREEN defined mode for an operation */
  547. {
  548.   union REGS regs;
  549.  
  550.   if (wfcinfo.wfc_scr==2)
  551.   {
  552.     regs.h.al=0x03;
  553.     regs.h.ah=0x00;
  554.     int86(0x10, ®s, ®s);
  555.   }
  556.   clrscr();
  557.   set_25();
  558.   if (mode)
  559.   {
  560.     textmode(wfcinfo.screen);
  561.     defscreenbottom=(int) peekb(0x0000,0x0484);
  562.     if (defscreenbottom<24)
  563.       defscreenbottom=24;
  564.     if (defscreenbottom>63)
  565.       defscreenbottom=24;
  566.     if ((defscreenbottom!=42) && (defscreenbottom!=49))
  567.       defscreenbottom=24;
  568.     screenbottom=defscreenbottom;
  569.   }
  570.   wfcinfo.wfc_scr= 0;
  571.   reset_colors();
  572. }
  573.  
  574. /*****************************************************************************/
  575.  
  576. long memavail(void)
  577. /* This will return the amount of memory free */
  578. {
  579.    union REGS regs;
  580.  
  581.    regs.h.ah = 0x48;
  582.    regs.x.bx = 0xFFFF;
  583.    int86(0x21,®s,®s);
  584.    return((long)regs.x.bx * 16L);
  585. }
  586.  
  587. /*****************************************************************************/
  588. /*                         Screen Saver Routines                             */
  589. /*****************************************************************************/
  590.  
  591. unsigned int star[101][3] =
  592. {
  593.   214,45,0,  13,177,0,  194,167,0, 78,70,0,   179,182,0,
  594.   122,154,0, 285,142,0, 38,57,0,   106,145,0, 152,38,0,  87,6,0,
  595.   291,164,0, 304,115,0, 217,136,0, 120,157,0, 174,136,0, 106,104,0,
  596.   130,105,0, 93,159,0,  314,31,0,  201,55,0,  33,59,0,   290,1,0,
  597.   234,189,0, 210,64,0,  98,197,0,  133,87,0,  153,121,0, 141,132,0,
  598.   274,161,0, 286,146,0, 272,131,0, 277,38,0,  66,115,0,  18,69,0,
  599.   99,58,0,   158,138,0, 283,150,0, 30,71,0,   48,141,0,  145,90,0,
  600.   18,18,0,   212,176,0, 209,17,0,  165,101,0, 76,182,0,  314,33,0,
  601.   106,36,0,  73,106,0,  34,0,0,    26,48,0,   106,104,0, 77,62,0,
  602.   147,31,0,  42,48,0,   297,50,0,  221,173,0, 90,62,0,   304,66,0,
  603.   58,122,0,  248,44,0,  303,68,0,  187,57,0,  216,4,0,   128,150,0,
  604.   176,88,0,  20,130,0,  138,155,0, 314,37,0,  109,34,0,  74,110,0,
  605.   286,85,0,  115,45,0,  100,20,0,  239,30,0,  27,138,0,  271,162,0,
  606.   284,17,0,  58,136,0,  273,18,0,  125,192,0, 244,34,0,  77,27,0,
  607.   89,30,0,   276,56,0,  264,24,0,  44,117,0,  51,45,0,   158,20,0,
  608.   86,114,0,  18,22,0,   215,196,0, 127,38,0,  240,160,0, 248,68,0,
  609.   38,95,0,   78,34,0,   239,28,0,  121,134,0, 262,176,0, 20,93,0
  610. };
  611.  
  612. void pixel(int x, int y, int attr)
  613. {
  614.   union REGS regs;
  615.  
  616.   regs.h.ah=12;
  617.   regs.h.al=attr;
  618.   regs.x.cx=x;
  619.   regs.x.dx=y;
  620.   int86(0x10, ®s, ®s);
  621. }
  622.  
  623. void display_stars(void)
  624. {
  625.   int starc=0, c1, ypost, xpost;
  626.  
  627.   for(; starc<101; starc++)
  628.   {
  629.     xpost=star[starc][2];
  630.     ypost=star[starc][1];
  631.     pixel(xpost, ypost, 0);
  632.     if (starc>0)
  633.       star[starc][0]+=1, c1=22;
  634.     if (starc>40)
  635.       star[starc][0]+=2, c1=24;
  636.     if (starc>70)
  637.       star[starc][0]+=3, c1=27;
  638.     if (starc>90)
  639.       star[starc][0]+=4, c1=30;
  640.     if (star[starc][0] > 320)
  641.       star[starc][0]-=320;
  642.     xpost=star[starc][0];
  643.     ypost=star[starc][1];
  644.     pixel(xpost, ypost, c1);
  645.     star[starc][2]=xpost;
  646.   }
  647. }
  648.  
  649. /*****************************************************************************/
  650.  
  651. unsigned char InKey(void)
  652. /* This function is the same than inkey(), but it is done to work with the
  653.  * GetAllKeys() function.
  654.  */
  655. {
  656.   unsigned char ch=0;
  657.  
  658.   if (x_only)
  659.     return(0);
  660.  
  661.   if (charbufferpointer) {
  662.     if (!charbuffer[charbufferpointer]) {
  663.       charbufferpointer = charbuffer[0] = 0;
  664.     } else {
  665.       if ((charbuffer[charbufferpointer])==3)
  666.         charbuffer[charbufferpointer]=16;
  667.       return(charbuffer[charbufferpointer++]);
  668.     }
  669.   }
  670.   if (kbhitb() || (in_extern == 2)) {
  671.     ch = getchd1();
  672.     lastcon = 1;
  673.     if (!(g_flags & g_flag_allow_extended)) {
  674.       if (!ch) {
  675.         if (in_extern)
  676.           in_extern = 2;
  677.         else {
  678.           ch = getchd1();
  679.           skey(ch);
  680.         if ((ch!=72) // UP
  681.             && (ch!=75) // LEFT
  682.             && (ch!=80) // DOWN
  683.             && (ch!=77) // RIGHT
  684.             && (ch!=71) // HOME
  685.             && (ch!=79)) // END
  686.           ch=0;
  687.         }
  688.       } else if (in_extern)
  689.         in_extern = 1;
  690.     }
  691.     timelastchar1=timer1();
  692.   } else if (incom && comhit()) {
  693.     ch = (get1c() & andwith);
  694.     lastcon = 0;
  695.   }
  696.   if (!(g_flags & g_flag_allow_extended))
  697.     skey1(&ch);
  698.  
  699.   return(ch);
  700. }
  701.  
  702. unsigned char GetAllKeys(void)
  703. /* This function is the same that getkey(), but it allows you to use the
  704.  * arrow keys (remote and locally) and the home/end keys. You can easily
  705.  * add any other extended keys as long as you know its ANSI and Scan code
  706.  * for this key.
  707.  */
  708. {
  709.   unsigned char ch;
  710.   int beepyet,done=0,pass=0;
  711.   long dd,tv,tv1;
  712.  
  713.   beepyet = 0;
  714.   timelastchar1=timer1();
  715.  
  716.   if (so())
  717.     tv=10920L;
  718.   else
  719.     tv=3276L;
  720.  
  721.   tv1=tv/2;
  722.  
  723.   if (!tagging || (thisuser.sysstatus & sysstatus_no_tag))
  724.     lines_listed = 0;
  725.   do
  726.   {
  727.     switch (pass)
  728.     {
  729.       case 0: if ((ch>31) && (ch<123)) done=1; break;
  730.       case 1:
  731.         if ((incom) && (ch!=255))
  732.           done=1;
  733.         if ((incom) && (ch!='\x1b'))
  734.         {
  735.           switch (ch)
  736.           {
  737.             case 71: return(71); // HOME
  738.             case 72: return(72); // UP
  739.             case 75: return(75); // LEFT
  740.             case 77: return(77); // RIGHT
  741.             case 79: return(79); // END
  742.             case 80: return(80); // DOWN
  743.             default: return(27); // ESC
  744.           }
  745.         }
  746.       break;
  747.       case 2:
  748.         switch(ch)
  749.         {
  750.           case 'A': return(72); // UP
  751.           case 'B': return(80); // DOWN
  752.           case 'C': return(77); // RIGHT
  753.           case 'D': return(75); // LEFT
  754.           case 'K': return(79); // END
  755.           case 'H': return(71); // HOME
  756.           default:  return(27); // ESC
  757.         }
  758.       default: done=1;
  759.     }
  760.     do
  761.     {
  762.       while (empty() && !hangup)
  763.       {
  764.         giveup_timeslice();
  765.         dd = timer1();
  766.         if ((dd<timelastchar1) && ((dd+1000)>timelastchar1))
  767.           timelastchar1=dd;
  768.         if (labs(dd - timelastchar1) > 65536L)
  769.           timelastchar1 -= 1572480L;
  770.         if (((dd - timelastchar1) > tv1) && (!beepyet))
  771.         {
  772.           beepyet = 1;
  773.           outchr(7);
  774.         }
  775.         if (labs(dd - timelastchar1) > tv)
  776.         {
  777.           nl();
  778.           if (!in_extern)
  779.             outstr(get_string(924));
  780.           nl();
  781.           hangup = 1;
  782.         }
  783.         checkhangup();
  784.       }
  785.       ch = InKey();
  786.     } while (!ch && !in_extern && !hangup);
  787.     pass++;
  788.   } while (!done && !hangup);
  789.   if (checkit && (ch > 127)) {
  790.     checkit = 0;
  791.     ch = ch & (andwith = 0x7F);
  792.   }
  793.   return(upcase(ch));
  794. }
  795.