diff options
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/ulogd_LOGEMU.c | 36 | ||||
-rw-r--r-- | extensions/ulogd_OPRINT.c | 47 | ||||
-rw-r--r-- | extensions/ulogd_SYSLOG.c | 27 |
3 files changed, 73 insertions, 37 deletions
diff --git a/extensions/ulogd_LOGEMU.c b/extensions/ulogd_LOGEMU.c index d8a9b5f..049bcd4 100644 --- a/extensions/ulogd_LOGEMU.c +++ b/extensions/ulogd_LOGEMU.c @@ -20,7 +20,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ulogd_LOGEMU.c,v 1.15 2003/09/28 15:19:26 laforge Exp $ + * $Id$ * */ @@ -57,7 +57,7 @@ static config_entry_t syslsync_ce = { &syslogf_ce, "sync", static FILE *of = NULL; -int _output_logemu(ulog_iret_t *res) +static int _output_logemu(ulog_iret_t *res) { static char buf[4096]; @@ -71,7 +71,7 @@ int _output_logemu(ulog_iret_t *res) return 0; } -void sighup_handler_logemu(int signal) +static void signal_handler_logemu(int signal) { switch (signal) { case SIGHUP: @@ -90,14 +90,7 @@ void sighup_handler_logemu(int signal) } -static ulog_output_t logemu_op = - { NULL, "syslogemu", &_output_logemu, &sighup_handler_logemu }; - -void _init(void) -{ - /* FIXME: error handling */ - config_parse_file("LOGEMU", &syslsync_ce); - +static int init_logemu(void) { #ifdef DEBUG_LOGEMU of = stdout; #else @@ -112,5 +105,26 @@ void _init(void) ulogd_log(ULOGD_ERROR, "can't resolve all keyhash id's\n"); } + return 1; +} + +static void fini_logemu(void) { + if (of != stdout) + fclose(of); +} + +static ulog_output_t logemu_op = { + .name = "syslogemu", + .init = &init_logemu, + .fini = &fini_logemu, + .output = &_output_logemu, + .signal = &signal_handler_logemu, +}; + +void _init(void) +{ + /* FIXME: error handling */ + config_parse_file("LOGEMU", &syslsync_ce); + register_output(&logemu_op); } diff --git a/extensions/ulogd_OPRINT.c b/extensions/ulogd_OPRINT.c index fdee135..186e3c9 100644 --- a/extensions/ulogd_OPRINT.c +++ b/extensions/ulogd_OPRINT.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: ulogd_OPRINT.c,v 1.9 2002/12/09 14:42:43 laforge Exp $ + * $Id$ * */ @@ -45,7 +45,7 @@ static FILE *of = NULL; -int _output_print(ulog_iret_t *res) +static int _output_print(ulog_iret_t *res) { ulog_iret_t *ret; @@ -83,7 +83,7 @@ static config_entry_t outf_ce = { NULL, "file", CONFIG_TYPE_STRING, CONFIG_OPT_NONE, 0, { string: ULOGD_OPRINT_DEFAULT } }; -void sighup_handler_print(int signal) +static void sighup_handler_print(int signal) { switch (signal) { @@ -102,22 +102,7 @@ void sighup_handler_print(int signal) } } -static ulog_output_t base_op[] = { - { NULL, "oprint", &_output_print, &sighup_handler_print }, - { NULL, "", NULL, NULL }, -}; - - -static void _base_reg_op(void) -{ - ulog_output_t *op = base_op; - ulog_output_t *p; - - for (p = op; p->output; p++) - register_output(p); -} - -void _init(void) +static int oprint_init(void) { #ifdef DEBUG of = stdout; @@ -131,6 +116,26 @@ void _init(void) exit(2); } #endif - - _base_reg_op(); + return 0; +} + +static void oprint_fini(void) +{ + if (of != stdout) + fclose(of); + + return; +} + +static ulog_output_t oprint_op = { + .name = "oprint", + .output = &_output_print, + .signal = &sighup_handler_print, + .init = &oprint_init, + .fini = &oprint_fini, +}; + +void _init(void) +{ + register_output(&oprint_op); } diff --git a/extensions/ulogd_SYSLOG.c b/extensions/ulogd_SYSLOG.c index 1be22d7..cb87fa9 100644 --- a/extensions/ulogd_SYSLOG.c +++ b/extensions/ulogd_SYSLOG.c @@ -57,7 +57,7 @@ static config_entry_t level_ce = { static int syslog_level, syslog_facility; -int _output_syslog(ulog_iret_t *res) +static int _output_syslog(ulog_iret_t *res) { static char buf[4096]; @@ -67,11 +67,8 @@ int _output_syslog(ulog_iret_t *res) return 0; } -static ulog_output_t syslog_op = { NULL, "syslog", &_output_syslog, NULL }; - -void _init(void) +static int syslog_init(void) { - /* FIXME: error handling */ config_parse_file("SYSLOG", &level_ce); @@ -125,6 +122,26 @@ void _init(void) exit(2); } + openlog("ulogd", LOG_NDELAY|LOG_PID, syslog_facility); + + return 0; +} + +static void syslog_fini(void) +{ + closelog(); +} + +static ulog_output_t syslog_op = { + .name = "syslog", + .init = &syslog_init, + .fini = &syslog_fini, + .output &_output_syslog +}; + + +void _init(void) +{ if (printpkt_init()) ulogd_log(ULOGD_ERROR, "can't resolve all keyhash id's\n"); |