diff options
author | markm <markm@FreeBSD.org> | 2001-12-20 14:25:46 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2001-12-20 14:25:46 +0000 |
commit | ea00e48044b4c63ff0b00ff8afa84d9a1ac54155 (patch) | |
tree | 735e71ebf880fba90adb57f05d2821e1c63de2df /usr.bin/tip/libacu/courier.c | |
parent | 3551cbb12e15475b2d7b2e33119ddd9e4f857531 (diff) | |
download | FreeBSD-src-ea00e48044b4c63ff0b00ff8afa84d9a1ac54155.zip FreeBSD-src-ea00e48044b4c63ff0b00ff8afa84d9a1ac54155.tar.gz |
Fix merge conflicts, and because this still has a zillion warnings,
protect the build with a WARNS=2.
Fix the build.
Diffstat (limited to 'usr.bin/tip/libacu/courier.c')
-rw-r--r-- | usr.bin/tip/libacu/courier.c | 85 |
1 files changed, 53 insertions, 32 deletions
diff --git a/usr.bin/tip/libacu/courier.c b/usr.bin/tip/libacu/courier.c index df19573..67c7529 100644 --- a/usr.bin/tip/libacu/courier.c +++ b/usr.bin/tip/libacu/courier.c @@ -1,3 +1,6 @@ +/* $OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $ */ +/* $NetBSD: courier.c,v 1.7 1997/02/11 09:24:16 mrg Exp $ */ + /* * Copyright (c) 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -31,20 +34,23 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + #ifndef lint -static const char rcsid[] = - "$FreeBSD$"; +#if 0 +static char sccsid[] = "@(#)courier.c 8.1 (Berkeley) 6/6/93"; +static char rcsid[] = "$OpenBSD: courier.c,v 1.9 2001/10/24 18:38:58 millert Exp $"; #endif +#endif /* not lint */ /* * Routines for calling up on a Courier modem. * Derived from Hayes driver. */ -#include "tipconf.h" #include "tip.h" -#include "acucommon.h" +#include <sys/ioctl.h> #include <stdio.h> -#include <unistd.h> #define MAXRETRY 5 @@ -52,30 +58,35 @@ static void sigALRM(); static int timeout = 0; static int connected = 0; static jmp_buf timeoutbuf, intbuf; -static int coursync(); +static int coursync(), cour_connect(), cour_swallow(); +void cour_nap(); + +void cour_disconnect __P((void)); +int cour_dialer(num, acu) - register char *num; + char *num; char *acu; { - register char *cp; -#if ACULOG + char *cp; +#ifdef ACULOG char line[80]; #endif - static int cour_connect(), cour_swallow(); + struct termios cntrl; if (boolean(value(VERBOSE))) printf("Using \"%s\"\n", acu); - acu_hupcl (); - + tcgetattr(FD, &cntrl); + cntrl.c_cflag |= HUPCL; + tcsetattr(FD, TCSAFLUSH, &cntrl); /* * Get in synch. */ if (!coursync()) { badsynch: printf("can't synchronize with courier\n"); -#if ACULOG +#ifdef ACULOG logent(value(HOST), num, "courier", "can't synch up"); #endif return (0); @@ -86,7 +97,7 @@ badsynch: if (boolean(value(VERBOSE))) cour_verbose_read(); #endif - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); if (!cour_swallow("\r\nOK\r\n")) goto badsynch; @@ -98,9 +109,9 @@ badsynch: cour_write(FD, num, strlen(num)); cour_write(FD, "\r", 1); connected = cour_connect(); -#if ACULOG +#ifdef ACULOG if (timeout) { - sprintf(line, "%d second dial timeout", + (void)sprintf(line, "%ld second dial timeout", number(value(DIALTIMEOUT))); logent(value(HOST), num, "cour", line); } @@ -110,6 +121,7 @@ badsynch: return (connected); } +void cour_disconnect() { /* first hang up the modem*/ @@ -120,6 +132,7 @@ cour_disconnect() close(FD); } +void cour_abort() { cour_write(FD, "\r", 1); /* send anything to abort the call */ @@ -136,8 +149,8 @@ sigALRM() static int cour_swallow(match) - register char *match; - { + char *match; +{ sig_t f; char c; @@ -224,8 +237,12 @@ again: for (bm = baud_msg ; bm->msg ; bm++) if (strcmp(bm->msg, dialer_buf+sizeof("CONNECT")-1) == 0) { - if (!acu_setspeed(bm->baud)) - goto error; + struct termios cntrl; + + tcgetattr(FD, &cntrl); + cfsetospeed(&cntrl, bm->baud); + cfsetispeed(&cntrl, bm->baud); + tcsetattr(FD, TCSAFLUSH, &cntrl); signal(SIGALRM, f); #ifdef DEBUG if (boolean(value(VERBOSE))) @@ -241,9 +258,7 @@ again: putchar(c); #endif } -error1: printf("%s\r\n", dialer_buf); -error: signal(SIGALRM, f); return (0); } @@ -260,7 +275,7 @@ coursync() char buf[40]; while (already++ < MAXRETRY) { - ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ + tcflush(FD, TCIOFLUSH); cour_write(FD, "\rAT Z\r", 6); /* reset modem */ bzero(buf, sizeof(buf)); sleep(1); @@ -271,8 +286,8 @@ coursync() buf[len] = '\0'; printf("coursync: (\"%s\")\n\r", buf); #endif - if (index(buf, '0') || - (index(buf, 'O') && index(buf, 'K'))) + if (strchr(buf, '0') || + (strchr(buf, 'O') && strchr(buf, 'K'))) return(1); } /* @@ -294,6 +309,7 @@ coursync() return (0); } +static void cour_write(fd, cp, n) int fd; char *cp; @@ -301,13 +317,13 @@ int n; { #ifdef notdef if (boolean(value(VERBOSE))) - write(STDOUT_FILENO, cp, n); + write(1, cp, n); #endif - acu_flush (); + tcdrain(fd); cour_nap(); for ( ; n-- ; cp++) { write(fd, cp, 1); - acu_flush (); + tcdrain(fd); cour_nap(); } } @@ -324,13 +340,18 @@ cour_verbose_read() return; if (read(FD, buf, n) != n) return; - write(STDOUT_FILENO, buf, n); + write(1, buf, n); } #endif +/* Give the courier 50 milliseconds between characters */ +void cour_nap() { - acu_nap (50); -} + struct timespec ts; -/* end of courier.c */ + ts.tv_sec = 0; + ts.tv_nsec = 50 * 1000000; + + nanosleep(&ts, NULL); +} |