From 236c10d33b1027d83caf6127336b924e81d32135 Mon Sep 17 00:00:00 2001 From: Holger Eitzenberger Date: Tue, 1 Feb 2011 17:30:57 +0100 Subject: ipset: pass ipset_arg argument pointer Signed-off-by: Holger Eitzenberger --- include/libipset/parse.h | 5 +++-- lib/parse.c | 11 +++++------ src/ipset.c | 10 ++-------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/libipset/parse.h b/include/libipset/parse.h index e87a60d..760df49 100644 --- a/include/libipset/parse.h +++ b/include/libipset/parse.h @@ -17,6 +17,7 @@ #define IPSET_PROTO_SEPARATOR ":" struct ipset_session; +struct ipset_arg; typedef int (*ipset_parsefn)(struct ipset_session *s, enum ipset_opt opt, const char *str); @@ -84,8 +85,8 @@ extern int ipset_parse_ignored(struct ipset_session *session, extern int ipset_parse_elem(struct ipset_session *session, enum ipset_opt opt, const char *str); extern int ipset_call_parser(struct ipset_session *session, - ipset_parsefn parse, const char *optstr, - enum ipset_opt optional, const char *str); + const struct ipset_arg *arg, + const char *str); /* Compatibility parser functions */ extern int ipset_parse_iptimeout(struct ipset_session *session, diff --git a/lib/parse.c b/lib/parse.c index e998df5..cd1ad32 100644 --- a/lib/parse.c +++ b/lib/parse.c @@ -1416,15 +1416,14 @@ ipset_parse_ignored(struct ipset_session *session, */ int ipset_call_parser(struct ipset_session *session, - ipset_parsefn parse, const char *optstr, - enum ipset_opt opt, const char *str) + const struct ipset_arg *arg, + const char *str) { if (ipset_data_flags_test(ipset_session_data(session), - IPSET_FLAG(opt))) - syntax_err("%s already specified", optstr); + IPSET_FLAG(arg->opt))) + syntax_err("%s already specified", arg->name[0]); - return parse(session, opt, parse == ipset_parse_ignored - ? optstr : str); + return arg->parse(session, arg->opt, str); } #define parse_elem(s, t, d, str) \ diff --git a/src/ipset.c b/src/ipset.c index 8ed3e10..2cfcfac 100644 --- a/src/ipset.c +++ b/src/ipset.c @@ -236,10 +236,7 @@ call_parser(int *argc, char *argv[], const struct ipset_arg *args) /* Fall through */ case IPSET_OPTIONAL_ARG: if (i + 1 <= *argc) { - ret = ipset_call_parser(session, - arg->parse, - optstr, arg->opt, - argv[i]); + ret = ipset_call_parser(session, arg, argv[i]); if (ret < 0) return ret; ipset_shift_argv(argc, argv, i); @@ -247,10 +244,7 @@ call_parser(int *argc, char *argv[], const struct ipset_arg *args) } /* Fall through */ default: - ret = ipset_call_parser(session, - arg->parse, - optstr, arg->opt, - optstr); + ret = ipset_call_parser(session, arg, optstr); if (ret < 0) return ret; } -- cgit v1.2.3