diff options
author | laforge <laforge> | 2000-09-12 13:43:34 +0000 |
---|---|---|
committer | laforge <laforge> | 2000-09-12 13:43:34 +0000 |
commit | 27f8e247583ba3d59af3ac475495eb5a8cedf480 (patch) | |
tree | 0779665cbf8193f020ef11508d0fa82d93204972 | |
parent | 22e0a4df69e4c017c1fad1e5f028219b0207264d (diff) |
ulogd_log now a function
-rw-r--r-- | include/ulogd/ulogd.h | 13 | ||||
-rw-r--r-- | ulogd.c | 19 |
2 files changed, 25 insertions, 7 deletions
diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h index 9e258d3..31beb29 100644 --- a/include/ulogd/ulogd.h +++ b/include/ulogd/ulogd.h @@ -78,11 +78,20 @@ typedef struct ulog_output { int* (*output)(ulog_iret_t *ret); } ulog_output_t; -/* public interface */ +/*********************************************************************** + * PUBLIC INTERFACE + ***********************************************************************/ + +/* register a new interpreter plugin */ void register_interpreter(ulog_interpreter_t *me); + +/* register a new output target */ void register_output(ulog_output_t *me); + +/* allocate a new ulog_iret_t */ ulog_iret_t *alloc_ret(const u_int16_t type, const char*); /* write a message to the daemons' logfile */ -void ulogd_log(int level, const char *message); +void ulogd_log(int level, const char *message, ...); + #endif @@ -1,4 +1,4 @@ -/* ulogd, Version $Revision: 1.7 $ +/* ulogd, Version $Revision: 1.8 $ * * first try of a logging daemon for my netfilter ULOG target * for the linux 2.4 netfilter subsystem. @@ -7,12 +7,14 @@ * * this code is released under the terms of GNU GPL * - * $Id: ulogd.c,v 1.7 2000/09/09 18:35:26 laforge Exp $ + * $Id: ulogd.c,v 1.8 2000/09/09 21:55:46 laforge Exp $ */ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdarg.h> +#include <time.h> #include <dlfcn.h> #include <sys/types.h> #include <dirent.h> @@ -138,13 +140,20 @@ void free_ret(ulog_iret_t *ret) } } -void ulogd_log(int level, const char *message) +void ulogd_log(int level, const char *format, ...) { char *timestr; + va_list ap; + time_t tm; - timestr = ctime(time()); - fprintf(logfile, "%s <%1.1d> %s\n", timestr, level, message); + va_start(ap, format); + tm = time(NULL); + timestr = ctime(&tm); + fprintf(logfile, "%s <%1.1d>", timestr, level); + + vfprintf(logfile, format, ap); + va_end(ap); } /* this should pass the result(s) to one or more registered output plugins, * but is currently only printing them out */ |