home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / MAILER.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  30KB  |  877 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. /*                                                                          */
  20. /*    For complete  details  of the licensing restrictions, please refer    */
  21. /*    to the License  agreement,  which  is published in its entirety in    */
  22. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  23. /*                                                                          */
  24. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  25. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  26. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  27. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  28. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  29. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  30. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  31. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  32. /*                                                                          */
  33. /*                                                                          */
  34. /* You can contact Bit Bucket Software Co. at any one of the following      */
  35. /* addresses:                                                               */
  36. /*                                                                          */
  37. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  38. /* P.O. Box 460398                AlterNet 7:491/0                          */
  39. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  40. /*                                Internet f491.n343.z1.fidonet.org         */
  41. /*                                                                          */
  42. /* Please feel free to contact us at any time to share your comments about  */
  43. /* our software and/or licensing policies.                                  */
  44. /*                                                                          */
  45. /*--------------------------------------------------------------------------*/
  46.  
  47. /* Include this file before any other includes or defines! */
  48.  
  49. #include "includes.h"
  50.  
  51. int poll_node (ADDRP);
  52. int call_node (ADDRP, int);
  53.  
  54. int unattended ()
  55. {
  56. #ifdef MILQ
  57.     REGIONP OldCurWin = CurWinSet( callwin );
  58. #endif
  59.     int no_inbound = 0;
  60.     int j, m;
  61.     long init_timer, t = -1L, t1;                   /* used for the timeouts  */
  62.     long blank_timer;
  63.     struct _key_fnc_hdr *OldKeyFncHdr;
  64.     int done = 1;                                   /* if we exit with this, 
  65.                                                      * get out of BT          */
  66.     HFILE stream;
  67.     USHORT got;
  68.  
  69. #ifdef MILQ
  70.     HWND                OldActvAccel = MilqueActvAccel;
  71.     HWND                OldActvWnd = MilqueActvWnd;
  72.  
  73.     MilqueActvAccel = MilqueMailerAccel;
  74.     MilqueActvWnd = MilqueMailerWnd;
  75.     SetFocus( MilqueMailerActvWnd );
  76. #endif
  77.  
  78.     un_attended = 1;
  79.     clear_statusline ();
  80.  
  81.     comm_bits = BITS_8;
  82.     parity = NO_PARITY;
  83.     stop_bits = STOP_1;
  84.     program_baud ();
  85.  
  86.     OldKeyFncHdr = KbMapSet (&UnattendedKeyFncHdr);
  87.  
  88.     if (fullscreen)
  89.         {
  90.         screen_clear ();
  91.         sb_dirty ();
  92.         }
  93.  
  94.     opening_banner ();
  95.  
  96.     if (fullscreen)
  97.         {
  98.         mailer_banner ();
  99.         }
  100.  
  101.     if ((stream = share_open (PRDCT_PRFX ".BAN", O_RDONLY|O_BINARY, DENY_WRITE)) != -1)
  102.         {
  103.         (void)_dos_read (stream, BBSwelcome, WELCOME_LEN, &got);
  104.         (void) close (stream);
  105.         }
  106.     else
  107.         {
  108.         BBSwelcome[0] = '\0';
  109.         }
  110.  
  111.     /* Initialize the random number generator */
  112.     j = (int) time (NULL);
  113.     srand ((unsigned int) j);
  114.  
  115.     status_line (MSG_TXT(M_BINK_BEGIN), ANNOUNCE, COMPILER_NAME);
  116.     set_xy ("");
  117.  
  118.     set_prior(4);                                           /* Always High    */
  119.     XON_DISABLE ();
  120.     set_prior(2);                                           /* Regular        */
  121.  
  122.     /* Turn off forced events */
  123.     if (noforce)
  124.         {
  125.         find_event ();
  126.         noforce = 0;
  127.         }
  128.     if (redo_dynam)
  129.         {
  130.         for (j = 0; j < num_events; j++)
  131.             {
  132.             e_ptrs[j].behavior &= ~MAT_SKIP;
  133.             }
  134.         redo_dynam = 0;
  135.         }
  136.  
  137.     /*
  138.      * See if we should exit before initializing the modem (and therefore
  139.      * possibly letting a call sneak through)
  140.      */
  141.  
  142.     find_event ();
  143.     do_ready (MSG_TXT(M_READY_INIT));
  144.  
  145.     /* Make sure we have all necessary parameters and that the nodelist
  146.      * index gets read in. If not, then we must exit right now.
  147.      */
  148.  
  149.     if (!net_params || !nodefind (&boss_addr, 0))
  150.         if (boss_addr.Net != 0xffff)
  151.             {
  152.             status_line (MSG_TXT(M_MISCONFIGURED));
  153.             errl_exit (254);
  154.             }
  155.  
  156.     /* Set up outbound mail */
  157.     list_next_event ();
  158.     set_up_outbound ();
  159.  
  160.     if (!CARRIER)
  161.         {
  162.         mdm_init (modem_init);                              /* Reinit modem   */
  163.         }
  164.  
  165.     blank_timer = timerset ((unsigned int)blank_time);/* Set a timer  */
  166.     init_timer = timerset ((unsigned int)60000);    /* Set a 10 minute timer  */
  167.     t1 = timerset ((unsigned) next_minute ());      /* Set a 1 minute timer   */
  168.     waitfor_line = timerset ((unsigned int)6000);   /* no collisions for 1 min*/
  169.  
  170. top_of_mail:
  171.     un_attended = 1;
  172.     no_inbound = 0;
  173.     m = 1;
  174.  
  175.     /* As long as we don't press a key */
  176. bad_char:
  177.     more_mail = 1;
  178.     while (!(KEYPRESS () || ctrlc_ctr))
  179.         {
  180.         find_event ();
  181. #ifdef MILQ
  182.         if ( hold_hWnd != GetFocus() )
  183.           SendMessage( node_hWnd, WM_COMMAND, GD_LAST, (long)&hist.last_addr );
  184. #endif
  185.         /* Show that we are ready */
  186.         if (m)
  187.             {
  188.             if (fullscreen)
  189.                 {
  190.                 do_ready (MSG_TXT(M_READY_WAITING));
  191.                 list_next_event ();
  192.                 }
  193.             else
  194.                 status_line (MSG_TXT(M_EVENT_WAITING), cur_event + 1);
  195.  
  196.             blank_timer = timerset ((unsigned int)blank_time);/* Set a timer  */
  197.             init_timer = timerset ((unsigned int)60000);/* Set a 10 min timer */
  198.             t1 = timerset ((unsigned) next_minute ());  /* Set a 1 min timer  */
  199.             }
  200.  
  201.         if (timeup (t1))
  202.             {
  203.             put_up_time ();
  204.             list_next_event ();
  205.             t1 = timerset ((unsigned) next_minute ());  /* Set a 1 min timer  */
  206.             }
  207.  
  208.         /* See if blanking interval has elapsed */
  209.         if (timeup (blank_timer))
  210.             {
  211.             blank_timer = timerset ((unsigned int)blank_time);
  212.             screen_blank = 1;
  213.             if (fullscreen)
  214.                 sb_show ();
  215.             }
  216.  
  217.         /* If we haven't gotten anything in 10 minutes, re-init the modem */
  218.         if (timeup (init_timer))
  219.             {
  220.             mdm_init (modem_init);
  221.             init_timer = timerset ((unsigned int)60000); /* Set a 10 minute timer */
  222.  
  223.             /*
  224.              * Say that we have more mail so that things entered through other
  225.              * side of a multi-tasker will still go out
  226.              */
  227.  
  228.             set_up_outbound ();
  229.             more_mail = 1;
  230.             }
  231.  
  232.         m = 0;
  233.  
  234.         if (cur_event >= 0)
  235.             no_inbound = (e_ptrs[cur_event].behavior & MAT_OUTONLY);
  236.         else
  237.             no_inbound = 1;
  238.  
  239.         if (t != -1L)
  240.             t = random_time ((cur_event >= 0) ? e_ptrs[cur_event].wait_time : 5);
  241.         else 
  242.             t = timerset (1000);
  243.  
  244.        /*  variable 'no_inbound' will be TRUE if we are manually dialing out
  245.         *  or if we are in an event where we do not want incoming stuff.
  246.         */
  247.  
  248.         while ((!timeup (t)) && (!KEYPRESS ()) && (m == 0) && !ctrlc_ctr)
  249.             {
  250.             find_event ();
  251.             time_release ();
  252.             if (timeup (t1))
  253.                 {
  254.                 put_up_time ();
  255.                 list_next_event ();
  256.                 t1 = timerset ((unsigned) next_minute ());/* Set a 1 min timer*/
  257.                 }
  258.  
  259.             /* If we want inbound, see if there is any. If we send
  260.                 anything, clean up afterwards ...         */
  261.  
  262.             if (!no_inbound)
  263.                 {
  264.                 m = handle_inbound_mail (0);
  265.                 if (m)
  266.                     xmit_sameplace ();
  267.                 }
  268.             }
  269.  
  270.         if ((m) && (fullscreen))
  271.             {
  272.             do_ready (MSG_TXT(M_READY_WAITING));
  273.             list_next_event ();
  274.             }
  275.  
  276. immed_call:
  277.  
  278.         find_event ();
  279.  
  280.         /* If we have pressed a key, get out */
  281.  
  282.         if (KEYPRESS () || ctrlc_ctr)
  283.             break;
  284.  
  285.         /* If we are not in an event, or if this is a no-outbound
  286.            event, loop again */
  287.  
  288.         if ((cur_event < 0) || (e_ptrs[cur_event].behavior & MAT_NOOUT))
  289.             {
  290.             time_release ();
  291.             continue;
  292.             }
  293.  
  294.         if (more_mail)
  295.             more_mail = xmit_next (&next_addr);
  296.  
  297.         if (more_mail)
  298.             m = call_node (&next_addr, no_inbound);
  299.         else
  300.             {
  301.             /* No more mail to do, was it dynamic? */
  302.             if (e_ptrs[cur_event].behavior & MAT_DYNAM)
  303.                 {
  304.                 if (!blank_on_key)
  305.                     screen_blank = 0;
  306.                 e_ptrs[cur_event].behavior |= MAT_SKIP;
  307.                 status_line (":%s %s %d", MSG_TXT(M_END_OF), MSG_TXT(M_DYNAMIC_EVENT), cur_event + 1);
  308.                 t = -1L;
  309.                 goto top_of_mail;
  310.                 }
  311.             }
  312.         }
  313.  
  314.     screen_blank = 0;
  315.     if (fullscreen)
  316.         sb_show ();
  317.  
  318.     /* Eat the character we pressed */
  319.     if (ctrlc_ctr || !KEYPRESS ())
  320.         {
  321.         /*
  322.          * Be serious, there had to be a key pressed or we wouldn't be here I
  323.          * know it sounds silly, but ^C will sometimes do crap like this
  324.          */
  325.         status_line (MSG_TXT(M_EXIT_REQUEST));
  326.         }
  327.     else
  328.         {
  329.         blank_timer = timerset ((unsigned int)blank_time);/* Set a timer  */
  330.         j = (int) KbRemap (FOSSIL_CHAR ());
  331.         if (((unsigned)j & F_UN_BASE) == F_UN_BASE)
  332.             switch ((unsigned)j)
  333.                 {
  334.                 case F_UN_FUNKEY1:
  335.                 case F_UN_FUNKEY2:
  336.                 case F_UN_FUNKEY3:
  337.                 case F_UN_FUNKEY4:
  338.                 case F_UN_FUNKEY5:
  339.                 case F_UN_FUNKEY6:
  340.                 case F_UN_FUNKEY7:
  341.                 case F_UN_FUNKEY8:
  342.                 case F_UN_FUNKEY9:
  343.                 case F_UN_FUNKEY10:
  344.                     j = 1 + (int)((unsigned) j - (unsigned)F_UN_FUNKEY1);
  345.                     status_line (MSG_TXT(M_FUNCTION_KEY), j * 10);
  346.                     errl_exit (j * 10);
  347.                     break;
  348.  
  349.                 case F_UN_BLANKSCREEN:
  350.                     screen_blank = 1;
  351.                     if (fullscreen)
  352.                         sb_show ();
  353.                     break;
  354.  
  355.                 case F_UN_CLEARHIST:
  356.                     j = hist.which_day;
  357.                     (void) memset (&hist, 0, sizeof (HISTORY));
  358.                     hist.which_day = j;
  359.                     if (fullscreen)
  360.                         {
  361.                         do_today ();
  362.                         sb_show ();
  363.                         }
  364.                     break;
  365.  
  366.                 case F_UN_MSGEDITOR:
  367.                     if (BBSreader != NULL)
  368.                         {
  369.                         vfossil_cursor (1);
  370.                         status_line (MSG_TXT(M_DISABLE_MODEM));
  371.                         mdm_init (modem_busy);
  372.                         exit_DTR ();
  373.                         status_line (MSG_TXT(M_BEGIN_MESSAGE_READER));
  374.                         vfossil_close ();
  375.                         b_spawn (BBSreader);
  376.                         vfossil_init ();
  377.                         if (fullscreen)
  378.                             {
  379.                             screen_clear ();
  380.                             sb_dirty ();
  381.                             opening_banner ();
  382.                             mailer_banner ();
  383.                             }
  384.                         status_line (MSG_TXT(M_END_MESSAGE_READER));
  385.                         set_up_outbound ();
  386.                         m = 1;
  387.                         more_mail = 1;
  388.                         status_line (MSG_TXT(M_ENABLE_MODEM));
  389.                         RAISE_DTR ();
  390.                         mdm_init (modem_init);
  391.                         waitfor_line = timerset ((unsigned int)6000);
  392.                         }
  393.                     else
  394.                         {
  395.                         set_xy (NULL);
  396.                         status_line (MSG_TXT(M_NO_MESSAGE_READER));
  397.                         set_xy (NULL);
  398.                         m = 1;
  399.                         }
  400.                     break;
  401.  
  402.                 case F_UN_GETFILE:
  403.                     if (sb_popup (10, 10, 7, 60, Do_Get, 0))
  404.                         {
  405.                         status_line (MSG_TXT(M_NO_GET));
  406.                         }
  407.                     else
  408.                         {
  409.                         set_up_outbound ();
  410.                         m = 1;
  411.                         more_mail = 1;
  412.                         }
  413.                     break;
  414.  
  415.                 case F_UN_REINITMODEM:
  416.                     /* The idea for this code came from Holger Schurig */
  417.                     mdm_hangup ();
  418.                     set_up_outbound ();
  419.                     m = 1;
  420.                     more_mail = 1;
  421.                     break;
  422.  
  423.                 case F_UN_SHELL:
  424.                     status_line (MSG_TXT(M_SHELLING));
  425.                     if (fullscreen)
  426.                         gotoxy (0, SB_ROWS);
  427.                     vfossil_cursor (1);
  428.                     (void) cputs (MSG_TXT(M_TYPE_EXIT));
  429.                     LOWER_DTR ();
  430.                     change_prompt ();
  431.                     b_spawn (NULL);
  432.                     if (fullscreen)
  433.                         {
  434.                         screen_clear ();
  435.                         sb_dirty ();
  436.                         opening_banner ();
  437.                         mailer_banner ();
  438.                         }
  439.                     status_line (MSG_TXT(M_BINKLEY_BACK));
  440.                     m = 1;
  441.                     set_up_outbound ();
  442.                     set_prior(4);                            /* Always High */
  443.                     RAISE_DTR ();
  444.                     set_prior(2);                            /* Regular */
  445.                     break;
  446.  
  447.  
  448.                 case F_UN_KILLNODESMAIL:
  449.                     if (sb_popup (10, 5, 4, 70, Do_Kill, 0))
  450.                         {
  451.                         status_line (MSG_TXT(M_NO_KILL));
  452.                         }
  453.                     else
  454.                         {
  455.                         set_up_outbound ();
  456.                         m = 1;
  457.                         more_mail = 1;
  458.                         }
  459.                     break;
  460.  
  461.                 case F_UN_POLLBOSS:
  462.                     (void) poll_node (&boss_addr);
  463.                     m = 1;
  464.                     break;
  465.  
  466.                 case F_UN_ANSWER:
  467.                     if (ans_str != NULL)
  468.                         mdm_cmd_string (ans_str, 0);
  469.                     break;
  470.  
  471.                 case F_UN_POLLNODE:
  472.                     (void) poll_node ((ADDRP)NULL);
  473.                     m = 1;
  474.                     break;
  475.  
  476.                 case F_UN_QUITTHISEVENT:
  477.                     if (cur_event >= 0)
  478.                         e_ptrs[cur_event].behavior |= MAT_SKIP;
  479.                     goto top_of_mail;
  480.  
  481.                 case F_UN_RESTARTEVENTS:
  482.                     for (j = 0; j < num_events; j++)
  483.                         {
  484.                         /* Don't redo forced events */
  485.                         if (!(e_ptrs[j].behavior & MAT_FORCED))
  486.                             {
  487.                             e_ptrs[j].last_ran = (char)-1;
  488.                             e_ptrs[j].behavior &= ~MAT_SKIP;
  489.                             }
  490.                         }
  491.                     goto top_of_mail;
  492.  
  493.                 case F_UN_SENDFILE:
  494.                     if (sb_popup (10, 5, 6, 70, Do_Send, 0))
  495.                         {
  496.                         status_line (MSG_TXT(M_NO_SEND));
  497.                         }
  498.                     else
  499.                         {
  500.                         set_up_outbound ();
  501.                         m = 1;
  502.                         more_mail = 1;
  503.                         }
  504.                     break;
  505.  
  506.                 case F_UN_TERMINALMODE:
  507.                     status_line (MSG_TXT(M_ENTER_TERMINAL_MODE));
  508.                     done = 0;                                 /* We won't exit now */
  509.                     goto mail_done;
  510.  
  511.                 case F_UN_REPAINTSCREEN:
  512.                     if (fullscreen)
  513.                         {
  514.                         screen_clear ();
  515.                         sb_dirty ();
  516.                         sb_show ();
  517.                         }
  518.                     break;
  519.  
  520.                 case F_UN_HELPSCREEN:
  521.                     mailer_help ();
  522.                     if (fullscreen)
  523.                         {
  524.                         screen_clear ();
  525.                         sb_dirty ();
  526.                         opening_banner ();
  527.                         mailer_banner ();
  528.                         }
  529.                     m = 1;
  530.                     break;
  531.  
  532.                 case F_UN_EXITBINK:
  533.                     status_line (MSG_TXT(M_EXIT_REQUEST));
  534.                     goto mail_done;
  535.  
  536.                 case F_UN_SHELL1:
  537.                 case F_UN_SHELL2:
  538.                 case F_UN_SHELL3:
  539.                 case F_UN_SHELL4:
  540.                 case F_UN_SHELL5:
  541.                 case F_UN_SHELL6:
  542.                 case F_UN_SHELL7:
  543.                 case F_UN_SHELL8:
  544.                 case F_UN_SHELL9:
  545.                     j = (int) ((unsigned) j - (unsigned)F_UN_SHELL1);
  546.                     if (shells[j] != NULL)
  547.                         {
  548.                         status_line (MSG_TXT(M_KEYBOARD_SHELL), j + 1);
  549.                         mdm_init (modem_busy);
  550.                         exit_DTR ();
  551.                         close_up ();
  552.                         vfossil_cursor (1);
  553.                         b_spawn (shells[j]);
  554.                         come_back ();
  555.                         m = 1;
  556.                         status_line (MSG_TXT(M_END_KEYBOARD_SHELL));
  557.                         screen_clear ();
  558.                         if (fullscreen)
  559.                             sb_dirty ();
  560.                         opening_banner ();
  561.                         mailer_banner ();
  562.                         set_up_outbound ();
  563.                         RAISE_DTR ();
  564.                         mdm_init (modem_init);
  565.                         waitfor_line = timerset ((unsigned int)6000);
  566.                         }
  567.                     else
  568.                         status_line (MSG_TXT(M_NO_KEYBOARD_SHELL), j + 1);
  569.                     break;
  570.  
  571.                 case F_PEND_PGUP:
  572.                     if (next_mail == NULL)
  573.                         {
  574.                         next_mail = mail_top;
  575.                         }
  576.  
  577.                     if (next_mail != NULL)
  578.                         {
  579.                         for (j = 0; j < SB_ROW_HOLD; j++)
  580.                             {
  581.                             if (next_mail->prev != NULL)
  582.                                 next_mail = next_mail->prev;
  583.                             }
  584.                         xmit_window (next_mail);
  585.                         }
  586.                     break;
  587.  
  588.                 case F_PEND_PGDN:
  589.                     if (next_mail == NULL)
  590.                         {
  591.                         next_mail = mail_top;
  592.                         }
  593.  
  594.                     if (next_mail != NULL)
  595.                         {
  596.                         for (j = 0; j < SB_ROW_HOLD; j++)
  597.                             {
  598.                             if (next_mail->next != NULL)
  599.                                 next_mail = next_mail->next;
  600.                             }
  601.                         xmit_window (next_mail);
  602.                         }
  603.                     break;
  604.  
  605.                 case F_PEND_UPAR:
  606.                     if (next_mail == NULL)
  607.                         {
  608.                         next_mail = mail_top;
  609.                         }
  610.  
  611.                     if (next_mail != NULL)
  612.                         {
  613.                         if (next_mail->prev != NULL)
  614.                             next_mail = next_mail->prev;
  615.                         xmit_window (next_mail);
  616.                         }
  617.                     break;
  618.  
  619.                 case F_PEND_DNAR:
  620.                     if (next_mail == NULL)
  621.                         {
  622.                         next_mail = mail_top;
  623.                         }
  624.  
  625.                     if (next_mail != NULL)
  626.                         {
  627.                         if (next_mail->next != NULL)
  628.                             next_mail = next_mail->next;
  629.                         xmit_window (next_mail);
  630.                         }
  631.                     break;
  632.  
  633.                 case F_PEND_HOME:
  634.                     next_mail = mail_top;
  635.                     xmit_window (next_mail);
  636.                     break;
  637.  
  638.                 case F_PEND_END:
  639.                     if (next_mail == NULL)
  640.                         {
  641.                         next_mail = mail_top;
  642.                         }
  643.  
  644.                     if (next_mail != NULL)
  645.                         {
  646.                         while (next_mail->next != NULL)
  647.                             {
  648.                             next_mail = next_mail->next;
  649.                             }
  650.                         }
  651.  
  652.                     for (j = 0; j < (SB_ROW_HOLD - 1); j++)
  653.                         {
  654.                         if (next_mail->prev != NULL)
  655.                             next_mail = next_mail->prev;
  656.                         }
  657.                     xmit_window (next_mail);
  658.                     break;
  659.  
  660.                 case F_UN_CALLRIGHTNOW:
  661.                     if (cur_event >= 0)
  662.                         if (e_ptrs[cur_event].behavior & MAT_NOOUT)
  663.                             {
  664.                             status_line (MSG_TXT(M_NO_CALLS_NOW));
  665.                             goto immed_call;
  666.                             }
  667.  
  668.                     status_line (MSG_TXT(M_IMMEDIATE_CALL));
  669.                     m = 0;
  670.                     more_mail = 1;
  671.                     goto immed_call;
  672.  
  673.                 default:
  674.                     status_line (MSG_TXT(M_JUNK_CHARACTER));
  675.                     m = 1;
  676.                     break;
  677.                 }
  678.         else
  679.             switch (toupper (j & 0xff))
  680.                 {
  681.                 case 3:
  682.                     status_line (MSG_TXT(M_EXIT_REQUEST));
  683.                     goto mail_done;
  684.  
  685.                 case 0x20:
  686.                     m = 1;
  687.                     break;
  688.  
  689.                 default:
  690.                     status_line (MSG_TXT(M_JUNK_CHARACTER));
  691.                     m = 1;
  692.                     break;
  693.                 }
  694.         goto bad_char;
  695.         }
  696.  
  697. mail_done:
  698.  
  699.     write_sched ();
  700.     status_line (MSG_TXT (M_BINK_END), ANNOUNCE, COMPILER_NAME);
  701.     un_attended = 0;
  702.     if (fullscreen)
  703.         {
  704.         gotoxy (0, SB_ROWS);
  705.         }
  706.     set_prior(4);                                            /* Always High */
  707.     XON_ENABLE ();
  708.     set_prior(2);                                            /* Regular */
  709.     (void) KbMapSet(OldKeyFncHdr);
  710.  
  711. #ifdef MILQ
  712.     MilqueActvAccel = OldActvAccel;
  713.     MilqueActvWnd = OldActvWnd;
  714.     MilqueMailerActvWnd = GetFocus();
  715.     CurWinSet( OldCurWin );
  716. #endif
  717.  
  718.  
  719.     return (done);
  720. }
  721.  
  722. /*
  723.  * Poll a node. If address is supplied, use it. Otherwise,
  724.  * make a popup and ask for it.
  725.  */
  726.  
  727. int poll_node (ADDRP address)
  728. {
  729.    int m;
  730.    char jbuf[90];
  731.  
  732.    if (address == (ADDRP)NULL)
  733.       {
  734.       status_line (MSG_TXT(M_POLL_MODE));
  735.  
  736.       if (!fullscreen)
  737.          {
  738.          scr_printf ("\r\n");
  739.          clear_eol ();
  740.          scr_printf (MSG_TXT(M_ENTER_NET_NODE));
  741.          m = get_number (jbuf);
  742.          if (m)
  743.              {
  744.              m = find_address (jbuf, &next_addr);
  745.              }
  746.          if (!(m >= 1 && nodefind (&next_addr, 1)))
  747.              return (-1);
  748.          }
  749.       else
  750.          if (!sb_popup (10, 10, 4, 60, Do_Poll, 0))
  751.             {
  752.             status_line (MSG_TXT(M_POLL_COMPLETED));
  753.             return (-1);
  754.             }
  755.       }
  756.    else
  757.       next_addr = *address;
  758.  
  759.    doing_poll = 1;
  760.    if (fullscreen)
  761.        {
  762.        sprintf( junk,
  763.                 "%s %s",
  764.                   MSG_TXT(M_CURRENTLY_POLLING),
  765.                   Full_Addr_Str( &next_addr ) );
  766.        sb_move (file_hWnd, 1, 2);
  767.        FlLnModeSet( FILE_LN_1, 0 );
  768.        sb_puts( GetDlgItem( file_hWnd, FILE_LN_1 ), junk );
  769.        }
  770.    set_prior(4);                        /* Always High */
  771.    if ((do_mail (&next_addr, 1) == 1) && sent_mail)
  772.        {
  773.        next_mail = find_mail (&next_addr);
  774.        (void) bad_call (&next_addr, -1);
  775.        xmit_delete ();
  776.        }
  777.    set_prior(2);                        /* Regular */
  778.    doing_poll = 0;
  779.  
  780.    status_line (MSG_TXT(M_POLL_COMPLETED));
  781.    if (fullscreen)
  782.        {
  783.        mailer_banner ();
  784.        clear_filetransfer ();
  785.        }
  786.    RAISE_DTR ();
  787.    mdm_init (modem_init);
  788.    return (0);
  789. }
  790.  
  791. /*
  792.  * Call a node. If we get through, do call accounting. If
  793.  * we have a dialout collision, try to get the inbound.
  794.  */
  795.  
  796. int call_node (ADDRP address, int no_inbound)
  797. {
  798.     MAILP mp;
  799.     int m;
  800.  
  801.     /* save the next call in the list in case we exit */
  802.  
  803.     if ((next_mail == NULL) || (next_mail->next == NULL))
  804.         {
  805.         mp = mail_top;
  806.         }
  807.     else
  808.         {
  809.         mp = next_mail->next;
  810.         }
  811.     hist.next_addr = mp->mail_addr;
  812.  
  813.     /* If this is a CM call, tell do_mail not to pay
  814.        attention to the nodelist flags! */
  815.  
  816.     if ((e_ptrs[cur_event].behavior & (MAT_CM | MAT_HIPRICM))
  817.     &&  (next_mail->mailtypes & MAIL_CRASH))
  818.          m = -1;
  819.     else m =  0;
  820.  
  821.     set_prior(4);                               /* Always High    */
  822.     m = do_mail (address, m);
  823.     set_prior(2);                               /* Regular        */
  824.  
  825. /*
  826.  * If there was a session, handle bad-call accounting
  827.  * based on whether the session was a complete success
  828.  * or not. Then take an exit if appropriate, based on
  829.  * what actually arrived here.
  830.  */
  831.     if (m > 0)
  832.         {
  833.         if (m == 1)         /* There was a good session */
  834.             {
  835.             if (!sent_mail)
  836.                 {
  837.                 /* We connected but the transfer didn't work */
  838.                 (void) bad_call (address, 1);
  839.                 }
  840.             else
  841.                 {
  842.                 /* We got through, so delete his status file */
  843.                 (void) bad_call (address, -1);
  844.                 xmit_delete ();
  845.                 }
  846.             }
  847.  
  848.         if (m == 2)         /* Nothing happened */
  849.             (void) bad_call (address, 2);
  850.  
  851.         /* Take an exit if we got something in */
  852.  
  853.         if (got_arcmail || got_packet || got_mail)
  854.             receive_exit ();
  855.         mailer_banner ();
  856.         }
  857.     else if (m < 0)
  858.         {
  859.         if (m == -1)
  860.             status_line (MSG_TXT(M_INCOMING_CALL));
  861.        
  862.         /* Call collision or NO-DIAL-TONE. Try to answer the
  863.            call in time to catch the remote. Exception: if it
  864.            has been less than a minute since unbusying the line. */
  865.  
  866.         if (!no_inbound && timeup (waitfor_line))
  867.             {
  868.             m = handle_inbound_mail (1);
  869.             if (m)
  870.                 xmit_sameplace ();
  871.             }
  872.         }
  873.  
  874.     return (m);
  875. }
  876.  
  877.