diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-06-29 16:41:58 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2010-06-29 16:41:58 +0000 |
commit | b3edb9879a3bc199405b037a900f316d4f77e005 (patch) | |
tree | f014b2eea07d8afadc4b3d3c7cf020ee731ec9bb /usr.bin | |
parent | 7e2ce9013f05c75e01cb40373c07987f0ef38c18 (diff) |
Bye-bye acu which even UUCP-using naddy agrees "was obsolete 20 years ago" :-).
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tip/Makefile | 31 | ||||
-rw-r--r-- | usr.bin/tip/acu.c | 185 | ||||
-rw-r--r-- | usr.bin/tip/aculib/biz22.c | 177 | ||||
-rw-r--r-- | usr.bin/tip/aculib/biz31.c | 244 | ||||
-rw-r--r-- | usr.bin/tip/aculib/courier.c | 344 | ||||
-rw-r--r-- | usr.bin/tip/aculib/df.c | 127 | ||||
-rw-r--r-- | usr.bin/tip/aculib/dn11.c | 139 | ||||
-rw-r--r-- | usr.bin/tip/aculib/hayes.c | 314 | ||||
-rw-r--r-- | usr.bin/tip/aculib/t3000.c | 362 | ||||
-rw-r--r-- | usr.bin/tip/aculib/v3451.c | 202 | ||||
-rw-r--r-- | usr.bin/tip/aculib/v831.c | 253 | ||||
-rw-r--r-- | usr.bin/tip/aculib/ventel.c | 249 | ||||
-rw-r--r-- | usr.bin/tip/acutab.c | 79 | ||||
-rw-r--r-- | usr.bin/tip/cmds.c | 4 | ||||
-rw-r--r-- | usr.bin/tip/cu.1 | 11 | ||||
-rw-r--r-- | usr.bin/tip/cu.c | 21 | ||||
-rw-r--r-- | usr.bin/tip/log.c | 11 | ||||
-rw-r--r-- | usr.bin/tip/pathnames.h | 3 | ||||
-rw-r--r-- | usr.bin/tip/remote.c | 25 | ||||
-rw-r--r-- | usr.bin/tip/tip.1 | 40 | ||||
-rw-r--r-- | usr.bin/tip/tip.c | 25 | ||||
-rw-r--r-- | usr.bin/tip/tip.h | 98 | ||||
-rw-r--r-- | usr.bin/tip/vars.c | 6 |
23 files changed, 77 insertions, 2873 deletions
diff --git a/usr.bin/tip/Makefile b/usr.bin/tip/Makefile index 9cfce293f3f..e83ece49908 100644 --- a/usr.bin/tip/Makefile +++ b/usr.bin/tip/Makefile @@ -1,27 +1,12 @@ -# $OpenBSD: Makefile,v 1.11 2006/05/25 08:41:52 jmc Exp $ +# $OpenBSD: Makefile,v 1.12 2010/06/29 16:41:56 nicm Exp $ # # Files are: # /etc/remote remote host description file -# /etc/phones phone number file, owned by ${OWNER} and -# mode 6?? # /var/log/aculog ACU accounting file, owned by ${OWNER} and # mode 6?? {if ACULOG defined} -# Presently supports: -# BIZCOMP -# DEC DF02-AC, DF03-AC -# DEC DN-11/Able Quadracall -# HAYES and Hayes emulators -# USR COURIER (2400 baud) -# VENTEL 212+ -# VADIC 831 RS232 adaptor -# VADIC 3451 -# TELEBIT T3000 # # Configuration defines: -# DF02, DF03, DN11 ACU's supported -# BIZ1031, BIZ1022, VENTEL, V831, V3451, HAYES, COURIER, T3000 # ACULOG turn on tip logging of ACU use -# PRISTINE no phone #'s put in ACU log file # CONNECT worthless command # DEFBR default baud rate to make connection at # DEFFS default frame size for FTP buffering of @@ -33,16 +18,8 @@ PROG= tip LINKS= ${BINDIR}/tip ${BINDIR}/cu MAN= tip.1 cu.1 -CFLAGS+=-I${.CURDIR} -DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE \ - -DCONNECT -DV831 -DVENTEL -DHAYES -DCOURIER -DT3000 -.PATH: ${.CURDIR}/aculib -SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c \ - remote.c tip.c tipout.c uucplock.c value.c vars.c \ - biz22.c courier.c df.c dn11.c hayes.c t3000.c v3451.c v831.c ventel.c - -# -- acutab is configuration dependent, and so depends on the Makefile -# -- remote.o depends on the Makefile because of DEFBR and DEFFS -# -- log.o depends on the Makefile because of ACULOG -acutab.o log.o remote.o: Makefile +CFLAGS+=-I${.CURDIR} -DDEFBR=9600 -DDEFFS=BUFSIZ -DACULOG -DCONNECT +SRCS= cmds.c cmdtab.c cu.c hunt.c log.c partab.c remote.c tip.c \ + tipout.c uucplock.c value.c vars.c .include <bsd.prog.mk> diff --git a/usr.bin/tip/acu.c b/usr.bin/tip/acu.c deleted file mode 100644 index 1a136728c75..00000000000 --- a/usr.bin/tip/acu.c +++ /dev/null @@ -1,185 +0,0 @@ -/* $OpenBSD: acu.c,v 1.17 2009/10/27 23:59:44 deraadt Exp $ */ -/* $NetBSD: acu.c,v 1.4 1996/12/29 10:34:03 cgd Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "tip.h" - -static acu_t *acu = NULL; -static int conflag; -static void acuabort(int); -static acu_t *acutype(char *); -static jmp_buf jmpbuf; -/* - * Establish connection for tip - * - * If DU is true, we should dial an ACU whose type is AT. - * The phone numbers are in PN, and the call unit is in CU. - * - * If the PN is an '@', then we consult the PHONES file for - * the phone numbers. This file is /etc/phones, unless overridden - * by an exported shell variable. - * - * The data base files must be in the format: - * host-name[ \t]*phone-number - * with the possibility of multiple phone numbers - * for a single host acting as a rotary (in the order - * found in the file). - */ -char * -con(void) -{ - char *cp = PN; - char *phnum, string[256]; - FILE *fp; - volatile int tried = 0; - - if (!DU) { /* regular connect message */ - if (CM != NULL) - parwrite(FD, CM, size(CM)); - logent(value(HOST), "", DV, "call completed"); - return (NULL); - } - /* - * @ =>'s use data base in PHONES environment variable - * otherwise, use /etc/phones - */ - signal(SIGINT, acuabort); - signal(SIGQUIT, acuabort); - if (setjmp(jmpbuf)) { - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - printf("\ncall aborted\n"); - logent(value(HOST), "", "", "call aborted"); - if (acu != NULL) { - setboolean(value(VERBOSE), FALSE); - if (conflag) - disconnect(NULL); - else - (*acu->acu_abort)(); - } - return ("interrupt"); - } - if ((acu = acutype(AT)) == NULL) - return ("unknown ACU type"); - if (*cp != '@') { - while (*cp) { - phnum = cp; - cp += strcspn(cp, ","); - if (*cp != '\0') - *cp++ = '\0'; - - if (strlen(phnum) == 0) - continue; - - conflag = (*acu->acu_dialer)(phnum, CU); - if (conflag) - break; - - logent(value(HOST), phnum, acu->acu_name, "call failed"); - tried++; - } - } else { - if ((fp = fopen(PH, "r")) == NULL) { - printf("%s: ", PH); - return ("can't open phone number file"); - } - while (fgets(string, sizeof(string), fp) != NULL) { - cp = &string[strcspn(string, " \t\n")]; - if (*cp != '\0') - *cp++ = '\0'; - - if (strcmp(string, value(HOST)) != 0) - continue; - - cp += strspn(cp, " \t\n"); - phnum = cp; - *(cp + strcspn(cp, ",\n")) = '\0'; - - if (strlen(phnum) == 0) - continue; - - conflag = (*acu->acu_dialer)(phnum, CU); - if (conflag) - break; - - logent(value(HOST), phnum, acu->acu_name, "call failed"); - tried++; - } - fclose(fp); - } - if (conflag) { - if (CM != NULL) - parwrite(FD, CM, size(CM)); - logent(value(HOST), phnum, acu->acu_name, "call completed"); - return (NULL); - } else if (!tried) { - logent(value(HOST), "", acu->acu_name, "missing phone number"); - return ("missing phone number"); - } else { - (*acu->acu_abort)(); - return ("call failed"); - } -} - -void -disconnect(char *reason) -{ - if (!conflag) { - logent(value(HOST), "", DV, "call terminated"); - return; - } - if (reason == NULL) { - logent(value(HOST), "", acu->acu_name, "call terminated"); - if (boolean(value(VERBOSE))) - printf("\r\ndisconnecting..."); - } else - logent(value(HOST), "", acu->acu_name, reason); - (*acu->acu_disconnect)(); -} - -static void -acuabort(int s) -{ - signal(s, SIG_IGN); - longjmp(jmpbuf, 1); -} - -static acu_t * -acutype(char *s) -{ - acu_t *p; - extern acu_t acutable[]; - - for (p = acutable; p->acu_name != '\0'; p++) - if (!strcmp(s, p->acu_name)) - return (p); - return (NULL); -} diff --git a/usr.bin/tip/aculib/biz22.c b/usr.bin/tip/aculib/biz22.c deleted file mode 100644 index a0144e1d7a9..00000000000 --- a/usr.bin/tip/aculib/biz22.c +++ /dev/null @@ -1,177 +0,0 @@ -/* $OpenBSD: biz22.c,v 1.14 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: biz22.c,v 1.6 1997/02/11 09:24:11 mrg Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "tip.h" - -#define DISCONNECT_CMD "\20\04" /* disconnection string */ - -static int dialtimeout = 0; -static jmp_buf timeoutbuf; - -static int biz_dialer(char *, char *); -static void sigALRM(int); -static int cmd(char *); -static int detect(char *); - -/* - * Dial up on a BIZCOMP Model 1022 with either - * tone dialing (mod = "V") - * pulse dialing (mod = "W") - */ -static int -biz_dialer(char *num, char *mod) -{ - int connected = 0; - char cbuf[40]; - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - /* - * Disable auto-answer and configure for tone/pulse - * dialing - */ - if (cmd("\02K\r")) { - printf("can't initialize bizcomp..."); - return (0); - } - (void)strlcpy(cbuf, "\02.\r", sizeof cbuf); - cbuf[1] = *mod; - if (cmd(cbuf)) { - printf("can't set dialing mode..."); - return (0); - } - (void)snprintf(cbuf, sizeof(cbuf), "\02D%s\r", num); - write(FD, cbuf, strlen(cbuf)); - if (!detect("7\r")) { - printf("can't get dial tone..."); - return (0); - } - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * 2 \r or 7 \r failure - * 1 \r success - */ - connected = detect("1\r"); -#ifdef ACULOG - if (dialtimeout) { - char line[80]; - - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz1022", line); - } -#endif - if (dialtimeout) - biz22_disconnect(); /* insurance */ - return (connected); -} - -int -biz22w_dialer(char *num, char *acu) -{ - return (biz_dialer(num, "W")); -} - -int -biz22f_dialer(char *num, char *acu) -{ - return (biz_dialer(num, "V")); -} - -void -biz22_disconnect(void) -{ - write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1); - sleep(2); - tcflush(FD, TCIOFLUSH); -} - -void -biz22_abort(void) -{ - write(FD, "\02", 1); -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - dialtimeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cmd(char *s) -{ - sig_t f; - char c; - - write(FD, s, strlen(s)); - f = signal(SIGALRM, sigALRM); - if (setjmp(timeoutbuf)) { - biz22_abort(); - signal(SIGALRM, f); - return (1); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - signal(SIGALRM, f); - c &= 0177; - return (c != '\r'); -} - -static int -detect(char *s) -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - dialtimeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - biz22_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; - if (c != *s++) - return (0); - } - signal(SIGALRM, f); - return (dialtimeout == 0); -} diff --git a/usr.bin/tip/aculib/biz31.c b/usr.bin/tip/aculib/biz31.c deleted file mode 100644 index d77ffae3a3e..00000000000 --- a/usr.bin/tip/aculib/biz31.c +++ /dev/null @@ -1,244 +0,0 @@ -/* $OpenBSD: biz31.c,v 1.11 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: biz31.c,v 1.5 1997/02/11 09:24:14 mrg Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "tip.h" - -#define MAXRETRY 3 /* sync up retry count */ -#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */ - -static int biz_dialer(char *, char *); -static int bizsync(int); -static int echo(char *); -static void sigALRM(int); -static int detect(char *); -static int flush(char *); -static int bizsync(int); - -static int timeout = 0; -static jmp_buf timeoutbuf; - -/* - * Dial up on a BIZCOMP Model 1031 with either - * tone dialing (mod = "f") - * pulse dialing (mod = "w") - */ -static int -biz_dialer(char *num, char *mod) -{ - int connected = 0; - - if (!bizsync(FD)) { - logent(value(HOST), "", "biz", "out of sync"); - printf("bizcomp out of sync\n"); - delock(uucplock); - exit(0); - } - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - echo("#\rk$\r$\n"); /* disable auto-answer */ - echo("$>$.$ #\r"); /* tone/pulse dialing */ - echo(mod); - echo("$\r$\n"); - echo("$>$.$ #\re$ "); /* disconnection sequence */ - echo(DISCONNECT_CMD); - echo("\r$\n$\r$\n"); - echo("$>$.$ #\rr$ "); /* repeat dial */ - echo(num); - echo("\r$\n"); - if (boolean(value(VERBOSE))) - printf("ringing..."); - /* - * The reply from the BIZCOMP should be: - * `^G NO CONNECTION\r\n^G\r\n' failure - * ` CONNECTION\r\n^G' success - */ - connected = detect(" "); -#ifdef ACULOG - if (timeout) { - char line[80]; - - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "biz", line); - } -#endif - if (!connected) - flush(" NO CONNECTION\r\n\07\r\n"); - else - flush("CONNECTION\r\n\07"); - if (timeout) - biz31_disconnect(); /* insurance */ - return (connected); -} - -int -biz31w_dialer(char *num, char *acu) -{ - return (biz_dialer(num, "w")); -} - -int -biz31f_dialer(char *num, char *acu) -{ - return (biz_dialer(num, "f")); -} - -void -biz31_disconnect(void) -{ - write(FD, DISCONNECT_CMD, sizeof(DISCONNECT_CMD)-1); - sleep(2); - tcflush(FD, TCIOFLUSH); -} - -void -biz31_abort(void) -{ - write(FD, "\33", 1); -} - -static int -echo(char *s) -{ - char c; - - while (c = *s++) switch (c) { - - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - timeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -detect(char *s) -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - timeout = 0; - while (*s) { - if (setjmp(timeoutbuf)) { - printf("\07timeout waiting for reply\n"); - biz31_abort(); - break; - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - if (c != *s++) - break; - } - signal(SIGALRM, f); - return (timeout == 0); -} - -static int -flush(char *s) -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - while (*s++) { - if (setjmp(timeoutbuf)) - break; - alarm(10); - read(FD, &c, 1); - alarm(0); - } - signal(SIGALRM, f); - timeout = 0; /* guard against disconnection */ -} - -/* - * This convoluted piece of code attempts to get - * the bizcomp in sync. If you don't have the capacity or nread - * call there are gory ways to simulate this. - */ -static int -bizsync(int fd) -{ -#ifdef FIOCAPACITY - struct capacity b; -# define chars(b) ((b).cp_nbytes) -# define IOCTL FIOCAPACITY -#endif -#ifdef FIONREAD - long b; -# define chars(b) (b) -# define IOCTL FIONREAD -#endif - int already = 0; - char buf[10]; - -retry: - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0) - tcflush(FD, TCIOFLUSH); - write(fd, "\rp>\r", 4); - sleep(1); - if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0) { - if (chars(b) != 10) { - nono: - if (already > MAXRETRY) - return (0); - write(fd, DISCONNECT_CMD, 4); - sleep(2); - already++; - goto retry; - } else { - read(fd, buf, 10); - if (strncmp(buf, "p >\r\n\r\n>", 8)) - goto nono; - } - } - return (1); -} diff --git a/usr.bin/tip/aculib/courier.c b/usr.bin/tip/aculib/courier.c deleted file mode 100644 index 2a9f9f4d9aa..00000000000 --- a/usr.bin/tip/aculib/courier.c +++ /dev/null @@ -1,344 +0,0 @@ -/* $OpenBSD: courier.c,v 1.16 2009/10/27 23:59:45 deraadt 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. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for calling up on a Courier modem. - * Derived from Hayes driver. - */ -#include "tip.h" -#include <sys/ioctl.h> -#include <stdio.h> - -#define MAXRETRY 5 - -static int dialtimeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf; - -static void sigALRM(int); -static int cour_swallow(char *); -static int cour_connect(void); -static int coursync(void); -static void cour_write(int, char *, int); -static void cour_nap(void); -#ifdef DEBUG -static void cour_verbose_read(void); -#endif - -int -cour_dialer(char *num, char *acu) -{ - char *cp; -#ifdef ACULOG - char line[80]; -#endif - struct termios cntrl; - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - tcgetattr(FD, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(FD, TCSAFLUSH, &cntrl); - /* - * Get in synch. - */ - if (!coursync()) { -badsynch: - printf("can't synchronize with courier\n"); -#ifdef ACULOG - logent(value(HOST), num, "courier", "can't synch up"); -#endif - return (0); - } - cour_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - cour_verbose_read(); -#endif - tcflush(FD, TCIOFLUSH); - cour_write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); - if (!cour_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - cour_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - cour_write(FD, num, strlen(num)); - cour_write(FD, "\r", 1); - connected = cour_connect(); -#ifdef ACULOG - if (dialtimeout) { - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "cour", line); - } -#endif - if (dialtimeout) - cour_disconnect(); - return (connected); -} - -void -cour_disconnect(void) -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - coursync(); /* reset */ - close(FD); -} - -void -cour_abort(void) -{ - cour_write(FD, "\r", 1); /* send anything to abort the call */ - cour_disconnect(); -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - printf("\07timeout waiting for reply\n"); - dialtimeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -cour_swallow(char *match) -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - dialtimeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -struct baud_msg { - char *msg; - int baud; -} baud_msg[] = { - { "", B300 }, - { " 1200", B1200 }, - { " 2400", B2400 }, - { " 9600", B9600 }, - { " 9600/ARQ", B9600 }, - { 0, 0 }, -}; - -static int -cour_connect(void) -{ - char c; - int nc, nl, n; - char dialer_buf[64]; - struct baud_msg *bm; - sig_t f; - - if (cour_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - dialtimeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (cour_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = baud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - 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))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } - printf("%s\r\n", dialer_buf); - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the courier in sync. - */ -static int -coursync(void) -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - tcflush(FD, TCIOFLUSH); - cour_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("coursync: (\"%s\")\n\r", buf); -#endif - if (strchr(buf, '0') || - (strchr(buf, 'O') && strchr(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - cour_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - cour_write(FD, "\rAT Z\r", 6); - return (0); -} - -static void -cour_write(int fd, char *cp, int n) -{ -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - tcdrain(fd); - cour_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - tcdrain(fd); - cour_nap(); - } -} - -#ifdef DEBUG -static void -cour_verbose_read(void) -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* Give the courier 50 milliseconds between characters */ -static void -cour_nap(void) -{ - struct timespec ts; - - ts.tv_sec = 0; - ts.tv_nsec = 50 * 1000000; - - nanosleep(&ts, NULL); -} diff --git a/usr.bin/tip/aculib/df.c b/usr.bin/tip/aculib/df.c deleted file mode 100644 index 39b09901d29..00000000000 --- a/usr.bin/tip/aculib/df.c +++ /dev/null @@ -1,127 +0,0 @@ -/* $OpenBSD: df.c,v 1.10 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: df.c,v 1.4 1995/10/29 00:49:51 pk Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Dial the DF02-AC or DF03-AC - */ - -#include "tip.h" - -static jmp_buf Sjbuf; - -static int df_dialer(char *, char *, int); -static void alrm_timeout(int); - -int -df02_dialer(char *num, char *acu) -{ - return (df_dialer(num, acu, 0)); -} - -int -df03_dialer(char *num, char *acu) -{ - return (df_dialer(num, acu, 1)); -} - -static int -df_dialer(char *num, char *acu, int df03) -{ - int f = FD; - struct termios cntrl; - int speed = 0; - char c = '\0'; - - tcgetattr(f, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(f, TCSANOW, &cntrl); - if (setjmp(Sjbuf)) { - printf("connection timed out\r\n"); - df_disconnect(); - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); -#ifdef TIOCMSET - if (df03) { - int st = TIOCM_ST; /* secondary Transmit flag */ - - tcgetattr(f, &cntrl); - speed = cfgetospeed(&cntrl); - if (speed != B1200) { /* must dial at 1200 baud */ - cfsetospeed(&cntrl, B1200); - cfsetispeed(&cntrl, B1200); - tcsetattr(f, TCSAFLUSH, &cntrl); - ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */ - } else - ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */ - } -#endif - signal(SIGALRM, alrm_timeout); - alarm(5 * strlen(num) + 10); - tcflush(f, TCIOFLUSH); - write(f, "\001", 1); - sleep(1); - write(f, "\002", 1); - write(f, num, strlen(num)); - read(f, &c, 1); -#ifdef TIOCMSET - if (df03 && speed != B1200) { - cfsetospeed(&cntrl, speed); - cfsetispeed(&cntrl, speed); - tcsetattr(f, TCSAFLUSH, &cntrl); - } -#endif - return (c == 'A'); -} - -void -df_disconnect(void) -{ - write(FD, "\001", 1); - sleep(1); - tcflush(FD, TCIOFLUSH); -} - -void -df_abort(void) -{ - df_disconnect(); -} - -/*ARGSUSED*/ -static void -alrm_timeout(int signo) -{ - longjmp(Sjbuf, 1); -} diff --git a/usr.bin/tip/aculib/dn11.c b/usr.bin/tip/aculib/dn11.c deleted file mode 100644 index 57144e3d244..00000000000 --- a/usr.bin/tip/aculib/dn11.c +++ /dev/null @@ -1,139 +0,0 @@ -/* $OpenBSD: dn11.c,v 1.10 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: dn11.c,v 1.4 1995/10/29 00:49:53 pk Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for dialing up on DN-11 - */ -#include "tip.h" - -static jmp_buf jmpbuf; -static pid_t child = -1, dn; - -static void alarmtr(int); - -int -dn_dialer(char *num, char *acu) -{ - int lt, nw; - int timelim; - struct termios cntrl; - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); - if ((dn = open(acu, 1)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(dn); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - nw = write(dn, num, lt = strlen(num)); - exit(nw != lt); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, 2)) < 0) { - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(dn); - return (0); - } - alarm(0); - tcgetattr(dn, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(dn, TCSANOW, &cntrl); - signal(SIGALRM, SIG_DFL); - while ((nw = wait(<)) != child && nw != -1) - ; - fflush(stdout); - close(dn); - if (lt != 0) { - close(FD); - return (0); - } - return (1); -} - -/*ARGSUSED*/ -static void -alarmtr(int signo) -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -void -dn_disconnect(void) -{ - sleep(2); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -void -dn_abort(void) -{ - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (dn > 0) - close(dn); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} diff --git a/usr.bin/tip/aculib/hayes.c b/usr.bin/tip/aculib/hayes.c deleted file mode 100644 index c52004c0194..00000000000 --- a/usr.bin/tip/aculib/hayes.c +++ /dev/null @@ -1,314 +0,0 @@ -/* $OpenBSD: hayes.c,v 1.15 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: hayes.c,v 1.6 1997/02/11 09:24:17 mrg Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for calling up on a Hayes Modem - * (based on the old VenTel driver). - * The modem is expected to be strapped for "echo". - * Also, the switches enabling the DTR and CD lines - * must be set correctly. - * NOTICE: - * The easy way to hang up a modem is always simply to - * clear the DTR signal. However, if the +++ sequence - * (which switches the modem back to local mode) is sent - * before modem is hung up, removal of the DTR signal - * has no effect (except that it prevents the modem from - * recognizing commands). - * (by Helge Skrivervik, Calma Company, Sunnyvale, CA. 1984) - */ -/* - * TODO: - * It is probably not a good idea to switch the modem - * state between 'verbose' and terse (status messages). - * This should be kicked out and we should use verbose - * mode only. This would make it consistent with normal - * interactive use thru the command 'tip dialer'. - */ -#include "tip.h" - -#include <termios.h> -#include <sys/ioctl.h> - -#define min(a,b) ((a < b) ? a : b) - -static int dialtimeout = 0; -static jmp_buf timeoutbuf; - -#define DUMBUFLEN 40 -static char dumbuf[DUMBUFLEN]; - -#define DIALING 1 -#define IDLE 2 -#define CONNECTED 3 -#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(char *num, char *acu) -{ - char *cp; - int connected = 0; - char dummy; - struct termios cntrl; -#ifdef ACULOG - char line[80]; -#endif - if (hay_sync() == 0) /* make sure we can talk to the modem */ - return(0); - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - tcgetattr(FD, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(FD, TCSANOW, &cntrl); - tcflush(FD, TCIOFLUSH); - write(FD, "ATv0\r", 5); /* tell modem to use short status codes */ - gobble("\r"); - gobble("\r"); - write(FD, "ATTD", 4); /* send dial command */ - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - write(FD, num, strlen(num)); - state = DIALING; - write(FD, "\r", 1); - connected = 0; - if (gobble("\r")) { - if ((dummy = gobble("01234")) != '1') - error_rep(dummy); - else - connected = 1; - } - if (connected) - state = CONNECTED; - else { - state = FAILED; - return (connected); /* lets get out of here.. */ - } - tcflush(FD, TCIOFLUSH); -#ifdef ACULOG - if (dialtimeout) { - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "hayes", line); - } -#endif - if (dialtimeout) - hay_disconnect(); /* insurance */ - return (connected); -} - -void -hay_disconnect(void) -{ - /* first hang up the modem*/ -#ifdef DEBUG - printf("\rdisconnecting modem....\n\r"); -#endif - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - goodbye(); -} - -void -hay_abort(void) -{ - write(FD, "\r", 1); /* send anything to abort the call */ - hay_disconnect(); -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - printf("\07timeout waiting for reply\n\r"); - dialtimeout = 1; - longjmp(timeoutbuf, 1); -} - -static char -gobble(char *match) -{ - char c; - sig_t f; - int i, status = 0; - - f = signal(SIGALRM, sigALRM); - dialtimeout = 0; -#ifdef DEBUG - printf("\ngobble: waiting for %s\n", match); -#endif - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - printf("%c 0x%x ", c, c); -#endif - for (i = 0; i < strlen(match); i++) - if (c == match[i]) - status = c; - } while (status == 0); - signal(SIGALRM, SIG_DFL); -#ifdef DEBUG - printf("\n"); -#endif - return (status); -} - -static void -error_rep(char c) -{ - printf("\n\r"); - switch (c) { - - case '0': - printf("OK"); - break; - - 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); - } - printf("\n\r"); - return; -} - -/* - * set modem back to normal verbose status codes. - */ -static void -goodbye(void) -{ - int len; - - tcflush(FD, TCIOFLUSH); - if (hay_sync()) { -#ifdef DEBUG - ssize_t rlen; -#else - char c; -#endif - - sleep(1); -#ifndef DEBUG - tcflush(FD, TCIOFLUSH); -#endif - write(FD, "ATH0\r", 5); /* insurance */ -#ifndef DEBUG - c = gobble("03"); - if (c != '0' && c != '3') { - printf("cannot hang up modem\n\r"); - printf("please use 'tip dialer' to make sure the line is hung up\n\r"); - } -#endif - sleep(1); - ioctl(FD, FIONREAD, &len); -#ifdef DEBUG - printf("goodbye1: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%zd): %s\r\n", rlen, dumbuf); -#endif - write(FD, "ATv1\r", 5); - sleep(1); -#ifdef DEBUG - ioctl(FD, FIONREAD, &len); - printf("goodbye2: len=%d -- ", len); - rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); - dumbuf[rlen] = '\0'; - printf("read (%zd): %s\r\n", rlen, dumbuf); -#endif - } - tcflush(FD, TCIOFLUSH); - ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */ - close(FD); -} - -#define MAXRETRY 5 - -static int -hay_sync(void) -{ - int len, retry = 0; - - while (retry++ <= MAXRETRY) { - write(FD, "AT\r", 3); - sleep(1); - ioctl(FD, FIONREAD, &len); - if (len) { - len = read(FD, dumbuf, min(len, DUMBUFLEN)); - if (strchr(dumbuf, '0') || - (strchr(dumbuf, 'O') && strchr(dumbuf, 'K'))) - return(1); -#ifdef DEBUG - dumbuf[len] = '\0'; - printf("hay_sync: (\"%s\") %d\n\r", dumbuf, retry); -#endif - } - ioctl(FD, TIOCCDTR, 0); - ioctl(FD, TIOCSDTR, 0); - } - printf("Cannot synchronize with hayes...\n\r"); - return(0); -} diff --git a/usr.bin/tip/aculib/t3000.c b/usr.bin/tip/aculib/t3000.c deleted file mode 100644 index 728cd37a582..00000000000 --- a/usr.bin/tip/aculib/t3000.c +++ /dev/null @@ -1,362 +0,0 @@ -/* $OpenBSD: t3000.c,v 1.15 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: t3000.c,v 1.5 1997/02/11 09:24:18 mrg Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for calling up on a Telebit T3000 modem. - * Derived from Courier driver. - */ -#include "tip.h" - -#include <sys/ioctl.h> -#include <stdio.h> - -#define MAXRETRY 5 - -static int dialtimeout = 0; -static int connected = 0; -static jmp_buf timeoutbuf; - -static void sigALRM(int); -static int t3000_swallow(char *); -static int t3000_connect(void); -static int t3000_sync(void); -static void t3000_write(int, char *, int); -static void t3000_nap(void); -#ifdef DEBUG -static void t3000_verbose_read(void); -#endif - -int -t3000_dialer(char *num, char *acu) -{ - char *cp; - struct termios cntrl; -#ifdef ACULOG - char line[80]; -#endif - - if (boolean(value(VERBOSE))) - printf("Using \"%s\"\n", acu); - - tcgetattr(FD, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(FD, TCSANOW, &cntrl); - /* - * Get in synch. - */ - if (!t3000_sync()) { -badsynch: - printf("can't synchronize with t3000\n"); -#ifdef ACULOG - logent(value(HOST), num, "t3000", "can't synch up"); -#endif - return (0); - } - t3000_write(FD, "AT E0\r", 6); /* turn off echoing */ - sleep(1); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - t3000_verbose_read(); -#endif - tcflush(FD, TCIOFLUSH); - t3000_write(FD, "AT E0 H0 Q0 X4 V1\r", 18); - if (!t3000_swallow("\r\nOK\r\n")) - goto badsynch; - fflush(stdout); - t3000_write(FD, "AT D", 4); - for (cp = num; *cp; cp++) - if (*cp == '=') - *cp = ','; - t3000_write(FD, num, strlen(num)); - t3000_write(FD, "\r", 1); - connected = t3000_connect(); -#ifdef ACULOG - if (dialtimeout) { - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "t3000", line); - } -#endif - if (dialtimeout) - t3000_disconnect(); - return (connected); -} - -void -t3000_disconnect(void) -{ - /* first hang up the modem*/ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - t3000_sync(); /* reset */ - close(FD); -} - -void -t3000_abort(void) -{ - t3000_write(FD, "\r", 1); /* send anything to abort the call */ - t3000_disconnect(); -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - printf("\07timeout waiting for reply\n"); - dialtimeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -t3000_swallow(char *match) -{ - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - dialtimeout = 0; - do { - if (*match =='\0') { - signal(SIGALRM, f); - return (1); - } - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, &c, 1); - alarm(0); - c &= 0177; -#ifdef DEBUG - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c == *match++); -#ifdef DEBUG - if (boolean(value(VERBOSE))) - fflush(stdout); -#endif - signal(SIGALRM, SIG_DFL); - return (0); -} - -#ifndef B19200 /* XXX */ -#define B19200 EXTA -#define B38400 EXTB -#endif - -struct tbaud_msg { - char *msg; - int baud; - int baud2; -} tbaud_msg[] = { - { "", B300, 0 }, - { " 1200", B1200, 0 }, - { " 2400", B2400, 0 }, - { " 4800", B4800, 0 }, - { " 9600", B9600, 0 }, - { " 14400", B19200, B9600 }, - { " 19200", B19200, B9600 }, - { " 38400", B38400, B9600 }, - { " 57600", B38400, B9600 }, - { " 7512", B9600, 0 }, - { " 1275", B2400, 0 }, - { " 7200", B9600, 0 }, - { " 12000", B19200, B9600 }, - { 0, 0, 0 }, -}; - -static int -t3000_connect(void) -{ - char c; - int nc, nl, n; - char dialer_buf[64]; - struct tbaud_msg *bm; - sig_t f; - - if (t3000_swallow("\r\n") == 0) - return (0); - f = signal(SIGALRM, sigALRM); -again: - nc = 0; nl = sizeof(dialer_buf)-1; - bzero(dialer_buf, sizeof(dialer_buf)); - dialtimeout = 0; - for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { - if (setjmp(timeoutbuf)) - break; - alarm(number(value(DIALTIMEOUT))); - n = read(FD, &c, 1); - alarm(0); - if (n <= 0) - break; - c &= 0x7f; - if (c == '\r') { - if (t3000_swallow("\n") == 0) - break; - if (!dialer_buf[0]) - goto again; - if (strcmp(dialer_buf, "RINGING") == 0 && - boolean(value(VERBOSE))) { -#ifdef DEBUG - printf("%s\r\n", dialer_buf); -#endif - goto again; - } - if (strncmp(dialer_buf, "CONNECT", - sizeof("CONNECT")-1) != 0) - break; - for (bm = tbaud_msg ; bm->msg ; bm++) - if (strcmp(bm->msg, - dialer_buf+sizeof("CONNECT")-1) == 0) { - 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))) - printf("%s\r\n", dialer_buf); -#endif - return (1); - } - break; - } - dialer_buf[nc] = c; -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } - printf("%s\r\n", dialer_buf); - signal(SIGALRM, f); - return (0); -} - -/* - * This convoluted piece of code attempts to get - * the t3000 in sync. - */ -static int -t3000_sync(void) -{ - int already = 0; - int len; - char buf[40]; - - while (already++ < MAXRETRY) { - tcflush(FD, TCIOFLUSH); - t3000_write(FD, "\rAT Z\r", 6); /* reset modem */ - bzero(buf, sizeof(buf)); - sleep(2); - ioctl(FD, FIONREAD, &len); -#if 1 -if (len == 0) len = 1; -#endif - if (len) { - len = read(FD, buf, sizeof(buf)); -#ifdef DEBUG - buf[len] = '\0'; - printf("t3000_sync: (\"%s\")\n\r", buf); -#endif - if (strchr(buf, '0') || - (strchr(buf, 'O') && strchr(buf, 'K'))) - return(1); - } - /* - * If not strapped for DTR control, - * try to get command mode. - */ - sleep(1); - t3000_write(FD, "+++", 3); - sleep(1); - /* - * Toggle DTR to force anyone off that might have left - * the modem connected. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - } - t3000_write(FD, "\rAT Z\r", 6); - return (0); -} - -static void -t3000_write(int fd, char *cp, int n) -{ -#ifdef notdef - if (boolean(value(VERBOSE))) - write(1, cp, n); -#endif - tcdrain(fd); - t3000_nap(); - for ( ; n-- ; cp++) { - write(fd, cp, 1); - tcdrain(fd); - t3000_nap(); - } -} - -#ifdef DEBUG -static void -t3000_verbose_read(void) -{ - int n = 0; - char buf[BUFSIZ]; - - if (ioctl(FD, FIONREAD, &n) < 0) - return; - if (n <= 0) - return; - if (read(FD, buf, n) != n) - return; - write(1, buf, n); -} -#endif - -/* Give the t3000 50 milliseconds between characters */ -static void -t3000_nap(void) -{ - struct timespec ts; - - ts.tv_sec = 0; - ts.tv_nsec = 50 * 1000000; - - nanosleep(&ts, NULL); -} diff --git a/usr.bin/tip/aculib/v3451.c b/usr.bin/tip/aculib/v3451.c deleted file mode 100644 index 64621d2e835..00000000000 --- a/usr.bin/tip/aculib/v3451.c +++ /dev/null @@ -1,202 +0,0 @@ -/* $OpenBSD: v3451.c,v 1.10 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: v3451.c,v 1.6 1997/02/11 09:24:20 mrg Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for calling up on a Vadic 3451 Modem - */ -#include "tip.h" - -static jmp_buf Sjbuf; - -static void vawrite(char *, int); -static int expect(char *); -static void alarmtr(int); -static int notin(char *, char *); -static int prefix(char *, char *); - -int -v3451_dialer(char *num, char *acu) -{ - sig_t func; - int ok; - int slow = number(value(BAUDRATE)) < 1200; - char phone[50]; - struct termios cntrl; - - /* - * Get in synch - */ - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("I\r", 1 + slow); - vawrite("\005\r", 2 + slow); - if (!expect("READY")) { - printf("can't synchronize with vadic 3451\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "can't synch up"); -#endif - return (0); - } - tcgetattr(FD, &cntrl); - term.c_cflag |= HUPCL; - tcsetattr(FD, TCSANOW, &cntrl); - sleep(1); - vawrite("D\r", 2 + slow); - if (!expect("NUMBER?")) { - printf("Vadic will not accept dial command\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept dial"); -#endif - return (0); - } - (void)snprintf(phone, sizeof phone, "%s\r", num); - vawrite(phone, 1 + slow); - if (!expect(phone)) { - printf("Vadic will not accept phone number\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "will not accept number"); -#endif - return (0); - } - func = signal(SIGINT,SIG_IGN); - /* - * You cannot interrupt the Vadic when its dialing; - * even dropping DTR does not work (definitely a - * brain damaged design). - */ - vawrite("\r", 1 + slow); - vawrite("\r", 1 + slow); - if (!expect("DIALING:")) { - printf("Vadic failed to dial\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "failed to dial"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - ok = expect("ON LINE"); - signal(SIGINT, func); - if (!ok) { - printf("call failed\n"); -#ifdef ACULOG - logent(value(HOST), num, "vadic", "call failed"); -#endif - return (0); - } - tcflush(FD, TCIOFLUSH); - return (1); -} - -void -v3451_disconnect(void) -{ - close(FD); -} - -void -v3451_abort(void) -{ - close(FD); -} - -static void -vawrite(char *cp, int delay) -{ - for (; *cp; sleep(delay), cp++) - write(FD, cp, 1); -} - -static int -expect(char *cp) -{ - char buf[300]; - char *rp = buf; - int timeout = 30, online = 0; - - if (strcmp(cp, "\"\"") == 0) - return (1); - *rp = 0; - /* - * If we are waiting for the Vadic to complete - * dialing and get a connection, allow more time - * Unfortunately, the Vadic times out 24 seconds after - * the last digit is dialed - */ - online = strcmp(cp, "ON LINE") == 0; - if (online) - timeout = number(value(DIALTIMEOUT)); - signal(SIGALRM, alarmtr); - if (setjmp(Sjbuf)) - return (0); - alarm(timeout); - while (notin(cp, buf) && rp < buf + sizeof (buf) - 1) { - if (online && notin("FAILED CALL", buf) == 0) - return (0); - if (read(FD, rp, 1) < 0) { - alarm(0); - return (0); - } - if (*rp &= 0177) - rp++; - *rp = '\0'; - } - alarm(0); - return (1); -} - -/*ARGSUSED*/ -static void -alarmtr(int signo) -{ - longjmp(Sjbuf, 1); -} - -static int -notin(char *sh, char *lg) -{ - for (; *lg; lg++) - if (prefix(sh, lg)) - return (0); - return (1); -} - -static int -prefix(char *s1, char *s2) -{ - char c; - - while ((c = *s1++) == *s2++) - if (c == '\0') - return (1); - return (c == '\0'); -} diff --git a/usr.bin/tip/aculib/v831.c b/usr.bin/tip/aculib/v831.c deleted file mode 100644 index ff70eda8a9e..00000000000 --- a/usr.bin/tip/aculib/v831.c +++ /dev/null @@ -1,253 +0,0 @@ -/* $OpenBSD: v831.c,v 1.12 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: v831.c,v 1.5 1996/12/29 10:42:01 cgd Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for dialing up on Vadic 831 - */ -#include "tip.h" -#include <termios.h> - -static jmp_buf jmpbuf; -static pid_t child = -1; - -static void alarmtr(int); -static int dialit(char *, char *); -static char * sanitize(char *); - -int -v831_dialer(char *num, char *acu) -{ - int status; - int timelim; - pid_t pid; - - if (boolean(value(VERBOSE))) - printf("\nstarting call..."); -#ifdef DEBUG - printf ("(acu=%s)\n", acu); -#endif - if ((AC = open(acu, O_RDWR)) < 0) { - if (errno == EBUSY) - printf("line busy..."); - else - printf("acu open error..."); - return (0); - } - if (setjmp(jmpbuf)) { - kill(child, SIGKILL); - close(AC); - return (0); - } - signal(SIGALRM, alarmtr); - timelim = 5 * strlen(num); - alarm(timelim < 30 ? 30 : timelim); - if ((child = fork()) == 0) { - /* - * ignore this stuff for aborts - */ - signal(SIGALRM, SIG_IGN); - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - sleep(2); - exit(dialit(num, acu) != 'A'); - } - /* - * open line - will return on carrier - */ - if ((FD = open(DV, O_RDWR)) < 0) { -#ifdef DEBUG - printf("(after open, errno=%d)\n", errno); -#endif - if (errno == EIO) - printf("lost carrier..."); - else - printf("dialup line open failed..."); - alarm(0); - kill(child, SIGKILL); - close(AC); - return (0); - } - alarm(0); - signal(SIGALRM, SIG_DFL); - while ((pid = wait(&status)) != child && pid != -1) - ; - if (status) { - close(AC); - return (0); - } - return (1); -} - -/*ARGSUSED*/ -static void -alarmtr(int signo) -{ - alarm(0); - longjmp(jmpbuf, 1); -} - -/* - * Insurance, for some reason we don't seem to be - * hanging up... - */ -void -v831_disconnect(void) -{ - struct termios cntrl; - - sleep(2); -#ifdef DEBUG - printf("[disconnect: FD=%d]\n", FD); -#endif - if (FD > 0) { - ioctl(FD, TIOCCDTR, 0); - tcgetattr(FD, &cntrl); - cfsetospeed(&cntrl, 0); - cfsetispeed(&cntrl, 0); - tcsetattr(FD, TCSAFLUSH, &cntrl); - ioctl(FD, TIOCNXCL, NULL); - } - close(FD); -} - -void -v831_abort(void) -{ -#ifdef DEBUG - printf("[abort: AC=%d]\n", AC); -#endif - sleep(2); - if (child > 0) - kill(child, SIGKILL); - if (FD > 0) - ioctl(FD, TIOCNXCL, NULL); - close(AC); - if (FD > 0) - ioctl(FD, TIOCCDTR, 0); - close(FD); -} - -/* - * Sigh, this probably must be changed at each site. - */ -struct vaconfig { - char *vc_name; - char vc_rack; - char vc_modem; -} vaconfig[] = { - { "/dev/cua0",'4','0' }, - { "/dev/cua1",'4','1' }, - { 0 } -}; - -#define pc(x) (c = x, write(AC,&c,1)) -#define ABORT 01 -#define SI 017 -#define STX 02 -#define ETX 03 - -static int -dialit(char *phonenum, char *acu) -{ - struct vaconfig *vp; - struct termios cntrl; - char c; - int i; - - phonenum = sanitize(phonenum); -#ifdef DEBUG - printf ("(dial phonenum=%s)\n", phonenum); -#endif - if (*phonenum == '<' && phonenum[1] == 0) - return ('Z'); - for (vp = vaconfig; vp->vc_name; vp++) - if (strcmp(vp->vc_name, acu) == 0) - break; - if (vp->vc_name == 0) { - printf("Unable to locate dialer (%s)\n", acu); - return ('K'); - } - tcgetattr(AC, &cntrl); - cfsetospeed(&cntrl, B2400); - cfsetispeed(&cntrl, B2400); - cntrl.c_cflag |= PARODD | PARENB; - cntrl.c_lflag &= ~(ISIG | ICANON); - tcsetattr(AC, TCSANOW, &cntrl); - tcflush(AC, TCIOFLUSH); - pc(STX); - pc(vp->vc_rack); - pc(vp->vc_modem); - while (*phonenum && *phonenum != '<') - pc(*phonenum++); - pc(SI); - pc(ETX); - sleep(1); - i = read(AC, &c, 1); -#ifdef DEBUG - printf("read %d chars, char=%c, errno %d\n", i, c, errno); -#endif - if (i != 1) - c = 'M'; - if (c == 'B' || c == 'G') { - char cc, oc = c; - - pc(ABORT); - read(AC, &cc, 1); -#ifdef DEBUG - printf("abort response=%c\n", cc); -#endif - c = oc; - v831_disconnect(); - } - close(AC); -#ifdef DEBUG - printf("dialit: returns %c\n", c); -#endif - return (c); -} - -static char * -sanitize(char *s) -{ - static char buf[128]; - char *cp; - - for (cp = buf; *s; s++) { - if (!isdigit(*s) && *s == '<' && *s != '_') - continue; - if (*s == '_') - *s = '='; - *cp++ = *s; - } - *cp++ = 0; - return (buf); -} diff --git a/usr.bin/tip/aculib/ventel.c b/usr.bin/tip/aculib/ventel.c deleted file mode 100644 index a0f9a9e94f1..00000000000 --- a/usr.bin/tip/aculib/ventel.c +++ /dev/null @@ -1,249 +0,0 @@ -/* $OpenBSD: ventel.c,v 1.13 2009/10/27 23:59:45 deraadt Exp $ */ -/* $NetBSD: ventel.c,v 1.6 1997/02/11 09:24:21 mrg Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Routines for calling up on a Ventel Modem - * The Ventel is expected to be strapped for local echo (just like uucp) - */ -#include "tip.h" -#include <termios.h> -#include <sys/ioctl.h> - -#define MAXRETRY 5 - -static int dialtimeout = 0; -static jmp_buf timeoutbuf; - -static void echo(char *); -static void sigALRM(int); -static int gobble(char, char *); -static int vensync(int); - -/* - * some sleep calls have been replaced by this macro - * because some ventel modems require two <cr>s in less than - * a second in order to 'wake up'... yes, it is dirty... - */ -#define delay(num,denom) busyloop(CPUSPEED*num/denom) -#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */ -#define DELAY(n) do { long N = (n); while (--N > 0); } while (0) -#define busyloop(n) do { DELAY(n); } while (0) - -int -ven_dialer(char *num, char *acu) -{ - char *cp; - int connected = 0; - char *msg, line[80]; - struct termios cntrl; - - /* - * Get in synch with a couple of carriage returns - */ - if (!vensync(FD)) { - printf("can't synchronize with ventel\n"); -#ifdef ACULOG - logent(value(HOST), num, "ventel", "can't synch up"); -#endif - return (0); - } - if (boolean(value(VERBOSE))) - printf("\ndialing..."); - fflush(stdout); - tcgetattr(FD, &cntrl); - cntrl.c_cflag |= HUPCL; - tcsetattr(FD, TCSANOW, &cntrl); - echo("#k$\r$\n$D$I$A$L$:$ "); - for (cp = num; *cp; cp++) { - delay(1, 10); - write(FD, cp, 1); - } - delay(1, 10); - write(FD, "\r", 1); - gobble('\n', line); - if (gobble('\n', line)) - connected = gobble('!', line); - tcflush(FD, TCIOFLUSH); -#ifdef ACULOG - if (dialtimeout) { - (void)snprintf(line, sizeof line, "%ld second dial timeout", - number(value(DIALTIMEOUT))); - logent(value(HOST), num, "ventel", line); - } -#endif - if (dialtimeout) - ven_disconnect(); /* insurance */ - if (connected || dialtimeout || !boolean(value(VERBOSE))) - return (connected); - /* call failed, parse response for user */ - cp = strchr(line, '\r'); - if (cp) - *cp = '\0'; - for (cp = line; (cp = strchr(cp, ' ')) != NULL; cp++) - if (cp[1] == ' ') - break; - if (cp) { - while (*cp == ' ') - cp++; - msg = cp; - while (*cp) { - if (isupper(*cp)) - *cp = tolower(*cp); - cp++; - } - printf("%s...", msg); - } - return (connected); -} - -void -ven_disconnect(void) -{ - close(FD); -} - -void -ven_abort(void) -{ - write(FD, "\03", 1); - close(FD); -} - -static void -echo(char *s) -{ - char c; - - while ((c = *s++) != NULL) - switch (c) { - case '$': - read(FD, &c, 1); - s++; - break; - - case '#': - c = *s++; - write(FD, &c, 1); - break; - - default: - write(FD, &c, 1); - read(FD, &c, 1); - } -} - -/*ARGSUSED*/ -static void -sigALRM(int signo) -{ - printf("\07timeout waiting for reply\n"); - dialtimeout = 1; - longjmp(timeoutbuf, 1); -} - -static int -gobble(char match, char response[]) -{ - char *cp = response; - sig_t f; - char c; - - f = signal(SIGALRM, sigALRM); - dialtimeout = 0; - do { - if (setjmp(timeoutbuf)) { - signal(SIGALRM, f); - *cp = '\0'; - return (0); - } - alarm(number(value(DIALTIMEOUT))); - read(FD, cp, 1); - alarm(0); - c = (*cp++ &= 0177); -#ifdef notdef - if (boolean(value(VERBOSE))) - putchar(c); -#endif - } while (c != '\n' && c != match); - signal(SIGALRM, SIG_DFL); - *cp = '\0'; - return (c == match); -} - -#define min(a,b) ((a)>(b)?(b):(a)) -/* - * This convoluted piece of code attempts to get - * the ventel in sync. If you don't have FIONREAD - * there are gory ways to simulate this. - */ -static int -vensync(int fd) -{ - int already = 0, nread; - char buf[60]; - - /* - * Toggle DTR to force anyone off that might have left - * the modem connected, and insure a consistent state - * to start from. - * - * If you don't have the ioctl calls to diddle directly - * with DTR, you can always try setting the baud rate to 0. - */ - ioctl(FD, TIOCCDTR, 0); - sleep(1); - ioctl(FD, TIOCSDTR, 0); - while (already < MAXRETRY) { - /* - * After reseting the modem, send it two \r's to - * autobaud on. Make sure to delay between them - * so the modem can frame the incoming characters. - */ - write(fd, "\r", 1); - delay(1,10); - write(fd, "\r", 1); - sleep(2); - if (ioctl(fd, FIONREAD, (caddr_t)&nread) < 0) { - perror("tip: ioctl"); - continue; - } - while (nread > 0) { - read(fd, buf, min(nread, 60)); - if ((buf[nread - 1] & 0177) == '$') - return (1); - nread -= min(nread, 60); - } - sleep(1); - already++; - } - return (0); -} diff --git a/usr.bin/tip/acutab.c b/usr.bin/tip/acutab.c deleted file mode 100644 index 77f23771ffe..00000000000 --- a/usr.bin/tip/acutab.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: acutab.c,v 1.6 2009/10/27 23:59:44 deraadt Exp $ */ -/* $NetBSD: acutab.c,v 1.3 1994/12/08 09:30:41 jtc Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 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. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "tip.h" - -acu_t acutable[] = { -#if BIZ1031 - { "biz31f", biz31f_dialer, biz31_disconnect, biz31_abort }, - { "biz31w", biz31w_dialer, biz31_disconnect, biz31_abort }, -#endif -#if BIZ1022 - { "biz22f", biz22f_dialer, biz22_disconnect, biz22_abort }, - { "biz22w", biz22w_dialer, biz22_disconnect, biz22_abort }, -#endif -#if DF02 - { "df02", df02_dialer, df_disconnect, df_abort }, -#endif -#if DF03 - { "df03", df03_dialer, df_disconnect, df_abort }, -#endif -#if DN11 - { "dn11", dn_dialer, dn_disconnect, dn_abort }, -#endif -#ifdef VENTEL - { "ventel", ven_dialer, ven_disconnect, ven_abort }, -#endif -#ifdef HAYES - { "hayes", hay_dialer, hay_disconnect, hay_abort }, -#endif -#ifdef COURIER - { "courier", cour_dialer, cour_disconnect, cour_abort }, -#endif -#ifdef T3000 - { "t3000", t3000_dialer, t3000_disconnect, t3000_abort }, -#endif -#ifdef V3451 -#ifndef V831 - { "vadic", v3451_dialer, v3451_disconnect, v3451_abort }, -#endif - { "v3451", v3451_dialer, v3451_disconnect, v3451_abort }, -#endif -#ifdef V831 -#ifndef V3451 - { "vadic", v831_dialer, v831_disconnect, v831_abort }, -#endif - { "v831", v831_dialer, v831_disconnect, v831_abort }, -#endif - { 0, 0, 0, 0 } -}; - diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c index f5b4661e376..6615f84e495 100644 --- a/usr.bin/tip/cmds.c +++ b/usr.bin/tip/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.32 2010/02/07 20:16:47 nicm Exp $ */ +/* $OpenBSD: cmds.c,v 1.33 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */ /* @@ -649,7 +649,7 @@ tipabort(char *msg) signal(SIGTERM, SIG_IGN); kill(tipout_pid, SIGTERM); - disconnect(msg); + logent(value(HOST), DV, "call terminated"); if (msg != NULL) printf("\r\n%s", msg); printf("\r\n[EOT]\r\n"); diff --git a/usr.bin/tip/cu.1 b/usr.bin/tip/cu.1 index a27a6ccfbc8..85472c9a256 100644 --- a/usr.bin/tip/cu.1 +++ b/usr.bin/tip/cu.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cu.1,v 1.7 2010/03/04 09:10:22 sobrado Exp $ +.\" $OpenBSD: cu.1,v 1.8 2010/06/29 16:41:56 nicm Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)tip.1 8.4 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: March 4 2010 $ +.Dd $Mdocdate: June 29 2010 $ .Dt CU 1 .Os .Sh NAME @@ -38,7 +38,6 @@ .Sh SYNOPSIS .Nm .Op Fl ehot -.Op Fl a Ar acu .Op Fl l Ar line .Op Fl s Ar speed \*(Ba Fl Ar speed .Op Ar phone-number @@ -53,8 +52,6 @@ debugging purposes. .Pp The options are as follows: .Bl -tag -width 4n -.It Fl a Ar acu -Set the acu. .It Fl e Use even parity. If both @@ -336,10 +333,6 @@ abbreviated (bool) Discard unprintable characters when a session is being scripted; abbreviated .Ar be . -.It Ar dialtimeout -(num) When dialing a phone number, the time (in seconds) to wait for a -connection to be established; abbreviated -.Ar dial . .It Ar echocheck (bool) Synchronize with the remote host during file transfer by waiting for the echo of the last character transmitted; default is diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c index d8f12e11faf..261242ca986 100644 --- a/usr.bin/tip/cu.c +++ b/usr.bin/tip/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.25 2009/12/12 18:14:00 nicm Exp $ */ +/* $OpenBSD: cu.c,v 1.26 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */ /* @@ -49,7 +49,7 @@ cumain(int argc, char *argv[]) if (argc < 2) cuusage(); - CU = DV = NULL; + DV = NULL; BR = DEFBR; parity = 0; /* none */ @@ -80,13 +80,8 @@ cumain(int argc, char *argv[]) } getopt: - while ((ch = getopt(argc, argv, "a:l:s:htoe")) != -1) { + while ((ch = getopt(argc, argv, "l:s:htoe")) != -1) { switch (ch) { - case 'a': - if (optarg[0] == '\0') - errx(3, "invalid acu: \"\""); - CU = optarg; - break; case 'l': if (DV != NULL) { fprintf(stderr, @@ -110,7 +105,7 @@ getopt: HD = TRUE; break; case 't': - HW = 1, DU = -1; + HW = 1; break; case 'o': if (parity != 0) @@ -184,11 +179,7 @@ getopt: (void)uu_unlock(uucplock); exit(3); } - if (con()) { - printf("Connect failed\n"); - (void)uu_unlock(uucplock); - exit(1); - } + con(); if (!HW && ttysetup(BR)) { fprintf(stderr, "%s: unsupported speed %ld\n", __progname, BR); @@ -200,7 +191,7 @@ getopt: static void cuusage(void) { - fprintf(stderr, "usage: cu [-ehot] [-a acu] [-l line] " + fprintf(stderr, "usage: cu [-ehot] [-l line] " "[-s speed | -speed] [phone-number]\n"); exit(8); } diff --git a/usr.bin/tip/log.c b/usr.bin/tip/log.c index 71d43c0da3b..b66d0f9770d 100644 --- a/usr.bin/tip/log.c +++ b/usr.bin/tip/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.10 2009/10/27 23:59:44 deraadt Exp $ */ +/* $OpenBSD: log.c,v 1.11 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: log.c,v 1.4 1994/12/24 17:56:28 cgd Exp $ */ /* @@ -39,7 +39,7 @@ static FILE *flog = NULL; * Log file maintenance routines */ void -logent(char *group, char *num, char *acu, char *message) +logent(char *group, char *acu, char *message) { char *user, *timestamp; struct passwd *pwd; @@ -60,13 +60,8 @@ logent(char *group, char *num, char *acu, char *message) t = time(0); timestamp = ctime(&t); timestamp[24] = '\0'; - fprintf(flog, "%s (%s) <%s, %s, %s> %s\n", + fprintf(flog, "%s (%s) <%s, %s> %s\n", user, timestamp, group, -#ifdef PRISTINE - "", -#else - num, -#endif acu, message); (void) fflush(flog); (void) flock(fileno(flog), LOCK_UN); diff --git a/usr.bin/tip/pathnames.h b/usr.bin/tip/pathnames.h index cc5995756c6..76778e65344 100644 --- a/usr.bin/tip/pathnames.h +++ b/usr.bin/tip/pathnames.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pathnames.h,v 1.3 2003/06/03 02:56:18 millert Exp $ */ +/* $OpenBSD: pathnames.h,v 1.4 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: pathnames.h,v 1.3 1994/12/08 09:30:59 jtc Exp $ */ /* @@ -36,5 +36,4 @@ #define _PATH_ACULOG "/var/log/aculog" #define _PATH_LOCKDIRNAME "/var/spool/lock/LCK..%s" -#define _PATH_PHONES "/etc/phones" #define _PATH_REMOTE "/etc/remote" diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c index e57c9c68787..e996118329d 100644 --- a/usr.bin/tip/remote.c +++ b/usr.bin/tip/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.19 2010/06/29 05:55:37 nicm Exp $ */ +/* $OpenBSD: remote.c,v 1.20 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $ */ /* @@ -42,12 +42,12 @@ * data base. */ static char **caps[] = { - &AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI, + &DV, &CM, &EL, &IE, &OE, &PN, &PR, &DI, &ES, &EX, &FO, &RC, &RE, &PA }; static char *capstrings[] = { - "at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr", + "dv", "cm", "el", "ie", "oe", "pn", "pr", "di", "es", "ex", "fo", "rc", "re", "pa", 0 }; @@ -77,10 +77,8 @@ getremcap(char *host) if ((stat = cgetent(&bp, db_array, host)) < 0) { if ((DV != NULL) || (host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) { - CU = DV; HO = host; HW = 1; - DU = 0; if (!BR) BR = DEFBR; FS = DEFFS; @@ -113,24 +111,10 @@ getremcap(char *host) LD = TTYDISC; if (cgetnum(bp, "fs", &FS) == -1) FS = DEFFS; - if (DU < 0) - DU = 0; - else - DU = cgetflag("du"); if (DV == NULL) { fprintf(stderr, "%s: missing device spec\n", host); exit(3); } - if (DU && CU == NULL) - CU = DV; - if (DU && PN == NULL) { - fprintf(stderr, "%s: missing phone number\n", host); - exit(3); - } - if (DU && AT == NULL) { - fprintf(stderr, "%s: missing acu type\n", host); - exit(3); - } HD = cgetflag("hd"); @@ -138,8 +122,7 @@ getremcap(char *host) * This effectively eliminates the "hw" attribute * from the description file */ - if (!HW) - HW = (CU == NULL) || (DU && strcmp(DV, CU) == 0); + HW = 1; HO = host; /* * see if uppercase mode should be turned on initially diff --git a/usr.bin/tip/tip.1 b/usr.bin/tip/tip.1 index 33b1a81d672..a6d9aa67778 100644 --- a/usr.bin/tip/tip.1 +++ b/usr.bin/tip/tip.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tip.1,v 1.40 2009/01/09 00:24:34 jmc Exp $ +.\" $OpenBSD: tip.1,v 1.41 2010/06/29 16:41:56 nicm Exp $ .\" $NetBSD: tip.1,v 1.7 1994/12/08 09:31:05 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)tip.1 8.4 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: January 9 2009 $ +.Dd $Mdocdate: June 29 2010 $ .Dt TIP 1 .Os .Sh NAME @@ -320,29 +320,6 @@ may be set to indicate .Nm should synchronize with the remote system on the echo of each transmitted character. -.Pp -When -.Nm -must dial a phone number to connect to a system it will print various -messages indicating its actions. -.Nm -supports a variety of auto-call units and modems with the -.Ar at -capability in system descriptions. -.Pp -Support for Ventel 212+ (ventel), Hayes AT-style (hayes), -USRobotics Courier (courier), Telebit T3000 (t3000) and -Racal-Vadic 831 (vadic) units is enabled by default. -.Pp -Support for Bizcomp 1031[fw] (biz31[fw]), Bizcomp 1022[fw] -(biz22[fw]), DEC DF0[23]-AC (df0[23]), DEC DN-11 (dn11) and -Racal-Vadic 3451 (v3451) units can be added by recompiling -.Nm tip -with the appropriate defines. -.Pp -Note that if support for both the Racal-Vadic 831 and 3451 is enabled -they are referred to as the v831 and v3451 respectively. -If only one of the two is supported, it is referred to as vadic. .Ss VARIABLES .Nm maintains a set of variables which control its operation. @@ -400,10 +377,6 @@ abbreviated (bool) Discard unprintable characters when a session is being scripted; abbreviated .Ar be . -.It Ar dialtimeout -(num) When dialing a phone number, the time (in seconds) to wait for a -connection to be established; abbreviated -.Ar dial . .It Ar echocheck (bool) Synchronize with the remote host during file transfer by waiting for the echo of the last character transmitted; default is @@ -547,10 +520,6 @@ command. The default value for .Ar system-name if none is specified via the command line. -.It Ev PHONES -A path to a -.Xr phones 5 -database. .It Ev REMOTE A system description, or an absolute path to a .Xr remote 5 @@ -567,10 +536,6 @@ command; default value is initialization file .It Pa tip.record record file -.It Pa /etc/phones -default -.Xr phones 5 -file .It Pa /etc/remote global .Xr remote 5 @@ -583,7 +548,6 @@ lock file to avoid conflicts with .El .Sh SEE ALSO .Xr cu 1 , -.Xr phones 5 , .Xr remote 5 .Sh HISTORY The diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c index a96783271c1..268f93a339b 100644 --- a/usr.bin/tip/tip.c +++ b/usr.bin/tip/tip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tip.c,v 1.39 2010/06/29 05:55:37 nicm Exp $ */ +/* $OpenBSD: tip.c,v 1.40 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */ /* @@ -34,7 +34,7 @@ * tip - UNIX link to other systems * tip [-v] [-speed] system-name * or - * cu phone-number [-s speed] [-l line] [-a acu] + * cu phone-number [-s speed] [-l line] */ #include <sys/types.h> @@ -138,13 +138,6 @@ notnumber: } setbuf(stdout, NULL); loginit(); - - /* - * Kludge, their's no easy way to get the initialization - * in the right order, so force it here - */ - if ((PH = getenv("PHONES")) == NULL) - PH = _PATH_PHONES; vinit(); /* init variables */ setparity("none"); /* set the parity table */ @@ -159,11 +152,7 @@ notnumber: (void)uu_unlock(uucplock); exit(3); } - if ((p = con())) { - printf("\07%s\n[EOT]\n", p); - (void)uu_unlock(uucplock); - exit(1); - } + con(); if (!HW && ttysetup(number(value(BAUDRATE)))) { fprintf(stderr, "%s: bad baud rate %ld\n", __progname, number(value(BAUDRATE))); @@ -240,6 +229,14 @@ cucommon: } void +con(void) +{ + if (CM != NULL) + parwrite(FD, CM, size(CM)); + logent(value(HOST), DV, "call completed"); +} + +void cleanup(int signo) { (void)uu_unlock(uucplock); diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h index 1665c5695dd..cc43e36c17c 100644 --- a/usr.bin/tip/tip.h +++ b/usr.bin/tip/tip.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tip.h,v 1.34 2010/06/29 05:55:37 nicm Exp $ */ +/* $OpenBSD: tip.h,v 1.35 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */ /* @@ -64,20 +64,16 @@ char *EL; /* chars marking an EOL */ char *CM; /* initial connection message */ char *IE; /* EOT to expect on input */ char *OE; /* EOT to send to complete FT */ -char *CU; /* call unit if making a phone call */ -char *AT; /* acu type */ char *PN; /* phone number(s) */ char *DI; /* disconnect string */ char *PA; /* parity to be generated */ -char *PH; /* phone number file */ char *RM; /* remote file name */ char *HO; /* host name */ long BR; /* line speed for conversation */ long FS; /* frame size for transfers */ -short DU; /* this host is dialed up */ short HW; /* this device is hardwired, see hunt.c */ char *ES; /* escape character */ char *EX; /* exceptions */ @@ -126,18 +122,6 @@ typedef #define TMASK 017 /* - * Definition of ACU line description - */ -typedef - struct { - char *acu_name; - int (*acu_dialer)(char *, char *); - void (*acu_disconnect)(void); - void (*acu_abort)(void); - } - acu_t; - -/* * variable manipulation stuff -- * if we defined the value entry in value_t, then we couldn't * initialize it in vars.c, so we cast it as needed to keep lint @@ -176,7 +160,7 @@ extern int noesc; /* no escape `~' char */ extern value_t vtable[]; /* variable table */ #ifndef ACULOG -#define logent(a, b, c, d) +#define logent(a, b, c) #define loginit() #endif @@ -185,42 +169,42 @@ extern value_t vtable[]; /* variable table */ * value(DEFINE) turns into a static address. */ -#define BEAUTIFY 0 -#define BAUDRATE 1 -#define DIALTIMEOUT 2 -#define EOFREAD 3 -#define EOFWRITE 4 -#define EOL 5 -#define ESCAPE 6 -#define EXCEPTIONS 7 -#define FORCE 8 -#define FRAMESIZE 9 -#define HOST 10 -#define LOG 11 -#define PHONES 12 -#define PROMPT 13 -#define RAISE 14 -#define RAISECHAR 15 -#define RECORD 16 -#define REMOTE 17 -#define SCRIPT 18 -#define TABEXPAND 19 -#define VERBOSE 20 -#define SHELL 21 -#define HOME 22 -#define ECHOCHECK 23 -#define DISCONNECT 24 -#define TAND 25 -#define LDELAY 26 -#define CDELAY 27 -#define ETIMEOUT 28 -#define RAWFTP 29 -#define HALFDUPLEX 30 -#define LECHO 31 -#define PARITY 32 -#define HARDWAREFLOW 33 -#define LINEDISC 34 -#define DC 35 +enum { + BEAUTIFY = 0, + BAUDRATE, + EOFREAD, + EOFWRITE, + EOL, + ESCAPE, + EXCEPTIONS, + FORCE, + FRAMESIZE, + HOST, + LOG, + PROMPT, + RAISE, + RAISECHAR, + RECORD, + REMOTE, + SCRIPT, + TABEXPAND, + VERBOSE, + SHELL, + HOME, + ECHOCHECK, + DISCONNECT, + TAND, + LDELAY, + CDELAY, + ETIMEOUT, + RAWFTP, + HALFDUPLEX, + LECHO, + PARITY, + HARDWAREFLOW, + LINEDISC, + DC +}; struct termios term; /* current mode of terminal */ struct termios defterm; /* initial mode of terminal */ @@ -256,7 +240,7 @@ extern int disc; /* current tty discpline */ extern char *__progname; /* program name */ -char *con(void); +void con(void); char *ctrl(char); char *expand(char *); char *getremote(char *); @@ -296,7 +280,7 @@ void cu_take(int); void cumain(int, char **); void df_abort(void); void df_disconnect(void); -void disconnect(char *); +void disconnect(void); void dn_abort(void); void dn_disconnect(void); void finish(int); @@ -306,7 +290,7 @@ void hay_abort(void); void hay_disconnect(void); void help(int); void listvariables(int); -void logent(char *, char *, char *, char *); +void logent(char *, char *, char *); void loginit(void); void parwrite(int, char *, size_t); void pipefile(int); diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c index a75fd3f9ae7..760b26ff83c 100644 --- a/usr.bin/tip/vars.c +++ b/usr.bin/tip/vars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vars.c,v 1.10 2009/10/27 23:59:45 deraadt Exp $ */ +/* $OpenBSD: vars.c,v 1.11 2010/06/29 16:41:56 nicm Exp $ */ /* $NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $ */ /* @@ -41,8 +41,6 @@ value_t vtable[] = { "be", (char *)TRUE }, { "baudrate", NUMBER|IREMOTE|INIT, (READ<<PUBLIC)|(WRITE<<ROOT), "ba", (char *)&BR }, - { "dialtimeout",NUMBER, (READ<<PUBLIC)|(WRITE<<ROOT), - "dial", (char *)60 }, { "eofread", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC, "eofr", (char *)&IE }, { "eofwrite", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC, @@ -61,8 +59,6 @@ value_t vtable[] = { "ho", (char *)&HO }, { "log", STRING|INIT, (READ|WRITE)<<ROOT, NULL, _PATH_ACULOG }, - { "phones", STRING|INIT|IREMOTE, READ<<PUBLIC, - NULL, (char *)&PH }, { "prompt", CHAR, (READ|WRITE)<<PUBLIC, "pr", (char *)'\n' }, { "raise", BOOL, (READ|WRITE)<<PUBLIC, |