Initial Import from SVN

This commit is contained in:
Matt Jenkins
2014-04-09 14:27:18 +01:00
parent 8976e834c4
commit 895f96d2f7
3153 changed files with 748589 additions and 0 deletions

103
src/cmd/tip/Makefile Normal file
View File

@@ -0,0 +1,103 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
#
# Copyright (c) 1987 Regents of the University of California.
# All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
# @(#)Makefile 5.4.1 (2.11BSD) 1996/12/1
#
# make file for intermachine communications package
#
# Files are:
# /etc/remote remote host description file
# /etc/phones phone number file, owned by ${OWNER} and
# mode 6??
# ${ADM}/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
# PENRIL autodialer
# USR COURIER (2400 baud)
# VENTEL 212+
# VADIC 831 RS232 adaptor
# VADIC 3451
# (drivers are located in aculib.a)
#
# Configuration defines:
# DF02, DF03, DN11 ACU's supported
# BIZ1031, BIZ1022, VENTEL, V831, V3451, HAYES, COURIER, PENRIL
# 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
# writes on local side
# BUFSIZ buffer sizing from stdio, must be fed
# explicitly to remcap.c if not 1024
ADM = var/log
OWNER = uucp
GROUP = daemon
CONFIG = -DHAYES
LIBS += -lacu -L./aculib
CFLAGS += -DDEFBR=1200 -DDEFFS=BUFSIZ -DACULOG -DPRISTINE -Wall -Werror
SRCS = acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c partab.c remcap.c \
remote.c tip.c tipout.c uucplock.c value.c vars.c
OBJS = acu.o acutab.o cmds.o cmdtab.o cu.o hunt.o log.o partab.o remcap.o \
remote.o tip.o tipout.o uucplock.o value.o vars.o
all: aculib tip
tip: ${OBJS}
${CC} ${LDFLAGS} -o tip.elf ${OBJS} ${LIBS}
${OBJDUMP} -S tip.elf > tip.dis
${SIZE} tip.elf
${ELF2AOUT} tip.elf $@
# acutab is configuration dependent, and so depends on the makefile
acutab.o: Makefile
acutab.o: acutab.c
${CC} -c ${CFLAGS} ${CONFIG} acutab.c
# remote.o depends on the makefile because of DEFBR and DEFFS
# log.o depends on the makefile because of ACULOG
log.o remote.o: Makefile
aculib: FRC
cd aculib; make ${MFLAGS}
clean: FRC
rm -f ${OBJS} core tip tip.elf tip.dis
cd aculib; make ${MFLAGS} clean
depend: FRC
mkdep ${CFLAGS} ${SRCS}
cd aculib; make ${MFLAGS} depend
install: aculib tip
cd aculib; make ${MFLAGS} install
cp tip ${DESTDIR}/bin/tip
rm -f ${DESTDIR}/bin/cu
touch ${DESTDIR}/${ADM}/aculog
chmod 600 ${DESTDIR}/${ADM}/aculog
-mkdir -p ${DESTDIR}/var/lock
@echo "create /etc/remote and /etc/phones"
cp remote-file ${DESTDIR}/etc/remote
cp phones-file ${DESTDIR}/etc/phones
lint: FRC
lint ${CFLAGS} ${SRCS}
tags: FRC
ctags ${SRCS}
FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

61
src/cmd/tip/README Normal file
View File

@@ -0,0 +1,61 @@
Tip can be configured in a number of ways:
ACU's:
-----
ACU Define in makefile
-------------------- ---------------
BIZCOMP 1022, 1031 BIZ1022, BIZ1031
DEC DF02-AC, DF03-AC DF02, DF03
DEC DN-11/Able Quadracall DN11
Ventel VENTEL
Vadic 831 V831
New ACU's may be added by editing the ACU description table
in acutab.c and writing a ``driver''.
ACU usage can be monitored by defining ACULOG in the makefile.
If this is done and no phone numbers should appear in the
log file, define PRISTINE in the makefile.
Variables:
---------
Tip's internal workings revolve around a set of (possibly)
user defined variables. These are statically initialized
in vars.c, and from the remote file.
Note that adding or deleting variables requires tip to be completedly
recompiled, as indexes into the variable table are used to avoid
expensive lookups. These defines are set in tip.h.
Commands:
--------
The command dispatch table is defined in cmdtab.c. Commands
may have attributes such as EXPerimental and PRIVileged (only
root may execute).
--------------------------------------------------------------------------
Recent changes about Jan 82
A new, improved version of tip is now available. The most important
addition is the capacility to specify a phone number with tip. The
default baud rate is 1200. To use it do:
tip phone-number
or
tip -300 phone-number
for 300 baud.
A ~^Z command has been added to tip as well.
A new cu program is available that interfaces to the tip program.
It attempts to give the same user interface as cu but it is really
the tip program so you have all the advantages of tip. This allows
cu (actually tip) to search for a free ACU instead of having the
user specify which one he wants.

18
src/cmd/tip/TODO Normal file
View File

@@ -0,0 +1,18 @@
1. Rethink protection glitches on REMOTE & PHONES
files (setuid/setgid??).
2. Make clean fix for scripting being set in .tiprc
3. change EOFREAD to recognize more general strings.
4. add an option that returns an exit status based on
whether resources for the requested operation are available.
5. write a program to list known systems (a quick shell script
should do it); people keep forgetting the names.
6. change remote file descriptions so that acu attributes are
are attached to a device so that several different devices
can be used to get to the same system (perhaps hardwired
and phone line). got any ideas here? I'm looking at something
like dv=cua1,cul1,dn11;cua2,,df03.

162
src/cmd/tip/acu.c Normal file
View File

