home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVSOR / BBS.C < prev    next >
C/C++ Source or Header  |  1996-11-30  |  22KB  |  877 lines

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