home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / MAILROOT.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  22KB  |  687 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-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                 This module was written by Bob Hartman                   */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                   BinkleyTerm Mail Control Routines                      */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. char *estring (int, int);
  51.  
  52. int do_mail (ADDRP baddr, int type) /* 1 = manual, 0 = normal, -1 = CM */
  53. {
  54.     int i;
  55.  
  56.     long callstart, callend;
  57.     long call_cost, call_cost_ths;
  58.  
  59.     long eh, em, es;
  60.  
  61.     b_init ();
  62.     caller = 1;
  63.     got_packet = 0;
  64.     got_arcmail = 0;
  65.     got_mail = 0;
  66.     sent_mail = 0;
  67.     no_WaZOO_Session = no_WaZOO;
  68.     callstart = 0L;
  69.  
  70. #ifdef MILQ
  71.     UsePaths = FALSE;
  72. #endif
  73.  
  74.     (void) sprintf (junk, "%s", Full_Addr_Str (baddr));
  75.  
  76.     called_addr = remote_addr = *baddr;     /* structure assignment */
  77.     SendMessage( node_hWnd, WM_COMMAND, GD_CRNT, (long)baddr );
  78.  
  79.     if (!net_params)
  80.         {
  81.         status_line (MSG_TXT(M_INSUFFICIENT_DATA));
  82.         set_xy ("");
  83.         return (0);
  84.         }
  85.  
  86.     if (!nodeproc (junk))
  87.         return (0);
  88.  
  89.     if (type > 0)
  90.         {
  91.         if (flag_file (TEST_AND_SET, &called_addr, 1))
  92.             {
  93.             if (CARRIER)
  94.                 mdm_hangup ();
  95.             return (0);
  96.             }
  97.  
  98.         if (CARRIER)                        /* called manually maybe? */
  99.             goto process_the_damned_mail;   /* yup, just do some mail */
  100.  
  101.  
  102.         do_dial_strings ();
  103.         try_2_connect ((char *) (newnodedes.PhoneNumber));  /* try to connect */
  104.         }
  105.     else
  106.         {
  107.         /* If this is supposed to be only local, then get out if it isn't */
  108.         if (type == 0)
  109.            {
  110.            if (e_ptrs[cur_event].behavior & MAT_LOCAL)
  111.                {
  112.                if (e_ptrs[cur_event].node_cost < 0)
  113.                    {
  114.                    if ((int) newnodedes.RealCost < -e_ptrs[cur_event].node_cost)
  115.                        {
  116.                        return (0);
  117.                        }
  118.                    }
  119.                else
  120.                    {
  121.                    if ((int) newnodedes.RealCost > e_ptrs[cur_event].node_cost)
  122.                        {
  123.                        return (0);
  124.                        }
  125.                    }
  126.                }
  127.            /* If it is supposed to be 24 hour mail only, get out if it isn't */
  128.            if ((newnodelist || version7) && 
  129.                (!(e_ptrs[cur_event].behavior & MAT_NOMAIL24)) &&
  130.                (!(newnodedes.NodeFlags & B_CM)))
  131.                return (0);
  132.            /* If we aren't supposed to send to CM's now, get out */
  133.            if ((newnodelist || version7) &&
  134.                (e_ptrs[cur_event].behavior & MAT_NOCM) &&
  135.                (newnodedes.NodeFlags & B_CM))
  136.                return (0);
  137.            }
  138.  
  139.         /* Try to connect */
  140.  
  141.         if (flag_file (TEST_AND_SET, &called_addr, 1))
  142.             {
  143.             if (CARRIER)
  144.                 mdm_hangup ();
  145.             return (0);
  146.             }
  147.  
  148.         do_dial_strings ();
  149.         if (un_attended && fullscreen)
  150.             {
  151.             sb_move (hold_hWnd, 2, 1);
  152.             sb_wa (hold_hWnd, colors.calling, 31);
  153.             }
  154.  
  155.         callstart = time (NULL);
  156.  
  157.         if (!blank_on_key)
  158.             screen_blank = 0;
  159.  
  160.         if ((i = try_1_connect ((char *) (newnodedes.PhoneNumber))) < 0)
  161.             {
  162.             if (un_attended && fullscreen)
  163.                 {
  164.                 sb_move (hold_hWnd, 2, 1);
  165.                 sb_wa (hold_hWnd, colors.hold, 31);
  166.                 }
  167.             (void) flag_file (CLEAR_FLAG, &called_addr, 1);
  168.             return (i);
  169.             }
  170.         }
  171.  
  172. process_the_damned_mail:
  173.  
  174.     if (CARRIER)                                         /* if we did,        */
  175.         {
  176.         if (type > 0)
  177.            callstart = time (NULL);
  178.  
  179.         b_session (1);                                  /* do a mail session  */
  180.  
  181.         callend = time (NULL);
  182.         hist.last_Elapsed = callend - callstart;
  183.  
  184.         eh = (callend - callstart) / 3600L;
  185.         em = ((callend - callstart) / 60L) - (eh * 60L);
  186.         es = (callend - callstart) - (eh * 3600L) - (em * 60L);
  187.  
  188.         hist.callcost += (call_cost = cost_of_call (callstart, callend));
  189.  
  190.         call_cost_ths = call_cost % 100L;               /* Separate dollars & */
  191.         call_cost = call_cost / 100L;                   /* cents for formats  */
  192.  
  193. #ifdef MILQ
  194.         sprintf( last_Elapsed_Str,
  195.                  "%02d:%02d:%02d",
  196.                    eh, em, es );
  197.         sb_puts( node_Elapsed, last_Elapsed_Str );
  198. #endif
  199.         status_line (MSG_TXT(M_NODE_COST), Full_Addr_Str (baddr), 
  200.                         eh, em, es, call_cost, call_cost_ths);
  201.         mdm_hangup ();
  202.  
  203. #ifdef MILQ
  204.         UsePaths = FALSE;
  205. #endif
  206.  
  207.         ++hist.connects;
  208.         if (un_attended && fullscreen)
  209.             {
  210.             do_today();
  211.             SendMessage( node_hWnd, WM_COMMAND, GD_LAST, (LONG)baddr );
  212.             }
  213.  
  214.         write_stats ();
  215.  
  216.         if (un_attended && (got_arcmail || got_packet || got_mail))
  217.             {
  218.             (void) bad_call (baddr, -1);
  219.             receive_exit ();
  220.             }
  221.         if (un_attended && fullscreen)
  222.             {
  223.             sb_move (hold_hWnd, 2, 1);
  224.             sb_wa (hold_hWnd, colors.hold, 31);
  225.             }
  226.         return (1);
  227.         }
  228.     else
  229.         {
  230.         status_line (MSG_TXT(M_END_OF_ATTEMPT));
  231.         (void) flag_file (CLEAR_FLAG, &called_addr, 1);
  232.         }
  233.     if (un_attended && fullscreen)
  234.         {
  235.         sb_move (hold_hWnd, 2, 1);
  236.         sb_wa (hold_hWnd, colors.hold, 31);
  237.         }
  238.     write_stats ();
  239.     return (2);
  240. }
  241.  
  242. int handle_inbound_mail (int answer_now)
  243. {
  244.     long t;                                             /* used for timeouts  */
  245.     int mr;                                             /* Modem response     */
  246.  
  247.  
  248.     caller = 0;
  249.  
  250.     (void) memset ((char *)&remote_addr, 0, sizeof (remote_addr));
  251.     remote_addr.Domain = NULL;             /* only Microsoft can explain this */
  252.  
  253. inloop:
  254.  
  255.     /* Do we have carrier, RING, or NO DIAL TONE? */
  256.  
  257.     if (!answer_now && !(server_mode && CARRIER) && !CHAR_AVAIL ())
  258.         {
  259.         time_release ();
  260.         return (0);                                     /* No, nothing to do  */
  261.         }
  262.  
  263.     mail_only = 1;
  264.     if ((cur_event >= 0) && (e_ptrs[cur_event].behavior & MAT_BBS))
  265.         mail_only = 0;
  266.  
  267. should_answer:
  268.  
  269.     if (KEYPRESS ())                            /* If aborted by user,        */
  270.         return (1);                             /* get out                    */
  271.  
  272.     if (!blank_on_key)
  273.         screen_blank = 0;
  274.  
  275.     if (un_attended && fullscreen)
  276.         sb_show ();
  277.  
  278.     if (server_mode && CARRIER)
  279.         goto got_carrier;
  280.  
  281.     if (answer_now)
  282.         {
  283.         mr = 3;
  284.         answer_now = 0;
  285.         }
  286.     else mr = modem_response (500);
  287.  
  288.     if ((mr == 3) && (ans_str != NULL)) /* saw RING  */
  289.         {
  290.        /*
  291.         * Try to make sure we don't send out the answer string while stuff is
  292.         * still coming from the modem.  Most modems don't like that kind of
  293.         * sequence (including HST's!). 
  294.         */
  295.         t = timerset (100);
  296.         while (CHAR_AVAIL () && (!timeup (t)))
  297.             {
  298.             t = timerset (100);
  299.             (void) MODEM_IN ();
  300.             }
  301.         CLEAR_INBOUND ();
  302.         mdm_cmd_string (ans_str, 0);            /* transmit the answer string */
  303.         goto should_answer;
  304.         }
  305.     else if (mr != 2)
  306.         {
  307.         t = timerset (6000);                    /* set 1 minute timer         */
  308.         while ((!timeup (t))
  309.             && (!CHAR_AVAIL ())
  310.             && (!KEYPRESS ()))
  311.             time_release ();                    /* wait for another result    */
  312.         goto inloop;                            /* then proceed along         */
  313.         }
  314.  
  315. got_carrier:
  316.  
  317.     if (CARRIER)                                /* if we have a carrier,      */
  318.         {
  319.         b_session (0);                          /* do a mail session          */
  320.         mdm_hangup ();                          /* Make sure to hang up       */
  321.  
  322.         /* We got inbound mail */
  323.         if (got_arcmail || got_packet || got_mail)
  324.             {
  325.             receive_exit ();
  326.             }
  327.         }
  328.     else
  329.         mdm_hangup ();                          /* Try to reset modem         */
  330.  
  331.     mailer_banner ();
  332.     return (1);
  333. }
  334.  
  335. void receive_exit ()
  336. {
  337.     char junk1[150];
  338.     int i;
  339.     BINK_EVENT evt;
  340.  
  341.     if (cur_event >= 0)
  342.         evt = e_ptrs [cur_event];
  343.  
  344.     if (cur_event >= 0)
  345.         {
  346.         if (got_arcmail && (evt.errlevel[2]))
  347.             {
  348.             status_line (MSG_TXT(M_EXIT_COMPRESSED),
  349.                           evt.errlevel[2]);
  350.  
  351.             errl_exit (evt.errlevel[2]);
  352.             }
  353.  
  354.         for (i = 0; i < 6; i++)
  355.             {
  356.             if (user_exits[i])
  357.                 {
  358.                 status_line (MSG_TXT(M_EXIT_AFTER_EXTENT),
  359.                               &(evt.err_extent[i][0]),
  360.                                 evt.errlevel[i + 3]);
  361.                 errl_exit (evt.errlevel[i + 3]);
  362.                 }
  363.             }
  364.         }
  365.  
  366.     if ((got_mail || got_packet)
  367.     &&  (cur_event >= 0) && (evt.errlevel[1]))
  368.         {
  369.         status_line (MSG_TXT(M_EXIT_AFTER_MAIL),
  370.                       evt.errlevel[1]);
  371.  
  372.         errl_exit (evt.errlevel[1]);
  373.         }
  374.  
  375.     if ((aftermail != NULL) && (got_mail || got_packet || got_arcmail))
  376.         {
  377.         status_line (MSG_TXT(M_AFTERMAIL));
  378.         mdm_init (modem_busy);
  379.         exit_DTR ();
  380.         screen_clear ();
  381.         vfossil_cursor (1);
  382.         (void) strcpy (junk1, aftermail);
  383.         if (cur_event >= 0)
  384.             (void) strcat (junk1, evt.cmd);
  385.         close_up ();
  386.         b_spawn (junk1);
  387.         come_back ();
  388.         RAISE_DTR ();
  389.         status_line (MSG_TXT(M_OK_AFTERMAIL));
  390.         mdm_init (modem_init);
  391.         xmit_reset ();
  392.         waitfor_line = timerset ((unsigned int)6000);
  393.         }
  394.  
  395.     got_arcmail = 0;
  396.     got_packet = 0;
  397.     got_mail = 0;
  398. }
  399.  
  400. void errl_exit (int n)
  401. {
  402.     write_sched ();
  403.  
  404.     status_line (MSG_TXT (M_BINK_END), ANNOUNCE, COMPILER_NAME);
  405.     mdm_init (modem_busy);                      /* Reinitialize the modem     */
  406.     exit_DTR ();
  407.     if (fullscreen)
  408.         gotoxy (0, SB_ROWS);
  409.  
  410.     if (vfossil_installed)
  411.         vfossil_close ();
  412.  
  413.     if (!share)
  414.         MDM_DISABLE ();
  415.     exit (n);
  416. }
  417.  
  418. long random_time (int x)
  419. {
  420.     int i;
  421.  
  422.     if (x == 0)
  423.         {
  424.         return (0L);
  425.         }
  426.  
  427.     /* Number of seconds to delay is random based on x +/- 50% */
  428.     i = (rand () % (x + 1)) + (x / 2);
  429.  
  430.     return (timerset ((unsigned int) (i * 100)));
  431. }
  432.  
  433.  
  434. char *HoldAreaNameMunge(ADDRP maddr)
  435. {
  436.     static char munged[127];
  437.     register char *p, *q;
  438.     int i;
  439.  
  440.     if ((maddr->Domain != my_addr.Domain) && (maddr->Domain != NULL))
  441.         {
  442.         *domain_loc = '\0';
  443.         (void) strcpy (munged, domain_area);
  444.         q = &(munged[strlen (munged)]);
  445.         for (i = 0; domain_name[i] != NULL; i++)
  446.             {
  447.             if (domain_name[i] == maddr->Domain)
  448.                 {
  449.                 if (domain_abbrev[i] != NULL)
  450.                     {
  451.                     p = domain_abbrev[i];
  452.                     while (*p)
  453.                         *q++ = *p++;
  454.                     if (no_zones)
  455.                         (void) sprintf (q, "\\");
  456.                     else
  457.                         (void) sprintf (q, ".%03x\\", maddr->Zone);
  458.                     }
  459.                 break;
  460.                 }
  461.             }
  462.         }
  463.     else
  464.         {
  465.         (void) strcpy (munged, hold_area);
  466.         q = &(munged[strlen (munged)]);
  467.         if (!((maddr->Zone == alias[0].Zone) || (no_zones)))
  468.            {
  469.            --q;
  470.            (void) sprintf(q,".%03x\\",maddr->Zone);
  471.            }
  472.         }
  473.     return(munged);
  474. }
  475.  
  476.  
  477. void mailer_banner ()
  478. {
  479.     if (fullscreen && un_attended)
  480.         {
  481.         vfossil_cursor (0);
  482.  
  483.         (void) sprintf (junk, "%-2d", cur_event + 1);
  484.         sb_move (settings_hWnd, SET_EVNT_ROW, SET_COL);
  485.         sb_puts (settings_Evt, junk);
  486.  
  487.         (void) sprintf (junk, "%-5u Com%d", cur_baud.rate_value, port_ptr + 1);
  488.         sb_move (settings_hWnd, SET_PORT_ROW, SET_COL);
  489.         sb_puts (settings_Port, junk);
  490.         clear_filetransfer ();
  491.  
  492.         (void) sprintf (junk, "M'Task: %s", mtask_name );
  493.         sb_move (settings_hWnd, SET_TASK_ROW, 2);
  494. #ifndef MILQ
  495.         sb_puts (settings_hWnd, "                   ");
  496. #endif
  497.         sb_move (settings_hWnd, SET_TASK_ROW, 2);
  498.         sb_puts (settings_MTask, junk );
  499.         }
  500.     (void) set_baud (max_baud.rate_value, 0);
  501. }
  502.  
  503. #ifdef MILQ
  504. int PASCAL clear_enum( HWND hWnd,
  505.                        DWORD lParam ) {
  506.   SendMessage( hWnd, WM_SETTEXT, 0, (long)(char far *)"" );
  507.   return TRUE;
  508.   }
  509. #endif
  510.  
  511. void clear_filetransfer ()
  512. {
  513. #ifdef MILQ
  514.     EnumChildWindows( file_hWnd, clear_enum, 0L );
  515. #endif
  516.     FlLnModeSet( FILE_LN_1, 0 );
  517.     FlLnModeSet( FILE_LN_2, 0 );
  518.     if (fullscreen && un_attended)
  519.         sb_fillc (file_hWnd, ' ');
  520. }
  521.  
  522. static char ebuf[50];
  523. char *estring (int e, int how_big)
  524. {
  525.     char j[30];
  526.  
  527.     ebuf[0] = '\0';
  528.     if (e >= 0)
  529.         {
  530.         if (e_ptrs[e].behavior & MAT_BBS)
  531.             {
  532.             (void) strcat (ebuf, "B");
  533.             if (how_big)
  534.                 (void) strcat (ebuf, " ");
  535.             }
  536.         if (e_ptrs[e].behavior & MAT_CM)
  537.             {
  538.             (void) strcat (ebuf, "C");
  539.             if (how_big)
  540.                 (void) strcat (ebuf, " ");
  541.             }
  542.         if (e_ptrs[e].behavior & MAT_DYNAM)
  543.             {
  544.             (void) strcat (ebuf, "D");
  545.             if (how_big)
  546.                 (void) strcat (ebuf, " ");
  547.             }
  548.         if (how_big && (e_ptrs[e].behavior & MAT_FORCED))
  549.             (void) strcat (ebuf, "F ");
  550.         if (e_ptrs[e].behavior & MAT_HIPRICM)
  551.             {
  552.             (void) strcat (ebuf, "H");
  553.             if (how_big)
  554.                 (void) strcat (ebuf, " ");
  555.             }
  556.         if (e_ptrs[e].behavior & MAT_NOCM)
  557.             {
  558.             (void) strcat (ebuf, "K");
  559.             if (how_big)
  560.                 (void) strcat (ebuf, " ");
  561.             }
  562.         if (e_ptrs[e].behavior & MAT_LOCAL)
  563.             {
  564.             (void) strcat (ebuf, "L");
  565.             if (how_big)
  566.                 {
  567.                 if (e_ptrs[e].node_cost >= 0)
  568.                     (void) sprintf (j, "<%d ", (e_ptrs[e].node_cost) + 1);
  569.                 else
  570.                     (void) sprintf (j, ">%d ", -(e_ptrs[e].node_cost) - 1);
  571.                 (void) strcat (ebuf, j);
  572.                 }
  573.             }
  574.         if (how_big && (e_ptrs[e].behavior & MAT_NOMAIL24))
  575.             (void) strcat (ebuf, "M ");
  576.         if (e_ptrs[e].behavior & MAT_NOREQ)
  577.             {
  578.             (void) strcat (ebuf, "N");
  579.             if (how_big)
  580.                 (void) strcat (ebuf, " ");
  581.             }
  582.         if (e_ptrs[e].behavior & MAT_OUTONLY)
  583.             {
  584.             (void) strcat (ebuf, "S");
  585.             if (how_big)
  586.                 (void) strcat (ebuf, " ");
  587.             }
  588.         if (e_ptrs[e].behavior & MAT_NOOUT)
  589.             {
  590.             (void) strcat (ebuf, "R");
  591.             if (how_big)
  592.                 (void) strcat (ebuf, " ");
  593.             }
  594.         if (how_big && (e_ptrs[e].behavior & MAT_NOOUTREQ))
  595.             (void) strcat (ebuf, "X");
  596.         }
  597.     return (ebuf);
  598. }
  599.  
  600. void do_ready (char *str)
  601. {
  602.     if (fullscreen && un_attended)
  603.         {
  604.         if (!doing_poll)
  605.             {
  606.             clear_filetransfer ();
  607.             }
  608.         (void) sprintf (junk, "%-2d/%-6.6s", cur_event + 1, estring (cur_event, 0));
  609.         sb_move (settings_hWnd, SET_EVNT_ROW, SET_COL);
  610.         sb_puts (settings_Evt, junk);
  611.         sb_move (settings_hWnd, SET_STAT_ROW, SET_COL);
  612.         sb_puts (settings_Status, str);
  613.         SendMessage( settings_hWnd, WM_COMMAND, GD_DSP, 0L );
  614.         sb_show ();
  615.         }
  616. }
  617.  
  618. void list_next_event ()
  619. {
  620.     int i, k;
  621.     int read[2];
  622.     char *p;
  623.     char j[100];
  624.     FILE *fpt;
  625.     struct FILEINFO dta;
  626.  
  627.     i = time_to_next (0);
  628.  
  629.     if ((next_event >= 0) && fullscreen)
  630.         {
  631.         clear_filetransfer ();
  632.  
  633.         (void) sprintf (j, MSG_TXT(M_NEXT_EVENT), next_event + 1, i);
  634.         sb_move (file_hWnd, 1, 2);
  635.         sb_puts( GetDlgItem( file_hWnd, FILE_LN_1 ), j );
  636.         p = estring (next_event, 1);
  637.         if (*p != '\0')
  638.             {
  639.             (void) sprintf (j, MSG_TXT(M_EVENT_FLAGS), p);
  640.             sb_move (file_hWnd, 2, 2);
  641.             FlLnModeSet( FILE_LN_2, 0 );
  642.             sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 ), j );
  643.             }
  644.         if (netmail != NULL)
  645.             {
  646.             (void) strcpy (j, netmail);
  647.             (void) strcat (j, "LASTREAD");          /* Full path to LASTREAD  */
  648.  
  649.             fpt = share_fopen (j, "rb", DENY_WRITE);/* Open the file          */
  650.             if (fpt != NULL)
  651.                 {
  652.             /*
  653.              * Try to read two records. If there are two, the first record is the
  654.              * current pointer and the second one is the last-read. If there is
  655.              * one record, it is the last-read.
  656.              */
  657.  
  658.                 i = fread (read, sizeof (int), 2, fpt); /* Get lastread ptr   */
  659.                 (void) fclose (fpt);                    /* Then close the file*/
  660.                 if (i)
  661.                     {
  662.                     k = read [i-1];                     /* Last msg read      */
  663.                     (void) strcpy (j, netmail);
  664.                     (void) strcat (j, "*.msg");         /* Wildcard for .MSG  */
  665.                     if (!dfind (&dta, j, 0))            /* If there are any,  */
  666.                         {
  667.                         do
  668.                             {
  669.                             if (atoi(dta.name) > k)     /* See if one's more  */
  670.                                 {
  671.                                 sb_move (file_hWnd, 2, 50);
  672.                                 sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 + GD_STATUS ),
  673.                                          MSG_TXT(M_UNREAD_NETMAIL));
  674.                                 break;
  675.                                 }
  676.                             }
  677.                         while (!dfind (&dta, j, 1));    /* Check all of them  */
  678.                         }
  679.                     }   /* If any records read from LASTREAD */
  680.                 }       /* If we were able to open LASTREAD  */
  681.             }           /* If the user specified NetMail     */
  682.  
  683.         sb_show ();
  684.         }               /* If next event and fullscreen      */
  685. }
  686.  
  687.