@@ -0,0 +1,162 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
static acu_t *acu = NOACU;
static int conflag;
static acu_t *acutype();
static jmp_buf jmpbuf;
static void
acuabort(int s)
{
signal(s, SIG_IGN);
longjmp(jmpbuf, 1);
}
/*
* 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 overriden
* 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 *
connect()
{
register char *cp = PN;
char *phnum, string[256];
FILE *fd;
int tried = 0;
if (!DU) { /* regular connect message */
if (CM != NOSTR)
pwrite(FD, CM, size(CM));
logent(value(HOST), "", DV, "call completed");
return (NOSTR);
}
/*
* @ =>'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 != NOACU) {
boolean(value(VERBOSE)) = FALSE;
if (conflag)
disconnect(NOSTR);
else
(*acu->acu_abort)();
}
return ("interrupt");
}
if ((acu = acutype(AT)) == NOACU)
return ("unknown ACU type");
if (*cp != '@') {
while (*cp) {
for (phnum = cp; *cp && *cp != ','; cp++)
;
if (*cp)
*cp++ = '\0';
conflag = (*acu->acu_dialer)(phnum, CU);
if (conflag) {
logent(value(HOST), phnum, acu->acu_name,
"call completed");
return (NOSTR);
} else
logent(value(HOST), phnum, acu->acu_name,
"call failed");
tried++;
}
} else {
if ((fd = fopen(PH, "r")) == NOFILE) {
printf("%s: ", PH);
return ("can't open phone number file");
}
while (fgets(string, sizeof(string), fd) != NOSTR) {
for (cp = string; !any(*cp, " \t\n"); cp++)
;
if (*cp == '\n') {
fclose(fd);
return ("unrecognizable host name");
}
*cp++ = '\0';
if (strcmp(string, value(HOST)))
continue;
while (any(*cp, " \t"))
cp++;
if (*cp == '\n') {
fclose(fd);
return ("missing phone number");
}
for (phnum = cp; *cp && *cp != ',' && *cp != '\n'; cp++)
;
if (*cp)
*cp++ = '\0';
conflag = (*acu->acu_dialer)(phnum, CU);
if (conflag) {
fclose(fd);
logent(value(HOST), phnum, acu->acu_name,
"call completed");
return (NOSTR);
} else
logent(value(HOST), phnum, acu->acu_name,
"call failed");
tried++;
}
fclose(fd);
}
if (!tried)
logent(value(HOST), "", acu->acu_name, "missing phone number");
else
(*acu->acu_abort)();
return (tried ? "call failed" : "missing phone number");
}
void disconnect(reason)
char *reason;
{
if (!conflag) {
logent(value(HOST), "", DV, "call terminated");
return;
}
if (reason == NOSTR) {
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 acu_t *
acutype(s)
register char *s;
{
register acu_t *p;
extern acu_t acutable[];
for (p = acutable; p->acu_name != '\0'; p++)
if (!strcmp(s, p->acu_name))
return (p);
return (NOACU);
}

552
src/cmd/tip/aculib/.depend Normal file
View File

@@ -0,0 +1,552 @@
biz22.o: biz22.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
biz31.o: biz31.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
courier.o: courier.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h \
/usr/include/i386-linux-gnu/sys/time.h
df.o: df.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
dn11.o: dn11.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
hayes.o: hayes.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
ventel.o: ventel.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
v831.o: v831.c /usr/include/i386-linux-gnu/sys/time.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h ../tip.h \
/usr/include/i386-linux-gnu/sys/types.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
v3451.o: v3451.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h
penril.o: penril.c ../tip.h /usr/include/i386-linux-gnu/sys/types.h \
/usr/include/features.h /usr/include/i386-linux-gnu/bits/predefs.h \
/usr/include/i386-linux-gnu/sys/cdefs.h \
/usr/include/i386-linux-gnu/bits/wordsize.h \
/usr/include/i386-linux-gnu/gnu/stubs.h \
/usr/include/i386-linux-gnu/gnu/stubs-32.h \
/usr/include/i386-linux-gnu/bits/types.h \
/usr/include/i386-linux-gnu/bits/typesizes.h /usr/include/time.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stddef.h /usr/include/endian.h \
/usr/include/i386-linux-gnu/bits/endian.h \
/usr/include/i386-linux-gnu/bits/byteswap.h \
/usr/include/i386-linux-gnu/sys/select.h \
/usr/include/i386-linux-gnu/bits/select.h \
/usr/include/i386-linux-gnu/bits/sigset.h \
/usr/include/i386-linux-gnu/bits/time.h \
/usr/include/i386-linux-gnu/sys/sysmacros.h \
/usr/include/i386-linux-gnu/bits/pthreadtypes.h \
/usr/include/i386-linux-gnu/sys/file.h /usr/include/fcntl.h \
/usr/include/i386-linux-gnu/bits/fcntl.h \
/usr/include/i386-linux-gnu/bits/stat.h \
/usr/include/i386-linux-gnu/bits/fcntl2.h /usr/include/sgtty.h \
/usr/include/i386-linux-gnu/sys/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctls.h \
/usr/include/i386-linux-gnu/asm/ioctls.h \
/usr/include/asm-generic/ioctls.h /usr/include/linux/ioctl.h \
/usr/include/i386-linux-gnu/asm/ioctl.h /usr/include/asm-generic/ioctl.h \
/usr/include/i386-linux-gnu/bits/ioctl-types.h \
/usr/include/i386-linux-gnu/sys/ttydefaults.h /usr/include/signal.h \
/usr/include/i386-linux-gnu/bits/signum.h \
/usr/include/i386-linux-gnu/bits/siginfo.h \
/usr/include/i386-linux-gnu/bits/sigaction.h \
/usr/include/i386-linux-gnu/bits/sigcontext.h \
/usr/include/i386-linux-gnu/asm/sigcontext.h /usr/include/linux/types.h \
/usr/include/i386-linux-gnu/asm/types.h /usr/include/asm-generic/types.h \
/usr/include/asm-generic/int-ll64.h \
/usr/include/i386-linux-gnu/asm/bitsperlong.h \
/usr/include/asm-generic/bitsperlong.h /usr/include/linux/posix_types.h \
/usr/include/linux/stddef.h \
/usr/include/i386-linux-gnu/asm/posix_types.h \
/usr/include/i386-linux-gnu/asm/posix_types_32.h \
/usr/include/i386-linux-gnu/bits/sigstack.h \
/usr/include/i386-linux-gnu/sys/ucontext.h \
/usr/include/i386-linux-gnu/bits/sigthread.h /usr/include/stdio.h \
/usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \
/usr/lib/gcc/i686-linux-gnu/4.6.1/include/stdarg.h \
/usr/include/i386-linux-gnu/bits/stdio_lim.h \
/usr/include/i386-linux-gnu/bits/sys_errlist.h \
/usr/include/i386-linux-gnu/bits/stdio.h \
/usr/include/i386-linux-gnu/bits/stdio2.h /usr/include/pwd.h \
/usr/include/ctype.h /usr/include/xlocale.h /usr/include/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp.h \
/usr/include/i386-linux-gnu/bits/setjmp2.h /usr/include/errno.h \
/usr/include/i386-linux-gnu/bits/errno.h /usr/include/linux/errno.h \
/usr/include/i386-linux-gnu/asm/errno.h /usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h

View File

@@ -0,0 +1,53 @@
TOPSRC = $(shell cd ../../../..; pwd)
include $(TOPSRC)/target.mk
#
# Copyright (c) 1987 Regents of the University of California.
# All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
# @(#)Makefile 5.3.2 (2.11BSD GTE) 1996/12/1
#
# make file for tip device drivers
#
# Current drivers:
# BIZCOMP
# USR COURIER (2400 baud)
# DEC DF02-AC, DF03-AC
# DEC DN-11/Able Quadracall
# HAYES and Hayes emulators
# PENRIL auto-dialer
# VENTEL 212+ (w/o echo)
# VADIC 831 RS232 adaptor
# VADIC 3451
CFLAGS += -I.. -Wall -Werror
SRCS= biz22.c biz31.c courier.c df.c dn11.c hayes.c ventel.c v831.c \
v3451.c penril.c
OBJS= biz22.o biz31.o courier.o df.o dn11.o hayes.o ventel.o v831.o \
v3451.o penril.o
all: libacu.a
libacu.a: ${OBJS}
$(AR) -rc libacu.a ${OBJS}
$(RANLIB) libacu.a
clean: FRC
rm -f ${OBJS} core libacu.a
depend: FRC
mkdep ${CFLAGS} ${SRCS}
lint: FRC
lint ${CFLAGS} ${SRCS}
tags: FRC
ctags ${SRCS}
install:
FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY

154
src/cmd/tip/aculib/biz22.c Normal file
View File

@@ -0,0 +1,154 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <stdlib.h>
#include <string.h>
#include "tip.h"
#define DISCONNECT_CMD "\20\04" /* disconnection string */
static int timeout = 0;
static jmp_buf timeoutbuf;
static int detect(register char *s);
static int cmd(register char *s);
void biz22_disconnect()
{
int rw = 2;
write(FD, DISCONNECT_CMD, 4);
sleep(2);
ioctl(FD, TIOCFLUSH, &rw);
}
/*
* Dial up on a BIZCOMP Model 1022 with either
* tone dialing (mod = "V")
* pulse dialing (mod = "W")
*/
static int
biz_dialer(num, mod)
char *num, *mod;
{
register 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);
}
strcpy(cbuf, "\02.\r");
cbuf[1] = *mod;
if (cmd(cbuf)) {
printf("can't set dialing mode...");
return (0);
}
strcpy(cbuf, "\02D");
strcat(cbuf, num);
strcat(cbuf, "\r");
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 (timeout) {
char line[80];
sprintf(line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "biz1022", line);
}
#endif
if (timeout)
biz22_disconnect(); /* insurance */
return (connected);
}
int biz22w_dialer(num, acu)
char *num, *acu;
{
return (biz_dialer(num, "W"));
}
int biz22f_dialer(num, acu)
char *num, *acu;
{
return (biz_dialer(num, "V"));
}
void biz22_abort()
{
write(FD, "\02", 1);
}
static void
sigALRM(int i)
{
timeout = 1;
longjmp(timeoutbuf, 1);
}
static int
cmd(s)
register char *s;
{
char c;
sig_t f;
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(s)
register char *s;
{
char c;
sig_t f;
f = signal(SIGALRM, sigALRM);
timeout = 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 (timeout == 0);
}

212
src/cmd/tip/aculib/biz31.c Normal file
View File

@@ -0,0 +1,212 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
#define MAXRETRY 3 /* sync up retry count */
#define DISCONNECT_CMD "\21\25\11\24" /* disconnection string */
static int timeout = 0;
static jmp_buf timeoutbuf;
static int bizsync(int fd);
static int detect(register char *s);
void biz31_disconnect()
{
write(FD, DISCONNECT_CMD, 4);
sleep(2);
ioctl(FD, TIOCFLUSH);
}
static void
echo(s)
register 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);
}
}
static void
sigALRM(int i)
{
timeout = 1;
longjmp(timeoutbuf, 1);
}
static void
flush(s)
register char *s;
{
char c;
sig_t f;
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 */
}
/*
* Dial up on a BIZCOMP Model 1031 with either
* tone dialing (mod = "f")
* pulse dialing (mod = "w")
*/
static int
biz_dialer(num, mod)
char *num, *mod;
{
register 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];
sprintf(line, "%d 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(num, acu)
char *num, *acu;
{
return (biz_dialer(num, "w"));
}
int biz31f_dialer(num, acu)
char *num, *acu;
{
return (biz_dialer(num, "f"));
}
void biz31_abort()
{
write(FD, "\33", 1);
}
static int
detect(s)
register char *s;
{
char c;
sig_t f;
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);
}
/*
* 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(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
register int already = 0;
char buf[10];
retry:
if (ioctl(fd, IOCTL, (caddr_t)&b) >= 0 && chars(b) > 0)
ioctl(fd, TIOCFLUSH);
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);
}

View File

@@ -0,0 +1,353 @@
/*
* Copyright (c) 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#define write cour_write
/*
* Routines for calling up on a Courier modem.
* Derived from Hayes driver.
*/
#include "tip.h"
#define MAXRETRY 5
static int timeout = 0;
static int connected = 0;
static jmp_buf timeoutbuf;
static void cour_napx();
void cour_nap(void);
static int coursync();
static int cour_connect();
static int cour_swallow(register char *match);
void cour_disconnect()
{
/* first hang up the modem*/
ioctl(FD, TIOCCDTR, 0);
sleep(1);
ioctl(FD, TIOCSDTR, 0);
coursync(); /* reset */
close(FD);
}
int cour_dialer(num, acu)
register char *num;
char *acu;
{
register char *cp;
#ifdef ACULOG
char line[80];
#endif
if (boolean(value(VERBOSE)))
printf("Using \"%s\"\n", acu);
ioctl(FD, TIOCHPCL, 0);
/*
* 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);
}
write(FD, "AT E0\r", 6); /* turn off echoing */
sleep(1);
#ifdef DEBUG
if (boolean(value(VERBOSE)))
verbose_read();
#endif
ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21);
if (!cour_swallow("\r\nOK\r\n"))
goto badsynch;
fflush(stdout);
write(FD, "AT D", 4);
for (cp = num; *cp; cp++)
if (*cp == '=')
*cp = ',';
write(FD, num, strlen(num));
write(FD, "\r", 1);
connected = cour_connect();
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "cour", line);
}
#endif
if (timeout)
cour_disconnect();
return (connected);
}
void cour_abort()
{
write(FD, "\r", 1); /* send anything to abort the call */
cour_disconnect();
}
static void
sigALRM(int i)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
longjmp(timeoutbuf, 1);
}
static int
cour_swallow(match)
register char *match;
{
char c;
sig_t f;
f = signal(SIGALRM, sigALRM);
timeout = 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);
}
static struct baud_msg {
char *msg;
int baud;
} baud_msg[] = {
{ "", B300 },
{ " 1200", B1200 },
{ " 2400", B2400 },
{ 0, 0 },
};
static int
cour_connect()
{
char c;
int nc, nl, n;
struct sgttyb sb;
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));
timeout = 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 ; bm++)
if (strcmp(bm->msg,
dialer_buf+sizeof("CONNECT")-1) == 0) {
if (ioctl(FD, TIOCGETP, &sb) < 0) {
perror("TIOCGETP");
goto error;
}
sb.sg_ispeed = sb.sg_ospeed = bm->baud;
if (ioctl(FD, TIOCSETP, &sb) < 0) {
perror("TIOCSETP");
goto error;
}
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);
error:
signal(SIGALRM, f);
return (0);
}
/*
* This convoluted piece of code attempts to get
* the courier in sync.
*/
static int
coursync()
{
int already, len;
long nread;
char buf[40];
for (already=0; already<MAXRETRY; already++) {
ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */
write(FD, "\rAT Z\r", 6); /* reset modem */
bzero(buf, sizeof(buf));
sleep(1);
ioctl(FD, FIONREAD, &nread);
if (nread) {
len = read(FD, buf, sizeof(buf));
buf[len] = '\0';
#ifdef DEBUG
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);
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);
}
write(FD, "\rAT Z\r", 6);
return (0);
}
#undef write
extern ssize_t write(int fd, const void *cp, size_t n);
ssize_t cour_write(fd, cp, n)
int fd;
const void *cp;
size_t n;
{
struct sgttyb sb;
int n0 = n;
#ifdef notdef
if (boolean(value(VERBOSE)))
write(1, cp, n);
#endif
ioctl(fd, TIOCGETP, &sb);
ioctl(fd, TIOCSETP, &sb);
cour_nap();
for ( ; n-- ; cp++) {
write(fd, cp, 1);
ioctl(fd, TIOCGETP, &sb);
ioctl(fd, TIOCSETP, &sb);
cour_nap();
}
return n0;
}
#ifdef DEBUG
verbose_read()
{
long n = 0;
char buf[BUFSIZ];
if (ioctl(FD, FIONREAD, &n) < 0)
return;
if (n <= 0)
return;
if (read(FD, buf, (int)n) != n)
return;
write(1, buf, (int)n);
}
#endif
/*
* Code stolen from /usr/src/lib/libc/gen/sleep.c
*/
#include <sys/time.h>
#define mask(s) sigmask(s)
#define setvec(vec, a) \
vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
static int napms = 50; /* Give the courier 50 milliseconds between characters */
static int ringring;
void cour_nap()
{
long omask;
struct itimerval itv, oitv;
register struct itimerval *itp = &itv;
struct sigvec vec, ovec;
timerclear(&itp->it_interval);
timerclear(&itp->it_value);
if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
return;
setvec(ovec, SIG_DFL);
omask = sigblock(mask(SIGALRM));
itp->it_value.tv_sec = napms/1000;
itp->it_value.tv_usec = ((napms%1000)*1000);
setvec(vec, cour_napx);
ringring = 0;
(void) sigvec(SIGALRM, &vec, &ovec);
(void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
while (!ringring)
sigpause(omask &~ mask(SIGALRM));
(void) sigvec(SIGALRM, &ovec, (struct sigvec *)0);
(void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0);
(void) sigsetmask(omask);
}
static void
cour_napx()
{
ringring = 1;
}

93
src/cmd/tip/aculib/df.c Normal file
View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Dial the DF02-AC or DF03-AC
*/
#include "tip.h"
static jmp_buf Sjbuf;
static void
timeout(int sig)
{
longjmp(Sjbuf, 1);
}
void df_disconnect()
{
int rw = 2;
write(FD, "\001", 1);
sleep(1);
ioctl(FD, TIOCFLUSH, &rw);
}
int df_dialer(num, acu, df03)
char *num, *acu;
int df03;
{
register int f = FD;
struct sgttyb buf;
int speed = 0, rw = 2;
char c = '\0';
ioctl(f, TIOCHPCL, 0); /* make sure it hangs up when done */
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 */
ioctl(f, TIOCGETP, &buf);
if (buf.sg_ospeed != B1200) { /* must dial at 1200 baud */
speed = buf.sg_ospeed;
buf.sg_ospeed = buf.sg_ispeed = B1200;
ioctl(f, TIOCSETP, &buf);
ioctl(f, TIOCMBIC, &st); /* clear ST for 300 baud */
} else
ioctl(f, TIOCMBIS, &st); /* set ST for 1200 baud */
}
#endif
signal(SIGALRM, timeout);
alarm(5 * strlen(num) + 10);
ioctl(f, TIOCFLUSH, &rw);
write(f, "\001", 1);
sleep(1);
write(f, "\002", 1);
write(f, num, strlen(num));
read(f, &c, 1);
#ifdef TIOCMSET
if (df03 && speed) {
buf.sg_ispeed = buf.sg_ospeed = speed;
ioctl(f, TIOCSETP, &buf);
}
#endif
return (c == 'A');
}
int df02_dialer(num, acu)
char *num, *acu;
{
return (df_dialer(num, acu, 0));
}
int df03_dialer(num, acu)
char *num, *acu;
{
return (df_dialer(num, acu, 1));
}
void df_abort()
{
df_disconnect();
}

106
src/cmd/tip/aculib/dn11.c Normal file
View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Routines for dialing up on DN-11
*/
#include "tip.h"
#include <fcntl.h>
#include <sys/wait.h>
static jmp_buf jmpbuf;
static int child = -1, dn;
void alarmtr(int sig)
{
alarm(0);
longjmp(jmpbuf, 1);
}
int dn_dialer(num, acu)
char *num, *acu;
{
int lt, nw;
register int timelim;
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);
ioctl(dn, TIOCHPCL, 0);
signal(SIGALRM, SIG_DFL);
while ((nw = wait(&lt)) != child && nw != -1)
;
fflush(stdout);
close(dn);
if (lt != 0) {
close(FD);
return (0);
}
return (1);
}
/*
* Insurance, for some reason we don't seem to be
* hanging up...
*/
void dn_disconnect()
{
sleep(2);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
close(FD);
}
void dn_abort()
{
sleep(2);
if (child > 0)
kill(child, SIGKILL);
if (dn > 0)
close(dn);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
close(FD);
}

268
src/cmd/tip/aculib/hayes.c Normal file
View File

@@ -0,0 +1,268 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* 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"
#define min(a,b) ((a < b) ? a : b)
static int timeout = 0;
static jmp_buf timeoutbuf;
static char gobble();
#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 sig)
{
printf("\07timeout waiting for reply\n\r");
timeout = 1;
longjmp(timeoutbuf, 1);
}
#define MAXRETRY 5
int hay_sync()
{
int len, retry = 0;
long llen;
while (retry++ <= MAXRETRY) {
write(FD, "AT\r", 3);
sleep(1);
ioctl(FD, FIONREAD, &llen);
len = llen;
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);
}
void error_rep(c)
register 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");
}
/*
* set modem back to normal verbose status codes.
*/
void goodbye()
{
int len;
int zero = 0;
long llen;
char c;
ioctl(FD, TIOCFLUSH, &zero); /* get rid of trash */
if (hay_sync()) {
sleep(1);
#ifndef DEBUG
ioctl(FD, TIOCFLUSH, &zero);
#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, &llen);
len = llen;
#ifdef DEBUG
printf("goodbye1: len=%d -- ", len);
int rlen = read(FD, dumbuf, min(len, DUMBUFLEN));
dumbuf[rlen] = '\0';
printf("read (%d): %s\r\n", rlen, dumbuf);
#endif
write(FD, "ATV1\r", 5);
sleep(1);
#ifdef DEBUG
ioctl(FD, FIONREAD, &llen);
len = llen;
printf("goodbye2: len=%d -- ", len);
rlen = read(FD, dumbuf, min(len, DUMBUFLEN));
dumbuf[rlen] = '\0';
printf("read (%d): %s\r\n", rlen, dumbuf);
#endif
}
ioctl(FD, TIOCFLUSH, &zero); /* clear the input buffer */
ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */
close(FD);
}
void hay_disconnect()
{
/* first hang up the modem*/
#ifdef DEBUG
printf("\rdisconnecting modem....\n\r");
#endif
ioctl(FD, TIOCCDTR, 0);
sleep(1);
ioctl(FD, TIOCSDTR, 0);
goodbye();
}
int hay_dialer(num, acu)
register char *num;
char *acu;
{
register int connected = 0;
int zero = 0;
char dummy;
#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);
ioctl(FD, TIOCHPCL, 0);
ioctl(FD,TIOCFLUSH, &zero);
write(FD, "ATV0E0X0\r", 9); /* numeric codes,noecho,base cmds */
sleep(1);
ioctl(FD, TIOCFLUSH, &zero); /* get rid of garbage */
write(FD, "ATDT", 4); /* send dial command */
write(FD, num, strlen(num));
state = DIALING;
write(FD, "\r", 1);
connected = 0;
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.. */
}
ioctl(FD, TIOCFLUSH, &zero);
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "hayes", line);
}
#endif
if (timeout)
hay_disconnect(); /* insurance */
return (connected);
}
void hay_abort()
{
write(FD, "\r", 1); /* send anything to abort the call */
hay_disconnect();
}
static char
gobble(match)
register char *match;
{
char c;
sig_t f;
int i, status = 0;
f = signal(SIGALRM, sigALRM);
timeout = 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);
}

224
src/cmd/tip/aculib/penril.c Normal file
View File

