libxtables: simple aliasing macro for exit_error
PATCH 1/1 libxtables: simple aliasing macro for exit_error
I think this is it for exit_error(). I didnt want to convert all the calls to exit_error(), so i introduced a simple macro to point to the xtables_globals
Next, after you look at these changes i would like to create a xtables_merge_options and convert apps defining their own merge_options to use it.
cheers,
jamal
commit 24a8e3b70bf70fd62da0ef493eb43fa5bb16d436
Author: Jamal Hadi Salim <[email protected]> Date: Tue Feb 10 09:34:11 2009 -0500
Rename xtables_globals exit_error cb to exit_err and introduce a very simple aliasing macro to point to it. convert iptables, ip6tables and iptables_xml to use it. Note iptables_xml does not have to define its own exit_error() since it can use the basic one provided.
include/xtables.h.in +4 -4
@@ -189,7 +189,7 @@ struct xtables_globals char *program_version; char *program_name; struct option *opts; - void (*exit_error)(enum xtables_exittype status, const char *msg, ...); + void (*exit_err)(enum xtables_exittype status, const char *msg, ...) __attribute__((noreturn, format(printf,2,3))); }; extern const char *xtables_program_name;
@@ -204,7 +204,7 @@ extern void *xtables_malloc(size_t); extern int xtables_insmod(const char *, const char *, bool); extern int xtables_load_ko(const char *, bool); -int xtables_set_params(struct xtables_globals *xtp); +extern int xtables_set_params(struct xtables_globals *xtp); void xtables_free_opts(int reset_offset, struct option *original_opts); extern struct xtables_match *xtables_find_match(const char *name,
@@ -230,8 +230,8 @@ xtables_parse_interface(const char *arg, char *vianame, unsigned char *mask); int xtables_check_inverse(const char option[], int *invert, int *my_optind, int argc); -void exit_error(enum xtables_exittype, const char *, ...) - __attribute__((noreturn, format(printf,2,3))); +extern struct xtables_globals *xt_params; +#define exit_error xt_params->exit_err extern void xtables_param_act(unsigned int, const char *, ...); extern const char *xtables_ipaddr_to_numeric(const struct in_addr *);
ip6tables.c +3 -2
@@ -145,12 +145,13 @@ int line = -1;static struct option *opts = original_opts;static unsigned int global_option_offset =0 ; +void ip6tables_exit_error (enum xtables_exittype status,const char *msg, ...) __attribute__((noreturn,format (printf,2 ,3 )));struct xtables_globals ip6tables_globals = { .option_offset =0 , .program_version =IPTABLES_VERSION , .program_name ="ip6tables" , .opts = original_opts, - .exit_error = exit_error, + .exit_err = ip6tables_exit_error, };/* Table of legal combinations of commands and options. If any of the
@@ -336,7 +337,7 @@ exit_printhelp(struct ip6tables_rule_match *matches) }void -exit_error (enum xtables_exittype status,const char *msg, ...) +ip6tables_exit_error (enum xtables_exittype status,const char *msg, ...) {va_list args;
iptables-xml.c +0 -13
@@ -31,18 +31,6 @@ const char *program_version;#ifndef IPTABLES_MULTI int line =0 ; -void exit_error (enum xtables_exittype status,const char *msg, ...) -{ -va_list args; - -va_start (args, msg); -fprintf (stderr,"%s v%s: " , program_name, program_version); -vfprintf (stderr, msg, args); -va_end (args); -fprintf (stderr,"\n" ); -/* On error paths, make sure that we don't leak memory */ -exit (status); -}#endif static void print_usage (const char *name,const char *version)
@@ -634,7 +622,6 @@ struct xtables_globals iptables_xml_globals = { .option_offset = 0, .program_version = IPTABLES_VERSION, .program_name = "iptables-xml", - .exit_error = exit_error, };#ifdef IPTABLES_MULTI
iptables.c +4 -2
@@ -145,12 +145,14 @@ int line = -1;static struct option *opts = original_opts;static unsigned int global_option_offset =0 ; +void iptables_exit_error (enum xtables_exittype status,const char *msg, ...) __attribute__((noreturn,format (printf,2 ,3 ))); +struct xtables_globals iptables_globals = { .option_offset =0 , .program_version =IPTABLES_VERSION , .program_name ="iptables" , .opts = original_opts, - .exit_error = exit_error, + .exit_err = iptables_exit_error, };/* Table of legal combinations of commands and options. If any of the
@@ -348,7 +350,7 @@ exit_printhelp(struct iptables_rule_match *matches) }void -exit_error (enum xtables_exittype status,const char *msg, ...) +iptables_exit_error (enum xtables_exittype status,const char *msg, ...) {va_list args;
xtables.c +24 -21
168 lines not on this page · raw message
Patrick McHardy
AppliedQuoted 7 lines · jamal
I think this is it for
exit_error(). I didnt want to convert all the calls toexit_error(), so i introduced a simple macro to point to thextables_globalsNext, after you look at these changes i would like to create a
xtables_merge_optionsand convert apps defining their ownmerge_optionsto use it.
Applied, thanks.