summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/dvmrpctl/parser.c36
-rw-r--r--usr.sbin/dvmrpctl/parser.h4
-rw-r--r--usr.sbin/ldpctl/parser.c36
-rw-r--r--usr.sbin/ldpctl/parser.h4
-rw-r--r--usr.sbin/ospf6ctl/parser.c36
-rw-r--r--usr.sbin/ospf6ctl/parser.h4
-rw-r--r--usr.sbin/ospfctl/parser.c36
-rw-r--r--usr.sbin/ospfctl/parser.h4
-rw-r--r--usr.sbin/relayctl/parser.c36
-rw-r--r--usr.sbin/relayctl/parser.h4
-rw-r--r--usr.sbin/ripctl/parser.c36
-rw-r--r--usr.sbin/ripctl/parser.h4
-rw-r--r--usr.sbin/smtpd/parser.c22
-rw-r--r--usr.sbin/smtpd/parser.h4
14 files changed, 140 insertions, 126 deletions
diff --git a/usr.sbin/dvmrpctl/parser.c b/usr.sbin/dvmrpctl/parser.c
index 4082425cad8..ffbf7c05a1e 100644
--- a/usr.sbin/dvmrpctl/parser.c
+++ b/usr.sbin/dvmrpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.4 2009/11/13 20:09:54 jsg Exp $ */
+/* $OpenBSD: parser.c,v 1.5 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -107,18 +107,21 @@ static const struct token t_log[] = {
};
-static struct parse_result res;
+static void show_valid_args(const struct token *);
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -141,8 +144,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -163,7 +167,7 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case FLAG:
@@ -171,35 +175,35 @@ match_token(const char *word, const struct token *table)
strlen(word)) == 0) {
match++;
t = &table[i];
- res.flags |= t->value;
+ res->flags |= t->value;
}
break;
case ADDRESS:
- if (parse_addr(word, &res.addr)) {
+ if (parse_addr(word, &res->addr)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case PREFIX:
- if (parse_prefix(word, &res.addr, &res.prefixlen)) {
+ if (parse_prefix(word, &res->addr, &res->prefixlen)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case IFNAME:
if (!match && word != NULL && strlen(word) > 0) {
- if (strlcpy(res.ifname, word,
- sizeof(res.ifname)) >=
- sizeof(res.ifname))
+ if (strlcpy(res->ifname, word,
+ sizeof(res->ifname)) >=
+ sizeof(res->ifname))
err(1, "interface name too long");
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
@@ -221,7 +225,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/dvmrpctl/parser.h b/usr.sbin/dvmrpctl/parser.h
index 90ac2c75e49..f3a349deeb7 100644
--- a/usr.sbin/dvmrpctl/parser.h
+++ b/usr.sbin/dvmrpctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.3 2009/11/13 20:09:54 jsg Exp $ */
+/* $OpenBSD: parser.h,v 1.4 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
@@ -51,8 +51,6 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
int parse_addr(const char *, struct in_addr *);
int parse_prefix(const char *, struct in_addr *,
u_int8_t *);
diff --git a/usr.sbin/ldpctl/parser.c b/usr.sbin/ldpctl/parser.c
index 662c7e9a06a..312e8611775 100644
--- a/usr.sbin/ldpctl/parser.c
+++ b/usr.sbin/ldpctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.4 2010/09/01 13:59:17 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.5 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -114,18 +114,21 @@ static const struct token t_show_fib[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
+static void show_valid_args(const struct token *);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -148,8 +151,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -170,7 +174,7 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case FLAG:
@@ -178,35 +182,35 @@ match_token(const char *word, const struct token *table)
strlen(word)) == 0) {
match++;
t = &table[i];
- res.flags |= t->value;
+ res->flags |= t->value;
}
break;
case ADDRESS:
- if (parse_addr(word, &res.addr)) {
+ if (parse_addr(word, &res->addr)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case PREFIX:
- if (parse_prefix(word, &res.addr, &res.prefixlen)) {
+ if (parse_prefix(word, &res->addr, &res->prefixlen)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case IFNAME:
if (!match && word != NULL && strlen(word) > 0) {
- if (strlcpy(res.ifname, word,
- sizeof(res.ifname)) >=
- sizeof(res.ifname))
+ if (strlcpy(res->ifname, word,
+ sizeof(res->ifname)) >=
+ sizeof(res->ifname))
err(1, "interface name too long");
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
@@ -228,7 +232,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/ldpctl/parser.h b/usr.sbin/ldpctl/parser.h
index 69d94ea410b..424eb0df59e 100644
--- a/usr.sbin/ldpctl/parser.h
+++ b/usr.sbin/ldpctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.4 2010/09/01 13:59:17 claudio Exp $ */
+/* $OpenBSD: parser.h,v 1.5 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -50,8 +50,6 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
int parse_addr(const char *, struct in_addr *);
int parse_prefix(const char *, struct in_addr *,
u_int8_t *);
diff --git a/usr.sbin/ospf6ctl/parser.c b/usr.sbin/ospf6ctl/parser.c
index 7d076ea7c2e..9e75173d75d 100644
--- a/usr.sbin/ospf6ctl/parser.c
+++ b/usr.sbin/ospf6ctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.9 2010/07/20 05:26:06 claudio Exp $ */
+/* $OpenBSD: parser.c,v 1.10 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -139,18 +139,21 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
+static void show_valid_args(const struct token *);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -173,8 +176,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -195,7 +199,7 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case FLAG:
@@ -203,35 +207,35 @@ match_token(const char *word, const struct token *table)
strlen(word)) == 0) {
match++;
t = &table[i];
- res.flags |= t->value;
+ res->flags |= t->value;
}
break;
case ADDRESS:
- if (parse_addr(word, &res.addr)) {
+ if (parse_addr(word, &res->addr)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case PREFIX:
- if (parse_prefix(word, &res.addr, &res.prefixlen)) {
+ if (parse_prefix(word, &res->addr, &res->prefixlen)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case IFNAME:
if (!match && word != NULL && strlen(word) > 0) {
- if (strlcpy(res.ifname, word,
- sizeof(res.ifname)) >=
- sizeof(res.ifname))
+ if (strlcpy(res->ifname, word,
+ sizeof(res->ifname)) >=
+ sizeof(res->ifname))
err(1, "interface name too long");
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
@@ -253,7 +257,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/ospf6ctl/parser.h b/usr.sbin/ospf6ctl/parser.h
index 4144f361e7f..ae7ed925bed 100644
--- a/usr.sbin/ospf6ctl/parser.h
+++ b/usr.sbin/ospf6ctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.7 2010/01/13 11:33:12 jsg Exp $ */
+/* $OpenBSD: parser.h,v 1.8 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -62,8 +62,6 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
int parse_addr(const char *, struct in6_addr *);
int parse_prefix(const char *, struct in6_addr *,
u_int8_t *);
diff --git a/usr.sbin/ospfctl/parser.c b/usr.sbin/ospfctl/parser.c
index 314ec0ffa33..8c2f70b51f3 100644
--- a/usr.sbin/ospfctl/parser.c
+++ b/usr.sbin/ospfctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.18 2010/02/19 10:35:52 dlg Exp $ */
+/* $OpenBSD: parser.c,v 1.19 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -138,18 +138,21 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
+static void show_valid_args(const struct token *);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -172,8 +175,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -194,7 +198,7 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case FLAG:
@@ -202,35 +206,35 @@ match_token(const char *word, const struct token *table)
strlen(word)) == 0) {
match++;
t = &table[i];
- res.flags |= t->value;
+ res->flags |= t->value;
}
break;
case ADDRESS:
- if (parse_addr(word, &res.addr)) {
+ if (parse_addr(word, &res->addr)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case PREFIX:
- if (parse_prefix(word, &res.addr, &res.prefixlen)) {
+ if (parse_prefix(word, &res->addr, &res->prefixlen)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case IFNAME:
if (!match && word != NULL && strlen(word) > 0) {
- if (strlcpy(res.ifname, word,
- sizeof(res.ifname)) >=
- sizeof(res.ifname))
+ if (strlcpy(res->ifname, word,
+ sizeof(res->ifname)) >=
+ sizeof(res->ifname))
err(1, "interface name too long");
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
@@ -252,7 +256,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/ospfctl/parser.h b/usr.sbin/ospfctl/parser.h
index 28676039257..9a741dd884f 100644
--- a/usr.sbin/ospfctl/parser.h
+++ b/usr.sbin/ospfctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.11 2010/02/19 10:35:52 dlg Exp $ */
+/* $OpenBSD: parser.h,v 1.12 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -62,8 +62,6 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
int parse_addr(const char *, struct in_addr *);
int parse_prefix(const char *, struct in_addr *,
u_int8_t *);
diff --git a/usr.sbin/relayctl/parser.c b/usr.sbin/relayctl/parser.c
index 7c0634db9c7..a9fa3a25814 100644
--- a/usr.sbin/relayctl/parser.c
+++ b/usr.sbin/relayctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.23 2010/01/11 06:40:14 jsg Exp $ */
+/* $OpenBSD: parser.c,v 1.24 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -131,18 +131,21 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
+static void show_valid_args(const struct token *);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -165,8 +168,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -188,16 +192,16 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case HOSTID:
if (word == NULL)
break;
- res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ res->id.id = strtonum(word, 0, UINT_MAX, &errstr);
if (errstr) {
- strlcpy(res.id.name, word, sizeof(res.id.name));
- res.id.id = EMPTY_ID;
+ strlcpy(res->id.name, word, sizeof(res->id.name));
+ res->id.id = EMPTY_ID;
}
t = &table[i];
match++;
@@ -205,10 +209,10 @@ match_token(const char *word, const struct token *table)
case TABLEID:
if (word == NULL)
break;
- res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ res->id.id = strtonum(word, 0, UINT_MAX, &errstr);
if (errstr) {
- strlcpy(res.id.name, word, sizeof(res.id.name));
- res.id.id = EMPTY_ID;
+ strlcpy(res->id.name, word, sizeof(res->id.name));
+ res->id.id = EMPTY_ID;
}
t = &table[i];
match++;
@@ -216,10 +220,10 @@ match_token(const char *word, const struct token *table)
case RDRID:
if (word == NULL)
break;
- res.id.id = strtonum(word, 0, UINT_MAX, &errstr);
+ res->id.id = strtonum(word, 0, UINT_MAX, &errstr);
if (errstr) {
- strlcpy(res.id.name, word, sizeof(res.id.name));
- res.id.id = EMPTY_ID;
+ strlcpy(res->id.name, word, sizeof(res->id.name));
+ res->id.id = EMPTY_ID;
}
t = &table[i];
match++;
@@ -242,7 +246,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/relayctl/parser.h b/usr.sbin/relayctl/parser.h
index 492e5454a92..8682b433c1f 100644
--- a/usr.sbin/relayctl/parser.h
+++ b/usr.sbin/relayctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.12 2010/01/11 06:40:14 jsg Exp $ */
+/* $OpenBSD: parser.h,v 1.13 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -44,5 +44,3 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
diff --git a/usr.sbin/ripctl/parser.c b/usr.sbin/ripctl/parser.c
index 04bd2becc9e..6ed7f935f2d 100644
--- a/usr.sbin/ripctl/parser.c
+++ b/usr.sbin/ripctl/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.4 2009/11/13 20:09:54 jsg Exp $ */
+/* $OpenBSD: parser.c,v 1.5 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -115,18 +115,21 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token *,
+ struct parse_result *);
+static void show_valid_args(const struct token *table)
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -149,8 +152,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token *table)
+static const struct token *
+match_token(const char *word, const struct token *table,
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -171,7 +175,7 @@ match_token(const char *word, const struct token *table)
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case FLAG:
@@ -179,35 +183,35 @@ match_token(const char *word, const struct token *table)
strlen(word)) == 0) {
match++;
t = &table[i];
- res.flags |= t->value;
+ res->flags |= t->value;
}
break;
case ADDRESS:
- if (parse_addr(word, &res.addr)) {
+ if (parse_addr(word, &res->addr)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case PREFIX:
- if (parse_prefix(word, &res.addr, &res.prefixlen)) {
+ if (parse_prefix(word, &res->addr, &res->prefixlen)) {
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case IFNAME:
if (!match && word != NULL && strlen(word) > 0) {
- if (strlcpy(res.ifname, word,
- sizeof(res.ifname)) >=
- sizeof(res.ifname))
+ if (strlcpy(res->ifname, word,
+ sizeof(res->ifname)) >=
+ sizeof(res->ifname))
err(1, "interface name too long");
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
@@ -229,7 +233,7 @@ match_token(const char *word, const struct token *table)
return (t);
}
-void
+static void
show_valid_args(const struct token *table)
{
int i;
diff --git a/usr.sbin/ripctl/parser.h b/usr.sbin/ripctl/parser.h
index c26c9ae13f4..dc761568860 100644
--- a/usr.sbin/ripctl/parser.h
+++ b/usr.sbin/ripctl/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.3 2009/11/13 20:09:54 jsg Exp $ */
+/* $OpenBSD: parser.h,v 1.4 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
@@ -50,8 +50,6 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);
int parse_addr(const char *, struct in_addr *);
int parse_prefix(const char *, struct in_addr *,
u_int8_t *);
diff --git a/usr.sbin/smtpd/parser.c b/usr.sbin/smtpd/parser.c
index 1c1eb941d6a..06936329691 100644
--- a/usr.sbin/smtpd/parser.c
+++ b/usr.sbin/smtpd/parser.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.c,v 1.14 2010/06/01 23:06:23 jacekm Exp $ */
+/* $OpenBSD: parser.c,v 1.15 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -121,18 +121,21 @@ static const struct token t_log[] = {
{ENDTOKEN, "", NONE, NULL}
};
-static struct parse_result res;
+static const struct token *match_token(const char *, const struct token [],
+ struct parse_result *res);
+static void show_valid_args(const struct token []);
struct parse_result *
parse(int argc, char *argv[])
{
+ static struct parse_result res;
const struct token *table = t_main;
const struct token *match;
bzero(&res, sizeof(res));
while (argc >= 0) {
- if ((match = match_token(argv[0], table)) == NULL) {
+ if ((match = match_token(argv[0], table, &res)) == NULL) {
fprintf(stderr, "valid commands/args:\n");
show_valid_args(table);
return (NULL);
@@ -155,8 +158,9 @@ parse(int argc, char *argv[])
return (&res);
}
-const struct token *
-match_token(const char *word, const struct token table[])
+static const struct token *
+match_token(const char *word, const struct token table[],
+ struct parse_result *res)
{
u_int i, match;
const struct token *t = NULL;
@@ -177,7 +181,7 @@ match_token(const char *word, const struct token table[])
match++;
t = &table[i];
if (t->value)
- res.action = t->value;
+ res->action = t->value;
}
break;
case VARIABLE:
@@ -185,8 +189,8 @@ match_token(const char *word, const struct token table[])
match++;
t = &table[i];
if (t->value) {
- res.action = t->value;
- res.data = word;
+ res->action = t->value;
+ res->data = word;
}
}
break;
@@ -208,7 +212,7 @@ match_token(const char *word, const struct token table[])
return (t);
}
-void
+static void
show_valid_args(const struct token table[])
{
int i;
diff --git a/usr.sbin/smtpd/parser.h b/usr.sbin/smtpd/parser.h
index 37039cab6d2..170c193710f 100644
--- a/usr.sbin/smtpd/parser.h
+++ b/usr.sbin/smtpd/parser.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: parser.h,v 1.13 2010/06/01 23:06:23 jacekm Exp $ */
+/* $OpenBSD: parser.h,v 1.14 2010/09/04 21:31:04 tedu Exp $ */
/*
* Copyright (c) 2006 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -44,5 +44,3 @@ struct parse_result {
};
struct parse_result *parse(int, char *[]);
-const struct token *match_token(const char *, const struct token *);
-void show_valid_args(const struct token *);