summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospfctl
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2010-09-04 21:31:04 +0000
committertedu <tedu@openbsd.org>2010-09-04 21:31:04 +0000
commit6be5843ec61e3a3d3891b84615bd5eb6f8c55d63 (patch)
tree0201aea89051ec69781f644fb00a69fb718875e7 /usr.sbin/ospfctl
parentRemove redundant prototype left behind by deraadt@ (diff)
downloadwireguard-openbsd-6be5843ec61e3a3d3891b84615bd5eb6f8c55d63.tar.xz
wireguard-openbsd-6be5843ec61e3a3d3891b84615bd5eb6f8c55d63.zip
move some things around to make intentions clear. not really a functional
change. ok claudio
Diffstat (limited to 'usr.sbin/ospfctl')
-rw-r--r--usr.sbin/ospfctl/parser.c36
-rw-r--r--usr.sbin/ospfctl/parser.h4
2 files changed, 21 insertions, 19 deletions
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 *);