diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2009-02-13 09:14:17 -0500 |
---|---|---|
committer | Jan Engelhardt <jengelh@medozas.de> | 2009-02-13 15:46:52 +0100 |
commit | 7e4db2f50133007f549f222468bde4f3adcf41ac (patch) | |
tree | 161425eb53b09d37cc86f961fdb1760548b8e338 /xtables.c | |
parent | 70581922f873a88306dd5b1cb83c5081ee239eb8 (diff) |
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 <hadi@cyberus.ca>
Diffstat (limited to 'xtables.c')
-rw-r--r-- | xtables.c | 57 |
1 files changed, 32 insertions, 25 deletions
@@ -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) { @@ -242,6 +217,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 */ void *xtables_calloc(size_t count, size_t size) |