@@ -0,0 +1,224 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Routines for calling up on a Penril Modem
* The Penril is expected to be strapped for local echo (just like uucp)
*/
#include "tip.h"
#define MAXRETRY 5
static void sigALRM(int);
static int timeout = 0;
static jmp_buf buftimeout;
static int pensync(int fd);
static int gobble(register char match, char response[]);
/*
* some sleep calls have been replaced by this macro
* because some penril 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 */
void busyloop(n)
{
while (--n > 0)
;
}
void pen_disconnect()
{
close(FD);
}
static void
echo(s)
register 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);
}
}
int pen_dialer(num, acu)
register char *num;
char *acu;
{
register char *cp;
register int connected = 0;
char *msg, *index(), line[80];
/*
* Get in synch with a couple of carriage returns
*/
if (!pensync(FD)) {
printf("can't synchronize with penril\n");
#ifdef ACULOG
logent(value(HOST), num, "penril", "can't synch up");
#endif
return (0);
}
if (boolean(value(VERBOSE)))
printf("\ndialing...");
fflush(stdout);
ioctl(FD, TIOCHPCL, 0);
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('O', line) && gobble('K', line);
ioctl(FD, TIOCFLUSH);
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "penril", line);
}
#endif
if (timeout)
pen_disconnect(); /* insurance */
if (connected || timeout || !boolean(value(VERBOSE)))
return (connected);
/* call failed, parse response for user */
cp = index(line, '\r');
if (cp)
*cp = '\0';
for (cp = line; (cp = index(cp, ' ')); 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 pen_abort()
{
write(FD, "\03", 1);
close(FD);
}
static void
sigALRM(int i)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
longjmp(buftimeout, 1);
}
static int
gobble(match, response)
register char match;
char response[];
{
register char *cp = response;
char c;
sig_t f;
f = signal(SIGALRM, sigALRM);
timeout = 0;
do {
if (setjmp(buftimeout)) {
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 penril in sync. If you don't have FIONREAD
* there are gory ways to simulate this.
*/
static int
pensync(fd)
{
int already = 0, nread;
long temp;
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);
sleep(2);
if (ioctl(fd, FIONREAD, &temp) < 0) {
perror("tip: ioctl");
continue;
}
nread = temp;
while (nread > 0) {
read(fd, buf, min(nread, 70));
if (((buf[nread - 6] & 0177) == 'B') &&
((buf[nread - 5] & 0177) == 'P') &&
((buf[nread - 4] & 0177) == 'S') &&
((buf[nread - 1] & 0177) == '>'))
return (1);
nread -= min(nread, 70);
}
sleep(1);
already++;
}
return (0);
}

179
src/cmd/tip/aculib/v3451.c Normal file
View File

@@ -0,0 +1,179 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Routines for calling up on a Vadic 3451 Modem
*/
#include <string.h>
#include "tip.h"
static jmp_buf Sjbuf;
static int prefix(register char *s1, register char *s2);
static int notin(char *sh, char *lg);
static int expect(register char *cp);
static void
vawrite(cp, delay)
register char *cp;
int delay;
{
for (; *cp; sleep(delay), cp++)
write(FD, cp, 1);
}
int v3451_dialer(num, acu)
register char *num;
char *acu;
{
int ok;
sig_t func;
int slow = number(value(BAUDRATE)) < 1200, rw = 2;
char phone[50];
#ifdef ACULOG
char line[80];
#endif
/*
* 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);
}
ioctl(FD, TIOCHPCL, 0);
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);
}
strcpy(phone, num);
strcat(phone, "\r");
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);
}
ioctl(FD, TIOCFLUSH, &rw);
return (1);
}
void v3451_disconnect()
{
close(FD);
}
void v3451_abort()
{
close(FD);
}
static void
alarmtr()
{
longjmp(Sjbuf, 1);
}
static int
expect(cp)
register char *cp;
{
char buf[300];
register 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);
}
static int
notin(sh, lg)
char *sh, *lg;
{
for (; *lg; lg++)
if (prefix(sh, lg))
return (0);
return (1);
}
static int
prefix(s1, s2)
register char *s1, *s2;
{
register char c;
while ((c = *s1++) == *s2++)
if (c == '\0')
return (1);
return (c == '\0');
}

226
src/cmd/tip/aculib/v831.c Normal file
View File

@@ -0,0 +1,226 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Routines for dialing up on Vadic 831
*/
#include <sys/time.h>
#include <fcntl.h>
#include <sys/wait.h>
#include "tip.h"
static jmp_buf jmpbuf;
static int child = -1;
/*
* 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 char *
sanitize(s)
register char *s;
{
static char buf[128];
register char *cp;
for (cp = buf; *s; s++) {
if (!isdigit(*s) && *s == '<' && *s != '_')
continue;
if (*s == '_')
*s = '=';
*cp++ = *s;
}
*cp++ = 0;
return (buf);
}
/*
* Insurance, for some reason we don't seem to be
* hanging up...
*/
void v831_disconnect()
{
struct sgttyb cntrl;
sleep(2);
#ifdef DEBUG
printf("[disconnect: FD=%d]\n", FD);
#endif
if (FD > 0) {
ioctl(FD, TIOCCDTR, 0);
ioctl(FD, TIOCGETP, &cntrl);
cntrl.sg_ispeed = cntrl.sg_ospeed = 0;
ioctl(FD, TIOCSETP, &cntrl);
ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL);
}
close(FD);
}
static int
dialit(phonenum, acu)
register char *phonenum;
char *acu;
{
register struct vaconfig *vp;
struct sgttyb cntrl;
char c;
int i, two = 2;
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');
}
ioctl(AC, TIOCGETP, &cntrl);
cntrl.sg_ispeed = cntrl.sg_ospeed = B2400;
cntrl.sg_flags = RAW | EVENP | ODDP;
ioctl(AC, TIOCSETP, &cntrl);
ioctl(AC, TIOCFLUSH, &two);
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 void
alarmtr(int sig)
{
alarm(0);
longjmp(jmpbuf, 1);
}
int v831_dialer(num, acu)
char *num, *acu;
{
int status, pid;
register int timelim;
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);
#ifdef notdef
ioctl(AC, TIOCHPCL, 0);
#endif
signal(SIGALRM, SIG_DFL);
while ((pid = wait(&status)) != child && pid != -1)
;
if (status) {
close(AC);
return (0);
}
return (1);
}
void v831_abort()
{
#ifdef DEBUG
printf("[abort: AC=%d]\n", AC);
#endif
sleep(2);
if (child > 0)
kill(child, SIGKILL);
if (AC > 0)
ioctl(FD, TIOCNXCL, (struct sgttyb *)NULL);
close(AC);
if (FD > 0)
ioctl(FD, TIOCCDTR, 0);
close(FD);
}

220
src/cmd/tip/aculib/ventel.c Normal file
View File

