diff options
author | 2010-06-29 23:38:05 +0000 | |
---|---|---|
committer | 2010-06-29 23:38:05 +0000 | |
commit | 26bdf192e988c3c2eefe54ea2cc2943b896b097c (patch) | |
tree | b9513a5fe1eec371891fc0731ed47b117454c12a | |
parent | Since dial-up is no longer supported, no need to store a phone number, or (diff) | |
download | wireguard-openbsd-26bdf192e988c3c2eefe54ea2cc2943b896b097c.tar.xz wireguard-openbsd-26bdf192e988c3c2eefe54ea2cc2943b896b097c.zip |
Add new read-only vtable entries for device and connection string and use those
instead of variables.
-rw-r--r-- | usr.bin/tip/cmds.c | 5 | ||||
-rw-r--r-- | usr.bin/tip/cu.c | 13 | ||||
-rw-r--r-- | usr.bin/tip/remote.c | 37 | ||||
-rw-r--r-- | usr.bin/tip/tip.c | 8 | ||||
-rw-r--r-- | usr.bin/tip/tip.h | 11 | ||||
-rw-r--r-- | usr.bin/tip/vars.c | 6 |
6 files changed, 33 insertions, 47 deletions
diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c index f28eed4019d..258486f521c 100644 --- a/usr.bin/tip/cmds.c +++ b/usr.bin/tip/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.36 2010/06/29 23:10:56 nicm Exp $ */ +/* $OpenBSD: cmds.c,v 1.37 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */ /* @@ -644,10 +644,9 @@ chdirectory(int c) void tipabort(char *msg) { - signal(SIGTERM, SIG_IGN); kill(tipout_pid, SIGTERM); - logent(value(HOST), DV, "call terminated"); + logent(value(HOST), value(DEVICE), "call terminated"); if (msg != NULL) printf("\r\n%s", msg); printf("\r\n[EOT]\r\n"); diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c index b696b12da1a..a147036c13b 100644 --- a/usr.bin/tip/cu.c +++ b/usr.bin/tip/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.30 2010/06/29 23:32:52 nicm Exp $ */ +/* $OpenBSD: cu.c,v 1.31 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */ /* @@ -49,7 +49,6 @@ cumain(int argc, char *argv[]) if (argc < 2) cuusage(); - DV = NULL; setnumber(value(BAUDRATE), DEFBR); parity = 0; /* none */ @@ -83,17 +82,19 @@ getopt: while ((ch = getopt(argc, argv, "l:s:htoe")) != -1) { switch (ch) { case 'l': - if (DV != NULL) { + if (value(DEVICE) != NULL) { fprintf(stderr, "%s: cannot specify multiple -l options\n", __progname); exit(3); } if (strchr(optarg, '/')) - DV = optarg; - else - if (asprintf(&DV, "%s%s", _PATH_DEV, optarg) == -1) + value(DEVICE) = optarg; + else { + if (asprintf(&value(DEVICE), + "%s%s", _PATH_DEV, optarg) == -1) err(3, "asprintf"); + } break; case 's': baudrate = (int)strtonum(optarg, 0, INT_MAX, &errstr); diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c index 8186a5cd1c1..0ca921a5dcd 100644 --- a/usr.bin/tip/remote.c +++ b/usr.bin/tip/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.24 2010/06/29 23:32:52 nicm Exp $ */ +/* $OpenBSD: remote.c,v 1.25 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $ */ /* @@ -37,18 +37,6 @@ #include "pathnames.h" #include "tip.h" -/* - * Attributes to be gleened from remote host description - * data base. - */ -static char **caps[] = { - &DV, &CM, &DI, 0 -}; - -static char *capstrings[] = { - "dv", "cm", "di", 0 -}; - static char *db_array[3] = { _PATH_REMOTE, 0, 0 }; #define cgetflag(f) (cgetcap(bp, f, ':') != NULL) @@ -74,8 +62,9 @@ getremcap(char *host) } if ((stat = cgetent(&bp, db_array, host)) < 0) { - if ((DV != NULL) || - (host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) { + if (value(DEVICE) != NULL || + (host[0] == '/' && access(host, R_OK | W_OK) == 0)) { + value(DEVICE) = host; value(HOST) = host; if (!number(value(BAUDRATE))) setnumber(value(BAUDRATE), DEFBR); @@ -100,11 +89,9 @@ getremcap(char *host) exit(3); } - for (p = capstrings, q = caps; *p != NULL; p++, q++) { - if (**q == NULL) - cgetstr(bp, *p, *q); - } - + cgetstr(bp, "dv", &value(DEVICE)); + cgetstr(bp, "cm", &value(CONNECT)); + cgetstr(bp, "di", &value(DISCONNECT)); cgetstr(bp, "el", &value(EOL)); cgetstr(bp, "ie", &value(EOFREAD)); cgetstr(bp, "oe", &value(EOFWRITE)); @@ -137,7 +124,7 @@ getremcap(char *host) setnumber(value(FRAMESIZE), DEFFS); else setnumber(value(FRAMESIZE), val); - if (DV == NULL) { + if (value(DEVICE) == NULL) { fprintf(stderr, "%s: missing device spec\n", host); exit(3); } @@ -204,7 +191,7 @@ getremote(char *host) exit(3); } getremcap(host); - next = DV; + next = value(DEVICE); lookedup++; } /* @@ -214,12 +201,12 @@ getremote(char *host) if (next == NULL) return (NULL); if ((cp = strchr(next, ',')) == NULL) { - DV = next; + value(DEVICE) = next; next = NULL; } else { *cp++ = '\0'; - DV = next; + value(DEVICE) = next; next = cp; } - return (DV); + return (value(DEVICE)); } diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c index c90a63fea69..c5651592cca 100644 --- a/usr.bin/tip/tip.c +++ b/usr.bin/tip/tip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tip.c,v 1.44 2010/06/29 23:32:52 nicm Exp $ */ +/* $OpenBSD: tip.c,v 1.45 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */ /* @@ -199,9 +199,9 @@ cucommon: void con(void) { - if (CM != NULL) - parwrite(FD, CM, size(CM)); - logent(value(HOST), DV, "call completed"); + if (value(CONNECT) != NULL) + parwrite(FD, value(CONNECT), size(value(CONNECT))); + logent(value(HOST), value(DEVICE), "call completed"); } void diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h index 7651630d794..3657dde10e9 100644 --- a/usr.bin/tip/tip.h +++ b/usr.bin/tip/tip.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tip.h,v 1.44 2010/06/29 23:32:52 nicm Exp $ */ +/* $OpenBSD: tip.h,v 1.45 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */ /* @@ -57,13 +57,6 @@ #include <limits.h> /* - * Remote host attributes - */ -char *DV; /* UNIX device(s) to open */ -char *CM; /* initial connection message */ -char *DI; /* disconnect string */ - -/* * String value table */ typedef struct { @@ -130,6 +123,8 @@ extern value_t vtable[]; /* variable table */ enum { BEAUTIFY = 0, BAUDRATE, + CONNECT, + DEVICE, EOFREAD, EOFWRITE, EOL, diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c index 96289102977..e53788d93c1 100644 --- a/usr.bin/tip/vars.c +++ b/usr.bin/tip/vars.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vars.c,v 1.14 2010/06/29 23:10:56 nicm Exp $ */ +/* $OpenBSD: vars.c,v 1.15 2010/06/29 23:38:05 nicm Exp $ */ /* $NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $ */ /* @@ -41,6 +41,10 @@ value_t vtable[] = { "be", (char *)1 }, { "baudrate", V_NUMBER|V_INIT, "ba", 0 }, + { "connect", V_STRING|V_INIT|V_READONLY, + "cm", 0 }, + { "device", V_STRING|V_INIT|V_READONLY, + "dv", 0 }, { "eofread", V_STRING|V_INIT, "eofr", 0 }, { "eofwrite", V_STRING|V_INIT, |