From 7e4db2f50133007f549f222468bde4f3adcf41ac Mon Sep 17 00:00:00 2001 From: Jamal Hadi Salim Date: Fri, 13 Feb 2009 09:14:17 -0500 Subject: libxtables: consolidate init calls into one function Introduce xtables_init_all() which hides three calls xtables_init(), xtables_set_nfproto(), and xtables_set_params(). Make ip[6]tables-restore, ip[6]tables-save and ip[6]tables-standalone use it. I moved xtables_set_params around for readability reasons. Signed-off-by: Jamal Hadi Salim --- xtables.c | 57 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 25 deletions(-) (limited to 'xtables.c') diff --git a/xtables.c b/xtables.c index bdb0133d..a812ef16 100644 --- a/xtables.c +++ b/xtables.c @@ -73,31 +73,6 @@ void basic_exit_err(enum xtables_exittype status, const char *msg, ...) } -/** - * xtables_set_params - set the global parameters used by xtables - * @xtp: input xtables_globals structure - * - * The app is expected to pass a valid xtables_globals data-filled - * with proper values - * @xtp cannot be NULL - * - * Returns -1 on failure to set and 0 on success - */ -int xtables_set_params(struct xtables_globals *xtp) -{ - if (!xtp) { - fprintf(stderr, "%s: Illegal global params\n",__func__); - return -1; - } - - xt_params = xtp; - - if (!xt_params->exit_err) - xt_params->exit_err = basic_exit_err; - - return 0; -} - void xtables_free_opts(int reset_offset) { if (xt_params->opts != xt_params->orig_opts) { @@ -241,6 +216,38 @@ void xtables_set_nfproto(uint8_t nfproto) } } +/** + * xtables_set_params - set the global parameters used by xtables + * @xtp: input xtables_globals structure + * + * The app is expected to pass a valid xtables_globals data-filled + * with proper values + * @xtp cannot be NULL + * + * Returns -1 on failure to set and 0 on success + */ +int xtables_set_params(struct xtables_globals *xtp) +{ + if (!xtp) { + fprintf(stderr, "%s: Illegal global params\n",__func__); + return -1; + } + + xt_params = xtp; + + if (!xt_params->exit_err) + xt_params->exit_err = basic_exit_err; + + return 0; +} + +int xtables_init_all(struct xtables_globals *xtp, uint8_t nfproto) +{ + xtables_init(); + xtables_set_nfproto(nfproto); + return xtables_set_params(xtp); +} + /** * xtables_*alloc - wrappers that exit on failure */ -- cgit v1.2.3