@@ -0,0 +1,220 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Routines for calling up on a Ventel Modem
* The Ventel is expected to be strapped for local echo (just like uucp)
*/
#include "tip.h"
#define MAXRETRY 5
static int timeout = 0;
static jmp_buf timeoutbuf;
static int vensync(int fd);
static int gobble(register char match, char response[]);
/*
* 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 */
void busyloop(n)
{
while (--n > 0)
;
}
void ven_disconnect()
{
close(FD);
}
static void
echo(s)
register 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);
}
}
int ven_dialer(num, acu)
register char *num;
char *acu;
{
register char *cp;
register int connected = 0;
char *msg, *index(), line[80];
/*
* 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);
ioctl(FD, TIOCHPCL, 0);
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);
ioctl(FD, TIOCFLUSH);
#ifdef ACULOG
if (timeout) {
sprintf(line, "%d second dial timeout",
number(value(DIALTIMEOUT)));
logent(value(HOST), num, "ventel", line);
}
#endif
if (timeout)
ven_disconnect(); /* insurance */
if (connected || timeout || !boolean(value(VERBOSE)))
return (connected);
/* call failed, parse response for user */
cp = index(line, '\r');
if (cp)
*cp = '\0';
for (cp = line; (cp = index(cp, ' ')); 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_abort()
{
write(FD, "\03", 1);
close(FD);
}
static void
sigALRM(int i)
{
printf("\07timeout waiting for reply\n");
timeout = 1;
longjmp(timeoutbuf, 1);
}
static int
gobble(match, response)
register char match;
char response[];
{
register char *cp = response;
char c;
sig_t f;
f = signal(SIGALRM, sigALRM);
timeout = 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(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);
}

64
src/cmd/tip/acutab.c Normal file
View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
extern int df02_dialer(), df03_dialer(), df_disconnect(), df_abort(),
biz31f_dialer(), biz31_disconnect(), biz31_abort(),
biz31w_dialer(),
biz22f_dialer(), biz22_disconnect(), biz22_abort(),
biz22w_dialer(),
ven_dialer(), ven_disconnect(), ven_abort(),
hay_dialer(), hay_disconnect(), hay_abort(),
cour_dialer(), cour_disconnect(), cour_abort(),
v3451_dialer(), v3451_disconnect(), v3451_abort(),
v831_dialer(), v831_disconnect(), v831_abort(),
pen_dialer(), pen_disconnect(), pen_abort(),
dn_dialer(), dn_disconnect(), dn_abort();
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 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
#ifdef PENRIL
{ "penril", pen_dialer, pen_disconnect, pen_abort },
#endif
{ 0, 0, 0, 0 },
};

862
src/cmd/tip/cmds.c Normal file
View File

@@ -0,0 +1,862 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <sys/wait.h>
#include "tip.h"
/*
* tip
*
* miscellaneous commands
*/
int quant[] = { 60, 60, 24 };
char null = '\0';
char *sep[] = { "second", "minute", "hour" };
static char *argv[10]; /* argument vector for take and put */
static jmp_buf intbuf;
int intprompt(); /* used in handling SIG_INT during prompt */
/*
* interrupt routine for file transfers
*/
void
intcopy(int sig)
{
raw();
quit = 1;
longjmp(intbuf, 1);
}
/*
* Interrupt service routine for FTP
*/
void
stopsnd(int sig)
{
stop = 1;
signal(SIGINT, SIG_IGN);
}
/*
* timeout function called on alarm
*/
void
timeout(int sig)
{
signal(SIGALRM, timeout);
timedout = 1;
}
static void prtime(s, a)
char *s;
time_t a;
{
register int i;
int nums[3];
for (i = 0; i < 3; i++) {
nums[i] = (int)(a % quant[i]);
a /= quant[i];
}
printf("%s", s);
while (--i >= 0)
if (nums[i] || (i == 0 && nums[1] == 0 && nums[2] == 0))
printf("%d %s%c ", nums[i], sep[i],
nums[i] == 1 ? '\0' : 's');
printf("\r\n!\r\n");
}
/*
* Bulk transfer routine --
* used by getfl(), cu_take(), and pipefile()
*/
static void transfer(buf, fd, eofchars)
char *buf, *eofchars;
{
register int ct;
char c, buffer[BUFSIZ];
register char *p = buffer;
register int cnt, eof;
time_t start;
sig_t f;
pwrite(FD, buf, size(buf));
quit = 0;
kill(pid, SIGIOT);
read(repdes[0], (char *)&ccc, 1); /* Wait until read process stops */
/*
* finish command
*/
pwrite(FD, "\r", 1);
do
read(FD, &c, 1);
while ((c&0177) != '\n');
ioctl(0, TIOCSETC, &defchars);
(void) setjmp(intbuf);
f = signal(SIGINT, intcopy);
start = time(0);
for (ct = 0; !quit;) {
eof = read(FD, &c, 1) <= 0;
c &= 0177;
if (quit)
continue;
if (eof || any(c, eofchars))
break;
if (c == 0)
continue; /* ignore nulls */
if (c == '\r')
continue;
*p++ = c;
if (c == '\n' && boolean(value(VERBOSE)))
printf("\r%d", ++ct);
if ((cnt = (p-buffer)) == number(value(FRAMESIZE))) {
if (write(fd, buffer, cnt) != cnt) {
printf("\r\nwrite error\r\n");
quit = 1;
}
p = buffer;
}
}
cnt = p - buffer;
if (cnt > 0)
if (write(fd, buffer, cnt) != cnt)
printf("\r\nwrite error\r\n");
if (boolean(value(VERBOSE)))
prtime(" lines transferred in ", time(0)-start);
ioctl(0, TIOCSETC, &tchars);
write(fildes[1], (char *)&ccc, 1);
signal(SIGINT, f);
close(fd);
}
/*
* FTP - remote ==> local
* get a file from the remote host
*/
void getfl(c)
int c;
{
char buf[256], *cp, *expand();
putchar(c);
/*
* get the UNIX receiving file's name
*/
if (prompt("Local file name? ", copyname))
return;
cp = expand(copyname);
if ((sfd = creat(cp, 0666)) < 0) {
printf("\r\n%s: cannot creat\r\n", copyname);
return;
}
/*
* collect parameters
*/
if (prompt("List command for remote system? ", buf)) {
unlink(copyname);
return;
}
transfer(buf, sfd, value(EOFREAD));
}
static int args(buf, a)
char *buf, *a[];
{
register char *p = buf, *start;
register char **parg = a;
register int n = 0;
do {
while (*p && (*p == ' ' || *p == '\t'))
p++;
start = p;
if (*p)
*parg = p;
while (*p && (*p != ' ' && *p != '\t'))
p++;
if (p != start)
parg++, n++;
if (*p)
*p++ = '\0';
} while (*p);
return(n);
}
/*
* Cu-like take command
*/
void cu_take(cc)
char cc;
{
int fd, argc;
char line[BUFSIZ], *expand(), *cp;
if (prompt("[take] ", copyname))
return;
argc = args(copyname, argv);
if (argc < 1 || argc > 2) {
printf("usage: <take> from [to]\r\n");
return;
}
if (argc == 1)
argv[1] = argv[0];
cp = expand(argv[1]);
if ((fd = creat(cp, 0666)) < 0) {
printf("\r\n%s: cannot create\r\n", argv[1]);
return;
}
sprintf(line, "cat %s;echo \01", argv[0]);
transfer(line, fd, "\01");
}
static void execute(s)
char *s;
{
register char *cp;
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
user_uid();
execl(value(SHELL), cp, "-c", s, (char*)0);
}
/*
* FTP - remote ==> local process
* send remote input to local process via pipe
*/
void pipefile()
{
int cpid, pdes[2];
char buf[256];
int status, p;
if (prompt("Local command? ", buf))
return;
if (pipe(pdes)) {
printf("can't establish pipe\r\n");
return;
}
if ((cpid = fork()) < 0) {
printf("can't fork!\r\n");
return;
} else if (cpid) {
if (prompt("List command for remote system? ", buf)) {
close(pdes[0]), close(pdes[1]);
kill (cpid, SIGKILL);
} else {
close(pdes[0]);
signal(SIGPIPE, intcopy);
transfer(buf, pdes[1], value(EOFREAD));
signal(SIGPIPE, SIG_DFL);
while ((p = wait(&status)) > 0 && p != cpid)
;
}
} else {
register int f;
dup2(pdes[0], 0);
close(pdes[0]);
for (f = 3; f < 20; f++)
close(f);
execute(buf);
printf("can't execl!\r\n");
exit(0);
}
}
/*
* FTP - send single character
* wait for echo & handle timeout
*/
static void send(c)
int c;
{
char cc;
int retry = 0;
cc = c;
pwrite(FD, &cc, 1);
#ifdef notdef
if (number(value(CDELAY)) > 0 && c != '\r')
nap(number(value(CDELAY)));
#endif
if (!boolean(value(ECHOCHECK))) {
#ifdef notdef
if (number(value(LDELAY)) > 0 && c == '\r')
nap(number(value(LDELAY)));
#endif
return;
}
tryagain:
timedout = 0;
alarm(value(ETIMEOUT));
read(FD, &cc, 1);
alarm(0);
if (timedout) {
printf("\r\ntimeout error (%s)\r\n", ctrl(c));
if (retry++ > 3)
return;
pwrite(FD, &null, 1); /* poke it */
goto tryagain;
}
}
/*
* Bulk transfer routine to remote host --
* used by sendfile() and cu_put()
*/
void transmit(fd, eofchars, command)
FILE *fd;
char *eofchars, *command;
{
char *pc, lastc;
int c, ccount, lcount;
time_t start_t, stop_t;
sig_t f;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
stop = 0;
f = signal(SIGINT, stopsnd);
ioctl(0, TIOCSETC, &defchars);
read(repdes[0], (char *)&ccc, 1);
if (command != NULL) {
for (pc = command; *pc; pc++)
send(*pc);
if (boolean(value(ECHOCHECK)))
read(FD, (char *)&c, 1); /* trailing \n */
else {
struct sgttyb buf;
ioctl(FD, TIOCGETP, &buf); /* this does a */
ioctl(FD, TIOCSETP, &buf); /* wflushtty */
sleep(5); /* wait for remote stty to take effect */
}
}
lcount = 0;
lastc = '\0';
start_t = time(0);
while (1) {
ccount = 0;
do {
c = getc(fd);
if (stop)
goto out;
if (c == EOF)
goto out;
if (c == 0177 && !boolean(value(RAWFTP)))
continue;
lastc = c;
if (c < 040) {
if (c == '\n') {
if (!boolean(value(RAWFTP)))
c = '\r';
}
else if (c == '\t') {
if (!boolean(value(RAWFTP))) {
if (boolean(value(TABEXPAND))) {
send(' ');
while ((++ccount % 8) != 0)
send(' ');
continue;
}
}
} else
if (!boolean(value(RAWFTP)))
continue;
}
send(c);
} while (c != '\r' && !boolean(value(RAWFTP)));
if (boolean(value(VERBOSE)))
printf("\r%d", ++lcount);
if (boolean(value(ECHOCHECK))) {
timedout = 0;
alarm(value(ETIMEOUT));
do { /* wait for prompt */
read(FD, (char *)&c, 1);
if (timedout || stop) {
if (timedout)
printf("\r\ntimed out at eol\r\n");
alarm(0);
goto out;
}
} while ((c&0177) != character(value(PROMPT)));
alarm(0);
}
}
out:
if (lastc != '\n' && !boolean(value(RAWFTP)))
send('\r');
for (pc = eofchars; *pc; pc++)
send(*pc);
stop_t = time(0);
fclose(fd);
signal(SIGINT, f);
if (boolean(value(VERBOSE))) {
if (boolean(value(RAWFTP)))
prtime(" chars transferred in ", stop_t-start_t);
else
prtime(" lines transferred in ", stop_t-start_t);
}
write(fildes[1], (char *)&ccc, 1);
ioctl(0, TIOCSETC, &tchars);
}
/*
* FTP - local ==> remote
* send local file to remote host
* terminate transmission with pseudo EOF sequence
*/
void sendfile(cc)
char cc;
{
FILE *fd;
char *fnamex;
char *expand();
putchar(cc);
/*
* get file name
*/
if (prompt("Local file name? ", fname))
return;
/*
* look up file
*/
fnamex = expand(fname);
if ((fd = fopen(fnamex, "r")) == NULL) {
printf("%s: cannot open\r\n", fname);
return;
}
transmit(fd, value(EOFWRITE), NULL);
if (!boolean(value(ECHOCHECK))) {
struct sgttyb buf;
ioctl(FD, TIOCGETP, &buf); /* this does a */
ioctl(FD, TIOCSETP, &buf); /* wflushtty */
}
}
/*
* Cu-like put command
*/
void cu_put(cc)
int cc;
{
FILE *fd;
char line[BUFSIZ];
int argc;
char *expand();
char *cpynamex;
if (prompt("[put] ", copyname))
return;
argc = args(copyname, argv);
if (argc < 1 || argc > 2) {
printf("usage: <put> from [to]\r\n");
return;
}
if (argc == 1)
argv[1] = argv[0];
cpynamex = expand(argv[0]);
if ((fd = fopen(cpynamex, "r")) == NULL) {
printf("%s: cannot open\r\n", cpynamex);
return;
}
if (boolean(value(ECHOCHECK)))
sprintf(line, "cat>%s\r", argv[1]);
else
sprintf(line, "stty -echo;cat>%s;stty echo\r", argv[1]);
transmit(fd, "\04", line);
}
/*
* Stolen from consh() -- puts a remote file on the output of a local command.
* Identical to consh() except for where stdout goes.
*/
void pipeout(c)
{
char buf[256];
int cpid, status, p;
time_t start;
putchar(c);
if (prompt("Local command? ", buf))
return;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
ioctl(0, TIOCSETC, &defchars);
read(repdes[0], (char *)&ccc, 1);
/*
* Set up file descriptors in the child and
* let it go...
*/
cpid = fork();
if (cpid < 0)
printf("can't fork!\r\n");
else if (cpid) {
start = time(0);
while ((p = wait(&status)) > 0 && p != cpid)
;
if (boolean(value(VERBOSE)))
prtime("away for ", time(0)-start);
} else {
register int i;
dup2(FD, 1);
for (i = 3; i < 20; i++)
close(i);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
execute(buf);
printf("can't find `%s'\r\n", buf);
exit(0);
}
write(fildes[1], (char *)&ccc, 1);
ioctl(0, TIOCSETC, &tchars);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
}
#ifdef CONNECT
/*
* Fork a program with:
* 0 <-> local tty in
* 1 <-> local tty out
* 2 <-> local tty out
* 3 <-> remote tty in
* 4 <-> remote tty out
*/
void consh(c)
{
char buf[256];
int cpid, status, p;
time_t start;
putchar(c);
if (prompt("Local command? ", buf))
return;
kill(pid, SIGIOT); /* put TIPOUT into a wait state */
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
ioctl(0, TIOCSETC, &defchars);
read(repdes[0], (char *)&ccc, 1);
/*
* Set up file descriptors in the child and
* let it go...
*/
if ((cpid = fork()) < 0)
printf("can't fork!\r\n");
else if (cpid) {
start = time(0);
while ((p = wait(&status)) > 0 && p != cpid)
;
if (boolean(value(VERBOSE)))
prtime("away for ", time(0)-start);
} else {
register int i;
dup2(FD, 3);
dup2(3, 4);
for (i = 5; i < 20; i++)
close(i);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
execute(buf);
printf("can't find `%s'\r\n", buf);
exit(0);
}
write(fildes[1], (char *)&ccc, 1);
ioctl(0, TIOCSETC, &tchars);
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
}
#endif
/*
* Escape to local shell
*/
void shell()
{
int shpid, status;
char *cp;
printf("[sh]\r\n");
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
unraw();
shpid = fork();
if (shpid != 0) {
while (shpid != wait(&status));
raw();
printf("\r\n!\r\n");
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
return;
} else {
signal(SIGQUIT, SIG_DFL);
signal(SIGINT, SIG_DFL);
if ((cp = strrchr(value(SHELL), '/')) == NULL)
cp = value(SHELL);
else
cp++;
shell_uid();
execl(value(SHELL), cp, (char*) 0);
printf("\r\ncan't execl!\r\n");
exit(1);
}
}
/*
* TIPIN portion of scripting
* initiate the conversation with TIPOUT
*/
void setscript()
{
char c;
/*
* enable TIPOUT side for dialogue
*/
kill(pid, SIGEMT);
if (boolean(value(SCRIPT)))
write(fildes[1], value(RECORD), size(value(RECORD)));
write(fildes[1], "\n", 1);
/*
* wait for TIPOUT to finish
*/
read(repdes[0], &c, 1);
if (c == 'n')
printf("can't create %s\r\n", value(RECORD));
}
/*
* Change current working directory of
* local portion of tip
*/
void chdirectory()
{
char dirname[80];
register char *cp = dirname;
if (prompt("[cd] ", dirname)) {
if (stoprompt)
return;
cp = value(HOME);
}
if (chdir(cp) < 0)
printf("%s: bad directory\r\n", cp);
printf("!\r\n");
}
void tipabort(msg)
char *msg;
{
kill(pid, SIGTERM);
disconnect(msg);
if (msg != NOSTR)
printf("\r\n%s", msg);
printf("\r\n[EOT]\r\n");
daemon_uid();
delock(uucplock);
unraw();
exit(0);
}
void finish()
{
char *dismsg;
if ((dismsg = value(DISCONNECT)) != NOSTR) {
write(FD, dismsg, strlen(dismsg));
sleep(5);
}
tipabort(NOSTR);
}
/*
* Turn tandem mode on or off for remote tty.
*/
static void tandem(option)
char *option;
{
struct sgttyb rmtty;
ioctl(FD, TIOCGETP, &rmtty);
if (strcmp(option,"on") == 0) {
rmtty.sg_flags |= TANDEM;
arg.sg_flags |= TANDEM;
} else {
rmtty.sg_flags &= ~TANDEM;
arg.sg_flags &= ~TANDEM;
}
ioctl(FD, TIOCSETP, &rmtty);
ioctl(0, TIOCSETP, &arg);
}
void variable()
{
char buf[256];
if (prompt("[set] ", buf))
return;
vlex(buf);
if (vtable[BEAUTIFY].v_access&CHANGED) {
vtable[BEAUTIFY].v_access &= ~CHANGED;
kill(pid, SIGSYS);
}
if (vtable[SCRIPT].v_access&CHANGED) {
vtable[SCRIPT].v_access &= ~CHANGED;
setscript();
/*
* So that "set record=blah script" doesn't
* cause two transactions to occur.
*/
if (vtable[RECORD].v_access&CHANGED)
vtable[RECORD].v_access &= ~CHANGED;
}
if (vtable[RECORD].v_access&CHANGED) {
vtable[RECORD].v_access &= ~CHANGED;
if (boolean(value(SCRIPT)))
setscript();
}
if (vtable[TAND].v_access&CHANGED) {
vtable[TAND].v_access &= ~CHANGED;
if (boolean(value(TAND)))
tandem("on");
else
tandem("off");
}
if (vtable[LECHO].v_access&CHANGED) {
vtable[LECHO].v_access &= ~CHANGED;
HD = boolean(value(LECHO));
}
if (vtable[PARITY].v_access&CHANGED) {
vtable[PARITY].v_access &= ~CHANGED;
setparity(NOSTR);
}
}
/*
* Send a break.
*/
void genbrk()
{
ioctl(FD, TIOCSBRK, NULL);
sleep(1);
ioctl(FD, TIOCCBRK, NULL);
}
/*
* Suspend tip
*/
void suspend(c)
int c;
{
unraw();
kill(c == CTRL(y) ? getpid() : 0, SIGTSTP);
raw();
}
/*
* Are any of the characters in the two strings the same?
*/
static int anyof(s1, s2)
register char *s1, *s2;
{
register int c;
while ((c = *s1++))
if (any(c, s2))
return(1);
return(0);
}
/*
* expand a file name if it includes shell meta characters
*/
char *
expand(name)
char name[];
{
static char xname[BUFSIZ];
char cmdbuf[BUFSIZ];
register int pid, l;
register char *cp, *Shell;
int s, pivec[2];
if (! anyof(name, "~{[*?$`'\"\\"))
return(name);
/* sigint = signal(SIGINT, SIG_IGN); */
if (pipe(pivec) < 0) {
perror("pipe");
/* signal(SIGINT, sigint) */
return(name);
}
sprintf(cmdbuf, "echo %s", name);
if ((pid = vfork()) == 0) {
Shell = value(SHELL);
if (Shell == NOSTR)
Shell = "/bin/sh";
close(pivec[0]);
close(1);
dup(pivec[1]);
close(pivec[1]);
close(2);
shell_uid();
execl(Shell, Shell, "-c", cmdbuf, (char*)0);
_exit(1);
}
if (pid == -1) {
perror("fork");
close(pivec[0]);
close(pivec[1]);
return(NOSTR);
}
close(pivec[1]);
l = read(pivec[0], xname, BUFSIZ);
close(pivec[0]);
while (wait(&s) != pid);
;
s &= 0377;
if (s != 0 && s != SIGPIPE) {
fprintf(stderr, "\"Echo\" failed\n");
return(NOSTR);
}
if (l < 0) {
perror("read");
return(NOSTR);
}
if (l == 0) {
fprintf(stderr, "\"%s\": No match\n", name);
return(NOSTR);
}
if (l == BUFSIZ) {
fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
return(NOSTR);
}
xname[l] = 0;
for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
;
*++cp = '\0';
return(xname);
}

32
src/cmd/tip/cmdtab.c Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
extern int shell(), getfl(), sendfile(), chdirectory();
extern int help(), pipefile(), pipeout(), consh(), variable();
extern int cu_take(), cu_put(), dollar(), genbrk(), suspend();
esctable_t etable[] = {
{ '!', NORM, "shell", shell },
{ '<', NORM, "receive file from remote host", getfl },
{ '>', NORM, "send file to remote host", sendfile },
{ 't', NORM, "take file from remote UNIX", cu_take },
{ 'p', NORM, "put file to remote UNIX", cu_put },
{ '|', NORM, "pipe remote file", pipefile },
{ '$', NORM, "pipe local command to remote host", pipeout },
#ifdef CONNECT
{ 'C', NORM, "connect program to remote host", consh },
#endif
{ 'c', NORM, "change directory", chdirectory },
{ '.', NORM, "exit from tip", (int(*)())finish },
{CTRL(d),NORM, "exit from tip", (int(*)())finish },
{CTRL(y),NORM, "suspend tip (local+remote)", suspend },
{CTRL(z),NORM, "suspend tip (local only)", suspend },
{ 's', NORM, "set variable", variable },
{ '?', NORM, "get this summary", help },
{ '#', NORM, "send break", genbrk },
{ 0, 0, 0 }
};

101
src/cmd/tip/cu.c Normal file
View File

@@ -0,0 +1,101 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
void cleanup(int);
int timeout();
/*
* Botch the interface to look like cu's
*/
void cumain(argc, argv)
char *argv[];
{
register int i;
static char sbuf[12];
if (argc < 2) {
printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
exit(8);
}
CU = DV = NOSTR;
BR = DEFBR;
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
PN = argv[1];
else switch (argv[1][1]) {
case 't':
HW = 1, DU = -1;
--argc;
continue;
case 'a':
CU = argv[2]; ++argv; --argc;
break;
case 's':
if (argc < 3 || speed(atoi(argv[2])) == 0) {
fprintf(stderr, "cu: unsupported speed %s\n",
argv[2]);
exit(3);
}
BR = atoi(argv[2]); ++argv; --argc;
break;
case 'l':
DV = argv[2]; ++argv; --argc;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (CU)
CU[strlen(CU)-1] = argv[1][1];
if (DV)
DV[strlen(DV)-1] = argv[1][1];
break;
default:
printf("Bad flag %s", argv[1]);
break;
}
}
signal(SIGINT, cleanup);
signal(SIGQUIT, cleanup);
signal(SIGHUP, cleanup);
signal(SIGTERM, cleanup);
/*
* The "cu" host name is used to define the
* attributes of the generic dialer.
*/
(void)sprintf(sbuf, "cu%d", BR);
if ((i = hunt(sbuf)) == 0) {
printf("all ports busy\n");
exit(3);
}
if (i == -1) {
printf("link down\n");
delock(uucplock);
exit(3);
}
setbuf(stdout, NULL);
loginit();
user_uid();
vinit();
setparity("none");
boolean(value(VERBOSE)) = 0;
if (HW)
ttysetup(speed(BR));
if (connect()) {
printf("Connect failed\n");
daemon_uid();
delock(uucplock);
exit(1);
}
if (!HW)
ttysetup(speed(BR));
}

