home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / W / WWIVSOR.ZIP / BBS.C < prev    next >
C/C++ Source or Header  |  1995-05-11  |  23KB  |  891 lines

  1. /*****************************************************************************
  2.  
  3.                 WWIV Version 4
  4.                     Copyright (C) 1988-1995 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. #pragma hdrstop
  16.  
  17. #define _DEFINE_GLOBALS_
  18. #include "vars.h"
  19. #include "subxtr.h"
  20. #include <math.h>
  21.  
  22. #ifdef __OS2__
  23. #include <process.h>
  24. #else
  25. unsigned _stklen=15360;
  26. #endif
  27.  
  28. int unx;
  29.  
  30. extern char cid_num[], cid_name[];
  31.  
  32. /****************************************************************************/
  33.  
  34. void getcaller(void)
  35. {
  36.   char s[81],ch,lokb,*ss;
  37.   int any,fast=0,i;
  38.   double d;
  39.   userrec tu;
  40.   c_sub=c_dir=0;
  41.  
  42.   cid_num[0]=0;
  43.   cid_name[0]=0;
  44.   frequent_init();
  45.   sl1(1,"");
  46.   imodem(0);
  47.   usernum=0;
  48.   wfc=0;
  49.   write_inst(INST_LOC_WFC,0,INST_FLAGS_NONE);
  50.   read_user(1,&thisuser);
  51.   read_qscn(1,qsc,0);
  52.   usernum=1;
  53.   reset_act_sl();
  54.   fwaiting=thisuser.waiting;
  55.   if (thisuser.inact & inact_deleted) {
  56.     thisuser.screenchars=80;
  57.     thisuser.screenlines=25;
  58.   }
  59.   screenlinest=defscreenbottom+1;
  60.   d=(1.0+timer()) / 102.723;
  61.   d-=floor(d);
  62.   d*=10000.0;
  63.   srand((unsigned int)d);
  64.   do {
  65.     write_inst(INST_LOC_WFC,0,INST_FLAGS_NONE);
  66.     set_net_num(0);
  67.     any=0;
  68.     wfc=1;
  69.     if (date_changed())
  70.       if (date_changed()) {
  71.         printf("\n\nClock Corrupted.\n\n");
  72.         printf("Should put BBS in a batch file like:\n\n");
  73.         printf("copy con: wwiv.bat\n");
  74.         printf(":top\n");
  75.         printf("setclock\n");
  76.         printf("bbs\n");
  77.         printf("if errorlevel 1 goto top\n");
  78.         printf("^Z\n");
  79.         end_bbs(noklevel);
  80.       }
  81.     if ((strcmp(date(), status.date1)!=0)) {
  82.       if (instance==1) {
  83.         holdphone(1);
  84.         beginday();
  85.         holdphone(0);
  86.         clrscrb();
  87.       }
  88.     }
  89.     check_event();
  90.     if (do_event) {
  91.       run_event();
  92.       any=1;
  93.     }
  94.     lokb=0;
  95.     strcpy(curspeed,get_string(1042));
  96.     if ((!any) && ((rand() % 8000)==0) && (net_sysnum) &&
  97.         (ok_modem_stuff) && (sysinfo.flags & OP_FLAGS_NET_CALLOUT) &&
  98.         ((instance==1) || (status.net_version>=34)) &&
  99.         ((syscfgovr.com_ISR[syscfgovr.primaryport]<8) || (status.net_version>=35))) {
  100.       attempt_callout();
  101.       any=1;
  102.     }
  103.     if (kbhitb()) {
  104.       wfc=0;
  105.       read_user(1,&thisuser);
  106.       read_qscn(1,qsc,0);
  107.       fwaiting=thisuser.waiting;
  108.       wfc=1;
  109.     }
  110.     okskey=0;
  111.     ch=upcase(inkey());
  112.     if (ch) {
  113.       wfc=2;
  114.       any=1;
  115.       switch(ch) {
  116.         case '=':
  117.           if (ok_local()) {
  118.             holdphone(1);
  119.             reset_files();
  120.             holdphone(0);
  121.           }
  122.           break;
  123.         case '?':
  124.           if (ok_local()) {
  125.             i=7;
  126.             do {
  127.               clrscrb();
  128.               nl();
  129.               printmenu(i);
  130.               ch=upcase(getkey());
  131.               if ((ch!=' ') && (ch!=27))
  132.                 if (i==7)
  133.                   i=19;
  134.                 else
  135.                   i=7;
  136.             } while ((ch!=' ') && (ch!=27));
  137.           }
  138.           break;
  139.         case ' ':
  140.           outs(get_string(41));
  141.           d=timer();
  142.           while ((!kbhitb()) && (fabs(timer()-d)<60.0));
  143.           if (kbhitb()) {
  144.             ch=upcase(getchd1());
  145.             if (ch==str_yes[0]) {
  146.               outs(str_yes);
  147.               outstr("\r\n");
  148.               lokb=1;
  149.               if ((syscfg.sysconfig & sysconfig_off_hook)==0)
  150.                 dtr(0);
  151.             } else {
  152.               if (!ok_local())
  153.                 break;
  154.               ss=get_string(42);
  155.               if (ch==upcase(*ss)) {
  156.                 unx=1;
  157.                 fast=1;
  158.               } else {
  159.                 switch (ch) {
  160.                   case '1':
  161.                   case '2':
  162.                   case '3':
  163.                   case '4':
  164.                   case '5':
  165.                   case '6':
  166.                   case '7':
  167.                   case '8':
  168.                   case '9':
  169.                     fast=1;
  170.                     unx=ch-48;
  171.                     break;
  172.                 }
  173.               }
  174.               read_status();
  175.               if ((!fast) || (unx>status.users))
  176.                 break;
  177.               read_user(unx,&tu);
  178.               if ((tu.sl!=255) || (tu.inact & inact_deleted))
  179.                 break;
  180.               usernum=unx;
  181.               i=wfc; wfc=0;
  182.               read_user(usernum,&thisuser);
  183.               read_qscn(usernum,qsc,0);
  184.               wfc=i;
  185.               outchr(ch);
  186.               outs("\r\n\r\n\r\n\r\n\r\n\r\n");
  187.               lokb=2;
  188.               if ((syscfg.sysconfig & sysconfig_off_hook)==0)
  189.                 dtr(0);
  190.               reset_act_sl();
  191.               changedsl();
  192.               if (set_language(thisuser.language)) {
  193.                 thisuser.language=0;
  194.                 set_language(thisuser.language);
  195.               }
  196.               break;
  197.             }
  198.             if (ch==0)
  199.               getchd1();
  200.           }
  201.           if (!lokb)
  202.             out1ch(12);
  203.           break;
  204.         case 'A':
  205.           if (!ok_modem_stuff)
  206.             break;
  207.           answer_phone();
  208.           break;
  209.         case 'B':
  210.           okskey=1;
  211.           if (ok_local()) {
  212.             write_inst(INST_LOC_BOARDEDIT,0,INST_FLAGS_NONE);
  213.             holdphone(1);
  214.             boardedit();
  215.             cleanup_net();
  216.             holdphone(0);
  217.           }
  218.           okskey=0;
  219.           break;
  220.         case 'C':
  221.           okskey=1;
  222.           if (ok_local()) {
  223.             write_inst(INST_LOC_CHAINEDIT,0,INST_FLAGS_NONE);
  224.             holdphone(1);
  225.             chainedit();
  226.             holdphone(0);
  227.           }
  228.           okskey=0;
  229.           break;
  230.         case 'D':
  231.           okskey=1;
  232.           if (ok_local()) {
  233.             write_inst(INST_LOC_DIREDIT,0,INST_FLAGS_NONE);
  234.             holdphone(1);
  235.             dlboardedit();
  236.             holdphone(0);
  237.           }
  238.           okskey=0;
  239.           break;
  240.         case 'W':
  241.           okskey=1;
  242.           if (ok_local()) {
  243.             write_inst(INST_LOC_TEDIT,0,INST_FLAGS_NONE);
  244.             holdphone(1);
  245.             text_edit();
  246.             holdphone(0);
  247.           }
  248.           okskey=0;
  249.           break;
  250.         case 'F':
  251.           if (ok_local()) {
  252.             write_inst(INST_LOC_DOS,0,INST_FLAGS_NONE);
  253.             holdphone(1);
  254.             nl();
  255.             pl(get_string(43));
  256.             nl();
  257.             extern_prog(getenv("COMSPEC"), EFLAG_SHRINK);
  258.             out1ch(12);
  259.             cleanup_net();
  260.             holdphone(0);
  261.           }
  262.           break;
  263.         case 'G':
  264.           okskey=1;
  265.           if (ok_local()) {
  266.             write_inst(INST_LOC_GFILEEDIT,0,INST_FLAGS_NONE);
  267.             holdphone(1);
  268.             gfileedit();
  269.             holdphone(0);
  270.           }
  271.           okskey=0;
  272.           break;
  273.         case 'I':
  274.           okskey=1;
  275.           if (ok_local()) {
  276.             write_inst(INST_LOC_VOTEEDIT,0,INST_FLAGS_NONE);
  277.             holdphone(1);
  278.             ivotes();
  279.             holdphone(0);
  280.           }
  281.           okskey=0;
  282.           break;
  283.         case 'J':
  284.           okskey=1;
  285.           if (ok_local()) {
  286.             holdphone(1);
  287.             edit_confs();
  288.             holdphone(0);
  289.           }
  290.           okskey=0;
  291.           break;
  292.         case 'K':
  293.           if (ok_local()) {
  294.             usernum=1;
  295.             holdphone(1);
  296.             okskey=1;
  297.             prt(2,get_string(7));
  298.             input(s,50);
  299.             load_workspace(s,0);
  300.             send_email();
  301.             okskey=0;
  302.             write_user(1,&thisuser);
  303.             cleanup_net();
  304.             holdphone(0);
  305.           }
  306.           break;
  307.         case 'L':
  308.           if (ok_local()) {
  309.             read_status();
  310.             slname(date(), s);
  311.             print_local_file(s,status.log1);
  312.           }
  313.           break;
  314.         case 'M':
  315.           okskey=1;
  316.           if (ok_local()) {
  317.             write_inst(INST_LOC_MAILR,0,INST_FLAGS_NONE);
  318.             holdphone(1);
  319.             mailr();
  320.             holdphone(0);
  321.           }
  322.           okskey=0;
  323.           break;
  324.         case 'N':
  325.           if (ok_local())
  326.             print_local_file("NET.LOG","NETDAT*.LOG");
  327.           break;
  328.         case 'P':
  329.           if (ok_local())
  330.             print_pending_list();
  331.           break;
  332.         case 'Q':
  333.           end_bbs(QUIT_LEVEL);
  334.           break;
  335.         case 27:
  336.           outstr(get_string(1043));
  337.           if (yn())
  338.             end_bbs(QUIT_LEVEL);
  339.           clrscrb();
  340.           break;
  341.         case 'R':
  342.           if (ok_local()) {
  343.             usernum=1;
  344.             holdphone(1);
  345.             okskey=1;
  346.             readmail();
  347.             okskey=0;
  348.             write_user(1,&thisuser);
  349.             cleanup_net();
  350.             holdphone(0);
  351.           }
  352.           break;
  353.         case 'S':
  354.           if (ok_local()) {
  355.             prstatus();
  356.             getkey();
  357.           }
  358.           break;
  359.         case 'T':
  360.           if ((ok_local()) && (syscfg.terminal[0])) {
  361.             write_inst(INST_LOC_TERM,0,INST_FLAGS_NONE);
  362.             if (syscfg.sysconfig & sysconfig_shrink_term)
  363.               extern_prog(syscfg.terminal, EFLAG_SHRINK);
  364.             else
  365.               extern_prog(syscfg.terminal, 0);
  366.             imodem(1);
  367.             imodem(0);
  368.           }
  369.           break;
  370.         case 'U':
  371.           okskey=1;
  372.           if (ok_local()) {
  373.             write_inst(INST_LOC_UEDIT,0,INST_FLAGS_NONE);
  374.             holdphone(1);
  375.             uedit(1,0);
  376.             holdphone(0);
  377.           }
  378.           okskey=0;
  379.           break;
  380.         case 'E':
  381.           if (ok_local()) {
  382.             usernum=1;
  383.             holdphone(1);
  384.             okskey=1;
  385.             send_email();
  386.             okskey=0;
  387.             write_user(1,&thisuser);
  388.             cleanup_net();
  389.             holdphone(0);
  390.           }
  391.           break;
  392.         case 'X':
  393.           for(i=0;i<50;i++) {
  394.             if(xenviron[i]!=NULL)
  395.               npr("\r\nxenv %d=%s",i,xenviron[i]);
  396.           }
  397. #ifndef __OS2__
  398.           npr("\r\nreal=%x, new=%x",INT_REAL_DOS,save_dos);
  399. #endif
  400.           nl();
  401.           pausescr();
  402.         break;
  403.         case 'Y':
  404.           if (ok_local()) {
  405.             read_status();
  406.             slname(date(), s);
  407.             print_local_file(status.log1,s);
  408.           }
  409.           break;
  410.         case 'Z':
  411.           if (ok_local()) {
  412.             zlog();
  413.             nl();
  414.             getkey();
  415.           }
  416.           break;
  417.         case '/':
  418.           if ((net_sysnum) && (ok_local()) && ok_modem_stuff &&
  419.               ((instance==1) || (status.net_version>=34)) &&
  420.                ((syscfgovr.com_ISR[syscfgovr.primaryport]<8) || (status.net_version>=35)))
  421.             force_callout(0);
  422.           break;
  423.         case '.':
  424.           if ((net_sysnum) && (ok_local()) && ok_modem_stuff &&
  425.               ((instance==1) || (status.net_version>=34)) &&
  426.                ((syscfgovr.com_ISR[syscfgovr.primaryport]<8) || (status.net_version>=35)))
  427.             force_callout(1);
  428.           break;
  429.         case ',':
  430.           if ((net_sysnum>0) || (net_num_max>1) && ok_local()) {
  431.             nl();
  432.             prt(2,get_string(23));
  433.             ch=onek("Q012");
  434.             switch (ch) {
  435.               case '0':
  436.                 print_local_file(get_string(1027),"");
  437.                 break;
  438.               case '1':
  439.                 print_local_file(get_string(1028),"");
  440.                 break;
  441.               case '2':
  442.                 print_local_file(get_string(1029),"");
  443.                 break;
  444.             }
  445.           }
  446.           break;
  447.         case '`':
  448.           if ((net_sysnum) && (ok_local())) {
  449.             holdphone(1);
  450.             print_net_listing(1);
  451.             holdphone(0);
  452.           }
  453.           break;
  454.         case 9:
  455.           if (ok_local()) {
  456.             holdphone(1);
  457.             instance_edit();
  458.             holdphone(0);
  459.           }
  460.           break;
  461.       }
  462.       if (!incom && !lokb) {
  463.         frequent_init();
  464.         read_user(1,&thisuser);
  465.         read_qscn(1,qsc,0);
  466.         fwaiting=thisuser.waiting;
  467.         reset_act_sl();
  468.         usernum=1;
  469.       }
  470.       okskey=0;
  471.       catsl();
  472.       write_inst(INST_LOC_WFC, 0, INST_FLAGS_NONE);
  473.     }
  474.     if ((comhit()) && (ok_modem_stuff) && (!lokb)) {
  475.       any=1;
  476.       if (peek1c()==10)
  477.         get1c();
  478.       else {
  479.         outs("* ");
  480.         if (mode_switch(1.0,0)==mode_ring)
  481.           answer_phone();
  482.         else if (modem_mode == mode_con) {
  483.           incom=outcom=1;
  484.           if (!(modem_flag & flag_ec))
  485.             wait1(45);
  486.           else
  487.             wait1(2);
  488.         }
  489.       }
  490.     }
  491.     if (!any) {
  492.       if (c_sub<num_subs) {
  493.         if (!sub_dates[c_sub]) {
  494.           any=1;
  495.           iscan1(c_sub,1);
  496.         }
  497.         c_sub++;
  498.       } else if (c_dir<num_dirs) {
  499.         if (!dir_dates[c_dir]) {
  500.           any=1;
  501.           dliscan_hash(c_dir);
  502.         }
  503.         c_dir++;
  504.       } else {
  505.         if (labs(timer1()-mult_time) > 1000L) {
  506.           cleanup_net();
  507.           mult_time=timer1();;
  508.           giveup_timeslice();
  509.         } else {
  510.           giveup_timeslice();
  511.         }
  512.       }
  513.     }
  514.   } while ((!incom) && (!lokb) && (!endday));
  515.   if (lokb) {
  516.     if (ok_modem_stuff)
  517.       modem_speed = modem_i->defl.modem_speed;
  518.     else
  519.       modem_speed = 14400;
  520.   }
  521.   using_modem=incom;
  522.   if (lokb==2)
  523.     using_modem=-1;
  524.   okskey=1;
  525.   if (!endday) {
  526.     clrscrb();
  527.     if (modem_mode==mode_fax)
  528.       outs(get_string(45));
  529.     else
  530.       outs(get_string(46));
  531.     outs(curspeed);
  532.     outs("...\r\n");
  533.   }
  534.   wfc=0;
  535. }
  536.  
  537. /****************************************************************************/
  538.  
  539. void main(int argc, char *argv[])
  540. {
  541.   char s[81],ch,frc[81],s1[81],*ss;
  542.   int i,i1,num_min=0;
  543.   unsigned int ui=0, us=0;
  544.   double dt;
  545.   unsigned short c_s,c_o;
  546.   int this_usernum=0;
  547.  
  548.   ss=getenv("BBS");
  549.   if (ss) {
  550.     if (strncmp(ss,"WWIV",4)==0) {
  551.       printf("You are already in the BBS, type 'EXIT' instead.\n\n");
  552.       exit(-1);
  553.     }
  554.   }
  555.   ss=getenv("WWIV_DIR");
  556.   if (ss) {
  557.     cd_to(ss);
  558.   }
  559.   ss=getenv("WWIV_INSTANCE");
  560.   if(ss) {
  561.     instance=atoi(ss);
  562.     if ((instance<=0) || (instance>999)) {
  563.       printf("WWIV_INSTANCE can only be 1..999\n");
  564.       exit(-1);
  565.     }
  566.   } else {
  567.     instance=1;
  568.   }
  569.   already_on=0;
  570.   endday=0;
  571.   oklevel=0;
  572.   noklevel=0;
  573.   ooneuser=0;
  574.   no_hangup=0;
  575.   ok_modem_stuff=1;
  576.   debuglevel=0;
  577.   oklevel=OK_LEVEL;
  578.   noklevel=NOK_LEVEL;
  579. #ifdef NOT_ANYMORE
  580.   if (instance > 1)
  581.     sprintf(rf,"RESTORE.%3.3d",instance);
  582.   else
  583.     sprintf(rf,"RESTORE.WWV");
  584.   if (exist(rf))
  585.     restoring_shrink=1;
  586.   else
  587.     restoring_shrink=0;
  588. #else
  589.   restoring_shrink=0;
  590. #endif
  591.   frc[0]=0;
  592.  
  593.   s1[0]=0;
  594.  
  595.   for (i=1; i<argc; i++) {
  596.     strcpy(s,argv[i]);
  597.     if ((s[0]=='-') || (s[0]=='/')) {
  598.       ch=upcase(s[1]);
  599.       switch(ch) {
  600.         case 'C':
  601.           flow_control=1;
  602.           break;
  603.         case 'B':
  604.           ui=(unsigned int) atol(&(s[2]));
  605.           if (ui==49664) {
  606.             strcpy(curspeed, "115200");
  607.             if (!us)
  608.               us=ui;
  609.             already_on=1;
  610.           } else if ((ui%300)==0) {
  611.             ultoa((unsigned long) ui,curspeed,10);
  612.             if (!us)
  613.               us=ui;
  614.             already_on=1;
  615.           } else {
  616.             ui=us=0;
  617.             if (stricmp(&(s[2]),get_string(1042))==0) {
  618.               strcpy(curspeed,get_string(1042));
  619.               already_on=1;
  620.             }
  621.           }
  622.           rip=0;
  623.           break;
  624.         case 'D':
  625.           debuglevel=atoi(&(s[2]));
  626.           break;
  627.         case 'F':
  628.           strcpy(frc,s+2);
  629.           strupr(frc);
  630.           already_on=1;
  631.           break;
  632.         case 'S':
  633.           us=(unsigned int) atol(&(s[2]));
  634.           if ((us%300) && (us != 49664)) {
  635.             us=ui;
  636.           }
  637.           break;
  638.         case 'N':
  639.           oklevel=atoi(&(s[2]));
  640.           break;
  641.         case 'A':
  642.           noklevel=atoi(&(s[2]));
  643.           break;
  644.         case 'O':
  645.           ooneuser=1;
  646.           break;
  647.         case 'H':
  648.           no_hangup=1;
  649.           break;
  650.         case 'P':
  651.           strcpy(s1, s+2);
  652.           strupr(s1);
  653.           break;
  654.         case 'I':
  655.           i1=atoi(&(s[2]));
  656.           if ((i1!=instance) || (!getenv("WWIV_INSTANCE"))) {
  657.             printf("\r\nEnvironment variable %s and /I%d (instance) must match.\r\n",ss,i1);
  658.             exit(noklevel);
  659.           }
  660.           share_installed();
  661.           break;
  662.         case 'M':
  663.           ok_modem_stuff=0;
  664.           break;
  665. #ifndef __OS2__
  666.         case 'X':
  667.           c_s=strtol(&(s[2]),NULL,16);
  668.           c_o=strtol(&(s[7]),NULL,16);
  669.           if (c_s && c_o) {
  670.             point_shrink=MK_FP(c_s, c_o);
  671.           }
  672.           break;
  673. #endif
  674.         case 'R':
  675.           num_min=atoi(&(s[2]));
  676.           break;
  677.         case 'V':
  678.           this_usernum=atoi(&(s[2]));
  679.           if (!already_on)
  680.             strcpy(curspeed,"KB");
  681.           already_on=1;
  682.           break;
  683.         case '?':
  684.           printf("WWIV Bulletin Board\n\n");
  685.           printf("BBS /B<rate> /S<rate> /N<level> /A<level> /R<min> /O /H /M /F /C /V<num>/?\n\n");
  686.           printf("  /B - someone already logged on at rate (modem speed)\n");
  687.           printf("  /S - used only with /B, indicates com port speed\n");
  688.           printf("  /N - normal exit level\n");
  689.           printf("  /A - abnormal exit level\n");
  690.           printf("  /R - specify max # minutes until event\n");
  691.           printf("  /O - quit WWIV after one user done\n");
  692.           printf("  /H - don't hang up on user when he logs off\n");
  693.           printf("  /M - don't access modem at all\n");
  694.           printf("  /F - pass full result code (\"CONNECT 9600/ARQ/HST/HST/V.42BIS\")\n");
  695.           printf("  /C - enable CTS/RTS flow control\n");
  696.           printf("  /V - pass usernumber online\n");
  697.           printf("  /? - display command line options\n\n");
  698.           exit(0);
  699.       }
  700.     }
  701.   }
  702.  
  703.   init();
  704.  
  705.   if (s1[0])
  706.     strcpy(syscfg.systempw,s1);
  707.  
  708.   if (syscfg.sysconfig & sysconfig_no_local) {
  709.     this_usernum=0;
  710.     already_on=0;
  711.   }
  712.  
  713.   if (frc[0])
  714.     process_full_result(frc);
  715.  
  716.   if (num_min) {
  717.     syscfg.executetime=(timer()+num_min*60)/60;
  718.     if (syscfg.executetime>1440)
  719.       syscfg.executetime-=1440;
  720.     syscfg.executestr[0]=0;
  721.     time_event=((double)syscfg.executetime)*60.0;
  722.     last_time=time_event-timer();
  723.     if (last_time<0.0)
  724.       last_time+=24.0*3600.0;
  725.   }
  726.  
  727. #ifdef OLD_SHRINK
  728.   if (restoring_shrink) {
  729.     restoring_shrink=0;
  730.     switch(restore_data(rf)) {
  731.       case -1: /* hanging up */
  732.         goto hanging_up;
  733.       case 0: /* WFC */
  734.         goto wfc_label;
  735.       case 1: /* main menu */
  736.       case 2:
  737.         goto main_menu_label;
  738.     }
  739.   }
  740. #endif
  741.  
  742.   do {
  743.  
  744.     if (this_usernum) {
  745.       usernum=this_usernum;
  746.       read_user(usernum, &thisuser);
  747.       if ((thisuser.inact & inact_deleted)==0) {
  748.         gotcaller(ui, us);
  749.         usernum=this_usernum;
  750.         read_user(usernum,&thisuser);
  751.         read_qscn(usernum, qsc, 0);
  752.         reset_act_sl();
  753.         changedsl();
  754.         checkit=0;
  755.         okmacro=1;
  756.         if ((!hangup) && (usernum>0) && (thisuser.restrict & restrict_logon) &&
  757.           (strcmp(date(),thisuser.laston)==0) && (thisuser.ontoday>0)) {
  758.           nl();
  759.           pl(get_string(361));
  760.           nl();
  761.           hangup=1;
  762.         }
  763.       } else
  764.         this_usernum=0;
  765.     }
  766.     if (!this_usernum) {
  767.       wait1(9);
  768.       if (already_on)
  769.         gotcaller(ui, us);
  770.       else
  771.         getcaller();
  772.     }
  773.     if (modem_mode==mode_fax) {
  774.       if (exist("WWIVFAX.*")) {
  775.         stuff_in(s1, "WWIVFAX %S %P", "", "", "", "", "");
  776.         extern_prog(s1, EFLAG_SHRINK | EFLAG_FILES);
  777.       }
  778.       goto hanging_up;
  779.     }
  780.     if (using_modem>-1) {
  781.       if (!using_modem)
  782.         holdphone(1);
  783.       if (!this_usernum)
  784.         getuser();
  785.     } else {
  786.       holdphone(1);
  787.       using_modem=0;
  788.       checkit=0;
  789.       okmacro=1;
  790.       usernum=unx;
  791.       reset_act_sl();
  792.       changedsl();
  793.     }
  794.     this_usernum=0;
  795.     if (!hangup) {
  796.       if ((strcmp(date(), status.date1)!=0))
  797.         beginday();
  798.       logon();
  799.  
  800. main_menu_label:
  801.  
  802.       setiia(90);
  803.       set_net_num(0);
  804.       while (!hangup) {
  805.         if (filelist) {
  806.           bbsfree(filelist);
  807.           filelist=NULL;
  808.         }
  809.         zap_ed_info();
  810.         switch(curdloads) {
  811.           case 2:
  812.             write_inst(INST_LOC_CHAINS,0,INST_FLAGS_NONE);
  813.             do_chains();
  814.           break;
  815.           case 1:
  816.             write_inst(INST_LOC_XFER,udir[curdir].subnum,INST_FLAGS_NONE);
  817.             dlmainmenu();
  818.           break;
  819.           case 0:
  820.           default:
  821.             write_inst(INST_LOC_MAIN,usub[cursub].subnum,INST_FLAGS_NONE);
  822.             mainmenu();
  823.           break;
  824.         }
  825.       }
  826.       logoff();
  827.       end_rip();
  828.     }
  829.  
  830. hanging_up:
  831. #ifdef RIPDRIVE
  832.   if (rd_on())  {
  833.     rd_disable();
  834.     strcpy(s,sysinfo.ripdir);           // Clean up files
  835.     strcat(s,"ripclip.brd");
  836.     unlink(s);
  837.     strcpy(s,sysinfo.ripdir);
  838.     strcat(s,"ripmouse.sav");
  839.     unlink(s);
  840.     strcpy(s,sysinfo.ripdir);
  841.     strcat(s,"ripterm.sav");
  842.     unlink(s);
  843.     strcpy(s,sysinfo.ripdir);
  844.     strcat(s,"ripterm0.sav");
  845.     unlink(s);
  846.   }
  847.   ripdrive = 0;
  848.   end_rip();
  849. #endif
  850.  
  851.     if ((!no_hangup) && (using_modem) && ok_modem_stuff) {
  852.       hang_it_up();
  853.     }
  854.     catsl();
  855.     frequent_init();
  856.  
  857. wfc_label:
  858.  
  859.     cleanup_net();
  860.     if (!using_modem)
  861.       holdphone(0);
  862.     if ((!no_hangup) && ok_modem_stuff)
  863.       dtr(0);
  864.     already_on=0;
  865.     if (sysop_alert && (!kbhitb())) {
  866.       dtr(1);
  867.       wait1(2);
  868.       holdphone(1);
  869.       dt=timer();
  870.       clrscrb();
  871.       nl();
  872.       pl(get_string(47));
  873.       nl();
  874.       while ((!kbhitb()) && (fabs(timer()-dt)<60.0)) {
  875.         setbeep(1);
  876.         wait1(9);
  877.         setbeep(0);
  878.         wait1(18);
  879.       }
  880.       clrscrb();
  881.       holdphone(0);
  882.     }
  883.     sysop_alert=0;
  884.   } while ((!endday) && (!ooneuser));
  885.  
  886.   outs("\f");
  887.   end_bbs(oklevel);
  888. }
  889.  
  890. /****************************************************************************/
  891.