diff options
author | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-30 19:02:48 +0000 |
commit | ab124e78b0271ddb904b761b31e5c9a0cf24e070 (patch) | |
tree | 0cf1447720c45721ed3d214a4eaaa6834bda155d /usr.bin/tip | |
parent | 15748830d0fcd29294a1969a1012655e74908c1e (diff) | |
download | FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.zip FreeBSD-src-ab124e78b0271ddb904b761b31e5c9a0cf24e070.tar.gz |
recording cvs-1.6 file death
Diffstat (limited to 'usr.bin/tip')
-rw-r--r-- | usr.bin/tip/pathnames.h | 44 | ||||
-rw-r--r-- | usr.bin/tip/tip.c | 608 | ||||
-rw-r--r-- | usr.bin/tip/tip.h | 280 | ||||
-rw-r--r-- | usr.bin/tip/tipout.c | 166 | ||||
-rw-r--r-- | usr.bin/tip/uucplock.c | 102 |
5 files changed, 0 insertions, 1200 deletions
diff --git a/usr.bin/tip/pathnames.h b/usr.bin/tip/pathnames.h deleted file mode 100644 index fae04cb..0000000 --- a/usr.bin/tip/pathnames.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)pathnames.h 8.1 (Berkeley) 6/6/93 - */ - -#include <paths.h> - -#define _PATH_ACULOG "/var/log/aculog" -#define _PATH_LOCKDIRNAME "/var/spool/lock/LCK..%s" -#ifdef notdef -#define _PATH_LOCKDIRNAME "/var/spool/uucp/LCK/LCK..%s" -#endif -#define _PATH_PHONES "/etc/phones" -#define _PATH_REMOTE "/etc/remote" diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c deleted file mode 100644 index 0d84e75..0000000 --- a/usr.bin/tip/tip.c +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1983, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -static char sccsid[] = "@(#)tip.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -/* - * tip - UNIX link to other systems - * tip [-v] [-speed] system-name - * or - * cu phone-number [-s speed] [-l line] [-a acu] - */ -#include "tip.h" -#include "pathnames.h" - -/* - * Baud rate mapping table - */ -int bauds[] = { - 0, 50, 75, 110, 134, 150, 200, 300, 600, - 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, -1 -}; - -int disc = OTTYDISC; /* tip normally runs this way */ -void intprompt(); -void timeout(); -void cleanup(); -void tipdone(); -char *sname(); -char PNbuf[256]; /* This limits the size of a number */ - -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 = %d bytes)\n", - 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: - (void)signal(SIGINT, cleanup); - (void)signal(SIGQUIT, cleanup); - (void)signal(SIGHUP, cleanup); - (void)signal(SIGTERM, cleanup); - (void)signal(SIGUSR1, tipdone); - - if ((i = hunt(system)) == 0) { - printf("all ports busy\n"); - exit(3); - } - if (i == -1) { - printf("link down\n"); - (void)uu_unlock(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 = _PATH_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))); - (void)uu_unlock(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); - if (p = connect()) { - printf("\07%s\n[EOT]\n", p); - daemon_uid(); - (void)uu_unlock(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); - (void)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"); - if (pid = fork()) - tipin(); - else - tipout(); - /*NOTREACHED*/ -} - -void -cleanup() -{ - - daemon_uid(); - (void)uu_unlock(uucplock); - if (odisc) - ioctl(0, TIOCSETD, (char *)&odisc); - exit(0); -} - -void -tipdone() -{ - tipabort("Hangup."); -} -/* - * 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; - -user_uid() -{ - if (uidswapped == 0) { - seteuid(uid); - uidswapped = 1; - } -} - -daemon_uid() -{ - - if (uidswapped) { - seteuid(euid); - uidswapped = 0; - } -} - -shell_uid() -{ - - seteuid(uid); -} - -/* - * put the controlling keyboard into raw mode - */ -raw() -{ - - ioctl(0, TIOCSETP, &arg); - ioctl(0, TIOCSETC, &tchars); - ioctl(0, TIOCSLTC, <chars); - ioctl(0, TIOCSETD, (char *)&disc); -} - - -/* - * return keyboard to normal mode - */ -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. - */ -prompt(s, p) - char *s; - register char *p; -{ - register char *b = p; - sig_t oint, oquit; - - stoprompt = 0; - oint = signal(SIGINT, intprompt); - oquit = signal(SIGQUIT, SIG_IGN); - unraw(); - printf("%s", s); - if (setjmp(promptbuf) == 0) - while ((*p = getchar()) != EOF && *p != '\n') - p++; - *p = '\0'; - - raw(); - (void)signal(SIGINT, oint); - (void)signal(SIGQUIT, oquit); - return (stoprompt || p == b); -} - -/* - * Interrupt service routine during prompting - */ -void -intprompt() -{ - - (void)signal(SIGINT, SIG_IGN); - stoprompt = 1; - printf("\r\n"); - longjmp(promptbuf, 1); -} - -/* - * ****TIPIN TIPIN**** - */ -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); - } -} - -extern esctable_t etable[]; - -/* - * Escape handler -- - * called on recognition of ``escapec'' at the beginning of a line - */ -escape() -{ - register char gch; - register esctable_t *p; - char c = character(value(ESCAPE)); - - 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); -} - -speed(n) - int n; -{ - register int *p; - - for (p = bauds; *p != -1; p++) - if (*p == n) - return (p - bauds); - return (NULL); -} - -any(c, p) - register char c, *p; -{ - while (p && *p) - if (*p++ == c) - return (1); - return (0); -} - -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) - char 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 - */ -help(c) - char c; -{ - register esctable_t *p; - - 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 - */ -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]; -static int bits8; - -/* - * 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. - */ -pwrite(fd, buf, n) - int fd; - char *buf; - register int n; -{ - register int i; - register char *bp; - extern int errno; - - bp = buf; - if (bits8 == 0) - for (i = 0; i < n; i++) { - *bp = partab[(*bp) & 0177]; - bp++; - } - if (write(fd, buf, n) < 0) { - if (errno == EIO) - tipabort("Lost carrier."); - if (errno == ENODEV) - tipabort("tty not available."); - /* this is questionable */ - perror("write"); - } -} - -/* - * Build a parity table with appropriate high-order bit. - */ -setparity(defparity) - char *defparity; -{ - register int i, flip, clr, set; - char *parity; - extern char evenpartab[]; - - if (value(PARITY) == NOSTR) - value(PARITY) = defparity; - parity = value(PARITY); - if (equal(parity, "none")) { - bits8 = 1; - return; - } - bits8 = 0; - flip = 0; - clr = 0377; - set = 0; - if (equal(parity, "odd")) - flip = 0200; /* reverse bit 7 */ - else if (equal(parity, "zero")) - clr = 0177; /* turn off bit 7 */ - else if (equal(parity, "one")) - set = 0200; /* turn on bit 7 */ - else if (!equal(parity, "even")) { - (void) fprintf(stderr, "%s: unknown parity value\r\n", parity); - (void) fflush(stderr); - } - for (i = 0; i < 0200; i++) - partab[i] = evenpartab[i] ^ flip | set & clr; -} diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h deleted file mode 100644 index f1b833d..0000000 --- a/usr.bin/tip/tip.h +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)tip.h 8.1 (Berkeley) 6/6/93 - */ - -/* - * tip - terminal interface program - */ - -#include <sys/types.h> -#include <machine/endian.h> -#include <sys/file.h> -#include <sys/time.h> - -#include <sgtty.h> -#include <signal.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <pwd.h> -#include <ctype.h> -#include <setjmp.h> -#include <unistd.h> -#include <errno.h> - -/* - * 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 */ - -long BR; /* line speed for conversation */ -long 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 */ -long DL; /* line delay for file transfers to remote */ -long CL; /* char delay for file transfers to remote */ -long 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[2]; - char zz_character[4]; - int *zz_address; - } - zzhack; - -#define value(v) vtable[v].v_value - -#define number(v) ((((zzhack *)(&(v))))->zz_number) - -#if BYTE_ORDER == LITTLE_ENDIAN -#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0]) -#define character(v) ((((zzhack *)(&(v))))->zz_character[0]) -#endif - -#if BYTE_ORDER == BIG_ENDIAN -#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1]) -#define character(v) ((((zzhack *)(&(v))))->zz_character[3]) -#endif - -#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 */ - -#ifndef ACULOG -#define logent(a, b, c, d) -#define loginit() -#endif - -/* - * 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 */ - -extern char *ctrl(); -extern char *vinterp(); -extern char *connect(); - -int tipabort __P((char *)); diff --git a/usr.bin/tip/tipout.c b/usr.bin/tip/tipout.c deleted file mode 100644 index 246cfb7..0000000 --- a/usr.bin/tip/tipout.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)tipout.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#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() -{ - - 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() -{ - 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() -{ - - if (boolean(value(SCRIPT)) && fscript != NULL) - fclose(fscript); - exit(0); -} - -void -intSYS() -{ - - boolean(value(BEAUTIFY)) = !boolean(value(BEAUTIFY)); - longjmp(sigbuf, 1); -} - -/* - * ****TIPOUT TIPOUT**** - */ -tipout() -{ - char buf[BUFSIZ]; - register char *cp; - register int cnt; - extern int errno; - int 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(); - /*NOTREACHED*/ - } else if (cnt == 0 && errno == ENOENT) { - kill(getppid(),SIGUSR1); - sigblock(sigmask(SIGTERM)); - intTERM(); - /*NOTREACHED*/ - } else { - printf("%d %d\r",cnt,errno); - fflush(stdout); - } - 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); - } - } -} diff --git a/usr.bin/tip/uucplock.c b/usr.bin/tip/uucplock.c deleted file mode 100644 index 917d812..0000000 --- a/usr.bin/tip/uucplock.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -static char sccsid[] = "@(#)uucplock.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#include <sys/types.h> -#include <sys/file.h> -#include <sys/dir.h> -#include <errno.h> -#include <unistd.h> -#include <stdio.h> -#include "pathnames.h" - -/* - * uucp style locking routines - * return: 0 - success - * -1 - failure - */ - -uu_lock(ttyname) - char *ttyname; -{ - int fd, pid; - char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN]; - FILE *ff; - - (void)sprintf(tbuf, _PATH_LOCKDIRNAME, ttyname); - fd = open(tbuf, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (fd >= 0) - ff = fdopen(fd, "w"); - if (fd < 0 || ff == NULL) { - /* - * file is already locked - * check to see if the process holding the lock still exists - */ - ff = fopen(tbuf, "r+"); - if (ff == NULL) { - perror("lock open"); - return(-1); - } - if (fscanf(ff, "%10d\n", &pid) != 1) { - perror("lock read"); - (void)fclose(ff); - return(-1); - } - - if (kill(pid, 0) == 0 || errno != ESRCH) { - (void)fclose(ff); /* process is still running */ - return(-1); - } - /* - * The process that locked the file isn't running, so - * we'll lock it ourselves - */ - rewind(ff); - /* fall out and finish the locking process */ - } - (void)fprintf(ff, "%10d\n", getpid()); - (void)fclose(ff); - return(0); -} - -uu_unlock(ttyname) - char *ttyname; -{ - char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN]; - - (void)sprintf(tbuf, _PATH_LOCKDIRNAME, ttyname); - return(unlink(tbuf)); -} |