67
src/cmd/tip/hunt.c Normal file
View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
#include <fcntl.h>
extern char *getremote();
extern char *rindex();
static jmp_buf deadline;
static int deadfl;
void
dead(int sig)
{
deadfl = 1;
longjmp(deadline, 1);
}
int hunt(name)
char *name;
{
register char *cp;
sig_t f;
f = signal(SIGALRM, dead);
while ((cp = getremote(name))) {
printf("hunt: cp = %s\n",cp);
deadfl = 0;
uucplock = rindex(cp, '/')+1;
printf("hunt: uucplock = %s\n",uucplock);
if (mlock(uucplock) < 0) {
printf("hunt: mlock(uucplock)<0\n");
delock(uucplock);
continue;
}
/*
* Straight through call units, such as the BIZCOMP,
* VADIC and the DF, must indicate they're hardwired in
* order to get an open file descriptor placed in FD.
* Otherwise, as for a DN-11, the open will have to
* be done in the "open" routine.
*/
if (!HW)
break;
if (setjmp(deadline) == 0) {
alarm(10);
FD = open(cp, O_RDWR);
}
alarm(0);
if (FD < 0) {
perror(cp);
deadfl = 1;
}
if (!deadfl) {
ioctl(FD, TIOCEXCL, 0);
ioctl(FD, TIOCHPCL, 0);
signal(SIGALRM, SIG_DFL);
return ((int)cp);
}
delock(uucplock);
}
signal(SIGALRM, f);
return (deadfl ? -1 : (int)cp);
}

