home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / bsrc_260.arj / SRC.ZIP / mdm_proc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  19.4 KB  |  731 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 Modem Handler Module                      */
  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. static int LOCALFUNC dial_modem (char *);
  49. static void LOCALFUNC phone_translate (char *, char *);
  50. static int LOCALFUNC parse_response (char *);
  51. static void LOCALFUNC empty_delay (void);
  52. static void LOCALFUNC MNP_Filter (void);
  53.  
  54. static char response_string[128];
  55.  
  56. void 
  57. do_dial_strings ()
  58. {
  59.     MDM_TRNS *m;
  60.  
  61.     predial = normprefix;
  62.     postdial = normsuffix;
  63.  
  64.     m = mm_head;
  65.     while (m != NULL)
  66.     {
  67.         if ((m->mdm == newnodedes.ModemType) &&
  68.             (*(m->pre) || *(m->suf)))
  69.         {
  70.             predial = m->pre;
  71.             postdial = m->suf;
  72.             return;
  73.         }
  74.         m = m->next;
  75.     }
  76. }
  77.  
  78. void 
  79. try_2_connect (char *phnum)
  80. {
  81.     long t1;
  82.     int j, k;
  83.  
  84.     for (j = 0; (j < poll_tries && !KEYPRESS ()); j++)    /* do polltries or till keypress */
  85.     {
  86.         CLEAR_INBOUND ();
  87.         k = dial_modem (phnum);
  88.  
  89.         if ((un_attended || doing_poll) && fullscreen)
  90.         {
  91.             ++hist.calls_made;
  92.             (void) sprintf (junk, "%-4d", hist.calls_made);
  93.             sb_move (historywin, HIST_ATT_ROW, HIST_COL);
  94.             sb_puts (historywin, junk);
  95.         }
  96.  
  97.         if ((k > 0) || KEYPRESS ())
  98.             break;
  99.         t1 = timerset (200);
  100.         mdm_hangup ();
  101.         while (!timeup (t1) && !KEYPRESS ())
  102.             time_release ();    /* pause for 2 seconds */
  103.     }
  104.     if (KEYPRESS ())            /* If user's been busy */
  105.     {
  106.         (void) FOSSIL_CHAR ();    /* Eat the character   */
  107.         if (!CARRIER)            /* Abort if no carrier */
  108.         {
  109.             status_line (MSG_TXT (M_CONNECT_ABORTED));
  110.             mdm_hangup ();
  111.         }
  112.     }
  113.  
  114.     predial = normprefix;
  115.     postdial = normsuffix;
  116. }
  117.  
  118. int 
  119. try_1_connect (char *phnum)
  120. {
  121.     int k;
  122.  
  123.     if ((k = dial_modem (phnum)) <= 0)
  124.     {
  125.         if (k != -2)            /* NO DIAL TONE needs express service */
  126.             mdm_hangup ();
  127.     }
  128.  
  129.     if ((un_attended || doing_poll) && fullscreen)
  130.     {
  131.         ++hist.calls_made;
  132.         (void) sprintf (junk, "%-4d", hist.calls_made);
  133.         sb_move (historywin, HIST_ATT_ROW, HIST_COL);
  134.         sb_puts (historywin, junk);
  135.     }
  136.  
  137.     predial = normprefix;
  138.     postdial = normsuffix;
  139.  
  140.     return (k);
  141. }
  142.  
  143. static void LOCALFUNC 
  144. phone_translate (char *number, char *translated)
  145. {
  146.     PN_TRNS *p;
  147.  
  148.     (void) strcpy (translated, number);
  149.     for (p = pn_head; p != NULL; p = p->next)
  150.     {
  151.         if (strncmp (p->num, number, (unsigned int) (p->len)) == 0)
  152.         {
  153.             (void) sprintf (translated, "%s%s%s", p->pre, &(number[p->len]), p->suf);
  154.             break;
  155.         }
  156.     }
  157. }
  158.  
  159. static int LOCALFUNC 
  160. dial_modem (char *numbertocall)
  161. {
  162.     int resp;
  163.     int retval = 0;
  164.  
  165.     long t;
  166.     char *translated = response_string;
  167.  
  168.     P_ANUMS altnums = anum_head;
  169.     char *number = numbertocall;
  170.     int dialmsg = M_DIALING_NUMBER;
  171.  
  172.     janus_OK = 0;
  173.     ARQ_lock = 0;
  174.  
  175.     for (;;)
  176.     {
  177.         phone_translate (number, translated);
  178.         if (translated[0] == '\"')            /* If it's a script          */
  179.         {
  180.             retval = do_script (translated);/* then do it that way       */
  181.             if (fullscreen)                    /* & clean up the bottom line*/
  182.                 bottom_line ();
  183.             break;
  184.         }
  185.  
  186.         status_line (MSG_TXT (dialmsg), translated);
  187.  
  188.         if (un_attended && fullscreen)
  189.         {
  190.             do_ready (MSG_TXT (M_READY_DIALING));
  191.         }
  192.  
  193.         /* First of all, if we have something, don't hang up on the guy! */
  194.  
  195.         if (!no_collide && CHAR_AVAIL ())
  196.         {
  197.             retval = -1;
  198.             break;
  199.         }
  200.  
  201.  
  202.         if (dial_setup != NULL)
  203.         {
  204.             mdm_cmd_string (dial_setup, 1);
  205.         }
  206.         else
  207.         {
  208.             LOWER_DTR ();                    /* drop DTR to reset modem   */
  209.             timer (20);                        /* leave it down 2 seconds   */
  210.             RAISE_DTR ();                    /* then raise DTR again      */
  211.             timer (5);                        /* and wait .5 sec for modem */
  212.         }
  213.  
  214.         if (!no_collide && CHAR_AVAIL ())    /* Is there something? return*/
  215.         {
  216.             retval = -1;
  217.             break;
  218.         }
  219.  
  220.         mdm_cmd_string (predial, 0);        /* transmit the dial prefix  */
  221.         mdm_cmd_string (translated, 0);        /* then the phone number     */
  222.         mdm_cmd_string (postdial, 0);        /* finally the dial suffix   */
  223.         if (no_collide)
  224.             CLEAR_INBOUND ();                /* Throw out all echo to now */
  225.         mdm_cmd_char (CR);                    /* terminate the string      */
  226.  
  227.         resp = modem_response (7500);
  228.         if (resp)                            /* we got a good response,   */
  229.         {
  230.             if (resp == RINGING || (resp & FAX)) /* Process incoming     */
  231.             {
  232.                 retval = -1;
  233.                 break;
  234.             }
  235.  
  236.             if (resp == INCOMING)            /* No dial tone. That's */
  237.             {
  238.                 retval = -2;                /* a potential remote.  */
  239.                 break;
  240.             }
  241.  
  242.             if (resp == DIALRETRY)            /* retry condition */
  243.             {
  244.                 if (altnums == NULL)        /* no retry number get out */
  245.                     break;
  246.  
  247.                 number = NULL;                /* precondition next number */
  248.  
  249.                 /* Scan alternate number list for another match */
  250.  
  251.                 while (altnums != NULL)
  252.                 {
  253.                     if (!stricmp (altnums->num, numbertocall))
  254.                     {
  255.                         number = altnums->alt;
  256.                         altnums = altnums->next;
  257.                         dialmsg = M_DIALING_ALTNUM;
  258.                         CLEAR_INBOUND ();
  259.                         break;
  260.                     }
  261.                     else
  262.                         altnums = altnums->next;
  263.                 }
  264.  
  265.                 if (number == NULL)
  266.                     break;
  267.                 else
  268.                     continue;
  269.             }
  270.  
  271.             /* Not RINGING, FAX, INCOMING or DIALRETRY */
  272.  
  273.             t = timerset (200);                /* Wait up to 2 seconds      */
  274.             while (!timeup (t))
  275.             {                                /* If carrier detect, AND    */
  276.                 if ((CHAR_AVAIL ()) && CARRIER)    /* some sign of life,    */
  277.                     break;                    /* leave early...            */
  278.                 else
  279.                     time_release ();/*PLF Sun  12-01-1991  05:55:16 */
  280.             }
  281.             retval = ((int) CARRIER);        /* Carrier should be on now  */
  282.         }
  283.  
  284.         /* If we get here we want out of the loop. */
  285.         break;
  286.     }
  287.     return (retval);    /* pass what we got back to the caller */
  288. }
  289.  
  290. char *
  291. get_response (long end_time)
  292. {
  293.     char *p = response_string;            /* points to character cell  */
  294.     char c;                                /* current modem character   */
  295.     int count = 0;                        /* count of characters       */
  296.  
  297.     while ((count < 127)                /* until we have 50 chars,   */
  298.         && (!timeup (end_time))            /* or out of time,           */
  299.         && (!KEYPRESS ()))                /* or user gets impatient    */
  300.     {
  301.         if (!CHAR_AVAIL ())                /* if nothing ready yet,     */
  302.         {
  303.             time_release ();
  304.             continue;                    /* just process timeouts     */
  305.         }
  306.         c = (char) (MODEM_IN () & 0xff);/* get a character           */
  307.         if (c == '\r' || c == '\n')        /* if a line ending          */
  308.         {
  309.             if (count != 0)                /* and we have something,    */
  310.                 break;                    /* get out                   */
  311.             else
  312.                 continue;                /* otherwise just keep going */
  313.         }
  314.         *p++ = c;                        /* store the character       */
  315.         ++count;                        /* increment the counter     */
  316.     }
  317.     *p = '\0';                            /* terminate the new string  */
  318.  
  319.     if (count != 0 && strnicmp (response_string, "AT", 2))
  320.     {
  321.         (void) fancy_str (response_string); /* make it pretty        */
  322.         status_line ("#%s", response_string); /* pop it out onscreen */
  323.     }
  324.  
  325.     return (response_string);            /* return the pointer        */
  326. }
  327.  
  328. static int LOCALFUNC 
  329. parse_response (char *response)
  330. {
  331.     char *p;                            /* temp character pointer    */
  332.     register int i;                        /* array pointer             */
  333.  
  334.     if (!mdm_resps)                        /* If we have no strings,    */
  335.         return (IGNORE);                /* always ignore...          */
  336.  
  337.     for (i = 0; i < resp_count; i++)     /* scan through array   */
  338.     {
  339.         p = mdm_resps[i].resp;            /* point at possible response*/
  340.  
  341.         if (strnicmp (response, p, strlen (p)) == 0)
  342.         {
  343.             /* We matched this result. Return its disposition*/
  344.             return ((int) (mdm_resps[i].disp));
  345.         }
  346.     }
  347.     return (IGNORE);                    /* ignore all unknowns       */
  348. }
  349.  
  350. int 
  351. modem_response (int ths)
  352. {
  353.     unsigned long baudrate;
  354.     long end_time;                            /* holds time at end of 2min */
  355.     char *response = "";                    /* pointer to modem response */
  356.     char *c;                                /* miscellaneous pointer     */
  357.     int result = IGNORE;                    /* result code               */
  358.     int i;
  359.     int ring_count = 0;                        /* # of RINGING responses    */
  360.  
  361.     end_time = timerset ((unsigned int) ths);    /* arm the timeout       */
  362.  
  363.     while ((result == IGNORE)                /* until success or failure, */
  364.         && (!timeup (end_time))                /* or out of time,           */
  365.         && (!KEYPRESS ()))                    /* or user gets impatient    */
  366.     {
  367.   /*
  368.    *  See if we've been through this code enough times to reach
  369.    *  the user-defined failure threshold. For this purpose,
  370.    *  we crudely assume that all IGNORE cases are rings.
  371.    *
  372.    *  Henry Clark and Ron Bemis get credit for this one.
  373.    */
  374.         if (ring_count++ >= ring_tries)
  375.         {
  376.             response = "NO ANSWER";
  377.             (void) fancy_str (response);
  378.             status_line ("#%s", response);
  379.             result = parse_response (response);
  380.             break;
  381.         }
  382.   /*
  383.    *  We're still here. So get the next modem response
  384.    *  (or time out trying).
  385.    */
  386.         response = get_response (end_time);    /* get a response            */
  387.         result = parse_response (response);    /* parse, determine status   */
  388.         time_release ();
  389.     }
  390.  
  391.     if (result == CONNECTED)                /* Got to be a CONNECT msg   */
  392.     {
  393.         mdm_reliable[0] = '\0';                /* Start with nothing        */
  394.  
  395.         if (strnicmp (response, "connect", 7) == 0)    /* if this is CONNECT*/
  396.         {
  397.             strcpy (saved_response, response);
  398.             c = skip_blanks (&response[7]);    /* get past the blanks       */
  399.             mdm_reliable[0] = '\0';            /* Start with nothing        */
  400.  
  401.             if (*c == '\0')                    /* if nothing there,         */
  402.             {
  403.                 baudrate = 300L;            /* say that it's 300 baud    */
  404.             }
  405.             else
  406.             {
  407.                 baudrate = (unsigned long) atol (c); /* else do fallback */
  408.  
  409.                 /* For 1200/75 split speed modems and "Connect 212" */
  410.  
  411.                 if ((baudrate == 1275) || (baudrate == 7512)
  412.                     || (baudrate == 75) || (baudrate == 212) || (baudrate == 12))
  413.                     baudrate = 1200L;
  414.  
  415.                 /* For "Connect 103" */
  416.                 if (baudrate == 103)
  417.                     baudrate = 300L;
  418.             }
  419.  
  420.             if ((fax_in) && !strnicmp (c, "FAX", 3))
  421.                 return (ZYXFAX);
  422.  
  423.             ARQ_lock = 0;
  424.  
  425.             while (isdigit (*c))            /* Get past digits           */
  426.                 ++c;
  427.             c = skip_blanks (c);            /* Get rid of blanks         */
  428.             if (*c != '\0')                    /* We have "reliable" info.  */
  429.             {
  430.                 (void) strcpy (mdm_reliable, c);    /* Copy in the info  */
  431.                 can_Janus (mdm_reliable);    /* Set the flag for Janus    */
  432.                 for (i = 0; i < ARQs; i++)
  433.                 {
  434.                     if ((strnicmp (mdm_reliable, ARQ[i], strlen (ARQ[i]))) == 0)
  435.                     {
  436.                         ARQ_lock = 1;
  437.                         break;
  438.                     }
  439.                 }
  440.             }
  441.  
  442.             if (baudrate)
  443.                 (void) set_baud (baudrate, 1);
  444.         }
  445.  
  446.         MNP_Filter ();
  447.     }
  448.     else if (result == FAX)                    /* FAX is a special case     */
  449.     {
  450.         strcpy (saved_response, response);
  451.     }
  452.     
  453.     return (result);            /* timeout or failure or OK  */
  454. }
  455.  
  456. void 
  457. mdm_cmd_string (char *mdm_cmd, int dospace)
  458. {
  459.     register char *c;
  460.     register int escaped = 0;
  461.  
  462.     if (mdm_cmd == NULL)                    /* defense from badness      */
  463.         return;
  464.  
  465.     for (c = mdm_cmd; *c; c++)
  466.     {
  467.         if (escaped)
  468.         {
  469.             SENDBYTE (*c);
  470.             escaped = 0;
  471.             continue;
  472.         }
  473.  
  474.         if (*c == '\\')
  475.         {
  476.             escaped = 1;
  477.             continue;
  478.         }
  479.  
  480.         if (!isspace (*c) || dospace)        /* don't output spaces       */
  481.             mdm_cmd_char (*c);                /* output the next character */
  482.     }
  483. }
  484.  
  485. static void LOCALFUNC 
  486. empty_delay ()
  487. {
  488.     long t;
  489.  
  490.     t = timerset (500);
  491.     while ((!OUT_EMPTY ()) && (!timeup (t)))
  492.         time_release ();                    /* wait for output to finish */
  493.  
  494.     if (!OUT_EMPTY ())
  495.     {
  496.         MDM_DISABLE ();
  497.         (void) Cominit (port_ptr, buftmo);
  498.         program_baud ();
  499.         RAISE_DTR ();
  500.         CLEAR_OUTBOUND ();
  501.         CLEAR_INBOUND ();
  502.         if (un_attended && fullscreen)
  503.         {
  504.             sb_dirty ();
  505.             sb_show ();
  506.         }
  507.     }
  508. }
  509.  
  510. void 
  511. mdm_cmd_char (int outchr)
  512. {
  513.     switch (outchr)
  514.     {
  515.     case '-':                    /* if it's a dash (phone no) */
  516.         return;                    /* ignore it                 */
  517.  
  518.     case '|':                    /* if the CR character,      */
  519.         outchr = CR;            /* substitute a real CR here */
  520.         break;
  521.  
  522.     case '.':                    /* Substitute ',' for '.'    */
  523.         outchr = ',';            /* for compatibility         */
  524.         break;
  525.  
  526.     case '~':                    /* if the "delay" character, */
  527.         empty_delay ();            /* wait for buffer to clear, */
  528.         timer (10);                /* then wait 1 second        */
  529.         return;                    /* and return                */
  530.  
  531.     case '^':                    /* Raise DTR                 */
  532.         empty_delay ();            /* wait for buffer to clear, */
  533.         RAISE_DTR ();            /* Turn on DTR               */
  534.         return;                    /* and return                */
  535.  
  536.     case 'v':                    /* Lower DTR                 */
  537.         empty_delay ();            /* wait for buffer to clear, */
  538.         LOWER_DTR ();            /* Turn off DTR              */
  539.         return;                    /* and return                */
  540.  
  541.     case '`':                    /* Short delay               */
  542.         timer (1);                /* short pause, .1 second    */
  543.         return;                    /* and return                */
  544.  
  545.     default:
  546.         break;
  547.     }
  548.  
  549.     SENDBYTE ((unsigned char) outchr); /* write the character*/
  550.  
  551.     if (outchr == CR)            /* if it was a CR,           */
  552.     {
  553.         empty_delay ();
  554.         timer (1);                /* allow .1 sec line quiet   */
  555.     }
  556.     else if (slowmodem)
  557.     {
  558.         timer (1);                /* wait .1 sec for output    */
  559.     }
  560. }
  561.  
  562. void 
  563. mdm_hangup ()
  564. {
  565.  
  566.    /*
  567.     * First, if a dial command is in progress, try to get the modem to abort
  568.     * it...
  569.     */
  570.  
  571.     CLEAR_OUTBOUND ();
  572.     CLEAR_INBOUND ();
  573.  
  574.     if (un_attended && fullscreen)
  575.     {
  576.         do_ready (MSG_TXT (M_READY_HANGUP));
  577.     }
  578.     else
  579.     {
  580.         status_line (MSG_TXT (M_MODEM_HANGUP));    /* Tell what we are doing    */
  581.     }
  582.  
  583.     if (un_attended || (term_init == NULL))
  584.     {
  585.         mdm_init (modem_init);    /* re-init the modem         */
  586.     }
  587.     else
  588.     {
  589.         mdm_init (term_init);    /* use term init if term mode*/
  590.     }
  591.  
  592.     timer (5);                    /* Wait another .5 sec       */
  593.  
  594.     ARQ_lock = 0;                /* Re-init lockbaud          */
  595.  
  596.     set_xy ("");
  597.     CLEAR_INBOUND ();            /* then flush input and exit */
  598. }
  599.  
  600. void 
  601. mdm_init (char *str)
  602. {
  603.     set_prior (4);                /* Always High    */
  604.  
  605.     CLEAR_OUTBOUND ();
  606.     CLEAR_INBOUND ();
  607.     if (init_setup != NULL)
  608.     {
  609.         (void) set_baud (max_baud.rate_value, 0);
  610.         mdm_cmd_string (init_setup, 1);
  611.     }
  612.     else
  613.     {
  614.         mdm_cmd_char (CR);        /* output a CR, then         */
  615.         LOWER_DTR ();            /* Drop DTR to hangup        */
  616.         timer (10);                /* Hold it down for 1 sec    */
  617.  
  618.         RAISE_DTR ();            /* Raise DTR,                */
  619.         timer (5);                /* Then hold it up for .5sec */
  620.  
  621.         (void) set_baud (max_baud.rate_value, 0);
  622.         mdm_cmd_char (' ');        /* output a space            */
  623.         mdm_cmd_char (CR);        /* then another CR           */
  624.     }
  625.     mdm_cmd_string (str, 0);    /* then the modem init string*/
  626.  
  627.     set_prior (2);                /* Regular                   */
  628.  
  629.     timer (5);                    /* Hold DTR for .5 sec more  */
  630.     CLEAR_INBOUND ();            /* then flush input and exit */
  631. }
  632.  
  633. void 
  634. send_break (int t)
  635. {
  636.     long t1;
  637.  
  638.     t1 = timerset ((unsigned int) t);
  639.     do_break (1);
  640.     while (!timeup (t1))
  641.         time_release ();
  642.     do_break (0);
  643. }
  644.  
  645. void 
  646. exit_DTR ()
  647. {
  648.     if (!leave_dtr_high)
  649.         LOWER_DTR ();
  650. }
  651.  
  652. /*
  653.  * We get here right after the CONNECT message. It could happen
  654.  * so quickly that we don't even have DCD set. (On a 33MHz 386
  655.  * and a T2500, that happens!)
  656.  *
  657.  * So: this routine waits up to 3 seconds for a carrier.
  658.  *
  659.  * It then eats anything that looks like an MNP string, with
  660.  * a total time allowed of 10 seconds (for streaming garbage)
  661.  * and maximum inter-character delay of 2 seconds.
  662.  */
  663.  
  664. static void LOCALFUNC 
  665. MNP_Filter ()
  666. {
  667.     long t, t1;
  668.     int c;
  669.     int logged = 0;
  670.  
  671.     t = timerset (300);            /* at most a three second delay  */
  672.     t1 = timerset (50);            /* From same point, .5 sec for LF*/
  673.  
  674.     while (!CARRIER && !timeup (t))
  675.         time_release ();        /*PLF Sun  12-01-1991  04:28:38 */
  676.  
  677.     /* Look for terminator character on connect string. If we see one,
  678.        eat it. Only wait up to .5 sec for it, though. (Note that if
  679.        we delayed for DCD, we count that time, since the LF should
  680.        have already been coming in from the modem) */
  681.  
  682.     do
  683.     {
  684.         c = PEEKBYTE ();
  685.         if (c != -1)
  686.             break;
  687.     } while (!timeup (t1));
  688.  
  689.     if (c == LF)
  690.         MODEM_IN ();
  691.  
  692.     /*    If this was a MNP connection, bail out right now. */
  693.  
  694.     for (c = 0; c < cMNP; c++)
  695.     {
  696.         if ((strnicmp (mdm_reliable, pchMNP[c], strlen (pchMNP[c]))) == 0)
  697.             return;
  698.     }
  699.  
  700.     t1 = timerset (1000);        /* 10 second drop dead timer    */
  701.     t = timerset (200);            /* at most a 2 second delay     */
  702.  
  703.     while (CARRIER && !timeup (t))
  704.     {
  705.         if (got_ESC ())
  706.         {                        /* Manual abort?        */
  707.             LOWER_DTR ();        /* Yes, drop carrier    */
  708.             return;
  709.         }
  710.  
  711.         if (timeup (t1))
  712.             break;
  713.  
  714.         if ((c = PEEKBYTE ()) != -1)
  715.         {
  716.             (void) TIMED_READ (0);
  717.  
  718.             /* If we get an MNP or v.42 character, eat it and wait for clear line */
  719.             if ((c != 0) && ((strchr (BadChars, (c | 0x80)) != NULL) || (strchr (BadChars, (c & 0x7f)) != NULL)))
  720.             {
  721.                 t = timerset (500);
  722.                 if ((logged++) == 0)
  723.                     status_line (MSG_TXT (M_FILTER));
  724.             }
  725.         }
  726.         else
  727.             time_release ();    /*PLF Sun  12-01-1991  04:28:38 */
  728.     }
  729. }
  730.  
  731.