home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / bsrc_260.arj / SRC.ZIP / b_sessio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-31  |  17.6 KB  |  726 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*                This module was written by Vince Perriello                */
  13. /*                                                                          */
  14. /*                   BinkleyTerm Mail Session Initiator                     */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*--------------------------------------------------------------------------*/
  43.  
  44. /* Include this file before any other includes or defines! */
  45.  
  46. #include "includes.h"
  47.  
  48. extern int CallerSendSync (void);
  49. extern int CalledRecvSync (void);
  50. extern int EMSI_Sender (void);
  51. extern int EMSI_Receiver (void);
  52.  
  53. void 
  54. b_session (int was_initiator)
  55. {
  56.     int i;
  57.     ADDR tmp;
  58.  
  59.     isOriginator = was_initiator;
  60.     start_hist = hist;
  61.  
  62.     CURRENT = DEFAULT;
  63.  
  64.     mail_finished = 0;
  65.  
  66.     (void) time (&etm);
  67.  
  68.     freq_accum.bytes = 0L;
  69.     freq_accum.files = 0;
  70.     freq_accum.time = 0L;
  71.  
  72.     if (un_attended && fullscreen)
  73.         do_ready (MSG_TXT (M_READY_CONNECT));
  74.  
  75.     /* Remove the old .REQ and .RSP files */
  76.  
  77.     for (i = 0; i < 10; i++)
  78.     {
  79.         if (alias[i].Net == 0)
  80.             break;
  81.  
  82.         tmp = alias[i];
  83.  
  84.         /* For a point, massage the address to get the right .REQ filename */
  85.  
  86.         if (tmp.Point != 0)
  87.         {
  88.             tmp.Node = tmp.Point;
  89.             tmp.Point = 0;
  90.             tmp.Net = (pvtnet > 0) ? (unsigned short) pvtnet : 0;
  91.         }
  92.  
  93.         (void) sprintf (junk, request_template, CURRENT.sc_Inbound, Hex_Addr_Str (&tmp), TaskNumber);
  94.         (void) unlink (junk);
  95.  
  96.         if (!pktrsp)            /* MB 93-12-12  PKTRSP */
  97.         {
  98.             (void) sprintf (junk, "%s.RSP", Hex_Addr_Str (&tmp));
  99.             (void) unlink (junk);
  100.         }
  101.     }
  102.  
  103.     /* remove old response PKTs */
  104.  
  105.     if (pktrsp)                    /* MB 93-12-12  PKTRSP */
  106.     {
  107.         struct FILEINFO dta = {0};
  108.         char fname[80];
  109.  
  110.         (void) sprintf (junk, "%s%02x*.PKT", flag_dir, TaskNumber);
  111.         if (!dfind (&dta, junk, 0))
  112.         {
  113.             do
  114.             {
  115.                 (void) sprintf (fname, "%s%s", flag_dir, dta.name);
  116.                 (void) unlink (fname);
  117.             }
  118.             while (!dfind (&dta, junk, 1));
  119.             dfind (&dta, NULL, 2);
  120.         }
  121.     }
  122.  
  123.     tmp.Zone = 0;
  124.     tmp.Net = 0;
  125.     tmp.Node = 0;
  126.     tmp.Point = 0;
  127.     tmp.Domain = NULL;
  128.  
  129.     remote_capabilities = 0;
  130.  
  131.     my_capabilities = (no_zapzed) ? 0 : (ZED_ZAPPER | ZED_ZIPPER);
  132.     my_capabilities |= (no_dietifna) ? 0 : Y_DIETIFNA;
  133.     if ((janus_baud >= cur_baud.rate_value) || (janus_OK))
  134.     {
  135.         if (!no_janus)
  136.             my_capabilities |= DOES_IANUS;
  137. #ifdef HAVE_HYDRA
  138.         if (!no_hydra)
  139.             my_capabilities |= DOES_HYDRA;
  140. #endif
  141.     }
  142.  
  143.     (void) flag_file (SET_SESSION_FLAG, &called_addr, 0);
  144.     if (was_initiator)
  145.     {
  146.  
  147.         /*
  148.          *    OUTBOUND -- meaning call was made by us.
  149.          */
  150.  
  151.         last_type (1, &remote_addr);
  152.  
  153.         /* See if this address is serviced by an external mail
  154.            agent. If so, call WaZOO with a special argument. */
  155.  
  156.         if (ExtMailMask && (newnodedes.ModemType == (byte)ExtMailMask))
  157.         {
  158.             no_EMSI_Session = 1;
  159.             remote_pickup = -2;
  160.             remote_capabilities = my_capabilities = 0;
  161.             WaZOO (1);
  162.         }
  163.         else
  164.         if (Whack_CR () == 0)
  165.         {
  166.  
  167. retry_outbound:
  168.  
  169.             switch (i = CallerSendSync ())
  170.             {
  171.             case 1:
  172.                 no_EMSI_Session = TRUE;
  173.                 FTSC_sender (0);
  174.                 break;
  175.  
  176.             case 2:
  177.                 if (YooHoo_Sender ())
  178.                 {
  179.                     if ((remote_capabilities & my_capabilities) == 0)
  180.                     {
  181.                         no_EMSI_Session = 1;
  182.                         no_WaZOO_Session = 1;
  183.                         status_line (MSG_TXT (M_NO_COMMON_PROTO));
  184.                         goto retry_outbound;
  185.                     }
  186.                     no_EMSI_Session = TRUE;
  187.                     remote_pickup = -1;
  188.                     WaZOO (1);
  189.                 }
  190.                 break;
  191.  
  192.             case 4:
  193.                 if (EMSI_Sender ())
  194.                 {
  195.                     if ((remote_capabilities & my_capabilities) == 0)
  196.                     {
  197.                         no_EMSI_Session = 1;
  198.                         no_WaZOO_Session = 1;
  199.                         status_line (MSG_TXT (M_NO_COMMON_PROTO));
  200.                         goto retry_outbound;
  201.                     }
  202.                     WaZOO (1);
  203.                 }
  204.                 break;
  205.  
  206.             default:
  207.                 break;
  208.  
  209.             }                    /* end switch */
  210.         }
  211.  
  212.     }
  213.     else
  214.     {
  215.  
  216.         /*
  217.          *    INBOUND -- meaning we were connected to by another system.
  218.          */
  219.  
  220. retry_inbound:
  221.  
  222.         b_init ();
  223.  
  224.         /* String following "Connect [xxxx]" is a special case of
  225.            an external mail string. */
  226.  
  227.         for (i = 0; i < num_ext_mail; i++)
  228.         {
  229.             if (stricmp (saved_response, ext_mail_string[i]) == 0)
  230.             {
  231.                 i += 5;
  232.                 goto ext_mail;
  233.             }
  234.         }
  235.  
  236.         switch (i = CalledRecvSync ())
  237.         {
  238.         case 1:                /* ESCape or Timeout    */
  239.             if (CARRIER && !mail_only)
  240.             {
  241.                 last_type (3, &tmp);
  242.                 (void) flag_file (CLEAR_SESSION_FLAG, &called_addr, 0);
  243.                 BBSexit ();
  244.             }
  245.             break;
  246.  
  247.         case 2:                /* FTSC Netmail Session */
  248.             if (CARRIER)
  249.             {
  250.                 tmp.Zone = (unsigned short) -1000;
  251.                 last_type (2, &tmp);
  252.                 tmp.Zone = 0;
  253.                 ++hist.mail_calls;
  254.                 if (un_attended && fullscreen)
  255.                 {
  256.                     (void) sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
  257.                     sb_move (historywin, HIST_MAIL_ROW, HIST_COL);
  258.                     sb_puts (historywin, junk);
  259.                     sb_show ();
  260.                 }
  261.                 no_EMSI_Session = TRUE;
  262.                 (void) FTSC_receiver (0);
  263.             }
  264.             break;
  265.  
  266.         case 3:                /* WaZOO Netmail Session*/
  267.             if (YooHoo_Receiver ())
  268.             {
  269.                 if ((remote_capabilities & my_capabilities) == 0)
  270.                 {
  271.                     no_WaZOO_Session = 1;
  272.                     no_EMSI_Session = TRUE;
  273.                     status_line (MSG_TXT (M_NO_COMMON_PROTO));
  274.                     goto retry_inbound;
  275.                 }
  276.                 last_type (1, &remote_addr);
  277.                 ++hist.mail_calls;
  278.                 if (un_attended && fullscreen)
  279.                 {
  280.                     (void) sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
  281.                     sb_move (historywin, HIST_MAIL_ROW, HIST_COL);
  282.                     sb_puts (historywin, junk);
  283.                     sb_show ();
  284.                 }
  285.                 remote_pickup = -1;
  286.                 no_EMSI_Session = TRUE;
  287.                 WaZOO (0);        /* do WaZOO!!!          */
  288.             }
  289.             break;
  290.  
  291.         case 4:                /* EMSI Netmail Session*/
  292.             if (EMSI_Receiver ())
  293.             {
  294.                 if ((remote_capabilities & my_capabilities) == 0)
  295.                 {
  296.                     no_WaZOO_Session = 1;
  297.                     no_EMSI_Session = TRUE;
  298.                     status_line (MSG_TXT (M_NO_COMMON_PROTO));
  299.                     goto retry_inbound;
  300.                 }
  301.                 last_type (1, &remote_addr);
  302.                 ++hist.mail_calls;
  303.                 if (un_attended && fullscreen)
  304.                 {
  305.                     (void) sprintf (junk, "%d/%d", hist.bbs_calls, hist.mail_calls);
  306.                     sb_move (historywin, HIST_MAIL_ROW, HIST_COL);
  307.                     sb_puts (historywin, junk);
  308.                     sb_show ();
  309.                 }
  310.                 WaZOO (0);        /* do EMSI!!!          */
  311.             }
  312.             break;
  313.  
  314.         default:
  315.             if (CARRIER && (i >= 5) && (i < (5 + num_ext_mail)))    /* See if ext mail */
  316.             {
  317. ext_mail:
  318.                 last_type (4, &tmp);
  319.                 (void) flag_file (CLEAR_SESSION_FLAG, &called_addr, 0);
  320.                 UUCPexit (lev_ext_mail[i - 5], 1);
  321.             }
  322.             break;
  323.  
  324.         }                        /* end switch */
  325.  
  326.     }                            /* end if (was_initiator) */
  327.  
  328.     saved_response[0] = '\0';
  329.     no_WaZOO_Session = no_WaZOO;
  330.     no_EMSI_Session = no_EMSI;
  331.     (void) flag_file (CLEAR_FLAG, &called_addr, 1);    /* ensure flag's gone */
  332.     (void) flag_file (CLEAR_SESSION_FLAG, &called_addr, 0);
  333.     return;
  334. }
  335.  
  336. void 
  337. b_init ()
  338. {
  339.     got_arcmail = got_packet = got_mail = sent_mail = got_fax = 0;
  340.     remote_addr.Zone = remote_addr.Net = remote_addr.Node = remote_addr.Point = 0;
  341.     remote_addr.Domain = NULL;
  342.     assumed = 0;
  343.     Netmail_Session = 0;
  344.     remote_capabilities = 0;
  345.     mail_finished = 0;
  346.     CURRENT = DEFAULT;
  347. }
  348.  
  349. /*
  350.  * Send banner-type lines to remote. Since strange modems like Courier HST
  351.  * have a propensity for thinking they are connected when talking to a dial
  352.  * tone (but do leave CTS down just to screw us up) we have to use a timeout
  353.  * to figure out if we are in trouble, and if so, we drop DTR to make the
  354.  * bogus carrier go away.
  355.  *
  356.  * This routine is used in modules B_BBS.C and RECVSYNC.C, both of which
  357.  * are called from this module only.
  358.  *
  359.  */
  360.  
  361. int 
  362. SendBanner (char far * string)
  363. {
  364.     long t1;
  365.     register char c;
  366.  
  367.     t1 = timerset (600);    /* 60 secs to send banner*/
  368.  
  369.     while (!timeup (t1) && CARRIER)
  370.     {
  371.         if (got_ESC ())            /* Manual abort?     */
  372.             break;                /* Use failure logic */
  373.  
  374.         if (!OUT_FULL ())
  375.         {
  376.             c = *string++;
  377.             if (!c || c == 0x1a)/* Test for end      */
  378.                 return (1);        /* Yes, success      */
  379.             SENDBYTE ((unsigned char) c);
  380.         }
  381.         else                    /* If output was full*/
  382.             time_release ();    /* give up timeslice */
  383.     }
  384.  
  385.    /*
  386.     * If we get here we had trouble. Drop DTR now to hopefully get out of
  387.     * this trouble. Flush outbound. Pause for 1 second.
  388.     */
  389.  
  390.     LOWER_DTR ();
  391.     CLEAR_OUTBOUND ();
  392.  
  393.     timer (10);
  394.  
  395.     CLEAR_INBOUND ();
  396.  
  397.     return (0);
  398. }
  399.  
  400. int 
  401. flag_file (int function, ADDRP address, int do_stat)
  402. {
  403.  
  404.     FILE *fptr;
  405.     char *HoldName;
  406.     static ADDR last_set[ALIAS_CNT];
  407.     static last_count;
  408.     char flagname[128];
  409.     char tmpname[128];
  410.     char BSYname[15];
  411.     static int had_to_punt[ALIAS_CNT];
  412.     int i, j;
  413.  
  414.     if (!TaskNumber)
  415.         return (FALSE);
  416.  
  417.     HoldName = HoldAreaNameMunge (address);
  418.  
  419.     switch (function)
  420.     {
  421.     case INITIALIZE:
  422.  
  423.         last_count = 0;
  424.  
  425.         /* Fall through for cleanup purposes */
  426.  
  427.     case CLEAR_SESSION_FLAG:
  428.  
  429.         /* At the end of a session, delete the task file */
  430.  
  431.         if (flag_dir)
  432.         {
  433.             (void) sprintf (flagname, "%sTask.%02x",
  434.                 flag_dir, TaskNumber);
  435.             (void) unlink (flagname);
  436.         }
  437.         return (FALSE);
  438.  
  439.     case SET_SESSION_FLAG:
  440.  
  441.         /* At the start of a session, set up the task number */
  442.  
  443.         if (flag_dir)
  444.         {
  445.             (void) sprintf (flagname, "%sTask.%02x",
  446.                 flag_dir, TaskNumber);
  447.             fptr = fopen (flagname, write_binary);
  448.             (void) fclose (fptr);
  449.         }
  450.         return (FALSE);
  451.  
  452.     case TEST_AND_SET:
  453.  
  454.         /*
  455.          * First see if we already HAVE this lock! If so, return now.
  456.          *
  457.          */
  458.  
  459.         for (i = 0; i < last_count; i++)
  460.         {
  461.             if (memcmp (&last_set[i], address, sizeof (ADDR)) == 0)
  462.                 return (FALSE);
  463.         }
  464.  
  465.         /*
  466.          * Next determine the directory in which we will create the flagfile.
  467.          * Also, the name of the file.
  468.          *
  469.          */
  470.  
  471.         if (address->Point != 0)
  472.         {
  473.             (void) sprintf (flagname, "%s%04hx%04hx.PNT\\",
  474.                 HoldName, address->Net, address->Node);
  475.             (void) sprintf (BSYname, "%08hx.BSY",
  476.                 address->Point);
  477.         }
  478.         else
  479.         {
  480.             (void) strcpy (flagname, HoldName);
  481.             (void) sprintf (BSYname, "%04hx%04hx.BSY",
  482.                 address->Net, address->Node);
  483.         }
  484.  
  485.         /*
  486.          * File opens are destructive by nature. Therefore use a file name
  487.          * that's unique to us. Create it in the chosen target. If we can't
  488.          * do that, try to use the flag directory.
  489.          *
  490.          */
  491.  
  492.         had_to_punt[last_count] = 0;
  493.         (void) sprintf (tmpname, "%sBINKBSY.%02x", flagname, TaskNumber);
  494.         fptr = fopen (tmpname, write_binary);
  495.         if ((fptr == NULL) && (flag_dir))
  496.         {
  497.             had_to_punt[last_count] = 1;
  498.             (void) strcpy (flagname, flag_dir);
  499.             (void) sprintf (tmpname, "%sBINKBSY.%02x", flagname, TaskNumber);
  500.             fptr = fopen (tmpname, write_binary);
  501.         }
  502.  
  503.         /*
  504.          * Now we've done all we can. The file is either open in the
  505.          * appropriate outbound or it's in the flag directory.
  506.          * If neither option worked out, go away. There's nothing to do.
  507.          *
  508.          */
  509.  
  510.         if (fptr == NULL)
  511.         {
  512.             if (do_stat)
  513.                 status_line (MSG_TXT (M_FAILED_CREATE_FLAG), tmpname);
  514.             return (TRUE);
  515.         }
  516.         (void) fclose (fptr);
  517.  
  518.         /*
  519.          * Now the test&set. Attempt to rename the file to a value specific
  520.          * to the remote node's address. If we succeed, we have the lock.
  521.          * If we do not, delete the temp file.
  522.          *
  523.          */
  524.  
  525.         (void) strcat (flagname, BSYname);    /* Add the .BSY file name */
  526.         if (!rename (tmpname, flagname))
  527.         {
  528.             if (do_stat)
  529.                 status_line (MSG_TXT (M_CREATED_FLAGFILE), flagname);
  530.             last_set[last_count++] = *address;
  531.             return (FALSE);
  532.         }
  533.  
  534.         if (do_stat)
  535.             status_line (MSG_TXT (M_THIS_ADDRESS_LOCKED), Full_Addr_Str (address));
  536.         (void) unlink (tmpname);
  537.         return (TRUE);
  538.  
  539.     case CLEAR_FLAG:
  540.  
  541.         /*
  542.          * Make sure we need to clear something.
  543.          * Zone should be something other than -1 if that's the case.
  544.          *
  545.          */
  546.  
  547.         if (!last_count)
  548.             return (TRUE);
  549.  
  550.         /*
  551.          * Next compare what we want to clear with what we think we have.
  552.          *
  553.          */
  554.  
  555.         for (i = 0; i < last_count; i++)
  556.             if (!memcmp (&last_set[i], address, sizeof (ADDR)))
  557.                 break;
  558.  
  559.         if (i >= last_count)    /* not yet set ??? */
  560.         {
  561.             if (do_stat)
  562.                 status_line (MSG_TXT (M_BAD_CLEAR_FLAGFILE),
  563.                     Full_Addr_Str (address));
  564.             return (TRUE);
  565.         }
  566.  
  567.         /*
  568.          * We match. Recalculate the directory. Yeah, that's redundant
  569.          * code, but it saves static space.
  570.          *
  571.          */
  572.  
  573.         if (address->Point != 0)
  574.         {
  575.             (void) sprintf (flagname, "%s%04hx%04hx.PNT\\",
  576.                 HoldName, address->Net, address->Node);
  577.             (void) sprintf (BSYname, "%08hx.BSY",
  578.                 address->Point);
  579.         }
  580.         else
  581.         {
  582.             (void) strcpy (flagname, HoldName);
  583.             (void) sprintf (BSYname, "%04hx%04hx.BSY",
  584.                 address->Net, address->Node);
  585.         }
  586.  
  587.         if (had_to_punt[i])
  588.             (void) strcpy (flagname, flag_dir);
  589.         (void) strcat (flagname, BSYname);
  590.  
  591.         had_to_punt[i] = 0;
  592.         j = i++;
  593.  
  594.         for (; i < last_count; j++, i++)
  595.         {
  596.             last_set[j] = last_set[i];
  597.             had_to_punt[j] = had_to_punt[i];
  598.         }
  599.  
  600.         last_count--;
  601.  
  602.         if (!unlink (flagname))
  603.         {
  604.             if (do_stat)
  605.                 status_line (MSG_TXT (M_CLEARED_FLAGFILE), flagname);
  606.             return (TRUE);
  607.         }
  608.  
  609.         if (do_stat)
  610.             status_line (MSG_TXT (M_FAILED_CLEAR_FLAG), flagname);
  611.         return (FALSE);
  612.  
  613.     default:
  614.         break;
  615.     }
  616.  
  617.     return (TRUE);
  618. }
  619.  
  620. void 
  621. forcexitcheck ()
  622. {
  623.     struct stat buf;
  624.     struct FILEINFO dta = {0};
  625.  
  626.     static char fname[256];
  627.     static long next_time = 0L;
  628.  
  629.     if (!flag_dir)
  630.         return;
  631.  
  632.     if (next_time && !timeup (next_time))
  633.         return;
  634.  
  635.     if (forcexit)
  636.     {
  637.         if (TaskNumber)
  638.         {
  639.             sprintf (fname, "%sFORCEXIT.%u", flag_dir, TaskNumber);
  640.         }
  641.         else
  642.         {
  643.             sprintf (fname, "%sFORCEXIT", flag_dir);
  644.         }
  645.  
  646.         if (!stat (fname, &buf))
  647.         {
  648.             unlink (fname);
  649.             screen_blank = 0;
  650.  
  651.             if (errlvlshell[forcexit - 1] == NULL)
  652.             {
  653.                 status_line (MSG_TXT (M_FORCED_EXIT), forcexit);
  654.                 errl_exit (forcexit);
  655.             }
  656.             else
  657.             {
  658.                 status_line (MSG_TXT (M_FORCED_SHELL), forcexit);
  659.                 errl_shell (forcexit);
  660.             }
  661.         }
  662.     }
  663.  
  664.     sprintf (fname, "%sBTEXIT??.??", flag_dir);
  665.  
  666.     if (!dfind (&dta, fname, 0))
  667.     {
  668.         do
  669.         {
  670.             int sExit = 0, sTask = 0;
  671.             int cScanned = 0;
  672.  
  673.             cScanned = sscanf (dta.name, "BTEXIT%02x.%02x", &sExit, &sTask);
  674.             if (cScanned && (sTask == TaskNumber))
  675.             {
  676.                 sprintf (fname, "%s%s", flag_dir, dta.name);
  677.                 unlink (fname);
  678.                 screen_blank = 0;
  679.  
  680.                 if (errlvlshell[sExit - 1] == NULL)
  681.                 {
  682.                     status_line (MSG_TXT (M_FORCED_EXIT), sExit);
  683.                     errl_exit (sExit);
  684.                 }
  685.                 else
  686.                 {
  687.                     status_line (MSG_TXT (M_FORCED_SHELL), sExit);
  688.                     errl_shell (sExit);
  689.                 }
  690.                 break;
  691.             }
  692.         } while (!dfind (&dta, fname, 1));
  693.  
  694.         dfind (&dta, NULL, 2);
  695.     }
  696.  
  697.     next_time = timerset (200);    /* Don't check for at least 2 seconds */
  698. }
  699.  
  700. int 
  701. forcerescancheck ()
  702. {
  703.     struct stat buf;
  704.  
  705.     static char fname[256];
  706.     static long next_time = 0L;
  707.  
  708.     if (!flag_dir)
  709.         return (0);
  710.  
  711.     if (next_time && !timeup (next_time))
  712.         return (0);
  713.  
  714.     sprintf (fname, "%sBTRESCAN.%02x", flag_dir, TaskNumber);
  715.  
  716.     if (!stat (fname, &buf))
  717.     {
  718.         unlink (fname);
  719.         next_time = timerset (1000); /* At least 10 seconds before next */
  720.         return (1);
  721.     }
  722.  
  723.     next_time = timerset (200);    /* Don't check for at least 2 seconds */
  724.     return 0;
  725. }
  726.