56
src/cmd/tip/log.c Normal file
View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
#include <time.h>
#ifdef ACULOG
static FILE *flog = NULL;
/*
* Log file maintenance routines
*/
void logent(group, num, acu, message)
char *group, *num, *acu, *message;
{
char *user, *timestamp;
struct passwd *pwd;
long t;
if (flog == NULL)
return;
if (flock(fileno(flog), LOCK_EX) < 0) {
perror("tip: flock");
return;
}
user = getlogin();
if (user == NOSTR) {
if ((pwd = getpwuid(getuid())) == NOPWD)
user = "???";
else
user = pwd->pw_name;
}
t = time(0);
timestamp = ctime(&t);
timestamp[24] = '\0';
fprintf(flog, "%s (%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);
}
void loginit()
{
flog = fopen(value(LOG), "a");
if (flog == NULL)
fprintf(stderr, "can't open log file %s.\r\n", value(LOG));
}
#endif

5
src/cmd/tip/m Normal file
View File

@@ -0,0 +1,5 @@
cd aculib; make
make[1]: Entering directory `/home/matt/retrobsd/src/cmd/tip/aculib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/matt/retrobsd/src/cmd/tip/aculib'
/usr/local/pic32-tools/bin/pic32-gcc -mips32r2 -EL -nostdinc -fshort-double -I/home/matt/retrobsd/include -I/usr/local/pic32-tools/lib/gcc/pic32mx/4.5.1/include -o tip acu.o acutab.o cmds.o cmdtab.o cu.o hunt.o log.o partab.o remcap.o remote.o tip.o tipout.o uucplock.o value.o vars.o aculib/aculib.a

27
src/cmd/tip/partab.c Normal file
View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Even parity table for 0-0177
*/
char evenpartab[] = {
0000,0201,0202,0003,0204,0005,0006,0207,
0210,0011,0012,0213,0014,0215,0216,0017,
0220,0021,0022,0223,0024,0225,0226,0027,
0030,0231,0232,0033,0234,0035,0036,0237,
0240,0041,0042,0243,0044,0245,0246,0047,
0050,0251,0252,0053,0254,0055,0056,0257,
0060,0261,0262,0063,0264,0065,0066,0267,
0270,0071,0072,0273,0074,0275,0276,0077,
0300,0101,0102,0303,0104,0305,0306,0107,
0110,0311,0312,0113,0314,0115,0116,0317,
0120,0321,0322,0123,0324,0125,0126,0327,
0330,0131,0132,0333,0134,0335,0336,0137,
0140,0341,0342,0143,0344,0145,0146,0347,
0350,0151,0152,0353,0154,0355,0356,0157,
0360,0161,0162,0363,0164,0365,0366,0167,
0170,0371,0372,0173,0374,0175,0176,0377,
};

17
src/cmd/tip/phones-file Normal file
View File

@@ -0,0 +1,17 @@
bert 004156427750-<
ernie 004156427652
lbl 004154864979-<
ames 009699129
decvax 00603-884-1241
decvax 006038841230
case 002163683923
casevax 002163683240
cwrunix 002163683240
cwruecmp 002163683906
ecmp 002163683906
navy 423012273700
gi 006028997900
gi750 008015823032
texas 512-474-5511
sri 415-326-7005
texas-20 512-477-6542

394
src/cmd/tip/remcap.c Normal file
View File

@@ -0,0 +1,394 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* remcap - routines for dealing with the remote host data base
*
* derived from termcap
*/
#include <sys/file.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
#define MAXHOP 32 /* max number of tc= indirections */
#define SYSREMOTE "/etc/remote" /* system remote file */
#define tgetent rgetent
#define tnchktc rnchktc
#define tnamatch rnamatch
#define tgetnum rgetnum
#define tgetflag rgetflag
#define tgetstr rgetstr
#define E_TERMCAP RM = SYSREMOTE
#define V_TERMCAP "REMOTE"
#define V_TERM "HOST"
char *RM;
/*
* termcap - routines for dealing with the terminal capability data base
*
* BUG: Should use a "last" pointer in tbuf, so that searching
* for capabilities alphabetically would not be a n**2/2
* process when large numbers of capabilities are given.
* Note: If we add a last pointer now we will screw up the
* tc capability. We really should compile termcap.
*
* Essentially all the work here is scanning and decoding escapes
* in string capabilities. We don't use stdio because the editor
* doesn't, and because living w/o it is not hard.
*/
static char *tbuf;
static int hopcount; /* detect infinite loops in termcap, init 0 */
static char *remotefile;
static int tnchktc (void);
/*
* Tnamatch deals with name matching. The first field of the termcap
* entry is a sequence of names separated by |'s, so we compare
* against each such name. The normal : terminator after the last
* name (before the first field) stops us.
*/
static int tnamatch(np)
char *np;
{
register char *Np, *Bp;
Bp = tbuf;
if (*Bp == '#')
return (0);
for (;;) {
for (Np = np; *Np && *Bp == *Np; Bp++, Np++)
continue;
if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0))
return (1);
while (*Bp && *Bp != ':' && *Bp != '|')
Bp++;
if (*Bp == 0 || *Bp == ':')
return (0);
Bp++;
}
}
static int getent(bp, name, cp)
char *bp, *name, *cp;
{
register int c;
register int i = 0, cnt = 0;
char ibuf[BUFSIZ], *cp2;
int tf;
tbuf = bp;
tf = 0;
/*
* TERMCAP can have one of two things in it. It can be the
* name of a file to use instead of /etc/termcap. In this
* case it better start with a "/". Or it can be an entry to
* use so we don't have to read the file. In this case it
* has to already have the newlines crunched out.
*/
if (cp && *cp) {
if (*cp!='/') {
cp2 = getenv(V_TERM);
if (cp2 == (char *)0 || strcmp(name,cp2) == 0) {
strcpy(bp,cp);
return (tnchktc());
} else
tf = open(E_TERMCAP, O_RDONLY);
} else
tf = open(RM = cp, O_RDONLY);
}
if (tf == 0)
tf = open(E_TERMCAP, O_RDONLY);
if (tf < 0)
return (-1);
for (;;) {
cp = bp;
for (;;) {
if (i == cnt) {
cnt = read(tf, ibuf, BUFSIZ);
if (cnt <= 0) {
close(tf);
return (0);
}
i = 0;
}
c = ibuf[i++];
if (c == '\n') {
if (cp > bp && cp[-1] == '\\') {
cp--;
continue;
}
break;
}
if (cp >= bp+BUFSIZ) {
write(2,"Remcap entry too long\n", 23);
break;
} else
*cp++ = c;
}
*cp = 0;
/*
* The real work for the match.
*/
if (tnamatch(name)) {
close(tf);
return (tnchktc());
}
}
}
/*
* tnchktc: check the last entry, see if it's tc=xxx. If so,
* recursively find xxx and append that entry (minus the names)
* to take the place of the tc=xxx entry. This allows termcap
* entries to say "like an HP2621 but doesn't turn on the labels".
* Note that this works because of the left to right scan.
*/
static int tnchktc()
{
register char *p, *q;
char tcname[16]; /* name of similar terminal */
char tcbuf[BUFSIZ];
char *holdtbuf = tbuf;
int l;
p = tbuf + strlen(tbuf) - 2; /* before the last colon */
while (*--p != ':')
if (p<tbuf) {
write(2, "Bad remcap entry\n", 18);
return (0);
}
p++;
/* p now points to beginning of last field */
if (p[0] != 't' || p[1] != 'c')
return (1);
strcpy(tcname, p+3);
q = tcname;
while (*q && *q != ':')
q++;
*q = 0;
if (++hopcount > MAXHOP) {
write(2, "Infinite tc= loop\n", 18);
return (0);
}
if (getent(tcbuf, tcname, remotefile) != 1) {
if (strcmp(remotefile, SYSREMOTE) == 0)
return (0);
else if (getent(tcbuf, tcname, SYSREMOTE) != 1)
return (0);
}
for (q = tcbuf; *q++ != ':'; )
;
l = p - holdtbuf + strlen(q);
if (l > BUFSIZ) {
write(2, "Remcap entry too long\n", 23);
q[BUFSIZ - (p-holdtbuf)] = 0;
}
strcpy(p, q);
tbuf = holdtbuf;
return (1);
}
/*
* Get an entry for terminal name in buffer bp,
* from the termcap file. Parse is very rudimentary;
* we just notice escaped newlines.
*/
int tgetent(bp, name)
char *bp, *name;
{
char lbuf[BUFSIZ], *cp, *p;
int rc1, rc2;
remotefile = cp = getenv(V_TERMCAP);
if (cp == (char *)0 || strcmp(cp, SYSREMOTE) == 0) {
remotefile = cp = SYSREMOTE;
return (getent(bp, name, cp));
} else {
if ((rc1 = getent(bp, name, cp)) != 1)
*bp = '\0';
remotefile = cp = SYSREMOTE;
rc2 = getent(lbuf, name, cp);
if (rc1 != 1 && rc2 != 1)
return (rc2);
if (rc2 == 1) {
p = lbuf;
if (rc1 == 1)
while (*p++ != ':')
;
if (strlen(bp) + strlen(p) > BUFSIZ) {
write(2, "Remcap entry too long\n", 23);
return (-1);
}
strcat(bp, p);
}
tbuf = bp;
return (1);
}
}
/*
* Skip to the next field. Notice that this is very dumb, not
* knowing about \: escapes or any such. If necessary, :'s can be put
* into the termcap file in octal.
*/
static char *
tskip(bp)
register char *bp;
{
while (*bp && *bp != ':')
bp++;
while (*bp == ':')
bp++;
return (bp);
}
/*
* Return the (numeric) option id.
* Numeric options look like
* li#80
* i.e. the option string is separated from the numeric value by
* a # character. If the option is not found we return -1.
* Note that we handle octal numbers beginning with 0.
*/
int tgetnum(id)
char *id;
{
register int i, base;
register char *bp = tbuf;
for (;;) {
bp = tskip(bp);
if (*bp == 0)
return (-1);
if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
continue;
if (*bp == '@')
return (-1);
if (*bp != '#')
continue;
bp++;
base = 10;
if (*bp == '0')
base = 8;
i = 0;
while (isdigit(*bp))
i *= base, i += *bp++ - '0';
return (i);
}
}
/*
* Handle a flag option.
* Flag options are given "naked", i.e. followed by a : or the end
* of the buffer. Return 1 if we find the option, or 0 if it is
* not given.
*/
int tgetflag(id)
char *id;
{
register char *bp = tbuf;
for (;;) {
bp = tskip(bp);
if (!*bp)
return (0);
if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) {
if (!*bp || *bp == ':')
return (1);
else if (*bp == '@')
return (0);
}
}
}
/*
* Tdecode does the grung work to decode the
* string capability escapes.
*/
static char *
tdecode(str, area)
register char *str;
char **area;
{
register char *cp;
register int c;
register char *dp;
int i;
cp = *area;
while ((c = *str++) && c != ':') {
switch (c) {
case '^':
c = *str++ & 037;
break;
case '\\':
dp = "E\033^^\\\\::n\nr\rt\tb\bf\f";
c = *str++;
nextc:
if (*dp++ == c) {
c = *dp++;
break;
}
dp++;
if (*dp)
goto nextc;
if (isdigit(c)) {
c -= '0', i = 2;
do
c <<= 3, c |= *str++ - '0';
while (--i && isdigit(*str));
}
break;
}
*cp++ = c;
}
*cp++ = 0;
str = *area;
*area = cp;
return (str);
}
/*
* Get a string valued option.
* These are given as
* cl=^Z
* Much decoding is done on the strings, and the strings are
* placed in area, which is a ref parameter which is updated.
* No checking on area overflow.
*/
char *
tgetstr(id, area)
char *id, **area;
{
register char *bp = tbuf;
for (;;) {
bp = tskip(bp);
if (!*bp)
return (0);
if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
continue;
if (*bp == '@')
return (0);
if (*bp != '=')
continue;
bp++;
return (tdecode(bp, area));
}
}

104
src/cmd/tip/remote-file Normal file
View File

@@ -0,0 +1,104 @@
#
# General dialer definitions used below
#
local|Local PTY connection:\
:dv=/dev/ptyp0,/dev/ptyp1,/dev/ptyp2,/dev/ptyp3:\
:br#115200:
dial1200|1200 Baud Able Quadracall attributes:\
:dv=/dev/cul1:br#1200:cu=/dev/cua1:at=dn11:du:
dial300|300 Bizcomp 1022 attributes:\
:dv=/dev/cul0:br#300:cu=/dev/cua0:at=dn11:du:
#
# UNIX system definitions
#
unix1200|1200 Baud dial-out to another UNIX system:\
:el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial1200:
unix300|300 Baud dial-out to another UNIX system:\
:el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial300:
#
# System descriptions
#
45|Sytek PDP-11/45:dv=/dev/ttyh1:br#9600:hw:el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:
bert|CSRG ARPA VAX-11/780:pn=@:tc=unix1200:
ernie|UCB VAX-11/780:pn=@:tc=unix1200:
lbl|LBL VAX-11/780:pn=@:tc=unix1200:
decvax|DEC VAX-11/780:pn=@:tc=unix1200:
casevax|cwrunix|CWRU VAX-11/750:pn=@:tc=unix1200:
cwruecmp|ecmp|CWRU VAX-11/780:pn=@:tc=unix1200:
case|CWRU DEC-20:pn=@:tc=unix1200:
ames|Ames TIP:pn=@:tc=unix1200:
navy|navy PWB 11/70:pn=@:tc=unix300:
gi750|General Instruments VAX-11/750, Arizona:pn=@:tc=unix1200:
gi|General Instruments VAX-11/780, Utah:pn=@:tc=unix1200:
video:dv=/dev/tty04:br#4800:
Second example:
45z|PDP-11/45Z system:\
:dv=/dev/tty32:br#9600:el=^U^C^S^Q^D:ie=%$:oe=^D:
decvax|DEC VAX-11/780:\
:pn=41148:tc=UNIX-300:
decvax-1200|DEC VAX-11/780:\
:pn=41230:tc=UNIX-1200:
decmail:\
:pn=42311:tc=VMS-1200:
ems:\
:pn=41991:tc=VMS-1200:
vms750|nymph|NPG 750:\
:dv=/dev/tty36,/dev/tty37:br#9600:el=^Z^U^C^S^Q^O:ie=$@:oe=^Z:
spa|SPA VAX-11/780:\
:pn=8=2270513:tc=UNIX-300:
vax4|DECnet hub:\
:pn=41662:tc=VMS-1200:
star|VMS development system:\
:pn=41701:tc=VMS-1200:
sultan|Software Tools:\
:pn=41701:tc=UNIX-1200:
cghub|demo room timesharing VAX:\
:pn=41023,41024:tc=VMS-300
phenix|phenix-300|Distributed systems:\
:pn=8=2472765,8=2472766,8=2472767,8=2472768:tc=VMS-300
market|arpanet:\
:pn=8=2317437,8=2317438,8=2317447,8=2317447,8=2317448,8=2317449,\
:8=2317450,8=2317451:tc=TOPS20-1200
market300|arpanet300:\
:pn=8=2311120,8=2311125,8=2311128:tc=TOPS20-300
tip0|tip1200:tc=UNIX-1200:
tip300:tc=UNIX-300:
cu0|cu300:tc=UNIX-300:
cu1200:tc=UNIX-1200:
UNIX-300:\
:dv=/dev/cua0:el=^D^U^C^S^Q^O@:du:at=df02:ie=#$%:oe=^D:br#300:
UNIX-1200:\
:dv=/dev/cua1,/dev/cua2,/dev/cua4:el=^D^U^C^S^Q^O@:du:at=df03:\
:ie=#$%:oe=^D:br#1200:
VMS-300|TOPS20-300:\
:dv=/dev/cua0:el=^Z^U^C^S^Q^O:du:at=df02:ie=$@:oe=^Z:br#300:
VMS-1200|TOPS20-1200:\
:dv=/dev/cua1,/dev/cua2,/dev/cua4:el=^Z^U^C^S^Q^O:du:at=df03:\
:ie=$@:oe=^Z:br#1200:
--------------------------------------------------------------------
The attributes are:
dv device to use for the tty
el EOL marks (default is NULL)
du make a call flag (dial up)
pn phone numbers (@ =>'s search phones file; possibly taken from
PHONES environment variable)
at ACU type
ie input EOF marks (default is NULL)
oe output EOF string (default is NULL)
cu call unit (default is dv)
br baud rate (defaults to 300)
fs frame size (default is BUFSIZ) -- used in buffering writes
on receive operations
tc to continue a capability

160
src/cmd/tip/remote.c Normal file
View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
/*
* Attributes to be gleened from remote host description
* data base.
*/
static char **caps[] = {
&AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI,
&ES, &EX, &FO, &RC, &RE, &PA
};
static char *capstrings[] = {
"at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr",
"di", "es", "ex", "fo", "rc", "re", "pa", 0
};
static void
getremcap(host)
register char *host;
{
int stat;
char tbuf[BUFSIZ];
static char buf[BUFSIZ/2];
char *bp = buf;
register char **p, ***q;
if ((stat = rgetent(tbuf, host)) <= 0) {
if (DV ||
(host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
CU = DV;
HO = host;
HW = 1;
DU = 0;
if (!BR)
BR = DEFBR;
FS = DEFFS;
return;
}
fprintf(stderr, stat == 0 ?
"tip: unknown host %s\n" :
"tip: can't open host description file\n", host);
exit(3);
}
for (p = capstrings, q = caps; *p != NULL; p++, q++)
if (**q == NULL)
**q = rgetstr(*p, &bp);
if (!BR && (BR = rgetnum("br")) < 0)
BR = DEFBR;
if ((FS = rgetnum("fs")) < 0)
FS = DEFFS;
if (DU < 0)
DU = 0;
else
DU = rgetflag("du");
if (DV == NOSTR) {
fprintf(stderr, "%s: missing device spec\n", host);
exit(3);
}
if (DU && CU == NOSTR)
CU = DV;
if (DU && PN == NOSTR) {
fprintf(stderr, "%s: missing phone number\n", host);
exit(3);
}
HD = rgetflag("hd");
/*
* This effectively eliminates the "hw" attribute
* from the description file
*/
if (!HW)
HW = (CU == NOSTR) || (DU && equal(DV, CU));
HO = host;
/*
* see if uppercase mode should be turned on initially
*/
if (rgetflag("ra"))
boolean(value(RAISE)) = 1;
if (rgetflag("ec"))
boolean(value(ECHOCHECK)) = 1;
if (rgetflag("be"))
boolean(value(BEAUTIFY)) = 1;
if (rgetflag("nb"))
boolean(value(BEAUTIFY)) = 0;
if (rgetflag("sc"))
boolean(value(SCRIPT)) = 1;
if (rgetflag("tb"))
boolean(value(TABEXPAND)) = 1;
if (rgetflag("vb"))
boolean(value(VERBOSE)) = 1;
if (rgetflag("nv"))
boolean(value(VERBOSE)) = 0;
if (rgetflag("ta"))
boolean(value(TAND)) = 1;
if (rgetflag("nt"))
boolean(value(TAND)) = 0;
if (rgetflag("rw"))
boolean(value(RAWFTP)) = 1;
if (rgetflag("hd"))
boolean(value(HALFDUPLEX)) = 1;
if (RE == NOSTR)
RE = (char *)"tip.record";
if (EX == NOSTR)
EX = (char *)"\t\n\b\f";
if (ES != NOSTR)
vstring("es", ES);
if (FO != NOSTR)
vstring("fo", FO);
if (PR != NOSTR)
vstring("pr", PR);
if (RC != NOSTR)
vstring("rc", RC);
if ((DL = rgetnum("dl")) < 0)
DL = 0;
if ((CL = rgetnum("cl")) < 0)
CL = 0;
if ((ET = rgetnum("et")) < 0)
ET = 10;
}
char *
getremote(host)
char *host;
{
register char *cp;
static char *next;
static int lookedup = 0;
if (!lookedup) {
if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
fprintf(stderr, "tip: no host specified\n");
exit(3);
}
getremcap(host);
next = DV;
lookedup++;
}
/*
* We return a new device each time we're called (to allow
* a rotary action to be simulated)
*/
if (next == NOSTR)
return (NOSTR);
if ((cp = strchr(next, ',')) == NULL) {
DV = next;
next = NOSTR;
} else {
*cp++ = '\0';
DV = next;
next = cp;
}
return (DV);
}

568
src/cmd/tip/tip.c Normal file
View File

@@ -0,0 +1,568 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* tip - UNIX link to other systems
* tip [-v] [-speed] system-name
* or
* cu phone-number [-s speed] [-l line] [-a acu]
*/
#include <stdlib.h>
#include <string.h>
#include "tip.h"
/*
* Baud rate mapping table
*/
int bauds[] = {
0, 50, 75, 150, 200, 300, 600,
1200, 1800, 2400, 4800, 9600, 19200,
38400, 57600, 115200, 230400, 460800,
500000, 576000, 921600, 1000000, 1152000,
1500000, 2000000, 2500000, 3000000,
3500000, 4000000, -1
};
int disc = 0; // OTTYDISC; /* tip normally runs this way */
void intprompt(int i);
void timeout(int i);
void cleanup(int i);
char *sname();
char PNbuf[256]; /* This limits the size of a number */
/*
* ****TIPIN TIPIN****
*/
static void tipin()
{
char gch, bol = 1;
/*
* Kinda klugey here...
* check for scripting being turned on from the .tiprc file,
* but be careful about just using setscript(), as we may
* send a SIGEMT before tipout has a chance to set up catching
* it; so wait a second, then setscript()
*/
if (boolean(value(SCRIPT))) {
sleep(1);
setscript();
}
while (1) {
gch = getchar()&0177;
if ((gch == character(value(ESCAPE))) && bol) {
if (!(gch = escape()))
continue;
} else if (!cumode && gch == character(value(RAISECHAR))) {
boolean(value(RAISE)) = !boolean(value(RAISE));
continue;
} else if (gch == '\r') {
bol = 1;
pwrite(FD, &gch, 1);
if (boolean(value(HALFDUPLEX)))
printf("\r\n");
continue;
} else if (!cumode && gch == character(value(FORCE)))
gch = getchar()&0177;
bol = any(gch, value(EOL));
if (boolean(value(RAISE)) && islower(gch))
gch = toupper(gch);
pwrite(FD, &gch, 1);
if (boolean(value(HALFDUPLEX)))
printf("%c", gch);
}
}
int main(argc, argv)
char *argv[];
{
char *system = NOSTR;
register int i;
register char *p;
char sbuf[12];
gid = getgid();
egid = getegid();
uid = getuid();
euid = geteuid();
if (equal(sname(argv[0]), "cu")) {
cumode = 1;
cumain(argc, argv);
goto cucommon;
}
if (argc > 4) {
fprintf(stderr, "usage: tip [-v] [-speed] [system-name]\n");
exit(1);
}
if (!isatty(0)) {
fprintf(stderr, "tip: must be interactive\n");
exit(1);
}
for (; argc > 1; argv++, argc--) {
if (argv[1][0] != '-')
system = argv[1];
else switch (argv[1][1]) {
case 'v':
vflag++;
break;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
BR = atoi(&argv[1][1]);
break;
default:
fprintf(stderr, "tip: %s, unknown option\n", argv[1]);
break;
}
}
if (system == NOSTR)
goto notnumber;
if (isalpha(*system))
goto notnumber;
/*
* System name is really a phone number...
* Copy the number then stomp on the original (in case the number
* is private, we don't want 'ps' or 'w' to find it).
*/
if (strlen(system) > sizeof PNbuf - 1) {
fprintf(stderr, "tip: phone number too long (max = %ld bytes)\n",
(long) sizeof PNbuf - 1);
exit(1);
}
strncpy( PNbuf, system, sizeof PNbuf - 1 );
for (p = system; *p; p++)
*p = '\0';
PN = PNbuf;
(void)sprintf(sbuf, "tip%d", BR);
system = sbuf;
notnumber:
signal(SIGINT, cleanup);
signal(SIGQUIT, cleanup);
signal(SIGHUP, cleanup);
signal(SIGTERM, cleanup);
if ((i = hunt(system)) == 0) {
printf("all ports busy\n");
exit(3);
}
if (i == -1) {
printf("link down\n");
delock(uucplock);
exit(3);
}
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")) == NOSTR)
PH = "/etc/phones";
vinit(); /* init variables */
setparity("even"); /* set the parity table */
if ((i = speed(number(value(BAUDRATE)))) == NULL) {
printf("tip: bad baud rate %d\n", number(value(BAUDRATE)));
delock(uucplock);
exit(3);
}
/*
* Now that we have the logfile and the ACU open
* return to the real uid and gid. These things will
* be closed on exit. Swap real and effective uid's
* so we can get the original permissions back
* for removing the uucp lock.
*/
user_uid();
/*
* Hardwired connections require the
* line speed set before they make any transmissions
* (this is particularly true of things like a DF03-AC)
*/
if (HW)
ttysetup(i);
p = connect();
if (p) {
printf("\07%s\n[EOT]\n", p);
daemon_uid();
delock(uucplock);
exit(1);
}
if (!HW)
ttysetup(i);
cucommon:
/*
* From here down the code is shared with
* the "cu" version of tip.
*/
ioctl(0, TIOCGETP, (char *)&defarg);
ioctl(0, TIOCGETC, (char *)&defchars);
ioctl(0, TIOCGLTC, (char *)&deflchars);
ioctl(0, TIOCGETD, (char *)&odisc);
arg = defarg;
arg.sg_flags = ANYP | CBREAK;
tchars = defchars;
tchars.t_intrc = tchars.t_quitc = -1;
ltchars = deflchars;
ltchars.t_suspc = ltchars.t_dsuspc = ltchars.t_flushc
= ltchars.t_lnextc = -1;
raw();
pipe(fildes); pipe(repdes);
signal(SIGALRM, timeout);
/*
* Everything's set up now:
* connection established (hardwired or dialup)
* line conditioned (baud rate, mode, etc.)
* internal data structures (variables)
* so, fork one process for local side and one for remote.
*/
printf(cumode ? "Connected\r\n" : "\07connected\r\n");
pid = fork();
if (pid)
tipin();
else
tipout();
/*NOTREACHED*/
return 0;
}
void cleanup(int i)
{
daemon_uid();
delock(uucplock);
if (odisc)
ioctl(0, TIOCSETD, (char *)&odisc);
exit(0);
}
/*
* Muck with user ID's. We are setuid to the owner of the lock
* directory when we start. user_uid() reverses real and effective
* ID's after startup, to run with the user's permissions.
* daemon_uid() switches back to the privileged uid for unlocking.
* Finally, to avoid running a shell with the wrong real uid,
* shell_uid() sets real and effective uid's to the user's real ID.
*/
static int uidswapped;
void user_uid()
{
if (uidswapped == 0) {
setregid(egid, gid);
setreuid(euid, uid);
uidswapped = 1;
}
}
void daemon_uid()
{
if (uidswapped) {
setreuid(uid, euid);
setregid(gid, egid);
uidswapped = 0;
}
}
void shell_uid()
{
setreuid(uid, uid);
setregid(gid, gid);
}
/*
* put the controlling keyboard into raw mode
*/
void raw()
{
ioctl(0, TIOCSETP, &arg);
ioctl(0, TIOCSETC, &tchars);
ioctl(0, TIOCSLTC, &ltchars);
ioctl(0, TIOCSETD, (char *)&disc);
}
/*
* return keyboard to normal mode
*/
void unraw()
{
ioctl(0, TIOCSETD, (char *)&odisc);
ioctl(0, TIOCSETP, (char *)&defarg);
ioctl(0, TIOCSETC, (char *)&defchars);
ioctl(0, TIOCSLTC, (char *)&deflchars);
}
static jmp_buf promptbuf;
/*
* Print string ``s'', then read a string
* in from the terminal. Handles signals & allows use of
* normal erase and kill characters.
*/
int prompt(s, p)
char *s;
register char *p;
{
register char *b = p;
sig_t oint;
stoprompt = 0;
oint = signal(SIGINT, intprompt);
oint = signal(SIGQUIT, SIG_IGN);
unraw();
printf("%s", s);
if (setjmp(promptbuf) == 0)
while ((*p = getchar()) != EOF && *p != '\n')
p++;
*p = '\0';
raw();
signal(SIGINT, oint);
signal(SIGQUIT, oint);
return (stoprompt || p == b);
}
/*
* Interrupt service routine during prompting
*/
void intprompt(int i)
{
signal(SIGINT, SIG_IGN);
stoprompt = 1;
printf("\r\n");
longjmp(promptbuf, 1);
}
/*
* Escape handler --
* called on recognition of ``escapec'' at the beginning of a line
*/
int escape()
{
register int gch;
register esctable_t *p;
char c = character(value(ESCAPE));
extern esctable_t etable[];
gch = (getchar()&0177);
for (p = etable; p->e_char; p++)
if (p->e_char == gch) {
if ((p->e_flags&PRIV) && uid)
continue;
printf("%s", ctrl(c));
(*p->e_func)(gch);
return (0);
}
/* ESCAPE ESCAPE forces ESCAPE */
if (c != gch)
pwrite(FD, &c, 1);
return (gch);
}
int speed(n)
int n;
{
register int *p;
for (p = bauds; *p != -1; p++)
if (*p == n)
return (p - bauds);
return (NULL);
}
int any(c, p)
register int c;
register char *p;
{
while (p && *p)
if (*p++ == c)
return (1);
return (0);
}
int size(s)
register char *s;
{
register int i = 0;
while (s && *s++)
i++;
return (i);
}
char *
interp(s)
register char *s;
{
static char buf[256];
register char *p = buf, c, *q;
while ((c = *s++)) {
for (q = "\nn\rr\tt\ff\033E\bb"; *q; q++)
if (*q++ == c) {
*p++ = '\\'; *p++ = *q;
goto next;
}
if (c < 040) {
*p++ = '^'; *p++ = c + 'A'-1;
} else if (c == 0177) {
*p++ = '^'; *p++ = '?';
} else
*p++ = c;
next:
;
}
*p = '\0';
return (buf);
}
char *
ctrl(c)
int c;
{
static char s[3];
if (c < 040 || c == 0177) {
s[0] = '^';
s[1] = c == 0177 ? '?' : c+'A'-1;
s[2] = '\0';
} else {
s[0] = c;
s[1] = '\0';
}
return (s);
}
/*
* Help command
*/
void help(c)
char c;
{
register esctable_t *p;
extern esctable_t etable[];
printf("%c\r\n", c);
for (p = etable; p->e_char; p++) {
if ((p->e_flags&PRIV) && uid)
continue;
printf("%2s", ctrl(character(value(ESCAPE))));
printf("%-2s %c %s\r\n", ctrl(p->e_char),
p->e_flags&EXP ? '*': ' ', p->e_help);
}
}
/*
* Set up the "remote" tty's state
*/
void ttysetup(speed)
int speed;
{
unsigned bits = LDECCTQ;
arg.sg_ispeed = arg.sg_ospeed = speed;
arg.sg_flags = RAW;
if (boolean(value(TAND)))
arg.sg_flags |= TANDEM;
ioctl(FD, TIOCSETP, (char *)&arg);
ioctl(FD, TIOCLBIS, (char *)&bits);
}
/*
* Return "simple" name from a file name,
* strip leading directories.
*/
char *
sname(s)
register char *s;
{
register char *p = s;
while (*s)
if (*s++ == '/')
p = s;
return (p);
}
static char partab[0200];
/*
* Do a write to the remote machine with the correct parity.
* We are doing 8 bit wide output, so we just generate a character
* with the right parity and output it.
*/
void pwrite(fd, buf, n)
int fd;
char *buf;
register int n;
{
//register int i;
register char *bp;
extern int errno;
bp = buf;
//for (i = 0; i < n; i++) {
// *bp = partab[(*bp) & 0177];
// bp++;
//}
if (write(fd, buf, n) < 0) {
if (errno == EIO)
tipabort("Lost carrier.");
/* this is questionable */
perror("write");
}
}
/*
* Build a parity table with appropriate high-order bit.
*/
void setparity(defparity)
char *defparity;
{
register int i;
char *parity;
extern char evenpartab[];
if (defparity != NOSTR && value(PARITY) == NOSTR)
value(PARITY) = defparity;
parity = value(PARITY);
for (i = 0; i < 0200; i++)
partab[i] = evenpartab[i];
if (equal(parity, "even"))
return;
if (equal(parity, "odd")) {
for (i = 0; i < 0200; i++)
partab[i] ^= 0200; /* reverse bit 7 */
return;
}
if (equal(parity, "none") || equal(parity, "zero")) {
for (i = 0; i < 0200; i++)
partab[i] &= ~0200; /* turn off bit 7 */
return;
}
if (equal(parity, "one")) {
for (i = 0; i < 0200; i++)
partab[i] |= 0200; /* turn on bit 7 */
return;
}
fprintf(stderr, "%s: unknown parity value\n", PA);
fflush(stderr);
}

266
src/cmd/tip/tip.h Normal file
View File

@@ -0,0 +1,266 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)tip.h 5.3.1 (2.11BSD GTE) 1/1/94
*/
/*
* tip - terminal interface program
*/
#include <sys/types.h>
#include <sys/file.h>
#include <sgtty.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
#include <ctype.h>
#include <setjmp.h>
#include <errno.h>
#ifdef CTRL
#undef CTRL
#endif
#define CTRL(c) ('c' & 037)
/*
* Remote host attributes
*/
char *DV; /* UNIX device(s) to open */
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 */
int BR; /* line speed for conversation */
int FS; /* frame size for transfers */
char DU; /* this host is dialed up */
char HW; /* this device is hardwired, see hunt.c */
char *ES; /* escape character */
char *EX; /* exceptions */
char *FO; /* force (literal next) char*/
char *RC; /* raise character */
char *RE; /* script record file */
char *PR; /* remote prompt */
int DL; /* line delay for file transfers to remote */
int CL; /* char delay for file transfers to remote */
int ET; /* echocheck timeout */
char HD; /* this host is half duplex - do local echo */
/*
* String value table
*/
typedef struct {
char *v_name; /* whose name is it */
char v_type; /* for interpreting set's */
char v_access; /* protection of touchy ones */
char *v_abrev; /* possible abreviation */
char *v_value; /* casted to a union later */
} value_t;
#define STRING 01 /* string valued */
#define BOOL 02 /* true-false value */
#define NUMBER 04 /* numeric value */
#define CHAR 010 /* character value */
#define WRITE 01 /* write access to variable */
#define READ 02 /* read access */
#define CHANGED 01 /* low bit is used to show modification */
#define PUBLIC 1 /* public access rights */
#define PRIVATE 03 /* private to definer */
#define ROOT 05 /* root defined */
#define TRUE 1
#define FALSE 0
#define ENVIRON 020 /* initialize out of the environment */
#define IREMOTE 040 /* initialize out of remote structure */
#define INIT 0100 /* static data space used for initialization */
#define TMASK 017
/*
* Definition of ACU line description
*/
typedef struct {
char *acu_name;
int (*acu_dialer)();
int (*acu_disconnect)();
int (*acu_abort)();
} acu_t;
#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */
/*
* 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
* happy.
*/
typedef union {
int zz_number;
short zz_boolean;
char zz_character;
int *zz_address;
} zzhack;
#define value(v) vtable[v].v_value
#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean)
#define number(v) ((((zzhack *)(&(v))))->zz_number)
#define character(v) ((((zzhack *)(&(v))))->zz_character)
#define address(v) ((((zzhack *)(&(v))))->zz_address)
/*
* Escape command table definitions --
* lookup in this table is performed when ``escapec'' is recognized
* at the begining of a line (as defined by the eolmarks variable).
*/
typedef struct {
char e_char; /* char to match on */
char e_flags; /* experimental, priviledged */
char *e_help; /* help string */
int (*e_func)(); /* command */
} esctable_t;
#define NORM 00 /* normal protection, execute anyone */
#define EXP 01 /* experimental, mark it with a `*' on help */
#define PRIV 02 /* priviledged, root execute only */
extern int vflag; /* verbose during reading of .tiprc file */
extern value_t vtable[]; /* variable table */
/*
* Definition of indices into variable table so
* 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 NOVAL ((value_t *)NULL)
#define NOACU ((acu_t *)NULL)
#define NOSTR ((char *)NULL)
#define NOFILE ((FILE *)NULL)
#define NOPWD ((struct passwd *)0)
struct sgttyb arg; /* current mode of local terminal */
struct sgttyb defarg; /* initial mode of local terminal */
struct tchars tchars; /* current state of terminal */
struct tchars defchars; /* initial state of terminal */
struct ltchars ltchars; /* current local characters of terminal */
struct ltchars deflchars; /* initial local characters of terminal */
FILE *fscript; /* FILE for scripting */
int fildes[2]; /* file transfer synchronization channel */
int repdes[2]; /* read process sychronization channel */
int FD; /* open file descriptor to remote host */
int AC; /* open file descriptor to dialer (v831 only) */
int vflag; /* print .tiprc initialization sequence */
int sfd; /* for ~< operation */
int pid; /* pid of tipout */
uid_t uid, euid; /* real and effective user id's */
gid_t gid, egid; /* real and effective group id's */
int stop; /* stop transfer session flag */
int quit; /* same; but on other end */
int intflag; /* recognized interrupt */
int stoprompt; /* for interrupting a prompt session */
int timedout; /* ~> transfer timedout */
int cumode; /* simulating the "cu" program */
char fname[80]; /* file name buffer for ~< */
char copyname[80]; /* file name buffer for ~> */
char ccc; /* synchronization character */
char ch; /* for tipout */
char *uucplock; /* name of lock file for uucp's */
int odisc; /* initial tty line discipline */
extern int disc; /* current tty discpline */
char *ctrl (int c);
char *connect (void);
void delock (char *s);
void pwrite (int fd, char *buf, int n);
int size (char *s);
void disconnect (char *reason);
void loginit (void);
void logent (char *group, char *num, char *acu, char *message);
int any (int c, char *p);
void raw (void);
void unraw (void);
int prompt (char *s, char *p);
void user_uid (void);
void shell_uid (void);
void daemon_uid (void);
void vinit (void);
void vlex (char *s);
int vstring (char *s, char *v);
void setparity (char *defparity);
int speed (int n);
int hunt (char *name);
void ttysetup (int speed);
int mlock (char *sys);
int rgetent (char *bp, char *name);
char *rgetstr (char *id, char **area);
int rgetnum (char *id);
int rgetflag (char *id);
void cumain (int argc, char *argv[]);
void tipout (void);
void setscript (void);
int escape (void);
void tipabort (char *msg);
void finish (void);
#ifndef ACULOG
#define logent(a, b, c, d)
#define loginit()
#endif

120
src/cmd/tip/tipout.c Normal file
View File

@@ -0,0 +1,120 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
/*
* tip
*
* lower fork of tip -- handles passive side
* reading from the remote host
*/
static jmp_buf sigbuf;
/*
* TIPOUT wait state routine --
* sent by TIPIN when it wants to posses the remote host
*/
void intIOT(int sig)
{
write(repdes[1],&ccc,1);
read(fildes[0], &ccc,1);
longjmp(sigbuf, 1);
}
/*
* Scripting command interpreter --
* accepts script file name over the pipe and acts accordingly
*/
void intEMT(int sig)
{
char c, line[256];
register char *pline = line;
char reply;
read(fildes[0], &c, 1);
while (c != '\n') {
*pline++ = c;
read(fildes[0], &c, 1);
}
*pline = '\0';
if (boolean(value(SCRIPT)) && fscript != NULL)
fclose(fscript);
if (pline == line) {
boolean(value(SCRIPT)) = FALSE;
reply = 'y';
} else {
if ((fscript = fopen(line, "a")) == NULL)
reply = 'n';
else {
reply = 'y';
boolean(value(SCRIPT)) = TRUE;
}
}
write(repdes[1], &reply, 1);
longjmp(sigbuf, 1);
}
void intTERM(int sig)
{
if (boolean(value(SCRIPT)) && fscript != NULL)
fclose(fscript);
exit(0);
}
void intSYS(int sig)
{
boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY));
longjmp(sigbuf, 1);
}
/*
* ****TIPOUT TIPOUT****
*/
void tipout()
{
char buf[BUFSIZ];
register char *cp;
register int cnt;
extern int errno;
long omask;
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGEMT, intEMT); /* attention from TIPIN */
signal(SIGTERM, intTERM); /* time to go signal */
signal(SIGIOT, intIOT); /* scripting going on signal */
signal(SIGHUP, intTERM); /* for dial-ups */
signal(SIGSYS, intSYS); /* beautify toggle */
(void) setjmp(sigbuf);
for (omask = 0;; sigsetmask(omask)) {
cnt = read(FD, buf, BUFSIZ);
if (cnt <= 0) {
/* lost carrier */
if (cnt < 0 && errno == EIO) {
sigblock(sigmask(SIGTERM));
intTERM(0);
/*NOTREACHED*/
}
continue;
}
#define ALLSIGS sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
omask = sigblock(ALLSIGS);
for (cp = buf; cp < buf + cnt; cp++)
*cp &= 0177;
write(1, buf, cnt);
if (boolean(value(SCRIPT)) && fscript != NULL) {
if (!boolean(value(BEAUTIFY))) {
fwrite(buf, 1, cnt, fscript);
continue;
}
for (cp = buf; cp < buf + cnt; cp++)
if ((*cp >= ' ' && *cp <= '~') ||
any(*cp, value(EXCEPTIONS)))
putc(*cp, fscript);
}
}
}

