diff options
Diffstat (limited to 'usr.bin/tip/libacu/hayes.c')
-rw-r--r-- | usr.bin/tip/libacu/hayes.c | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/usr.bin/tip/libacu/hayes.c b/usr.bin/tip/libacu/hayes.c index 7784f29..9e38830 100644 --- a/usr.bin/tip/libacu/hayes.c +++ b/usr.bin/tip/libacu/hayes.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $ */ +/* $OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $ */ /* $NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $ */ /* @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +36,7 @@ __FBSDID("$FreeBSD$"); #ifndef lint #if 0 static char sccsid[] = "@(#)hayes.c 8.1 (Berkeley) 6/6/93"; -static char rcsid[] = "$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $"; +static const char rcsid[] = "$OpenBSD: hayes.c,v 1.13 2006/03/17 19:17:13 moritz Exp $"; #endif #endif /* not lint */ @@ -74,12 +70,9 @@ static char rcsid[] = "$OpenBSD: hayes.c,v 1.8 2001/10/24 18:38:58 millert Exp $ #define min(a,b) ((a < b) ? a : b) -static void error_rep(char c); -static void goodbye(void); -static void sigALRM(); -static int timeout = 0; +static int dialtimeout = 0; static jmp_buf timeoutbuf; -static char gobble(); + #define DUMBUFLEN 40 static char dumbuf[DUMBUFLEN]; @@ -89,10 +82,14 @@ static char dumbuf[DUMBUFLEN]; #define FAILED 4 static int state = IDLE; +static void sigALRM(int); +static char gobble(char *); +static void error_rep(char); +static void goodbye(void); +static int hay_sync(void); + int -hay_dialer(num, acu) - char *num; - char *acu; +hay_dialer(char *num, char *acu) { char *cp; int connected = 0; @@ -135,20 +132,19 @@ hay_dialer(num, acu) } tcflush(FD, TCIOFLUSH); #ifdef ACULOG - if (timeout) { - (void)sprintf(line, "%ld second dial timeout", + if (dialtimeout) { + (void)snprintf(line, sizeof line, "%ld second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "hayes", line); } #endif - if (timeout) + if (dialtimeout) hay_disconnect(); /* insurance */ return (connected); } - void -hay_disconnect() +hay_disconnect(void) { /* first hang up the modem*/ #ifdef DEBUG @@ -161,32 +157,30 @@ hay_disconnect() } void -hay_abort() +hay_abort(void) { - write(FD, "\r", 1); /* send anything to abort the call */ hay_disconnect(); } +/*ARGSUSED*/ static void -sigALRM() +sigALRM(int signo) { - printf("\07timeout waiting for reply\n\r"); - timeout = 1; + dialtimeout = 1; longjmp(timeoutbuf, 1); } static char -gobble(match) - char *match; +gobble(char *match) { char c; sig_t f; int i, status = 0; f = signal(SIGALRM, sigALRM); - timeout = 0; + dialtimeout = 0; #ifdef DEBUG printf("\ngobble: waiting for %s\n", match); #endif @@ -214,8 +208,7 @@ gobble(match) } static void -error_rep(c) - char c; +error_rep(char c) { printf("\n\r"); switch (c) { @@ -227,23 +220,23 @@ error_rep(c) case '1': printf("CONNECT"); break; - + case '2': printf("RING"); break; - + case '3': printf("NO CARRIER"); break; - + case '4': printf("ERROR in input"); break; - + case '5': printf("CONNECT 1200"); break; - + default: printf("Unknown Modem error: %c (0x%x)", c, c); } @@ -299,8 +292,8 @@ goodbye(void) #define MAXRETRY 5 -int -hay_sync() +static int +hay_sync(void) { int len, retry = 0; |