dan@i10s7.ira.uka.de (Dan Mosedale) (05/17/91)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 4 (of 9)." # Contents: pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c # pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c # pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c # pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c # pf-bootstrap-v1.1a/tipx-p1/page.c pf-bootstrap-v1.1a/tipx-p1/tip.h # pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c # Wrapped by dan@nostromo on Fri May 17 02:31:41 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c'\" \(6421 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c' <<'END_OF_FILE' X/* X * Copyright (c) 1986 The Regents of the University of California. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by the University of California, Berkeley. The name of the X * University may not be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)courier.c 5.3 (Berkeley) 9/13/88"; X#endif /* not lint */ X X#define write cour_write X/* X * Routines for calling up on a Courier modem. X * Derived from Hayes driver. X */ X#include "tip.h" X#include <stdio.h> X X#define MAXRETRY 5 X Xstatic int sigALRM(); Xstatic int timeout = 0; Xstatic int connected = 0; Xstatic jmp_buf timeoutbuf, intbuf; Xstatic int (*osigint)(); X Xcour_dialer(num, acu) X register char *num; X char *acu; X{ X register char *cp; X#ifdef ACULOG X char line[80]; X#endif X if (boolean(value(VERBOSE))) X printf("Using \"%s\"\n", acu); X X ioctl(FD, TIOCHPCL, 0); X /* X * Get in synch. X */ X if (!coursync()) { Xbadsynch: X printf("can't synchronize with courier\n"); X#ifdef ACULOG X logent(value(HOST), num, "courier", "can't synch up"); X#endif X return (0); X } X write(FD, "AT E0\r", 6); /* turn off echoing */ X sleep(1); X#ifdef DEBUG X if (boolean(value(VERBOSE))) X verbose_read(); X#endif X ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ X write(FD, "AT C1 E0 H0 Q0 X6 V1\r", 21); X if (!cour_swallow("\r\nOK\r\n")) X goto badsynch; X fflush(stdout); X write(FD, "AT D", 4); X for (cp = num; *cp; cp++) X if (*cp == '=') X *cp = ','; X write(FD, num, strlen(num)); X write(FD, "\r", 1); X connected = cour_connect(); X#ifdef ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); X logent(value(HOST), num, "cour", line); X } X#endif X if (timeout) X cour_disconnect(); X return (connected); X} X Xcour_disconnect() X{ X /* first hang up the modem*/ X ioctl(FD, TIOCCDTR, 0); X sleep(1); X ioctl(FD, TIOCSDTR, 0); X coursync(); /* reset */ X close(FD); X} X Xcour_abort() X{ X write(FD, "\r", 1); /* send anything to abort the call */ X cour_disconnect(); X} X Xstatic int XsigALRM() X{ X printf("\07timeout waiting for reply\n"); X timeout = 1; X longjmp(timeoutbuf, 1); X} X Xstatic int Xcour_swallow(match) Xregister char *match; X{ X char c; X sigfunc_t (*f)(); X X f = signal(SIGALRM, sigALRM); X timeout = 0; X do { X if (*match =='\0') { X signal(SIGALRM, f); X return (1); X } X if (setjmp(timeoutbuf)) { X signal(SIGALRM, f); X return (0); X } X alarm(number(value(DIALTIMEOUT))); X read(FD, &c, 1); X alarm(0); X c &= 0177; X#ifdef DEBUG X if (boolean(value(VERBOSE))) X putchar(c); X#endif X } while (c == *match++); X#ifdef DEBUG X if (boolean(value(VERBOSE))) X fflush(stdout); X#endif X signal(SIGALRM, SIG_DFL); X return (0); X} X Xstruct baud_msg { X char *msg; X int baud; X} baud_msg[] = { X "", B300, X " 1200", B1200, X " 2400", B2400, X 0, 0, X}; X Xstatic int Xcour_connect() X{ X char c; X int nc, nl, n; X struct sgttyb sb; X char dialer_buf[64]; X struct baud_msg *bm; X sigfunc_t (*f)(); X X if (cour_swallow("\r\n") == 0) X return (0); X f = signal(SIGALRM, sigALRM); Xagain: X nc = 0; nl = sizeof(dialer_buf)-1; X bzero(dialer_buf, sizeof(dialer_buf)); X timeout = 0; X for (nc = 0, nl = sizeof(dialer_buf)-1 ; nl > 0 ; nc++, nl--) { X if (setjmp(timeoutbuf)) X break; X alarm(number(value(DIALTIMEOUT))); X n = read(FD, &c, 1); X alarm(0); X if (n <= 0) X break; X c &= 0x7f; X if (c == '\r') { X if (cour_swallow("\n") == 0) X break; X if (!dialer_buf[0]) X goto again; X if (strcmp(dialer_buf, "RINGING") == 0 && X boolean(value(VERBOSE))) { X#ifdef DEBUG X printf("%s\r\n", dialer_buf); X#endif X goto again; X } X if (strncmp(dialer_buf, "CONNECT", X sizeof("CONNECT")-1) != 0) X break; X for (bm = baud_msg ; bm ; bm++) X if (strcmp(bm->msg, X dialer_buf+sizeof("CONNECT")-1) == 0) { X if (ioctl(FD, TIOCGETP, &sb) < 0) { X perror("TIOCGETP"); X goto error; X } X sb.sg_ispeed = sb.sg_ospeed = bm->baud; X if (ioctl(FD, TIOCSETP, &sb) < 0) { X perror("TIOCSETP"); X goto error; X } X signal(SIGALRM, f); X#ifdef DEBUG X if (boolean(value(VERBOSE))) X printf("%s\r\n", dialer_buf); X#endif X return (1); X } X break; X } X dialer_buf[nc] = c; X#ifdef notdef X if (boolean(value(VERBOSE))) X putchar(c); X#endif X } Xerror1: X printf("%s\r\n", dialer_buf); Xerror: X signal(SIGALRM, f); X return (0); X} X X/* X * This convoluted piece of code attempts to get X * the courier in sync. X */ Xstatic int Xcoursync() X{ X int already = 0; X int len; X char buf[40]; X X while (already++ < MAXRETRY) { X ioctl(FD, TIOCFLUSH, 0); /* flush any clutter */ X write(FD, "\rAT Z\r", 6); /* reset modem */ X bzero(buf, sizeof(buf)); X sleep(1); X ioctl(FD, FIONREAD, &len); X if (len) { X len = read(FD, buf, sizeof(buf)); X#ifdef DEBUG X buf[len] = '\0'; X printf("coursync: (\"%s\")\n\r", buf); X#endif X if (index(buf, '0') || X (index(buf, 'O') && index(buf, 'K'))) X return(1); X } X /* X * If not strapped for DTR control, X * try to get command mode. X */ X sleep(1); X write(FD, "+++", 3); X sleep(1); X /* X * Toggle DTR to force anyone off that might have left X * the modem connected. X */ X ioctl(FD, TIOCCDTR, 0); X sleep(1); X ioctl(FD, TIOCSDTR, 0); X } X write(FD, "\rAT Z\r", 6); X return (0); X} X X#undef write X Xcour_write(fd, cp, n) Xint fd; Xchar *cp; Xint n; X{ X struct sgttyb sb; X#ifdef notdef X if (boolean(value(VERBOSE))) X write(1, cp, n); X#endif X ioctl(fd, TIOCGETP, &sb); X ioctl(fd, TIOCSETP, &sb); X cour_nap(); X for ( ; n-- ; cp++) { X write(fd, cp, 1); X ioctl(fd, TIOCGETP, &sb); X ioctl(fd, TIOCSETP, &sb); X cour_nap(); X } X} X X#ifdef DEBUG Xverbose_read() X{ X int n = 0; X char buf[BUFSIZ]; X X if (ioctl(FD, FIONREAD, &n) < 0) X return; X if (n <= 0) X return; X if (read(FD, buf, n) != n) X return; X write(1, buf, n); X} X#endif X X#include <sys/time.h> X Xcour_nap() X{ X struct timeval tv; X X tv.tv_sec = 0; X tv.tv_usec = 50000; /* 50 msec */ X select(0, NULL, NULL, NULL, &tv); X} END_OF_FILE if test 6421 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/libacu/courier.c' fi if test -f 'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c'\" \(6469 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c' <<'END_OF_FILE' X/* X * Copyright (c) 1983 The Regents of the University of California. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by the University of California, Berkeley. The name of the X * University may not be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X */ X X#ifndef lint Xstatic char sccsid[] = "@(#)hayes.c 5.2 (Berkeley) 9/13/88"; X#endif /* not lint */ X X/* X * Routines for calling up on a Hayes Modem X * (based on the old VenTel driver). X * The modem is expected to be strapped for "echo". X * Also, the switches enabling the DTR and CD lines X * must be set correctly. X * NOTICE: X * The easy way to hang up a modem is always simply to X * clear the DTR signal. However, if the +++ sequence X * (which switches the modem back to local mode) is sent X * before modem is hung up, removal of the DTR signal X * has no effect (except that it prevents the modem from X * recognizing commands). X * (by Helge Skrivervik, Calma Company, Sunnyvale, CA. 1984) X */ X/* X * TODO: X * It is probably not a good idea to switch the modem X * state between 'verbose' and terse (status messages). X * This should be kicked out and we should use verbose X * mode only. This would make it consistent with normal X * interactive use thru the command 'tip dialer'. X */ X#include "tip.h" X X#define min(a,b) ((a < b) ? a : b) X Xstatic int sigALRM(); Xstatic int timeout = 0; Xstatic jmp_buf timeoutbuf; Xstatic char gobble(); X#define DUMBUFLEN 40 Xstatic char dumbuf[DUMBUFLEN]; X X#define DIALING 1 X#define IDLE 2 X#define CONNECTED 3 X#define FAILED 4 Xstatic int state = IDLE; X Xhay_dialer(num, acu) X register char *num; X char *acu; X{ X register char *cp; X register int connected = 0; X char dummy; X#ifdef ACULOG X char line[80]; X#endif X if (hay_sync() == 0) /* make sure we can talk to the modem */ X return(0); X if (boolean(value(VERBOSE))) X printf("\ndialing..."); X fflush(stdout); X ioctl(FD, TIOCHPCL, 0); X ioctl(FD, TIOCFLUSH, 0); /* get rid of garbage */ X write(FD, "ATV0E0\r", 7); /* tell modem to use short status codes */ X if (gobble("A\r") == 'A') { X gobble("\r"); /* echo is on, need 2 swallows */ X gobble("\r"); X } X write(FD, "ATDT", 4); /* send dial command */ X write(FD, num, strlen(num)); X state = DIALING; X write(FD, "\r", 1); X connected = 0; X if ((dummy = gobble("012345678")) != '1') X error_rep(dummy); X else X connected = 1; X if (connected) X state = CONNECTED; X else { X state = FAILED; X return (connected); /* lets get out of here.. */ X } X ioctl(FD, TIOCFLUSH, 0); X#ifdef ACULOG X if (timeout) { X sprintf(line, "%d second dial timeout", X number(value(DIALTIMEOUT))); X logent(value(HOST), num, "hayes", line); X } X#endif X if (timeout) X hay_disconnect(); /* insurance */ X return (connected); X} X X Xhay_disconnect() X{ X char c; X int len, rlen; X X /* first hang up the modem*/ X#ifdef DEBUG X printf("\rdisconnecting modem....\n\r"); X#endif X ioctl(FD, TIOCCDTR, 0); X sleep(1); X ioctl(FD, TIOCSDTR, 0); X goodbye(); X} X Xhay_abort() X{ X X char c; X X write(FD, "\r", 1); /* send anything to abort the call */ X hay_disconnect(); X} X Xstatic int XsigALRM() X{ X X printf("\07timeout waiting for reply\n\r"); X timeout = 1; X longjmp(timeoutbuf, 1); X} X Xstatic char Xgobble(match) X register char *match; X{ X char c; X int (*f)(); X int i, status = 0; X X signal(SIGALRM, sigALRM); X timeout = 0; X#ifdef DEBUG X printf("\ngobble: waiting for %s\n", match); X#endif X do { X if (setjmp(timeoutbuf)) { X signal(SIGALRM, f); X return (0); X } X alarm(number(value(DIALTIMEOUT))); X read(FD, &c, 1); X alarm(0); X c &= 0177; X#ifdef DEBUG X printf((c>' ' && c<0177)?"%c ":"0x%x ", c); X#endif X for (i = 0; i < strlen(match); i++) X if (c == match[i]) X status = c; X } while (status == 0); X signal(SIGALRM, SIG_DFL); X#ifdef DEBUG X printf("\n"); X#endif X return (status); X} X Xerror_rep(c) X register char c; X{ X printf("\n\r"); X switch (c) { X X case '0': X printf("OK"); X break; X X case '1': X printf("CONNECT"); X break; X X case '2': X printf("RING"); X break; X X case '3': X printf("NO CARRIER"); X break; X X case '4': X printf("ERROR in input"); X break; X X case '5': X printf("CONNECT 1200"); X break; X X case '6': X printf("NO DIALTONE"); X break; X X case '7': X printf("BUSY"); X break; X X case '8': X printf("NO ANSWER"); X break; X X default: X printf("Unknown Modem error: %c (0x%x)", c, c); X } X printf("\n\r"); X return; X} X X/* X * set modem back to normal verbose status codes. X */ Xgoodbye() X{ X int len, rlen; X char c; X X ioctl(FD, TIOCFLUSH, &len); /* get rid of trash */ X if (hay_sync()) { X sleep(1); X#ifndef DEBUG X ioctl(FD, TIOCFLUSH, 0); X#endif X write(FD, "ATH0V0\r", 7); /* insurance */ X#ifndef DEBUG X number(value(DIALTIMEOUT)) = 10; /* shorten timeout */ X c = gobble("03"); X if (c != '0' && c != '3') { X printf("cannot hang up modem\n\r"); X printf("please use 'tip dialer' to make sure the line is hung up\n\r"); X } X#endif X sleep(1); X ioctl(FD, FIONREAD, &len); X#ifdef DEBUG X printf("goodbye1: len=%d -- ", len); X rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); X dumbuf[rlen] = '\0'; X printf("read (%d): %s\r\n", rlen, dumbuf); X#endif X write(FD, "ATV1E1\r", 7); X sleep(1); X#ifdef DEBUG X ioctl(FD, FIONREAD, &len); X printf("goodbye2: len=%d -- ", len); X rlen = read(FD, dumbuf, min(len, DUMBUFLEN)); X dumbuf[rlen] = '\0'; X printf("read (%d): %s\r\n", rlen, dumbuf); X#endif X } X ioctl(FD, TIOCFLUSH, 0); /* clear the input buffer */ X ioctl(FD, TIOCCDTR, 0); /* clear DTR (insurance) */ X close(FD); X} X X#define MAXRETRY 5 X Xhay_sync() X{ X int len, retry = 0; X X while (retry++ <= MAXRETRY) { X write(FD, "\rAT\r", 4); X sleep(1); X ioctl(FD, FIONREAD, &len); X if (len) { X len = read(FD, dumbuf, min(len, DUMBUFLEN)); X if (index(dumbuf, '0') || X (index(dumbuf, 'O') && index(dumbuf, 'K'))) X return(1); X#ifdef DEBUG X dumbuf[len] = '\0'; X printf("hay_sync: (\"%s\") %d\n\r", dumbuf, retry); X#endif X } X ioctl(FD, TIOCCDTR, 0); X ioctl(FD, TIOCSDTR, 0); X } X printf("Cannot synchronize with hayes...\n\r"); X return(0); X} END_OF_FILE if test 6469 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/libacu/hayes.c' fi if test -f 'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c'\" \(7112 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c' <<'END_OF_FILE' X/* X * Dialer support for Hayes Smartmodem(tm) 2400 modem. X */ X X#ifndef lint Xstatic char *RCSid = "$Header: sm2400.c,v 1.11 86/06/24 19:47:12 rayan Exp $"; X#endif X X#undef DEBUG 1 X X#ifdef DEBUG Xint debug = 1; X#define STATIC X#else X#define STATIC static X#endif X X#include "tip.h" X#include <sys/time.h> X X /* commands */ XSTATIC char NAME[] = "sm2400"; XSTATIC char WARMUP[] = "\rat\r"; XSTATIC char RESULT_CODES[] = "\ratq0\r"; XSTATIC char DONT_ANSWER[] = "\rats0=0\r"; XSTATIC char IGN_ESCAPE[] = "\rats2=128\r"; XSTATIC char CODES_4[] = "\ratx4\r"; XSTATIC char DIAL_PREFIX[] = "\ratdt"; X X /* result codes */; XSTATIC char MDM_OK[] = "\r\nOK\r\n"; XSTATIC char RING[] = "\r\nRING\r\n"; XSTATIC char NO_CARRIER[] = "\r\nNO CARRIER\r\n"; XSTATIC char ERROR[] = "\r\nERROR\r\n"; XSTATIC char CONNECT[] = "\r\nCONNECT\r\n"; XSTATIC char CONNECT_600[] = "\r\nCONNECT 0600\r\n"; XSTATIC char CONNECT_1200[] = "\r\nCONNECT 1200\r\n"; XSTATIC char CONNECT_2400[] = "\r\nCONNECT 2400\r\n"; XSTATIC char NO_DIALTONE[] = "\r\nNO DIALTONE\r\n"; XSTATIC char NO_ANSWER[] = "\r\nNO ANSWER\r\n"; XSTATIC char BUSY[] = "\r\nBUSY\r\n"; X XSTATIC char *nosm24con[] = { BUSY, X NO_DIALTONE, X NO_ANSWER, X ERROR, X RING, X NO_CARRIER, X 0 X }; X X/* The baudrate starts at 300, and doubles for next element of array */ XSTATIC char *sm24con[] = { CONNECT, X CONNECT_600, X CONNECT_1200, X CONNECT_2400, X 0 X }; X#ifdef USG XSTATIC struct termio termio; /* needed on USG to set HUPCL */ X#endif /* USG */ X X#define CMD_DELAY 5 /* number of seconds to wait for response X while in command mode */ X#define DIAL_DELAY 120 /* number of seconds to wait for response X after sending dial string */ X#define MAXSTR 100 X Xstatic jmp_buf jmpbuf; X Xint sm24read(), sm24write(); X Xsm24_dialer(num, acu) Xregister char *num; Xchar *acu; X{ X int ret; X int i, j; X char buf1[MAXSTR], buf2[MAXSTR], buf3[MAXSTR]; X#ifdef ACULOG X char line[MAXSTR]; X#endif X X /* X * wake up the modem if it's listening... X */ X if (boolean(value(VERBOSE))) X printf("diddling dialer..."); X X sleep(1); /* Give modem time to settle down after reset */ X if ((!sm24set(RESULT_CODES, buf1, num, "is naughty") X && !sm24set(RESULT_CODES, buf1, num, "not listening")) X || !sm24set(DONT_ANSWER, buf1, num, "auto-answer not turned off") X || !sm24set(IGN_ESCAPE, buf1, num, "escape code not turned off") X || !sm24set(CODES_4, buf1, num, "result codes not set")) X return 0; X X /* insurance ? */ X#ifdef USG X if (ioctl(FD, TCGETA, &termio) < 0) X perror("tip: TCGETA ioctl"); X termio.c_cflag |= HUPCL; X if (ioctl(FD, TCSETA, &termio) < 0) X perror("tip: TCSETA ioctl"); X#else /* USG */ X if (ioctl(FD, TIOCHPCL, 0) < 0) X perror("tip: TIOCHPCL ioctl"); X#endif /* USG */ X X buf2[0] = '\0'; X for (i = 0, j = 300; sm24con[i] != (char *)0; i++, j*=2) { X if (BR == j) { X strcpy(buf2, sm24con[i]); X break; X } X } X if (buf2[0] == '\0') { X sprintf(buf2, "unsupported baud rate (%d)", BR); X goto error; X } X X /* Is it safe to just say ATD and let the options setting rule? */ X sm24write(DIAL_PREFIX); X sm24write(num); X sm24write("\r"); X if (boolean(value(VERBOSE))) X printf(" dialing... "); X if (ret = sm24read(buf1, DIAL_DELAY, (u_int) strlen(buf2)) == 0) { X strcpy(buf2, "TIMEOUT on dial"); X goto error; X } X if (ret == -1) { X strcpy(buf2, "ioctl failed"); X goto error; X } X if (strncmp(buf1, buf2, strlen(buf2)) != 0) { X for (i = 0, j = 300; sm24con[i] != (char *)0; i++, j *= 2) { X if (!strncmp(buf1, sm24con[i], strlen(sm24con[i]))) { X /* This should never fail */ X if ((i = speed(j)) != NULL) { X BR = j; X ttysetup(i); X } else { X printf("speed(%d) failed\n", j); X return 0; X } X goto ok; X } X } X for (i = 0; nosm24con[i] != (char *)0; i++) { X if (!strncmp(buf1, nosm24con[i], strlen(nosm24con[i]))){ X char *bp, *cp; X for (bp = buf2, cp = nosm24con[i]; *cp; cp++) { X if (*cp != '\r' && *cp != '\n') X *bp++ = *cp; X } X *bp = '\0'; X goto error; X } X } X (void) strcpy(buf2, "UNKNOWN ERROR"); Xerror: X printf("dial failed (%s)\n", buf2); X sprintf(buf3, "dial failed (%s)", buf2); X#ifdef ACULOG X logent(value(HOST), num, NAME, buf3); X#endif X return 0; X } Xok: X if (boolean(value(VERBOSE))) X printf("(%d baud) ", BR); X i = 2; X#ifdef USG X if (ioctl(FD, TCFLSH, i) < 0) X perror("tip: TCFLSH ioctl"); X#else /* USG */ X if (ioctl(FD, TIOCFLUSH, &i) < 0) X perror("tip: TIOCFLUSH ioctl"); X#endif /* USG */ X return 1; X} X X Xsm24_disconnect() X{ X#ifdef USG X if (ioctl(FD, TCGETA, &termio) < 0) X perror("tip: TCGETA ioctl"); X termio.c_cflag &= (CBAUD & B0); X if (ioctl(FD, TCSETA, &termio) < 0) X perror("tip: TCSETA ioctl"); X sleep(2); X#endif /* USG */ X (void) close(FD); X} X X Xsm24_abort() X{ X sm24_disconnect(); X} X XSTATIC Xsm24write(cp) Xregister char *cp; X{ X struct timeval t; X X for (; *cp != '\0' ; cp++) { X if (write(FD, cp, 1) != 1) { X perror("tip: sm24write: write error"); X return; X } X#ifdef DEBUG X if (debug) { X fprintf(stderr, "written '%c'\n", *cp); X } X#endif X t.tv_sec = 0; X t.tv_usec = (10 * 1000000)/BR; X (void) select(32, 0, 0, 0, &t); X } X} X XSTATIC Xsm24read(buf, timeout, max) Xregister char *buf; Xunsigned int timeout, max; X{ X int alarmtr(); X struct timeval t; X register char *rp; X unsigned int numread, numprev = 0, numpndg = 0; X unsigned int toread; X X#ifdef DEBUG X if (debug) X fprintf(stderr, "\n---------\nentering sm24read(): timeout is: %d, max is: %d\n", timeout, max); X#endif X rp = buf; X *rp = '\0'; X (void) signal(SIGALRM, alarmtr); X if (setjmp(jmpbuf)) { X *rp = '\0'; X return 0; X } X (void) alarm(timeout); X /* wait till modem says something or until timeout */ X while (numpndg == 0 || numpndg != numprev) { X numprev = numpndg; X if (ioctl(FD, FIONREAD, &numpndg) == -1) { X perror("tip: FIONREAD ioctl"); X return -1; X } X t.tv_sec = 0; X t.tv_usec = (5 * 10 * 1000000)/BR; X (void) select(32, 0, 0, 0, &t); X } X (void) alarm(0); X#ifdef DEBUG X if (debug) X fprintf(stderr, "number of chars waiting is: %d\n", numpndg); X#endif X toread = ((numpndg > max) ? max : numpndg); X if ((numread = read(FD, rp, toread)) < toread) X perror("read error"); X#ifdef DEBUG X if (debug) { X int i; char *p; X fprintf(stderr, "read %d chars:", numread); X for (i=0, p=rp; i<numread; i++, p++) X fprintf(stderr, "%0.2x ", *p); X fprintf(stderr, "\n"); X fflush(stderr); X } X#endif X rp += numread; X *rp = '\0'; X#ifdef DEBUG X if (debug) { X fprintf(stderr, "\nbuf contains: ->%s<-\n", buf); X fprintf(stderr, "leaving sm24read()\n-----------\n"); X fflush(stderr); X } X#endif X return 1; X} X X XSTATIC Xaccept(baudrate) Xint baudrate; X{ X int i; X X BR = baudrate; X if ((i = speed(baudrate)) != NULL) X ttysetup(i); X} X X XSTATIC Xalarmtr() X{ X#ifdef DEBUG X if (debug) X fprintf(stderr, "alarm went off!\n"); X#endif X longjmp(jmpbuf, 1); X} X XSTATIC int Xsm24set(tosend, buf, num, errmsg) Xchar *tosend, *buf, *num, *errmsg; X{ X sm24write(tosend); X sm24read(buf, CMD_DELAY, (u_int) (sizeof MDM_OK) - 1); X if (strncmp(buf, MDM_OK, (sizeof MDM_OK) - 1) != 0) { X printf(" %s modem %s\n", NAME, errmsg); X#ifdef ACULOG X logent(value(HOST), num, NAME, errmsg); X#endif X return 0; X } X return 1; X} END_OF_FILE if test 7112 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/libacu/sm2400.c' fi if test -f 'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c'\" \(8131 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c' <<'END_OF_FILE' X/* X * Dialer support for Telebit Trailblazer Plus modem. X */ X X#ifndef lint Xstatic char *RCSid = "$Header: telebit.c,v 1.13 88/05/25 19:48:06 rayan Exp $"; X#endif X X#undef DEBUG 1 X X#ifdef DEBUG Xint debug = 1; X#define STATIC X#else X#define STATIC static X#endif X X#include "tip.h" X#include <sys/time.h> X X/* X * The following is the Telebit register setup used here with this code, with X * the TB+ attached to a fixed-speed interface on a remote terminal server. X * When attaching to a computer the appropriate register should be set so X * the TB+ interface speed matches the connect baud rate. X * XE0 F1 M1 Q1 P V1 X1 Version BA4.00 XS00=001 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=040 S08=002 S09=006 XS10=007 S11=070 S12=050 XS45=255 S47=004 S48=000 S49=000 XS50=000 S51=005 S52=002 S53=004 S54=003 S55=000 S56=017 S57=019 S58=000 S59=000 XS60=000 S61=000 S62=003 S63=001 S64=000 S65=000 S66=000 S67=000 S68=255 XS90=000 S91=000 S92=000 S95=000 XS100=000 S101=000 S102=000 S104=000 XS110=001 S111=030 S112=001 XS121=000 X * X */ X X /* commands */ XSTATIC char NAME[] = "telebit"; XSTATIC char WARMUP[] = "\rat\r"; XSTATIC char RESULT_CODES[] = "\ratq0\r"; XSTATIC char DONT_ANSWER[] = "\rats0=0\r"; XSTATIC char IGN_ESCAPE[] = "\rats55=3\r"; XSTATIC char CODES_4[] = "\ratx1\r"; XSTATIC char DIAL_PREFIX[] = "\ratdt"; X X /* result codes */; XSTATIC char MDM_OK[] = "\r\nOK\r\n"; XSTATIC char RING[] = "\r\nRING\r\n"; XSTATIC char RRING[] = "\r\nRRING\r\n"; XSTATIC char NO_CARRIER[] = "\r\nNO CARRIER\r\n"; XSTATIC char ERROR[] = "\r\nERROR\r\n"; XSTATIC char CONNECT[] = "\r\nCONNECT 300\r\n"; XSTATIC char CONNECT_1200[] = "\r\nCONNECT 1200\r\n"; XSTATIC char CONNECT_2400[] = "\r\nCONNECT 2400\r\n"; XSTATIC char CONNECT_FAST[] = "\r\nCONNECT FAST\r\n"; XSTATIC char NO_DIALTONE[] = "\r\nNO DIALTONE\r\n"; XSTATIC char NO_ANSWER[] = "\r\nNO ANSWER\r\n"; XSTATIC char BUSY[] = "\r\nBUSY\r\n"; X XSTATIC char *notbcon[] = { BUSY, X NO_DIALTONE, X NO_ANSWER, X ERROR, X RING, X NO_CARRIER, X 0 X }; X X/* The baudrate starts at 300, and doubles for next element of array */ XSTATIC char *tbcon[] = { CONNECT, X "ignore", X CONNECT_1200, X CONNECT_2400, X "ignore", X "ignore", X CONNECT_FAST, X 0 X }; X#ifdef USG XSTATIC struct termio termio; /* needed on USG to set HUPCL */ X#endif /* USG */ X X#define CMD_DELAY 5 /* number of seconds to wait for response X while in command mode */ X#define DIAL_DELAY 120 /* number of seconds to wait for response X after sending dial string */ X#define MAXSTR 100 X Xstatic jmp_buf jmpbuf; X Xint tbread(), tbwrite(); X Xtb_dialer(num, acu) Xregister char *num; Xchar *acu; X{ X int ret; X int i, j; X char buf1[MAXSTR], buf2[MAXSTR], buf3[MAXSTR]; X#ifdef ACULOG X char line[MAXSTR]; X#endif X X /* X * wake up the modem if it's listening... X */ X if (boolean(value(VERBOSE))) X printf("diddling dialer..."); X#ifdef DEBUG X if (debug) X fprintf(stderr, "BR=%d\n", BR); X#endif X X sleep(1); /* Give modem time to settle down after reset */ X if ((!tbset(RESULT_CODES, buf1, num, "is naughty") X && !tbset(RESULT_CODES, buf1, num, "not listening")) X || !tbset(DONT_ANSWER, buf1, num, "auto-answer not turned off") X || !tbset(IGN_ESCAPE, buf1, num, "escape code not turned off") X || !tbset(CODES_4, buf1, num, "result codes not set")) X return 0; X X /* insurance ? */ X#ifdef USG X if (ioctl(FD, TCGETA, &termio) < 0) X perror("tip: TCGETA ioctl"); X termio.c_cflag |= HUPCL; X if (ioctl(FD, TCSETA, &termio) < 0) X perror("tip: TCSETA ioctl"); X#else /* USG */ X if (ioctl(FD, TIOCHPCL, 0) < 0) X perror("tip: TIOCHPCL ioctl"); X#endif /* USG */ X X buf2[0] = '\0'; X for (i = 0, j = 300; tbcon[i] != (char *)0; i++, j*=2) { X if (BR == j) { X strcpy(buf2, tbcon[i]); X break; X } X } X if (buf2[0] == '\0') { X sprintf(buf2, "unsupported baud rate (%d)", BR); X goto error; X } X X /* Is it safe to just say ATD and let the options setting rule? */ X tbwrite(DIAL_PREFIX); X tbwrite(num); X tbwrite("\r"); X if (boolean(value(VERBOSE))) X printf(" dialing... "); X do { X if (ret = tbread(buf1, DIAL_DELAY, (u_int) strlen(buf2)) == 0) { X strcpy(buf2, "TIMEOUT on dial"); X goto error; X } X if (ret == -1) { X strcpy(buf2, "ioctl failed"); X goto error; X } X } while (strncmp(buf1, RRING, strlen(RRING)) == 0 X && (!boolean(value(VERBOSE)) || (printf("rrring... "), 1))); X if (strncmp(buf1, buf2, strlen(buf2)) != 0) { X for (i = 0, j = 300; tbcon[i] != (char *)0; i++, j *= 2) { X if (!strncmp(buf1, tbcon[i], strlen(tbcon[i]))) { X /* This should never fail */ X if ((i = speed(j)) != NULL) { X BR = j; X ttysetup(i); X } else { X printf("speed(%d) failed\n", j); X return 0; X } X goto ok; X } X } X for (i = 0; notbcon[i] != (char *)0; i++) { X if (!strncmp(buf1, notbcon[i], strlen(notbcon[i]))){ X char *bp, *cp; X for (bp = buf2, cp = notbcon[i]; *cp; cp++) { X if (*cp != '\r' && *cp != '\n') X *bp++ = *cp; X } X *bp = '\0'; X goto error; X } X } X (void) strcpy(buf2, "UNKNOWN ERROR ["); X (void) strcat(buf2, buf1); X (void) strcat(buf2, "]"); Xerror: X printf("dial failed (%s)\n", buf2); X sprintf(buf3, "dial failed (%s)", buf2); X#ifdef ACULOG X logent(value(HOST), num, NAME, buf3); X#endif X return 0; X } Xok: X if (boolean(value(VERBOSE))) X printf("(%d baud) ", BR); X i = 2; X#ifdef USG X if (ioctl(FD, TCFLSH, i) < 0) X perror("tip: TCFLSH ioctl"); X#else /* USG */ X if (ioctl(FD, TIOCFLUSH, &i) < 0) X perror("tip: TIOCFLUSH ioctl"); X#endif /* USG */ X return 1; X} X X Xtb_disconnect() X{ X#ifdef USG X if (ioctl(FD, TCGETA, &termio) < 0) X perror("tip: TCGETA ioctl"); X termio.c_cflag &= (CBAUD & B0); X if (ioctl(FD, TCSETA, &termio) < 0) X perror("tip: TCSETA ioctl"); X sleep(2); X#endif /* USG */ X (void) close(FD); X} X X Xtb_abort() X{ X tb_disconnect(); X} X XSTATIC Xtbwrite(cp) Xregister char *cp; X{ X struct timeval t; X X for (; *cp != '\0' ; cp++) { X if (write(FD, cp, 1) != 1) { X perror("tip: tbwrite: write error"); X return; X } X#ifdef DEBUG X if (debug) { X fprintf(stderr, "written '%c'\n", *cp); X } X#endif X t.tv_sec = 0; X t.tv_usec = (20 * 10 * 1000000)/BR; X (void) select(32, 0, 0, 0, &t); X } X} X XSTATIC Xtbread(buf, timeout, max) Xregister char *buf; Xunsigned int timeout, max; X{ X int alarmtr(); X struct timeval t; X register char *rp; X unsigned int numread, numprev = 0, numpndg = 0; X unsigned int toread; X X#ifdef DEBUG X if (debug) X fprintf(stderr, "\n---------\nentering tbread(): timeout is: %d, max is: %d\n", timeout, max); X#endif X rp = buf; X *rp = '\0'; X (void) signal(SIGALRM, alarmtr); X if (setjmp(jmpbuf)) { X *rp = '\0'; X return 0; X } X (void) alarm(timeout); X /* wait till modem says something or until timeout */ X while (numpndg == 0 || numpndg != numprev) { X numprev = numpndg; X if (ioctl(FD, FIONREAD, &numpndg) == -1) { X perror("tip: FIONREAD ioctl"); X return -1; X } X t.tv_sec = 0; X t.tv_usec = (100 * 10 * 1000000)/BR; X (void) select(32, 0, 0, 0, &t); X } X (void) alarm(0); X#ifdef DEBUG X if (debug) X fprintf(stderr, "number of chars waiting is: %d\n", numpndg); X#endif X toread = ((numpndg > max) ? max : numpndg); X if ((numread = read(FD, rp, toread)) < toread) X perror("read error"); X#ifdef DEBUG X if (debug) { X int i; char *p; X fprintf(stderr, "read %d chars:", numread); X for (i=0, p=rp; i<numread; i++, p++) X fprintf(stderr, "%0.2x ", *p); X fprintf(stderr, "\n"); X fflush(stderr); X } X#endif X rp += numread; X *rp = '\0'; X#ifdef DEBUG X if (debug) { X fprintf(stderr, "\nbuf contains: ->%s<-\n", buf); X fprintf(stderr, "leaving tbread()\n-----------\n"); X fflush(stderr); X } X#endif X return 1; X} X X XSTATIC Xaccept(baudrate) Xint baudrate; X{ X int i; X X BR = baudrate; X if ((i = speed(baudrate)) != NULL) X ttysetup(i); X} X X XSTATIC Xalarmtr() X{ X#ifdef DEBUG X if (debug) X fprintf(stderr, "alarm went off!\n"); X#endif X longjmp(jmpbuf, 1); X} X XSTATIC int Xtbset(tosend, buf, num, errmsg) Xchar *tosend, *buf, *num, *errmsg; X{ X tbwrite(tosend); X tbread(buf, CMD_DELAY, (u_int) (sizeof MDM_OK) - 1); X if (strncmp(buf, MDM_OK, (sizeof MDM_OK) - 1) != 0) { X printf(" %s modem %s\n", NAME, errmsg); X#ifdef ACULOG X logent(value(HOST), num, NAME, errmsg); X#endif X return 0; X } X return 1; X} END_OF_FILE if test 8131 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/libacu/telebit.c' fi if test -f 'pf-bootstrap-v1.1a/tipx-p1/page.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/page.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/page.c'\" \(5957 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/page.c' <<'END_OF_FILE' X#ifndef lint Xstatic char *sccsid = "@(#)page.c 1.4 MS/ACF 89/05/08"; X#endif X X/* X * tip/page.c (Douglas Kingston, Morgan Stanley & Co.) X * X * This file contains code to send alphanumeric pages via X * dialup paging services that support "Remote Entry Device X * Protocol" (aka "IXO"). These services typically send to X * devices like the Motorola PMR-2000 pager. X * X * This module is designed to use the ACK/NAK packet protocol X * to ensure the highest likelyhood of correct delivery of the X * message. The packets are checksummed and all messages are X * acknowledged by the receiver. X * X * To use this facility, tip must be called with the -p option, X * a system name (what system to dial up) and finally a data X * string which contains 3 items: A login code/password, a list X * pager id's to receive the message, and the message text. X * The three fields are separated by tabs. The pager id field X * is further subdivided into a list of pager ids by commas. X * X * For example: X * tip -p metro "12345678\t20001,20002\tPlease call the office." X * X * Would call the system called "metro" as listed in /etc/remote X * and login with the ID 12345678. The message "Please call X * the office." would be sent to pagers 20001 and 20002. X * X * This code has been tested only on the Metromedia Paging Services X * system around New York City, though it should work on other X * similiar systems. X * X * Douglas Kingston X * Morgan Stanley & Co. (19th Floor) X * 1251 Avenue of the Americas X * NY, NY, 10020 X */ X X#include <stdio.h> X#include <ctype.h> X#include <signal.h> X#include <sys/time.h> X#include "tip.h" X X#define STX 002 X#define ETX 003 X#define EOT 004 X#define ACK 006 X#define NAK 025 X#define ETB 027 X#define ESC 033 X#define RS 036 X Xextern int vflag, FD; Xextern jmp_buf jmpbuf; X Xextern char *strchr(); Xextern int recvtimeout(); X Xchar inbuf[270]; Xchar mbuf[32]; Xchar packet[270]; X Xstatic char *addstr(); X Xsendpage(data) Xchar *data; X{ X int ret = 1; X int trys, i; X char *cp, *pager, *message; X X if (boolean(value(VERBOSE))) X vflag++; X if (vflag) X fputs("[Connected]\n", stderr); X X cp = data; X if (pager = strchr(data, '\t')) { X *pager = 0; X pager++; X } else { X fprintf(stderr, "Bad paging data: '%s'\n", data); X return(1); X } X X trys = 0; X do { X if (trys++ > 3) { X fprintf(stderr, "ID= retries failed\n"); X goto done; X } X if (pgsend("\r")) X return(1); X } while (pgrecv("ID=", 5) < 3); X X trys = 0; Xlogin_again: X X if (pgsend("\033") || pgsend(cp) || pgsend("\r")) X return(1); X X /* Wait for ACK, NAK, EOT or Ready(?) */ X if (pgrecv("\r", 10) <= 0) { X fprintf(stderr, "login timeout\n"); X goto done; X } X switch(inbuf[0]) { X default: if (trys++ < 4) goto login_again; else goto done; X case ACK: break; X case NAK: if (trys++ < 4) goto login_again; else goto done; X case RS: fprintf(stderr, "login got RS\n"); goto done; X case ESC: X switch(inbuf[1]) { X case EOT: goto done; X case '[': if(inbuf[2] == 'p') break; X default: fprintf(stderr, "got unknown ESC code\n"); X goto login_again; X } X } X pgrecv("\r", 10); /* Swallow Go Ahead <ESC>[p */ X X if (message = strchr(pager, '\t')) { X *message = 0; X message++; X } else X message = "[Message not specified]"; Xnext_pager: X if (cp = strchr(pager, ',')) X *cp++ = 0; X buildpkt(pager, message); X X trys = 0; Xresend: X if (pgsend(packet)) X return(1); X pgrecv("^C\r\n", 10); /* ^C\r\n */ X X /* Wait for ACK, NAK, EOT or Ready(?) */ X if ((i = pgrecv("\r", 10)) <= 0) { X fprintf(stderr, "page send no reply\n"); X goto done; X } X switch(inbuf[i-2]) { X default: fprintf(stderr, "page send reply error\n"); X goto done; X case ACK: ret = 0; goto sent; X case NAK: if (trys++ < 4) goto resend; else goto done; X case RS: fprintf(stderr, "page send got RS\n"); goto done; X case ESC: X switch(inbuf[1]) { X case EOT: goto done; X case '[': if(inbuf[2] == 'p') { ret = 1; goto sent; } X default: fprintf(stderr, "got unknown ESC code\n"); X goto done; X } X } Xsent: X if(cp) { X pager = cp; X goto next_pager; X } X Xdone: X /* Logout: EOT CR */ X if (pgsend("\004\r")) X return(ret); X pgrecv("\r", 3); X fputs(ret ? "[Error in delivery]\n" : inbuf, stderr); X pgrecv("\r", 3); X return(ret); X} X Xpgsend(cp) Xchar *cp; X{ X int i, len = strlen(cp); X X nap(40); X if(vflag) X fprintf(stderr, "sending: "); X for (i = 0; i < len; i++) { X nap(75); X if(vflag) X show(cp, 1, stderr); X if (write(FD, cp, 1) != 1) { X fprintf(stderr, "pgsend error\n"); X return(-1); X } X cp++; X } X if(vflag) X fputc('\n', stderr); X return(0); X} X Xpgrecv(want, secs) Xchar *want; Xint secs; X{ X jmp_buf savebuf; X int i, size; X char *cp, *endcp; X X bcopy(jmpbuf, savebuf, sizeof(jmpbuf)); X if (setjmp(jmpbuf)) { X if(vflag) X fprintf(stderr, "\nrecv: timeout\n"); X bcopy(savebuf, jmpbuf, sizeof(jmpbuf)); X return(0); X } X signal(SIGALRM, recvtimeout); X alarm(secs); X X size = strlen(want); X if(vflag) { X fprintf(stderr, "recv (want "); X show(want, size, stderr); X fprintf(stderr, "/%d): ", size); X } X i = size-1; X X cp = inbuf; endcp = inbuf+sizeof(inbuf)-1; X *cp = 0; X mbuf[0] = 0; X while (strncmp(mbuf, want, size) != 0 && cp < endcp) { X bcopy(mbuf+1, mbuf, size); X if (read(FD, &mbuf[i], 1) != 1) X goto readerror; X mbuf[i] &= 0177; X *cp++ = mbuf[i]; X *cp = 0; X if(vflag) X show(&mbuf[i], 1, stderr); X } X alarm(0); X bcopy(savebuf, jmpbuf, sizeof(jmpbuf)); X if (vflag) X fputs(" -- got it\n", stderr); X return(cp - inbuf); Xreaderror: X alarm(0); X bcopy(savebuf, jmpbuf, sizeof(jmpbuf)); X return(-1); X} X Xbuildpkt(pager, message) Xchar *pager, *message; X{ X char *cp = &packet[0]; X int sum; X X *cp++ = STX; X sum = STX; X X cp = addstr(pager, &sum, cp); X cp = addstr(message, &sum, cp); X X *cp++ = ETX; X sum += ETX; X *cp++ = '0' + ((sum>>8)&0xf); X *cp++ = '0' + ((sum>>4)&0xf); X *cp++ = '0' + (sum&0xf); X *cp++ = '\r'; X *cp = 0; X} X Xstatic char * Xaddstr(s, sump, cp) Xchar *s, *cp; Xint *sump; X{ X char c; X int sum = *sump; X X while(c = *s++) { X *cp = (isprint(c) ? c : '?'); X sum += *cp; X cp++; X } X *cp++ = '\r'; X sum += '\r'; X X *sump = sum; X return(cp); X} END_OF_FILE if test 5957 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/page.c'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/page.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/page.c' fi if test -f 'pf-bootstrap-v1.1a/tipx-p1/tip.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/tipx-p1/tip.h'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/tipx-p1/tip.h'\" \(7981 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/tipx-p1/tip.h' <<'END_OF_FILE' X/* X * Copyright (c) 1983 The Regents of the University of California. X * All rights reserved. X * X * Redistribution and use in source and binary forms are permitted X * provided that the above copyright notice and this paragraph are X * duplicated in all such forms and that any documentation, X * advertising materials, and other materials related to such X * distribution and use acknowledge that the software was developed X * by the University of California, Berkeley. The name of the X * University may not be used to endorse or promote products derived X * from this software without specific prior written permission. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED X * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. X * X * @(#)tip.h 5.4 (Berkeley) 9/2/88 X */ X X/* X * tip - terminal interface program X */ X X#include <sys/types.h> X#include <sys/file.h> X X#include <sgtty.h> X#include <signal.h> X#include <stdio.h> X#include <pwd.h> X#include <ctype.h> X#include <setjmp.h> X#include <errno.h> X#include <netdb.h> X#include <string.h> X X#if defined(SUNOS4) || defined(__ANSI__) || defined(sparc) Xtypedef void sigfunc_t; X#else Xtypedef int sigfunc_t; X#endif X X/* X * Remote host attributes X */ Xchar *DV; /* UNIX device(s) to open */ Xchar *EL; /* chars marking an EOL */ Xchar *CM; /* initial connection message */ Xchar *IE; /* EOT to expect on input */ Xchar *OE; /* EOT to send to complete FT */ Xchar *CU; /* call unit if making a phone call */ Xchar *AT; /* acu type */ Xchar *PN; /* phone number(s) */ Xchar *DI; /* disconnect string */ Xchar *PA; /* parity to be generated */ X Xchar *PH; /* phone number file */ Xchar *RM; /* remote file name */ Xchar *HO; /* host name */ X Xchar *SA; /* local slip address */ Xchar *DA; /* destination slip address */ Xchar *SM; /* netmask for slip */ Xchar *ST; /* slip type */ Xchar *LS; /* login script file */ X Xint BR; /* line speed for conversation */ Xint FS; /* frame size for transfers */ X Xchar DU; /* this host is dialed up */ Xchar HW; /* this device is hardwired, see hunt.c */ Xchar *ES; /* escape character */ Xchar *EX; /* exceptions */ Xchar *FO; /* force (literal next) char*/ Xchar *RC; /* raise character */ Xchar *RE; /* script record file */ Xchar *PR; /* remote prompt */ Xint DL; /* line delay for file transfers to remote */ Xint CL; /* char delay for file transfers to remote */ Xint ET; /* echocheck timeout */ Xchar HD; /* this host is half duplex - do local echo */ X X/* X * String value table X */ Xtypedef X struct { X char *v_name; /* whose name is it */ X char v_type; /* for interpreting set's */ X char v_access; /* protection of touchy ones */ X char *v_abrev; /* possible abreviation */ X char *v_value; /* casted to a union later */ X } X value_t; X X#define STRING 01 /* string valued */ X#define BOOL 02 /* true-false value */ X#define NUMBER 04 /* numeric value */ X#define CHAR 010 /* character value */ X X#define WRITE 01 /* write access to variable */ X#define READ 02 /* read access */ X X#define CHANGED 01 /* low bit is used to show modification */ X#define PUBLIC 1 /* public access rights */ X#define PRIVATE 03 /* private to definer */ X#define ROOT 05 /* root defined */ X X#define TRUE 1 X#define FALSE 0 X X#define ENVIRON 020 /* initialize out of the environment */ X#define IREMOTE 040 /* initialize out of remote structure */ X#define INIT 0100 /* static data space used for initialization */ X#define TMASK 017 X X/* X * Definition of ACU line description X */ Xtypedef X struct { X char *acu_name; X int (*acu_dialer)(); X int (*acu_disconnect)(); X int (*acu_abort)(); X } X acu_t; X X#define equal(a, b) (strcmp(a,b)==0)/* A nice function to string compare */ X X/* X * variable manipulation stuff -- X * if we defined the value entry in value_t, then we couldn't X * initialize it in vars.c, so we cast it as needed to keep lint X * happy. X */ Xtypedef X union { X int zz_number; X short zz_boolean[2]; X char zz_character[4]; X int *zz_address; X } X zzhack; X X#define value(v) vtable[v].v_value X X#define number(v) ((((zzhack *)(&(v))))->zz_number) X#ifdef vax X#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[0]) X#define character(v) ((((zzhack *)(&(v))))->zz_character[0]) X#else X#define boolean(v) ((((zzhack *)(&(v))))->zz_boolean[1]) X#define character(v) ((((zzhack *)(&(v))))->zz_character[3]) X#endif X#define address(v) ((((zzhack *)(&(v))))->zz_address) X X/* X * Escape command table definitions -- X * lookup in this table is performed when ``escapec'' is recognized X * at the begining of a line (as defined by the eolmarks variable). X*/ X Xtypedef X struct { X char e_char; /* char to match on */ X char e_flags; /* experimental, priviledged */ X char *e_help; /* help string */ X int (*e_func)(); /* command */ X } X esctable_t; X X#define NORM 00 /* normal protection, execute anyone */ X#define EXP 01 /* experimental, mark it with a `*' on help */ X#define PRIV 02 /* priviledged, root execute only */ X Xextern int vflag; /* verbose during reading of .tiprc file */ Xextern value_t vtable[]; /* variable table */ X X#ifndef ACULOG X#define logent(a, b, c, d) X#define loginit() X#endif X X/* X * Definition of indices into variable table so X * value(DEFINE) turns into a static address. X */ X X#define BEAUTIFY 0 X#define BAUDRATE 1 X#define DIALTIMEOUT 2 X#define EOFREAD 3 X#define EOFWRITE 4 X#define EOL 5 X#define ESCAPE 6 X#define EXCEPTIONS 7 X#define FORCE 8 X#define FRAMESIZE 9 X#define HOST 10 X#define LOG 11 X#define PHONES 12 X#define PROMPT 13 X#define RAISE 14 X#define RAISECHAR 15 X#define RECORD 16 X#define REMOTE 17 X#define SCRIPT 18 X#define TABEXPAND 19 X#define VERBOSE 20 X#define SHELL 21 X#define HOME 22 X#define ECHOCHECK 23 X#define DISCONNECT 24 X#define TAND 25 X#define LDELAY 26 X#define CDELAY 27 X#define ETIMEOUT 28 X#define RAWFTP 29 X#define HALFDUPLEX 30 X#define LECHO 31 X#define PARITY 32 X#define SLIPADDR 33 X#define SLIPDSTADDR 34 X#define SLIPMASK 35 X#define SLIPTYPE 36 X#define LOGINSCRIPT 37 X#define SETROUTE 38 X#define LINESYNC 39 X#define DTRHUP 40 X X#define NOVAL ((value_t *)NULL) X#define NOACU ((acu_t *)NULL) X#define NOSTR ((char *)NULL) X#define NOFILE ((FILE *)NULL) X#define NOPWD ((struct passwd *)0) X Xstruct sgttyb arg; /* current mode of local terminal */ Xstruct sgttyb defarg; /* initial mode of local terminal */ Xstruct tchars tchars; /* current state of terminal */ Xstruct tchars defchars; /* initial state of terminal */ Xstruct ltchars ltchars; /* current local characters of terminal */ Xstruct ltchars deflchars; /* initial local characters of terminal */ X XFILE *fscript; /* FILE for scripting */ X Xint fildes[2]; /* file transfer synchronization channel */ Xint repdes[2]; /* read process sychronization channel */ Xint FD; /* open file descriptor to remote host */ Xint AC; /* open file descriptor to dialer (v831 only) */ Xint vflag; /* print .tiprc initialization sequence */ Xint sfd; /* for ~< operation */ Xint pid; /* pid of tipout */ Xuid_t uid, euid; /* real and effective user id's */ Xgid_t gid, egid; /* real and effective group id's */ Xint stop; /* stop transfer session flag */ Xint quit; /* same; but on other end */ Xint stoprompt; /* for interrupting a prompt session */ Xint timedout; /* ~> transfer timedout */ Xint cumode; /* simulating the "cu" program */ Xint slip; /* bring up SLIP on the line */ X Xchar fname[80]; /* file name buffer for ~< */ Xchar copyname[80]; /* file name buffer for ~> */ Xchar ccc; /* synchronization character */ Xchar uucplock[]; /* name of lock file for uucp's */ X Xint odisc; /* initial tty line discipline */ Xextern int disc; /* current tty discpline */ X Xextern char *ctrl(); Xextern char *ctime(); Xextern long time(); Xextern struct passwd *getpwuid(); Xextern char *getlogin(); Xextern char *vinterp(); Xextern char *getenv(); Xextern char *rindex(); Xextern char *index(); Xextern char *malloc(); Xextern char *lconnect(); X X#undef CTRL X#define CTRL(c) ((c)&037) END_OF_FILE if test 7981 -ne `wc -c <'pf-bootstrap-v1.1a/tipx-p1/tip.h'`; then echo shar: \"'pf-bootstrap-v1.1a/tipx-p1/tip.h'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/tipx-p1/tip.h' fi if test -f 'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c'\" else echo shar: Extracting \"'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c'\" \(8438 characters\) sed "s/^X//" >'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c' <<'END_OF_FILE' X/* X * XMODEM -- Implements the Christensen XMODEM protocol, X * for packetized file up/downloading. X * X * See the README file for some notes on SYS V adaptations. X * The program has been successfully run on VAXes (4.3BSD) and SUN-3/4s X * (SunOS 3.x) against MEX-PC and ZCOMM/DSZ. X * X * See the README and update.doc files for history and change notes. X * X * Please send bug fixes, additions and comments to: X * grandi@noao.edu X */ X X#include "xmodem.h" X Xmain(argc, argv) Xint argc; Xchar **argv; X{ X char *getenv(); X FILE *fopen(); X char *unix_cpm(); X char *strcpy(); X char *strcat(); X char *prtype(); X X char *fname = filename; /* convenient place to stash file names */ X char *logfile = "xmodem.log"; /* Name of LOG File */ X X char *stamptime(); /* for timestamp */ X X char *defname = "xmodem.in"; /* default file name if none given */ X X struct stat filestatbuf; /* file status info */ X X int index; X char flag; X long expsect; X int fd; X X /* initialize option flags */ X X XMITTYPE = 't'; /* assume text transfer */ X DEBUG = FALSE; /* keep debugging info in log */ X RECVFLAG = FALSE; /* not receive */ X SENDFLAG = FALSE; /* not send either */ X BATCH = FALSE; /* nor batch */ X CRCMODE = FALSE; /* use checksums for now */ X DELFLAG = FALSE; /* don't delete old log file */ X LOGFLAG = FALSE; /* keep log */ X LONGPACK = FALSE; /* do not use long packets on transmit */ X MDM7BAT = FALSE; /* no MODEM7 batch mode */ X YMDMBAT = FALSE; /* no YMODEM batch mode */ X TOOBUSY = FALSE; /* not too busy for sleeping in packet read */ X TIPFLAG = FALSE; /* no special logging on stderr */ X DELAYFLAG = FALSE; /* don't delay startup for a while */ X NOEOT = FALSE; /* don't suppress EOT verification */ X CANCAN = FALSE; /* don't allow CAN-CAN aborts in mid-transfer */ X YMODEMG = FALSE; /* no YMODEM-G */ X X fprintf(stderr, "XMODEM Version %s", VERSION); X fprintf(stderr, " -- UNIX-Microcomputer File Transfer Facility\n"); X X if (argc == 1) X { X help(); X exit(-1); X } X X index = 0; /* set index for flag loop */ X X stopsig(); /* suppress keyboard stop signal */ X X while ((flag = argv[1][index++]) != '\0') X switch (flag) { X case '-' : break; X case 'X' : X case 'x' : DEBUG = TRUE; /* turn on debugging log */ X break; X case 'C' : X case 'c' : CRCMODE = TRUE; /* enable CRC on receive */ X break; X case 'D' : X case 'd' : DELFLAG = TRUE; /* delete log file */ X break; X case 'L' : X case 'l' : LOGFLAG = FALSE; /* turn off log */ X break; X case 'm' : X case 'M' : MDM7BAT = TRUE; /* turn on MODEM7 batch protocol */ X BATCH = TRUE; X break; X case 'y' : X case 'Y' : YMDMBAT = TRUE; /* turn on YMODEM batch protocol */ X BATCH = TRUE; X break; X case 'k' : X case 'K' : LONGPACK = TRUE; /* use 1K packets on transmit */ X break; X case 't' : X case 'T' : TOOBUSY = TRUE; /* turn off sleeping */ X break; X case 'p' : X case 'P' : TIPFLAG = TRUE; /* turn on special handling for SunOS tip */ X break; X case 'w' : X case 'W' : DELAYFLAG = TRUE; /* delay startup */ X break; X case 'e' : X case 'E' : NOEOT = TRUE; /* turn off EOT verification */ X break; X case 'n' : X case 'N' : CANCAN = TRUE; /* allow mid-transfer CAN-CAN */ X break; X case 'g' : X case 'G' : YMODEMG = TRUE; /* YMODEM-G mode */ X CANCAN = TRUE; X CRCMODE = TRUE; X YMDMBAT = TRUE; X break; X case 'R' : X case 'r' : RECVFLAG = TRUE; /* receive file */ X XMITTYPE = gettype(argv[1][index++]); /* get t/b */ X break; X case 'S' : X case 's' : SENDFLAG = TRUE; /* send file */ X XMITTYPE = gettype(argv[1][index++]); X break; X default : fprintf(stderr, "Invalid Flag %c ignored\n", flag); X break; X } X X if (DEBUG) X LOGFLAG = TRUE; X X if (LOGFLAG) X { X if ((fname = getenv("HOME")) == 0) /* Get HOME variable */ X error("XMODEM Fatal Error- Can't get Environment!", FALSE); X fname = strcat(fname, "/"); X fname = strcat(fname, logfile); X if (!DELFLAG) X LOGFP = fopen(fname, "a"); /* append to LOG file */ X else X LOGFP = fopen(fname, "w"); /* new LOG file */ X if (!LOGFP) X error("XMODEM Fatal Error- Can't Open Log File", FALSE); X X fprintf(LOGFP,"\n++++++++ %s", stamptime()); X fprintf(LOGFP,"XMODEM Version %s\n", VERSION); X fprintf(LOGFP,"Command line: %s %s", argv[0], argv[1]); X for (index=2; index<argc; ++index) X fprintf(LOGFP, " %s", argv[index]); X fprintf(LOGFP, "\n"); X } X X getspeed(); /* get tty-speed for time estimates */ X X if (RECVFLAG && SENDFLAG) X error("XMODEM Fatal Error- Both Send and Receive Functions Specified", FALSE); X X if (MDM7BAT && (YMDMBAT || YMODEMG)) X error("XMODEM Fatal Error - Both YMODEM and MODEM7 Batch Protocols Specified", FALSE); X X if (!RECVFLAG && !SENDFLAG) X error("XMODEM Fatal Error - Either Send or Receive Function must be chosen!",FALSE); X X if (SENDFLAG && argc==2) X error("XMODEM Fatal Error - No file specified to send",FALSE); X X if (RECVFLAG && argc==2) X { X /* assume we really want CRC-16 in batch, unless we specify MODEM7 mode, unless we explicitly set CRCMODE */ X if (!CRCMODE) X CRCMODE = MDM7BAT ? FALSE : TRUE; X fprintf(stderr, "Ready for BATCH RECEIVE"); X fprintf(stderr, " in %s mode\n", prtype(XMITTYPE)); X if (!TIPFLAG) X fprintf(stderr, "Send several Control-X characters to cancel\n"); X logit("Batch Receive Started"); X logitarg(" in %s mode\n", prtype(XMITTYPE)); X strcpy(fname, defname); X } X X if (RECVFLAG && argc>2) X { X if(open(argv[2], 0) != -1) /* check for overwriting */ X { X logit("Warning -- Target File Exists and is Being Overwritten\n"); X fprintf(stderr, "Warning -- Target File Exists and is Being Overwritten\n"); X } X fprintf(stderr, "Ready to RECEIVE File %s", argv[2]); X fprintf(stderr, " in %s mode\n", prtype(XMITTYPE)); X if (!TIPFLAG) X fprintf(stderr, "Send several Control-X characters to cancel\n"); X logitarg("Receiving in %s mode\n", prtype(XMITTYPE)); X strcpy(fname,argv[2]); X } X X if (RECVFLAG) X { X if (DELAYFLAG) /* delay if -w requested */ X sleep(TIPDELAY); X setmodes(); /* set tty modes for transfer */ X X while(rfile(fname) != FALSE); /* receive files */ X X flushin(); X restoremodes(FALSE); /* restore normal tty modes */ X X sleep(2); /* give other side time to return to terminal mode */ X exit(0); X } X X if (SENDFLAG && BATCH) X { X if (YMDMBAT) X { X ytotleft = 0l; X yfilesleft = 0; X for (index=2; index<argc; index++) { X if (stat(argv[index], &filestatbuf) == 0) { X yfilesleft++; X ytotleft += filestatbuf.st_size; X if (XMITTYPE == 't') { X if((fd=open(argv[index],0)) >= 0) { X ytotleft += countnl(fd); X close(fd); X } X } X } X } X if (DEBUG) X fprintf(LOGFP, "DEBUG YMODEM file count: %d, %ld bytes\n", yfilesleft, ytotleft); X X fprintf(stderr, "Ready to YMODEM BATCH SEND"); X fprintf(stderr, " in %s mode\n", prtype(XMITTYPE)); X logit("YMODEM Batch Send Started"); X logitarg(" in %s mode\n", prtype(XMITTYPE)); X } X else if (MDM7BAT) X { X fprintf(stderr, "Ready to MODEM7 BATCH SEND"); X fprintf(stderr, " in %s mode\n", prtype(XMITTYPE)); X logit("MODEM7 Batch Send Started"); X logitarg(" in %s mode\n", prtype(XMITTYPE)); X } X if (!TIPFLAG) X fprintf(stderr, "Send several Control-X characters to cancel\n"); X X if (DELAYFLAG) /* delay if -w requested */ X sleep(TIPDELAY); X setmodes(); X for (index=2; index<argc; index++) { X if (stat(argv[index], &filestatbuf) < 0) { X logitarg("\nFile %s not found\n", argv[index]); X tlogitarg("\nFile %s not found\n", argv[index]); X continue; X } X sfile(argv[index]); X } X sfile(""); X flushin(); X restoremodes(FALSE); X X logit("Batch Send Complete\n"); X tlogit("Batch Send Complete\n"); X sleep(2); X exit (0); X } X X if (SENDFLAG && !BATCH) X { X if (stat(argv[2], &filestatbuf) < 0) X error("Can't find requested file", FALSE); X expsect = (filestatbuf.st_size/128)+1; X X fprintf(stderr, "File %s Ready to SEND", argv[2]); X fprintf(stderr, " in %s mode\n", prtype(XMITTYPE)); X fprintf(stderr, "Estimated File Size %ldK, %ld Sectors, %ld Bytes\n", X (filestatbuf.st_size/1024)+1, expsect, X filestatbuf.st_size); X projtime(expsect, stdout); X if (!TIPFLAG) X fprintf(stderr, "Send several Control-X characters to cancel\n"); X logitarg("Sending in %s mode\n", prtype(XMITTYPE)); X X setmodes(); X sfile(argv[2]); X flushin(); X restoremodes(FALSE); X X sleep(2); X exit(0); X } X} END_OF_FILE if test 8438 -ne `wc -c <'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c'`; then echo shar: \"'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c'\" unpacked with wrong size! fi # end of 'pf-bootstrap-v1.1a/xmodem-3.9/xmodem.c' fi echo shar: End of archive 4 \(of 9\). cp /dev/null ark4isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 9 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0