diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2009-02-11 13:02:21 +0100 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2009-02-11 13:02:21 +0100 |
commit | 40a8343d3ad0cdbc3a7e69c8d970ad75807c29ed (patch) | |
tree | 9dcd9d67ed463b32b6a7a3588fce3f068564c410 /xtables.c | |
parent | 84c3055bf08d0a8fe5db6e5f3f96dd826a290147 (diff) |
libxtables: Add exit_error cb to xtables_globals
Introduce exit_error() as part of xtables_globals structure.
When an application registers its xtables_globals definition
and does not specify its exit_error() it gets assigned a
basic version
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'xtables.c')
-rw-r--r-- | xtables.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -46,7 +46,20 @@ #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe" #endif -struct xtables_globals *xt_params; +struct xtables_globals *xt_params = NULL; + +void basic_exit_error(enum xtables_exittype status, const char *msg, ...) +{ + va_list args; + + va_start(args, msg); + fprintf(stderr, "%s v%s: ", xt_params->program_name, xt_params->program_version); + vfprintf(stderr, msg, args); + va_end(args); + fprintf(stderr, "\n"); + exit(status); +} + /** * xtables_set_params - set the global parameters used by xtables * @xtp: input xtables_globals structure @@ -65,6 +78,10 @@ int xtables_set_params(struct xtables_globals *xtp) } xt_params = xtp; + + if (!xt_params->exit_error) + xt_params->exit_error = basic_exit_error; + return 0; } |