+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
#ifndef lint
-static char sccsid[] = "@(#)tip.c 4.15 (Berkeley) %G%";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1983 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)tip.c 5.2 (Berkeley) %G%";
+#endif not lint
/*
* tip - UNIX link to other systems
int timeout();
int cleanup();
char *sname();
+char PNbuf[256]; /* This limits the size of a number */
extern char *sprintf();
main(argc, argv)
for (p = system; *p; p++)
if (isalpha(*p))
goto notnumber;
- PN = system; /* system name is really a phone number */
+ /*
+ * 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;
system = sprintf(sbuf, "tip%d", BR);
notnumber:
if ((PH = getenv("PHONES")) == NOSTR)
PH = "/etc/phones";
vinit(); /* init variables */
- setparity(); /* set the parity table */
+ 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);
/*
* Everything's set up now:
- * connection established (hardwired or diaulup)
+ * 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.
{
register int i;
register char *bp;
+ extern int errno;
bp = buf;
for (i = 0; i < n; i++) {
*bp = partab[(*bp) & 0177];
bp++;
}
- write(fd, buf, n);
+ if (write(fd, buf, n) < 0) {
+ if (errno == EIO)
+ abort("Lost carrier.");
+ /* this is questionable */
+ perror("write");
+ }
}
/*
* Build a parity table with appropriate high-order bit.
*/
-setparity()
+setparity(defparity)
+ char *defparity;
{
register int i;
char *parity;
extern char evenpartab[];
if (value(PARITY) == NOSTR)
- value(PARITY) = "even";
+ value(PARITY) = defparity;
parity = value(PARITY);
for (i = 0; i < 0200; i++)
partab[i] = evenpartab[i];