199
src/cmd/tip/uucplock.c Normal file
View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* defs that come from uucp.h
*/
#define NAMESIZE 32
#define FAIL -1
#define SAME 0
#define SLCKTIME 28800 /* system/device timeout (LCK.. files) in seconds (8 hours) */
#define ASSERT(e, f, v) if (!(e)) {\
fprintf(stderr, "AERROR - (%s) ", "e");\
fprintf(stderr, f, v);\
finish();\
}
#define LOCKPRE "/var/lock/LCK."
/*
* This code is taken almost directly from uucp and follows the same
* conventions. This is important since uucp and tip should
* respect each others locks.
*/
/* ulockf 3.2 10/26/79 11:40:29 */
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#define MAXLOCKS 10 /* maximum number of lock files */
char *Lockfile[MAXLOCKS];
int Nlocks = 0;
void finish (void);
/***
* stlock(name) put name in list of lock files
* char *name;
*
* return codes: none
*/
static void
stlock(name)
char *name;
{
char *p;
int i;
for (i = 0; i < Nlocks; i++) {
if (Lockfile[i] == NULL)
break;
}
ASSERT(i < MAXLOCKS, "TOO MANY LOCKS %d", i);
if (i >= Nlocks)
i = Nlocks++;
p = calloc(strlen(name) + 1, sizeof (char));
ASSERT(p != NULL, "CAN NOT ALLOCATE FOR %s", name);
strcpy(p, name);
Lockfile[i] = p;
}
/*
* this stuff from pjw
* /usr/pjw/bin/recover - check pids to remove unnecessary locks
*
* onelock(pid,tempfile,name) makes lock a name
* on behalf of pid. Tempfile must be in the same
* file system as name.
*
* lock(pid,tempfile,names) either locks all the
* names or none of them
*/
static int
onelock(pid, tempfile, name)
char *tempfile, *name;
{
int fd;
fd = creat(tempfile, 0444);
if (fd < 0)
return (-1);
write(fd,(char *)&pid, sizeof(int));
close(fd);
if (link(tempfile, name) < 0) {
unlink(tempfile);
return (-1);
}
unlink(tempfile);
return (0);
}
/*******
* ulockf(file, atime)
* char *file;
* time_t atime;
*
* ulockf - this routine will create a lock file (file).
* If one already exists, the create time is checked for
* older than the age time (atime).
* If it is older, an attempt will be made to unlink it
* and create a new one.
*
* return codes: 0 | FAIL
*/
static int
ulockf(file, atime)
char *file;
time_t atime;
{
struct stat stbuf;
time_t ptime;
int ret;
static int pid = -1;
static char tempfile[NAMESIZE];
if (pid < 0) {
pid = getpid();
sprintf(tempfile, "/var/lock/LTMP.%d", pid);
}
if (onelock(pid, tempfile, file) == -1) {
/* lock file exists */
/* get status to check age of the lock file */
ret = stat(file, &stbuf);
if (ret != -1) {
time(&ptime);
if ((ptime - stbuf.st_ctime) < atime) {
/* file not old enough to delete */
return (FAIL);
}
}
ret = unlink(file);
ret = onelock(pid, tempfile, file);
if (ret != 0)
return (FAIL);
}
stlock(file);
return (0);
}
/***
* rmlock(name) remove all lock files in list
* char *name; or name
*
* return codes: none
*/
static void
rmlock(name)
char *name;
{
int i;
for (i = 0; i < Nlocks; i++) {
if (Lockfile[i] == NULL)
continue;
if (name == NULL || strcmp(name, Lockfile[i]) == SAME) {
unlink(Lockfile[i]);
free(Lockfile[i]);
Lockfile[i] = NULL;
}
}
}
/***
* delock(s) remove a lock file
* char *s;
*
* return codes: 0 | FAIL
*/
void
delock(s)
char *s;
{
char ln[30];
sprintf(ln, "%s.%s", LOCKPRE, s);
rmlock(ln);
}
/***
* mlock(sys) create system lock
* char *sys;
*
* return codes: 0 | FAIL
*/
int mlock(sys)
char *sys;
{
char lname[30];
sprintf(lname, "%s.%s", LOCKPRE, sys);
return (ulockf(lname, (time_t) SLCKTIME ) < 0 ? FAIL : 0);
}

