summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tip/cmds.c48
-rw-r--r--usr.bin/tip/cu.c8
-rw-r--r--usr.bin/tip/tip.c4
-rw-r--r--usr.bin/tip/tip.h49
-rw-r--r--usr.bin/tip/tipout.c6
-rw-r--r--usr.bin/tip/value.c45
-rw-r--r--usr.bin/tip/vars.c97
7 files changed, 125 insertions, 132 deletions
diff --git a/usr.bin/tip/cmds.c b/usr.bin/tip/cmds.c
index 777fdca7e3d..c0c7cb4e437 100644
--- a/usr.bin/tip/cmds.c
+++ b/usr.bin/tip/cmds.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmds.c,v 1.34 2010/06/29 16:44:38 nicm Exp $ */
+/* $OpenBSD: cmds.c,v 1.35 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: cmds.c,v 1.7 1997/02/11 09:24:03 mrg Exp $ */
/*
@@ -741,49 +741,49 @@ variable(int c)
if (prompt("[set] ", buf, sizeof(buf)))
return;
vlex(buf);
- if (vtable[BEAUTIFY].v_access&CHANGED) {
- vtable[BEAUTIFY].v_access &= ~CHANGED;
+ if (vtable[BEAUTIFY].v_flags & V_CHANGED) {
+ vtable[BEAUTIFY].v_flags &= ~V_CHANGED;
write(tipout_fd, "B", 1);
}
- if (vtable[SCRIPT].v_access&CHANGED) {
- vtable[SCRIPT].v_access &= ~CHANGED;
+ if (vtable[SCRIPT].v_flags & V_CHANGED) {
+ vtable[SCRIPT].v_flags &= ~V_CHANGED;
setscript();
/*
* So that "set record=blah script" doesn't
* cause two transactions to occur.
*/
- if (vtable[RECORD].v_access&CHANGED)
- vtable[RECORD].v_access &= ~CHANGED;
+ if (vtable[RECORD].v_flags & V_CHANGED)
+ vtable[RECORD].v_flags &= ~V_CHANGED;
}
- if (vtable[RECORD].v_access&CHANGED) {
- vtable[RECORD].v_access &= ~CHANGED;
+ if (vtable[RECORD].v_flags & V_CHANGED) {
+ vtable[RECORD].v_flags &= ~V_CHANGED;
if (boolean(value(SCRIPT)))
setscript();
}
- if (vtable[TAND].v_access&CHANGED) {
- vtable[TAND].v_access &= ~CHANGED;
+ if (vtable[TAND].v_flags & V_CHANGED) {
+ vtable[TAND].v_flags &= ~V_CHANGED;
if (boolean(value(TAND)))
tandem("on");
else
tandem("off");
}
- if (vtable[LECHO].v_access&CHANGED) {
- vtable[LECHO].v_access &= ~CHANGED;
+ if (vtable[LECHO].v_flags & V_CHANGED) {
+ vtable[LECHO].v_flags &= ~V_CHANGED;
HD = boolean(value(LECHO));
}
- if (vtable[PARITY].v_access&CHANGED) {
- vtable[PARITY].v_access &= ~CHANGED;
+ if (vtable[PARITY].v_flags & V_CHANGED) {
+ vtable[PARITY].v_flags &= ~V_CHANGED;
setparity(NULL);
}
- if (vtable[HARDWAREFLOW].v_access&CHANGED) {
- vtable[HARDWAREFLOW].v_access &= ~CHANGED;
+ if (vtable[HARDWAREFLOW].v_flags & V_CHANGED) {
+ vtable[HARDWAREFLOW].v_flags &= ~V_CHANGED;
if (boolean(value(HARDWAREFLOW)))
hardwareflow("on");
else
hardwareflow("off");
}
- if (vtable[LINEDISC].v_access&CHANGED) {
- vtable[LINEDISC].v_access &= ~CHANGED;
+ if (vtable[LINEDISC].v_flags & V_CHANGED) {
+ vtable[LINEDISC].v_flags &= ~V_CHANGED;
linedisc(NULL);
}
}
@@ -798,8 +798,8 @@ listvariables(int c)
puts("v\r");
for (p = vtable; p->v_name; p++) {
fputs(p->v_name, stdout);
- switch (p->v_type&TMASK) {
- case STRING:
+ switch (p->v_flags & V_TYPEMASK) {
+ case V_STRING:
if (p->v_value) {
strnvis(buf, p->v_value, sizeof(buf),
VIS_WHITE|VIS_OCTAL);
@@ -808,14 +808,14 @@ listvariables(int c)
putchar('\r');
putchar('\n');
break;
- case NUMBER:
+ case V_NUMBER:
printf(" %ld\r\n", number(p->v_value));
break;
- case BOOL:
+ case V_BOOL:
printf(" %s\r\n",
!boolean(p->v_value) ? "false" : "true");
break;
- case CHAR:
+ case V_CHAR:
vis(buf, character(p->v_value), VIS_WHITE|VIS_OCTAL, 0);
printf(" %s\r\n", buf);
break;
diff --git a/usr.bin/tip/cu.c b/usr.bin/tip/cu.c
index 975835c3b5d..3f4d57193ae 100644
--- a/usr.bin/tip/cu.c
+++ b/usr.bin/tip/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.27 2010/06/29 17:42:35 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.28 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: cu.c,v 1.5 1997/02/11 09:24:05 mrg Exp $ */
/*
@@ -101,8 +101,8 @@ getopt:
errx(3, "speed is %s: %s", errstr, optarg);
break;
case 'h':
- setboolean(value(LECHO), TRUE);
- HD = TRUE;
+ setboolean(value(LECHO), 1);
+ HD = 1;
break;
case 't':
/* Was for a hardwired dial-up connection. */
@@ -172,7 +172,7 @@ getopt:
setparity("none");
break;
}
- setboolean(value(VERBOSE), FALSE);
+ setboolean(value(VERBOSE), 0);
if (ttysetup(BR)) {
fprintf(stderr, "%s: unsupported speed %ld\n",
__progname, BR);
diff --git a/usr.bin/tip/tip.c b/usr.bin/tip/tip.c
index a604e66379c..13ce24c8f8c 100644
--- a/usr.bin/tip/tip.c
+++ b/usr.bin/tip/tip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.c,v 1.41 2010/06/29 17:42:35 nicm Exp $ */
+/* $OpenBSD: tip.c,v 1.42 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: tip.c,v 1.13 1997/04/20 00:03:05 mellon Exp $ */
/*
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
int i, pair[2];
/* XXX preserve previous braindamaged behavior */
- setboolean(value(DC), TRUE);
+ setboolean(value(DC), 1);
if (strcmp(__progname, "cu") == 0) {
cumode = 1;
diff --git a/usr.bin/tip/tip.h b/usr.bin/tip/tip.h
index ecd610812e8..6d5f225318f 100644
--- a/usr.bin/tip/tip.h
+++ b/usr.bin/tip/tip.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tip.h,v 1.40 2010/06/29 20:57:33 nicm Exp $ */
+/* $OpenBSD: tip.h,v 1.41 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: tip.h,v 1.7 1997/04/20 00:02:46 mellon Exp $ */
/*
@@ -89,34 +89,25 @@ short 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 /* used to show modification */
-#define READONLY 02 /* variable is not writable */
-
-#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
+typedef struct {
+ char *v_name; /* variable name */
+ int v_flags; /* type and flags */
+ char *v_abbrev; /* possible abbreviation */
+ 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_TYPEMASK 017
+
+#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 */
/*
* variable manipulation stuff --
diff --git a/usr.bin/tip/tipout.c b/usr.bin/tip/tipout.c
index c3b2c733bb0..ca3bd6fdc44 100644
--- a/usr.bin/tip/tipout.c
+++ b/usr.bin/tip/tipout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tipout.c,v 1.21 2010/02/07 20:16:47 nicm Exp $ */
+/* $OpenBSD: tipout.c,v 1.22 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: tipout.c,v 1.5 1996/12/29 10:34:12 cgd Exp $ */
/*
@@ -81,14 +81,14 @@ tipout_script(void)
if (boolean(value(SCRIPT)) && fscript != NULL)
fclose(fscript);
if (pline == line) {
- setboolean(value(SCRIPT), FALSE);
+ setboolean(value(SCRIPT), 0);
reply = 'y';
} else {
if ((fscript = fopen(line, "a")) == NULL)
reply = 'n';
else {
reply = 'y';
- setboolean(value(SCRIPT), TRUE);
+ setboolean(value(SCRIPT), 1);
}
}
write(tipin_fd, &reply, 1);
diff --git a/usr.bin/tip/value.c b/usr.bin/tip/value.c
index 8fb533d5539..f6c75f4711e 100644
--- a/usr.bin/tip/value.c
+++ b/usr.bin/tip/value.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: value.c,v 1.20 2010/06/29 20:57:33 nicm Exp $ */
+/* $OpenBSD: value.c,v 1.21 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: value.c,v 1.6 1997/02/11 09:24:09 mrg Exp $ */
/*
@@ -54,10 +54,10 @@ vinit(void)
FILE *fp;
for (p = vtable; p->v_name != NULL; p++) {
- if (p->v_type&ENVIRON)
+ if (p->v_flags & V_ENVIRON)
if ((cp = getenv(p->v_name)))
p->v_value = cp;
- if (p->v_type&IREMOTE)
+ if (p->v_flags & V_IREMOTE)
setnumber(p->v_value, *address(p->v_value));
}
/*
@@ -88,39 +88,39 @@ vinit(void)
static void
vassign(value_t *p, char *v)
{
- if (p->v_access & READONLY) {
+ if (p->v_flags & V_READONLY) {
printf("access denied\r\n");
return;
}
- switch (p->v_type&TMASK) {
- case STRING:
+ switch (p->v_flags & V_TYPEMASK) {
+ case V_STRING:
if (p->v_value && strcmp(p->v_value, v) == 0)
return;
- if (!(p->v_type&(ENVIRON|INIT)))
+ if (!(p->v_flags & (V_ENVIRON|V_INIT)))
free(p->v_value);
if ((p->v_value = strdup(v)) == NULL) {
printf("out of core\r\n");
return;
}
- p->v_type &= ~(ENVIRON|INIT);
+ p->v_flags &= ~(V_ENVIRON|V_INIT);
break;
- case NUMBER:
+ case V_NUMBER:
if (number(p->v_value) == number(v))
return;
setnumber(p->v_value, number(v));
break;
- case BOOL:
+ case V_BOOL:
if (boolean(p->v_value) == (*v != '!'))
return;
setboolean(p->v_value, (*v != '!'));
break;
- case CHAR:
+ case V_CHAR:
if (character(p->v_value) == *v)
return;
setcharacter(p->v_value, *v);
}
- p->v_access |= CHANGED;
+ p->v_flags |= V_CHANGED;
}
void
@@ -156,7 +156,7 @@ vtoken(char *s)
*cp = '\0';
if ((p = vlookup(s))) {
cp++;
- if (p->v_type&NUMBER)
+ if ((p->v_flags & V_TYPEMASK) == V_NUMBER)
vassign(p, (char *)atoi(cp));
else {
if (strcmp(s, "record") == 0)
@@ -193,17 +193,17 @@ vprint(value_t *p)
while (col++ < MIDDLE)
putchar(' ');
col += size(p->v_name);
- switch (p->v_type&TMASK) {
+ switch (p->v_flags & V_TYPEMASK) {
- case BOOL:
- if (boolean(p->v_value) == FALSE) {
+ case V_BOOL:
+ if (!boolean(p->v_value)) {
col++;
putchar('!');
}
printf("%s", p->v_name);
break;
- case STRING:
+ case V_STRING:
printf("%s=", p->v_name);
col++;
if (p->v_value) {
@@ -213,12 +213,12 @@ vprint(value_t *p)
}
break;
- case NUMBER:
+ case V_NUMBER:
col += 6;
printf("%s=%-5ld", p->v_name, number(p->v_value));
break;
- case CHAR:
+ case V_CHAR:
printf("%s=", p->v_name);
col++;
if (p->v_value) {
@@ -240,10 +240,11 @@ vlookup(char *s)
{
value_t *p;
- for (p = vtable; p->v_name; p++)
+ for (p = vtable; p->v_name; p++) {
if (strcmp(p->v_name, s) == 0 ||
- (p->v_abrev && strcmp(p->v_abrev, s) == 0))
+ (p->v_abbrev && strcmp(p->v_abbrev, s) == 0))
return (p);
+ }
return (NULL);
}
@@ -310,7 +311,7 @@ vstring(char *s, char *v)
p = vlookup(s);
if (p == 0)
return (1);
- if (p->v_type&NUMBER)
+ if ((p->v_flags & V_TYPEMASK) == V_NUMBER)
vassign(p, (char *)atoi(v));
else {
if (strcmp(s, "record") == 0)
diff --git a/usr.bin/tip/vars.c b/usr.bin/tip/vars.c
index 4c11df7ae26..5343694e336 100644
--- a/usr.bin/tip/vars.c
+++ b/usr.bin/tip/vars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vars.c,v 1.12 2010/06/29 20:57:33 nicm Exp $ */
+/* $OpenBSD: vars.c,v 1.13 2010/06/29 21:34:50 nicm Exp $ */
/* $NetBSD: vars.c,v 1.3 1994/12/08 09:31:19 jtc Exp $ */
/*
@@ -37,73 +37,74 @@
* Definition of variables
*/
value_t vtable[] = {
- { "beautify", BOOL, 0,
- "be", (char *)TRUE },
- { "baudrate", NUMBER|IREMOTE|INIT, 0,
+ { "beautify", V_BOOL,
+ "be", (char *)1 },
+ { "baudrate", V_NUMBER|V_IREMOTE|V_INIT,
"ba", (char *)&BR },
- { "eofread", STRING|IREMOTE|INIT, 0,
+ { "eofread", V_STRING|V_IREMOTE|V_INIT,
"eofr", (char *)&IE },
- { "eofwrite", STRING|IREMOTE|INIT, 0,
+ { "eofwrite", V_STRING|V_IREMOTE|V_INIT,
"eofw", (char *)&OE },
- { "eol", STRING|IREMOTE|INIT, 0,
+ { "eol", V_STRING|V_IREMOTE|V_INIT,
NULL, (char *)&EL },
- { "escape", CHAR, 0,
+ { "escape", V_CHAR,
"es", (char *)'~' },
- { "exceptions", STRING|INIT|IREMOTE, 0,
+ { "exceptions", V_STRING|V_INIT|V_IREMOTE,
"ex", (char *)&EX },
- { "force", CHAR, 0,
+ { "force", V_CHAR,
"fo", (char *)CTRL('p') },
- { "framesize", NUMBER|IREMOTE|INIT, 0,
+ { "framesize", V_NUMBER|V_IREMOTE|V_INIT,
"fr", (char *)&FS },
- { "host", STRING|IREMOTE|INIT, READONLY,
+ { "host", V_STRING|V_IREMOTE|V_INIT|V_READONLY,
"ho", (char *)&HO },
- { "log", STRING|INIT, 0,
+ { "log", V_STRING|V_INIT,
NULL, _PATH_ACULOG },
- { "prompt", CHAR, 0,
+ { "prompt", V_CHAR,
"pr", (char *)'\n' },
- { "raise", BOOL, 0,
- "ra", (char *)FALSE },
- { "raisechar", CHAR, 0,
+ { "raise", V_BOOL,
+ "ra", (char *)0 },
+ { "raisechar", V_CHAR,
"rc", NULL },
- { "record", STRING|INIT|IREMOTE, 0,
+ { "record", V_STRING|V_INIT|V_IREMOTE,
"rec", (char *)&RE },
- { "remote", STRING|INIT|IREMOTE, READONLY,
+ { "remote", V_STRING|V_INIT|V_IREMOTE|V_READONLY,
NULL, (char *)&RM },
- { "script", BOOL, 0,
- "sc", (char *)FALSE },
- { "tabexpand", BOOL, 0,
- "tab", (char *)FALSE },
- { "verbose", BOOL, 0,
- "verb", (char *)TRUE },
- { "SHELL", STRING|ENVIRON|INIT, 0,
+ { "script", V_BOOL,
+ "sc", (char *)0 },
+ { "tabexpand", V_BOOL,
+ "tab", (char *)0 },
+ { "verbose", V_BOOL,
+ "verb", (char *)1 },
+ { "SHELL", V_STRING|V_ENVIRON|V_INIT,
NULL, _PATH_BSHELL },
- { "HOME", STRING|ENVIRON, 0,
+ { "HOME", V_STRING|V_ENVIRON,
NULL, NULL },
- { "echocheck", BOOL, 0,
- "ec", (char *)FALSE },
- { "disconnect", STRING|IREMOTE|INIT, 0,
+ { "echocheck", V_BOOL,
+ "ec", (char *)0 },
+ { "disconnect", V_STRING|V_IREMOTE|V_INIT,
"di", (char *)&DI },
- { "tandem", BOOL, 0,
- "ta", (char *)TRUE },
- { "linedelay", NUMBER|IREMOTE|INIT, 0,
+ { "tandem", V_BOOL,
+ "ta", (char *)1 },
+ { "linedelay", V_NUMBER|V_IREMOTE|V_INIT,
"ldelay", (char *)&DL },
- { "chardelay", NUMBER|IREMOTE|INIT, 0,
+ { "chardelay", V_NUMBER|V_IREMOTE|V_INIT,
"cdelay", (char *)&CL },
- { "etimeout", NUMBER|IREMOTE|INIT, 0,
+ { "etimeout", V_NUMBER|V_IREMOTE|V_INIT,
"et", (char *)&ET },
- { "rawftp", BOOL, 0,
- "raw", (char *)FALSE },
- { "halfduplex", BOOL, 0,
- "hdx", (char *)FALSE },
- { "localecho", BOOL, 0,
- "le", (char *)FALSE },
- { "parity", STRING|INIT|IREMOTE, 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 },
- { "hardwareflow", BOOL, 0,
- "hf", (char *)FALSE },
- { "linedisc", NUMBER|IREMOTE|INIT, 0,
+ { "hardwareflow", V_BOOL,
+ "hf", (char *)0 },
+ { "linedisc", V_NUMBER|V_IREMOTE|V_INIT,
"ld", (char *)&LD },
- { "direct", BOOL, 0,
- "dc", (char *)FALSE },
- { NULL, NULL, NULL, NULL, NULL }
+ { "direct", V_BOOL,
+ "dc", (char *)0 },
+ { NULL, 0,
+ NULL, NULL }
};