summaryrefslogtreecommitdiff
path: root/usr.bin/tip
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-06-29 23:10:57 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-06-29 23:10:57 +0000
commitd89d127e66ee4af18d3882acb5640e109ef4ce1b (patch)
treec7ec65645f76fe0959ed8a3263bc9e1cd9d1f644 /usr.bin/tip
parent75d6d488835bb219478325951388890c3b2d3a34 (diff)
For every variable which has a value table entry with IREMOTE, remove the
remote variable and always use the value from the vtable. This then allows the IREMOTE flag to be removed.
Diffstat (limited to 'usr.bin/tip')
-rw-r--r--usr.bin/tip/cmds.c4
-rw-r--r--usr.bin/tip/cu.c17
-rw-r--r--usr.bin/tip/remote.c89
-rw-r--r--usr.bin/tip/tip.c6
-rw-r--r--usr.bin/tip/tip.h36
-rw-r--r--usr.bin/tip/value.c7
-rw-r--r--usr.bin/tip/vars.c62
7 files changed, 112 insertions, 109 deletions
diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c
index c0c7cb4e437..f28eed4019d 100644
--- a/usr.bin/tip/cmds.c
+++ b/usr.bin/tip/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.35 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: cmds.c,v 1.36 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */
/*
@@ -769,7 +769,7 @@ variable(int c)
}
if (vtable[LECHO].v_flags & V_CHANGED) {
vtable[LECHO].v_flags &= ~V_CHANGED;
- HD = boolean(value(LECHO));
+ setboolean(value(HALFDUPLEX), boolean(value(LECHO)));
}
if (vtable[PARITY].v_flags & V_CHANGED) {
vtable[PARITY].v_flags &= ~V_CHANGED;
diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c
index 3f4d57193ae..b189d2d1f4b 100644
--- a/usr.bin/tip/cu.c
+++ b/usr.bin/tip/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.28 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.29 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/*
@@ -43,14 +43,14 @@ static void cuusage(void);
void
cumain(int argc, char *argv[])
{
- int ch, i, parity;
+ int ch, i, parity, baudrate;
const char *errstr;
static char sbuf[12];
if (argc < 2)
cuusage();
DV = NULL;
- BR = DEFBR;
+ setnumber(value(BAUDRATE), DEFBR);
parity = 0; /* none */
/*
@@ -96,13 +96,14 @@ getopt:
err(3, "asprintf");
break;
case 's':
- BR = (int)strtonum(optarg, 0, INT_MAX, &errstr);
+ baudrate = (int)strtonum(optarg, 0, INT_MAX, &errstr);
if (errstr)
errx(3, "speed is %s: %s", errstr, optarg);
+ setnumber(value(BAUDRATE), baudrate);
break;
case 'h':
setboolean(value(LECHO), 1);
- HD = 1;
+ setboolean(value(HALFDUPLEX), 1);
break;
case 't':
/* Was for a hardwired dial-up connection. */
@@ -148,7 +149,7 @@ getopt:
* The "cu" host name is used to define the
* attributes of the generic dialer.
*/
- (void)snprintf(sbuf, sizeof(sbuf), "cu%ld", BR);
+ (void)snprintf(sbuf, sizeof(sbuf), "cu%ld", number(value(BAUDRATE)));
if ((i = hunt(sbuf)) == 0) {
printf("all ports busy\n");
exit(3);
@@ -173,9 +174,9 @@ getopt:
break;
}
setboolean(value(VERBOSE), 0);
- if (ttysetup(BR)) {
+ if (ttysetup(number(value(BAUDRATE)))) {
fprintf(stderr, "%s: unsupported speed %ld\n",
- __progname, BR);
+ __progname, number(value(BAUDRATE)));
(void)uu_unlock(uucplock);
exit(3);
}
diff --git a/usr.bin/tip/remote.c b/usr.bin/tip/remote.c
index b668f55c301..aab33333f88 100644
--- a/usr.bin/tip/remote.c
+++ b/usr.bin/tip/remote.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remote.c,v 1.21 2010/06/29 17:42:35 nicm Exp $ */
+/* $OpenBSD: remote.c,v 1.22 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: remote.c,v 1.5 1997/04/20 00:02:45 mellon Exp $ */
/*
@@ -42,13 +42,11 @@
* data base.
*/
static char **caps[] = {
- &DV, &CM, &EL, &IE, &OE, &PN, &PR, &DI,
- &ES, &EX, &FO, &RC, &RE, &PA
+ &DV, &CM, &PN, &PR, &DI, &ES, &FO, &RC, 0
};
static char *capstrings[] = {
- "dv", "cm", "el", "ie", "oe", "pn", "pr",
- "di", "es", "ex", "fo", "rc", "re", "pa", 0
+ "dv", "cm", "pn", "pr", "di", "es", "fo", "rc", 0
};
static char *db_array[3] = { _PATH_REMOTE, 0, 0 };
@@ -60,8 +58,9 @@ static void getremcap(char *);
static void
getremcap(char *host)
{
- char **p, ***q, *bp, *rempath;
- int stat;
+ char **p, ***q, *bp, *rempath;
+ int stat;
+ long val;
rempath = getenv("REMOTE");
if (rempath != NULL) {
@@ -77,10 +76,10 @@ getremcap(char *host)
if ((stat = cgetent(&bp, db_array, host)) < 0) {
if ((DV != NULL) ||
(host[0] == '/' && access(DV = host, R_OK | W_OK) == 0)) {
- HO = host;
- if (!BR)
- BR = DEFBR;
- FS = DEFFS;
+ value(HOST) = host;
+ if (!number(value(BAUDRATE)))
+ setnumber(value(BAUDRATE), DEFBR);
+ setnumber(value(FRAMESIZE), DEFFS);
return;
}
switch (stat) {
@@ -101,26 +100,42 @@ getremcap(char *host)
exit(3);
}
- for (p = capstrings, q = caps; *p != NULL; p++, q++)
+ for (p = capstrings, q = caps; *p != NULL; p++, q++) {
if (**q == NULL)
cgetstr(bp, *p, *q);
- if (!BR && (cgetnum(bp, "br", &BR) == -1))
- BR = DEFBR;
- if (!LD && (cgetnum(bp, "ld", &LD) == -1))
- LD = TTYDISC;
- if (cgetnum(bp, "fs", &FS) == -1)
- FS = DEFFS;
+ }
+
+ cgetstr(bp, "el", &value(EOL));
+ cgetstr(bp, "ie", &value(EOFREAD));
+ cgetstr(bp, "oe", &value(EOFWRITE));
+ cgetstr(bp, "ex", &value(EXCEPTIONS));
+ cgetstr(bp, "re", &value(RECORD));
+ cgetstr(bp, "pa", &value(PARITY));
+
+ if (!number(value(BAUDRATE))) {
+ if (cgetnum(bp, "br", &val) == -1)
+ setnumber(value(BAUDRATE), DEFBR);
+ else
+ setnumber(value(BAUDRATE), val);
+ }
+ if (!number(value(LINEDISC))) {
+ if (cgetnum(bp, "ld", &val) == -1)
+ setnumber(value(LINEDISC), TTYDISC);
+ else
+ setnumber(value(LINEDISC), val);
+ }
+ if (cgetnum(bp, "fs", &val) == -1)
+ setnumber(value(FRAMESIZE), DEFFS);
+ else
+ setnumber(value(FRAMESIZE), val);
if (DV == NULL) {
fprintf(stderr, "%s: missing device spec\n", host);
exit(3);
}
- HD = cgetflag("hd");
- HO = host;
-
- /*
- * see if uppercase mode should be turned on initially
- */
+ value(HOST) = host;
+ if (cgetflag("hd"))
+ setboolean(value(HALFDUPLEX), 1);
if (cgetflag("ra"))
setboolean(value(RAISE), 1);
if (cgetflag("ec"))
@@ -149,10 +164,10 @@ getremcap(char *host)
setboolean(value(DC), 1);
if (cgetflag("hf"))
setboolean(value(HARDWAREFLOW), 1);
- if (RE == NULL)
- RE = (char *)"tip.record";
- if (EX == NULL)
- EX = (char *)"\t\n\b\f";
+ if (value(RECORD) == NULL)
+ value(RECORD) = "tip.record";
+ if (value(EXCEPTIONS) == NULL)
+ value(EXCEPTIONS) = "\t\n\b\f";
if (ES != NULL)
vstring("es", ES);
if (FO != NULL)
@@ -161,12 +176,18 @@ getremcap(char *host)
vstring("pr", PR);
if (RC != NULL)
vstring("rc", RC);
- if (cgetnum(bp, "dl", &DL) == -1)
- DL = 0;
- if (cgetnum(bp, "cl", &CL) == -1)
- CL = 0;
- if (cgetnum(bp, "et", &ET) == -1)
- ET = 10;
+ if (cgetnum(bp, "dl", &val) == -1)
+ setnumber(value(LDELAY), 0);
+ else
+ setnumber(value(LDELAY), val);
+ if (cgetnum(bp, "cl", &val) == -1)
+ setnumber(value(CDELAY), 0);
+ else
+ setnumber(value(CDELAY), val);
+ if (cgetnum(bp, "et", &val) == -1)
+ setnumber(value(ETIMEOUT), 0);
+ else
+ setnumber(value(ETIMEOUT), val);
}
char *
diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index 13ce24c8f8c..9dfa71f4c79 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.c,v 1.42 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: tip.c,v 1.43 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@@ -89,7 +89,7 @@ main(int argc, char *argv[])
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]);
+ setnumber(value(BAUDRATE), atoi(&argv[1][1]));
break;
default:
@@ -117,7 +117,7 @@ main(int argc, char *argv[])
for (p = sys; *p; p++)
*p = '\0';
PN = PNbuf;
- (void)snprintf(sbuf, sizeof(sbuf), "tip%ld", BR);
+ (void)snprintf(sbuf, sizeof(sbuf), "tip%ld", number(value(BAUDRATE)));
sys = sbuf;
notnumber:
diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h
index 6d5f225318f..e77ee275559 100644
--- a/usr.bin/tip/tip.h
+++ b/usr.bin/tip/tip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.h,v 1.41 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: tip.h,v 1.42 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/*
@@ -60,31 +60,14 @@
* 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 *PN; /* phone number(s) */
char *DI; /* disconnect string */
-char *PA; /* parity to be generated */
-
-char *RM; /* remote file name */
-char *HO; /* host name */
-
-long BR; /* line speed for conversation */
-long FS; /* frame size for transfers */
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 */
-long LD; /* line disc */
-short HD; /* this host is half duplex - do local echo */
/*
* String value table
@@ -96,18 +79,17 @@ typedef struct {
char *v_value; /* casted to a union later */
} value_t;
-#define V_STRING 01 /* string valued */
-#define V_BOOL 02 /* true-false value */
-#define V_NUMBER 04 /* numeric value */
-#define V_CHAR 010 /* character value */
+#define V_STRING 01 /* string valued */
+#define V_BOOL 02 /* true-false value */
+#define V_NUMBER 04 /* numeric value */
+#define V_CHAR 010 /* character value */
#define V_TYPEMASK 017
-#define V_CHANGED 020 /* to show modification */
-#define V_READONLY 040 /* variable is not writable */
+#define V_CHANGED 020 /* to show modification */
+#define V_READONLY 040 /* variable is not writable */
-#define V_ENVIRON 0100 /* initialize out of the environment */
-#define V_IREMOTE 0200 /* initialize out of remote structure */
-#define V_INIT 0400 /* static data space used for initialization */
+#define V_ENVIRON 0100 /* initialize out of the environment */
+#define V_INIT 0400 /* static data space used for initialization */
/*
* variable manipulation stuff --
diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c
index f6c75f4711e..888b66cdfd1 100644
--- a/usr.bin/tip/value.c
+++ b/usr.bin/tip/value.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: value.c,v 1.21 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: value.c,v 1.22 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $ */
/*
@@ -54,11 +54,10 @@ vinit(void)
FILE *fp;
for (p = vtable; p->v_name != NULL; p++) {
- if (p->v_flags & V_ENVIRON)
+ if (p->v_flags & V_ENVIRON) {
if ((cp = getenv(p->v_name)))
p->v_value = cp;
- if (p->v_flags & V_IREMOTE)
- setnumber(p->v_value, *address(p->v_value));
+ }
}
/*
* Read the .tiprc file in the HOME directory
diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c
index 5343694e336..96289102977 100644
--- a/usr.bin/tip/vars.c
+++ b/usr.bin/tip/vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vars.c,v 1.13 2010/06/29 21:34:50 nicm Exp $ */
+/* $OpenBSD: vars.c,v 1.14 2010/06/29 23:10:56 nicm Exp $ */
/* $NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $ */
/*
@@ -39,24 +39,24 @@
value_t vtable[] = {
{ "beautify", V_BOOL,
"be", (char *)1 },
- { "baudrate", V_NUMBER|V_IREMOTE|V_INIT,
- "ba", (char *)&BR },
- { "eofread", V_STRING|V_IREMOTE|V_INIT,
- "eofr", (char *)&IE },
- { "eofwrite", V_STRING|V_IREMOTE|V_INIT,
- "eofw", (char *)&OE },
- { "eol", V_STRING|V_IREMOTE|V_INIT,
- NULL, (char *)&EL },
+ { "baudrate", V_NUMBER|V_INIT,
+ "ba", 0 },
+ { "eofread", V_STRING|V_INIT,
+ "eofr", 0 },
+ { "eofwrite", V_STRING|V_INIT,
+ "eofw", 0 },
+ { "eol", V_STRING|V_INIT,
+ NULL, 0 },
{ "escape", V_CHAR,
"es", (char *)'~' },
- { "exceptions", V_STRING|V_INIT|V_IREMOTE,
- "ex", (char *)&EX },
+ { "exceptions", V_STRING|V_INIT,
+ "ex", 0 },
{ "force", V_CHAR,
"fo", (char *)CTRL('p') },
- { "framesize", V_NUMBER|V_IREMOTE|V_INIT,
- "fr", (char *)&FS },
- { "host", V_STRING|V_IREMOTE|V_INIT|V_READONLY,
- "ho", (char *)&HO },
+ { "framesize", V_NUMBER|V_INIT,
+ "fr", 0 },
+ { "host", V_STRING|V_INIT|V_READONLY,
+ "ho", 0 },
{ "log", V_STRING|V_INIT,
NULL, _PATH_ACULOG },
{ "prompt", V_CHAR,
@@ -65,10 +65,10 @@ value_t vtable[] = {
"ra", (char *)0 },
{ "raisechar", V_CHAR,
"rc", NULL },
- { "record", V_STRING|V_INIT|V_IREMOTE,
- "rec", (char *)&RE },
- { "remote", V_STRING|V_INIT|V_IREMOTE|V_READONLY,
- NULL, (char *)&RM },
+ { "record", V_STRING|V_INIT,
+ "rec", 0 },
+ { "remote", V_STRING|V_INIT|V_READONLY,
+ NULL, 0 },
{ "script", V_BOOL,
"sc", (char *)0 },
{ "tabexpand", V_BOOL,
@@ -81,28 +81,28 @@ value_t vtable[] = {
NULL, NULL },
{ "echocheck", V_BOOL,
"ec", (char *)0 },
- { "disconnect", V_STRING|V_IREMOTE|V_INIT,
- "di", (char *)&DI },
+ { "disconnect", V_STRING|V_INIT,
+ "di", 0 },
{ "tandem", V_BOOL,
"ta", (char *)1 },
- { "linedelay", V_NUMBER|V_IREMOTE|V_INIT,
- "ldelay", (char *)&DL },
- { "chardelay", V_NUMBER|V_IREMOTE|V_INIT,
- "cdelay", (char *)&CL },
- { "etimeout", V_NUMBER|V_IREMOTE|V_INIT,
- "et", (char *)&ET },
+ { "linedelay", V_NUMBER|V_INIT,
+ "ldelay", 0 },
+ { "chardelay", V_NUMBER|V_INIT,
+ "cdelay", 0 },
+ { "etimeout", V_NUMBER|V_INIT,
+ "et", 0 },
{ "rawftp", V_BOOL,
"raw", (char *)0 },
{ "halfduplex", V_BOOL,
"hdx", (char *)0 },
{ "localecho", V_BOOL,
"le", (char *)0 },
- { "parity", V_STRING|V_INIT|V_IREMOTE,
- "par", (char *)&PA },
+ { "parity", V_STRING|V_INIT,
+ "par", 0 },
{ "hardwareflow", V_BOOL,
"hf", (char *)0 },
- { "linedisc", V_NUMBER|V_IREMOTE|V_INIT,
- "ld", (char *)&LD },
+ { "linedisc", V_NUMBER|V_INIT,
+ "ld", 0 },
{ "direct", V_BOOL,
"dc", (char *)0 },
{ NULL, 0,