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>
diff --git a/iptables-restore.c b/iptables-restore.c
index 0103016..c52af0a 100644
--- a/iptables-restore.c
+++ b/iptables-restore.c
@@ -133,9 +133,14 @@
line = 0;
xtables_program_name = program_name;
- xtables_init();
- xtables_set_nfproto(NFPROTO_IPV4);
iptables_globals.program_name = "iptables-restore";
+ c = xtables_init_all(&iptables_globals, NFPROTO_IPV4);
+ if (c < 0) {
+ fprintf(stderr, "%s/%s Failed to initialize xtables\n",
+ iptables_globals.program_name,
+ iptables_globals.program_version);
+ exit(1);
+ }
#ifdef NO_SHARED_LIBS
init_extensions();
#endif