318
src/cmd/tip/value.c Normal file
View File

@@ -0,0 +1,318 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
#define MIDDLE 35
static int col = 0;
/*
* Variable manipulation
*/
void vinit()
{
register value_t *p;
register char *cp;
FILE *f;
char file[256];
for (p = vtable; p->v_name != NULL; p++) {
if (p->v_type&ENVIRON) {
cp = getenv(p->v_name);
if (cp)
p->v_value = cp;
}
if (p->v_type&IREMOTE)
number(p->v_value) = *address(p->v_value);
}
/*
* Read the .tiprc file in the HOME directory
* for sets
*/
strcpy(file, value(HOME));
strcat(file, "/.tiprc");
if ((f = fopen(file, "r")) != NULL) {
register char *tp;
while (fgets(file, sizeof(file)-1, f) != NULL) {
if (vflag)
printf("set %s", file);
tp = strrchr(file, '\n');
if (tp)
*tp = '\0';
vlex(file);
}
fclose(f);
}
/*
* To allow definition of exception prior to fork
*/
vtable[EXCEPTIONS].v_access &= ~(WRITE<<PUBLIC);
}
static int
vaccess(mode, rw)
register unsigned mode, rw;
{
if (mode & (rw<<PUBLIC))
return (1);
if (mode & (rw<<PRIVATE))
return (1);
return ((mode & (rw<<ROOT)) && getuid() == 0);
}
/*VARARGS1*/
void vassign(p, v)
register value_t *p;
char *v;
{
if (! vaccess(p->v_access, WRITE)) {
printf("access denied\r\n");
return;
}
switch (p->v_type&TMASK) {
case STRING:
if (equal(p->v_value, v))
return;
if (!(p->v_type&(ENVIRON|INIT)))
free(p->v_value);
if ((p->v_value = malloc(size(v)+1)) == NOSTR) {
printf("out of core\r\n");
return;
}
p->v_type &= ~(ENVIRON|INIT);
strcpy(p->v_value, v);
break;
case NUMBER:
if (number(p->v_value) == number(v))
return;
number(p->v_value) = number(v);
break;
case BOOL:
if (boolean(p->v_value) == (*v != '!'))
return;
boolean(p->v_value) = (*v != '!');
break;
case CHAR:
if (character(p->v_value) == *v)
return;
character(p->v_value) = *v;
}
p->v_access |= CHANGED;
}
static char *
vinterp(s, stop)
register char *s;
char stop;
{
register char *p = s, c;
int num;
while ((c = *s++) && c != stop)
switch (c) {
case '^':
if (*s)
*p++ = *s++ - 0100;
else
*p++ = c;
break;
case '\\':
num = 0;
c = *s++;
if (c >= '0' && c <= '7')
num = (num<<3)+(c-'0');
else {
register char *q = "n\nr\rt\tb\bf\f";
for (; *q; q++)
if (c == *q++) {
*p++ = *q;
goto cont;
}
*p++ = c;
cont:
break;
}
if ((c = *s++) >= '0' && c <= '7') {
num = (num<<3)+(c-'0');
if ((c = *s++) >= '0' && c <= '7')
num = (num<<3)+(c-'0');
else
s--;
} else
s--;
*p++ = num;
break;
default:
*p++ = c;
}
*p = '\0';
return (c == stop ? s-1 : NULL);
}
static void
vprint(p)
register value_t *p;
{
register char *cp;
extern char *interp(), *ctrl();
if (col > 0 && col < MIDDLE)
while (col++ < MIDDLE)
putchar(' ');
col += size(p->v_name);
switch (p->v_type&TMASK) {
case BOOL:
if (boolean(p->v_value) == FALSE) {
col++;
putchar('!');
}
printf("%s", p->v_name);
break;
case STRING:
printf("%s=", p->v_name);
col++;
if (p->v_value) {
cp = interp(p->v_value, NULL);
col += size(cp);
printf("%s", cp);
}
break;
case NUMBER:
col += 6;
printf("%s=%-5d", p->v_name, number(p->v_value));
break;
case CHAR:
printf("%s=", p->v_name);
col++;
if (p->v_value) {
cp = ctrl(character(p->v_value));
col += size(cp);
printf("%s", cp);
}
break;
}
if (col >= MIDDLE) {
col = 0;
printf("\r\n");
}
}
static value_t *
vlookup(s)
register char *s;
{
register value_t *p;
for (p = vtable; p->v_name; p++)
if (equal(p->v_name, s) || (p->v_abrev && equal(p->v_abrev, s)))
return (p);
return (NULL);
}
static void
vtoken(s)
register char *s;
{
register value_t *p;
register char *cp;
char *expand();
cp = strchr(s, '=');
if (cp) {
*cp = '\0';
p = vlookup(s);
if (p) {
cp++;
if (p->v_type&NUMBER)
vassign(p, atoi(cp));
else {
if (strcmp(s, "record") == 0)
cp = expand(cp);
vassign(p, cp);
}
return;
}
} else if ((cp = strchr(s, '?'))) {
*cp = '\0';
p = vlookup(s);
if (p && vaccess(p->v_access, READ)) {
vprint(p);
return;
}
} else {
if (*s != '!')
p = vlookup(s);
else
p = vlookup(s+1);
if (p != NOVAL) {
vassign(p, s);
return;
}
}
printf("%s: unknown variable\r\n", s);
}
void vlex(s)
register char *s;
{
register value_t *p;
if (equal(s, "all")) {
for (p = vtable; p->v_name; p++)
if (vaccess(p->v_access, READ))
vprint(p);
} else {
register char *cp;
do {
cp = vinterp(s, ' ');
if (cp)
cp++;
vtoken(s);
s = cp;
} while (s);
}
if (col > 0) {
printf("\r\n");
col = 0;
}
}
/*
* assign variable s with value v (for NUMBER or STRING or CHAR types)
*/
int vstring(s, v)
register char *s;
register char *v;
{
register value_t *p;
char *expand();
p = vlookup(s);
if (p == 0)
return (1);
if (p->v_type&NUMBER)
vassign(p, atoi(v));
else {
if (strcmp(s, "record") == 0)
v = expand(v);
vassign(p, v);
}
return (0);
}

79
src/cmd/tip/vars.c Normal file
View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include "tip.h"
/*
* Definition of variables
*/
value_t vtable[] = {
{ "beautify", BOOL, (READ|WRITE)<<PUBLIC,
"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,
"eofw", (char *)&OE },
{ "eol", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
NOSTR, (char *)&EL },
{ "escape", CHAR, (READ|WRITE)<<PUBLIC,
"es", (char *)'~' },
{ "exceptions", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"ex", (char *)&EX },
{ "force", CHAR, (READ|WRITE)<<PUBLIC,
"fo", (char *)CTRL(p) },
{ "framesize", NUMBER|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"fr", (char *)&FS },
{ "host", STRING|IREMOTE|INIT, READ<<PUBLIC,
"ho", (char *)&HO },
{ "log", STRING|INIT, (READ|WRITE)<<ROOT,
NOSTR, "/var/log/aculog" },
{ "phones", STRING|INIT|IREMOTE, READ<<PUBLIC,
NOSTR, (char *)&PH },
{ "prompt", CHAR, (READ|WRITE)<<PUBLIC,
"pr", (char *)'\n' },
{ "raise", BOOL, (READ|WRITE)<<PUBLIC,
"ra", (char *)FALSE },
{ "raisechar", CHAR, (READ|WRITE)<<PUBLIC,
"rc", (char *)CTRL(a) },
{ "record", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"rec", (char *)&RE },
{ "remote", STRING|INIT|IREMOTE, READ<<PUBLIC,
NOSTR, (char *)&RM },
{ "script", BOOL, (READ|WRITE)<<PUBLIC,
"sc", (char *)FALSE },
{ "tabexpand", BOOL, (READ|WRITE)<<PUBLIC,
"tab", (char *)FALSE },
{ "verbose", BOOL, (READ|WRITE)<<PUBLIC,
"verb", (char *)TRUE },
{ "SHELL", STRING|ENVIRON|INIT, (READ|WRITE)<<PUBLIC,
NULL, "/bin/sh" },
{ "HOME", STRING|ENVIRON, (READ|WRITE)<<PUBLIC,
NOSTR, NOSTR },
{ "echocheck", BOOL, (READ|WRITE)<<PUBLIC,
"ec", (char *)FALSE },
{ "disconnect", STRING|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"di", (char *)&DI },
{ "tandem", BOOL, (READ|WRITE)<<PUBLIC,
"ta", (char *)TRUE },
{ "linedelay", NUMBER|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"ldelay", (char *)&DL },
{ "chardelay", NUMBER|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"cdelay", (char *)&CL },
{ "etimeout", NUMBER|IREMOTE|INIT, (READ|WRITE)<<PUBLIC,
"et", (char *)&ET },
{ "rawftp", BOOL, (READ|WRITE)<<PUBLIC,
"raw", (char *)FALSE },
{ "halfduplex", BOOL, (READ|WRITE)<<PUBLIC,
"hdx", (char *)FALSE },
{ "localecho", BOOL, (READ|WRITE)<<PUBLIC,
"le", (char *)FALSE },
{ "parity", STRING|INIT|IREMOTE, (READ|WRITE)<<PUBLIC,
"par", (char *)&PA },
{ NOSTR, NULL, NULL, NOSTR, NOSTR }
};