From: <al...@us...> - 2003-06-16 19:18:50
|
Update of /cvsroot/msyslog/syslog/src In directory sc8-pr-cvs1:/tmp/cvs-serv10864/src Modified Files: modules.c modules.h syslogd.c syslogd.h Log Message: use typedefs now Index: modules.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.c,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- modules.c 22 May 2003 06:57:38 -0000 1.175 +++ modules.c 16 Jun 2003 19:18:39 -0000 1.176 @@ -66,98 +66,98 @@ extern int Debug; -int om_classic_init (int, char **, struct filed *, struct global*, void **, char **); -int om_tcp_init (int, char **, struct filed *, struct global*, void **, char **); -int om_udp_init (int, char **, struct filed *, struct global*, void **, char **); -int om_peo_init (int, char **, struct filed *, struct global*, void **, char **); -int om_regex_init (int, char **, struct filed *, struct global*, void **, char **); -int om_mysql_init (int, char **, struct filed *, struct global*, void **, char **); -int om_pgsql_init (int, char **, struct filed *, struct global*, void **, char **); -int om_classic_write (struct filed *, struct m_msg *, void *); -int om_tcp_write (struct filed *, struct m_msg *, void *); -int om_udp_write (struct filed *, struct m_msg *, void *); -int om_peo_write (struct filed *, struct m_msg *, void *); -int om_regex_write (struct filed *, struct m_msg *, void *); -int om_mysql_write (struct filed *, struct m_msg *, void *); -int om_pgsql_write (struct filed *, struct m_msg *, void *); -int om_classic_flush (struct filed *, void *); -int om_regex_flush (struct filed *, void *); -int om_pgsql_flush (struct filed *, void *); -int om_classic_close (struct filed *, void *); -int om_tcp_close (struct filed *, void *); -int om_udp_close (struct filed *, void *); -int om_peo_close (struct filed *, void *); -int om_regex_close (struct filed *, void *); -int om_mysql_close (struct filed *, void *); -int om_pgsql_close (struct filed *, void *); +int om_classic_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_tcp_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_udp_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_peo_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_regex_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_mysql_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_pgsql_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_classic_write (filed_t *, m_msg_t *, void *); +int om_tcp_write (filed_t *, m_msg_t *, void *); +int om_udp_write (filed_t *, m_msg_t *, void *); +int om_peo_write (filed_t *, m_msg_t *, void *); +int om_regex_write (filed_t *, m_msg_t *, void *); +int om_mysql_write (filed_t *, m_msg_t *, void *); +int om_pgsql_write (filed_t *, m_msg_t *, void *); +int om_classic_flush (filed_t *, void *); +int om_regex_flush (filed_t *, void *); +int om_pgsql_flush (filed_t *, void *); +int om_classic_close (filed_t *, void *); +int om_tcp_close (filed_t *, void *); +int om_udp_close (filed_t *, void *); +int om_peo_close (filed_t *, void *); +int om_regex_close (filed_t *, void *); +int om_mysql_close (filed_t *, void *); +int om_pgsql_close (filed_t *, void *); #ifdef HAVE_ORACLE8I_OMODULE -int om_oracle8i_init (int, char **, struct filed *, struct global*, void **, char **); -int om_oracle8i_write (struct filed *, struct m_msg *, void *); -int om_oracle8i_close (struct filed *, void *); +int om_oracle8i_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_oracle8i_write (filed_t *, m_msg_t *, void *); +int om_oracle8i_close (filed_t *, void *); #endif #ifdef HAVE_SNMPTRAP_OMODULE -int om_snmptrap_init (int, char **, struct filed *, struct global*, void **, char **); -int om_snmptrap_write (struct filed *, struct m_msg *, void *); -int om_snmptrap_close (struct filed *, void *); +int om_snmptrap_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_snmptrap_write (filed_t *, m_msg_t *, void *); +int om_snmptrap_close (filed_t *, void *); #endif #ifdef HAVE_QUEUE_OMODULE -int om_directory_init (int, char **, struct filed *, struct global*, void **, char **); -int om_queue_init (int, char **, struct filed *, struct global*, void **, char **); -int om_directory_write (struct filed *, struct m_msg *, void *); -int om_queue_write (struct filed *, struct m_msg *, void *); -int om_directory_flush (struct filed *, void *); -int om_queue_flush (struct filed *, void *); -int om_directory_close (struct filed *, void *); -int om_queue_close (struct filed *, void *); +int om_directory_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_queue_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_directory_write (filed_t *, m_msg_t *, void *); +int om_queue_write (filed_t *, m_msg_t *, void *); +int om_directory_flush (filed_t *, void *); +int om_queue_flush (filed_t *, void *); +int om_directory_close (filed_t *, void *); +int om_queue_close (filed_t *, void *); #endif #ifdef HAVE_REFRACT_OMODULE -int om_refract_init (int, char **, struct filed *, struct global*, void **, char **); -int om_refract_write (struct filed *, struct m_msg *, void *); -int om_refract_flush (struct filed *, void *); -int om_refract_close (struct filed *, void *); +int om_refract_init (int, char **, filed_t *, m_global_t *, void **, char **); +int om_refract_write (filed_t *, m_msg_t *, void *); +int om_refract_flush (filed_t *, void *); +int om_refract_close (filed_t *, void *); #endif #ifdef HAVE_BSD_IMODULE -int im_bsd_init (struct i_module *, char **, int); -int im_bsd_read (struct i_module *, int, struct m_msg *); -int im_bsd_close (struct i_module *); /* close input, optional */ +int im_bsd_init (i_module_t *, char **, int); +int im_bsd_read (i_module_t *, int, m_msg_t *); +int im_bsd_close (i_module_t *); /* close input, optional */ #endif #ifdef HAVE_LINUX_IMODULE -int im_linux_init (struct i_module *, char **, int); -int im_linux_read (struct i_module *, int, struct m_msg *); -int im_linux_close (struct i_module *); /* close input, optional */ +int im_linux_init (i_module_t *, char **, int); +int im_linux_read (i_module_t *, int, m_msg_t *); +int im_linux_close (i_module_t *); /* close input, optional */ #endif #ifdef HAVE_UNIX_IMODULE -int im_unix_init (struct i_module *, char **, int); -int im_unix_read (struct i_module *, int, struct m_msg *); -int im_unix_close (struct i_module *); /* close input, optional */ +int im_unix_init (i_module_t *, char **, int); +int im_unix_read (i_module_t *, int, m_msg_t *); +int im_unix_close (i_module_t *); /* close input, optional */ #endif #ifdef HAVE_STREAMS_IMODULE -int im_streams_init (struct i_module *, char **, int); -int im_streams_read (struct i_module *, int, struct m_msg *); -int im_streams_close (struct i_module *); /* close input, optional */ +int im_streams_init (i_module_t *, char **, int); +int im_streams_read (i_module_t *, int, m_msg_t *); +int im_streams_close (i_module_t *); /* close input, optional */ #endif #ifdef HAVE_SERIAL_IMODULE -int im_serial_init (struct i_module *, char **, int); -int im_serial_read (struct i_module *, int, struct m_msg *); -int im_serial_close (struct i_module *); /* close input, optional */ +int im_serial_init (i_module_t *, char **, int); +int im_serial_read (i_module_t *, int, m_msg_t *); +int im_serial_close (i_module_t *); /* close input, optional */ #endif -int im_file_init (struct i_module *, char **, int); -int im_file_read (struct i_module *, int, struct m_msg *); -int im_file_close (struct i_module *); /* close input, optional */ -int im_file_poll (struct i_module *); -int im_tcp_init (struct i_module *, char **, int); -int im_tcp_read (struct i_module *, int, struct m_msg *); -int im_tcp_close (struct i_module *); /* close input, optional */ -int im_udp_init (struct i_module *, char **, int); -int im_udp_read (struct i_module *, int, struct m_msg *); -int im_udp_close (struct i_module *); /* close input, optional */ +int im_file_init (i_module_t *, char **, int); +int im_file_read (i_module_t *, int, m_msg_t *); +int im_file_close (i_module_t *); /* close input, optional */ +int im_file_poll (i_module_t *); +int im_tcp_init (i_module_t *, char **, int); +int im_tcp_read (i_module_t *, int, m_msg_t *); +int im_tcp_close (i_module_t *); /* close input, optional */ +int im_udp_init (i_module_t *, char **, int); +int im_udp_read (i_module_t *, int, m_msg_t *); +int im_udp_close (i_module_t *); /* close input, optional */ -struct omodule omodules[] = { +omodule_t omodules[] = { { "classic", om_classic_init, om_classic_write, om_classic_flush, om_classic_close }, { "tcp", om_tcp_init, om_tcp_write, NULL, om_tcp_close }, { "udp", om_udp_init, om_udp_write, NULL, om_udp_close }, @@ -181,7 +181,7 @@ { NULL, NULL,NULL,NULL,NULL } }; -struct imodule imodules[] = { +imodule_t imodules[] = { #ifdef HAVE_BSD_IMODULE { "bsd", im_bsd_init, im_bsd_read, im_bsd_close, NULL }, #endif @@ -210,11 +210,11 @@ * 'line' is the command line of the input module */ int -imodule_create(struct i_module *I, char *line) +imodule_create(i_module_t *I, char *line) { int argc, i; char **argv = NULL; - struct i_module *im, *im_prev; + i_module_t *im, *im_prev; int ret = 1; /* create initial node for Inputs list */ @@ -225,8 +225,8 @@ im = im_prev; } else { - if ((im_prev->next = (struct i_module *)calloc(1, - sizeof(struct i_module))) == NULL) { + if ((im_prev->next = (i_module_t *)calloc(1, + sizeof(i_module_t))) == NULL) { m_dprintf(MSYSLOG_SERIOUS, "No memory available for " "calloc\n"); return (-1); @@ -301,12 +301,12 @@ * */ int -omodule_create(char *c, struct filed *f, struct global* global) +omodule_create(char *c, filed_t *f, m_global_t * global) { #define OMODULE_ARGV_MAX 20 char *line, *p, quotes, *argv[OMODULE_ARGV_MAX]; int argc, i; - struct o_module *om, *om_prev; + o_module_t *om, *om_prev; line = strdup(c); quotes = 0; p = line; @@ -314,16 +314,16 @@ /* create context and initialize module for logging */ while (*p) { if (f->omod == NULL) { - f->omod = (struct o_module *) - calloc(1, sizeof(struct o_module)); + f->omod = (o_module_t *) + calloc(1, sizeof(o_module_t)); om = f->omod; om_prev = NULL; } else { for (om_prev = f->omod; om_prev->next; om_prev = om_prev->next); - om_prev->next = (struct o_module *) - calloc(1, sizeof(struct o_module)); + om_prev->next = (o_module_t *) + calloc(1, sizeof(o_module_t)); om = om_prev->next; } Index: modules.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/modules.h,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- modules.h 15 Jun 2003 01:14:22 -0000 1.56 +++ modules.h 16 Jun 2003 19:18:39 -0000 1.57 @@ -57,7 +57,7 @@ void *ctx; /* XXX: remove this */ char *status; -} o_module; +} o_module_t; /* * This structure represents main details for the input modules @@ -71,9 +71,9 @@ int blen; int flags; /* internal module flags */ void *ctx; -} i_module; +} i_module_t; -int watch_fd_input(char, int , i_module *); /* add this fd to poll array */ +int watch_fd_input(char, int , i_module_t *); /* add this fd to poll array */ void unwatch_fd_input(char, int); /* remove this fd from poll arrays */ #endif Index: syslogd.c =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.c,v retrieving revision 1.264 retrieving revision 1.265 diff -u -d -r1.264 -r1.265 --- syslogd.c 5 Jun 2003 16:10:57 -0000 1.264 +++ syslogd.c 16 Jun 2003 19:18:39 -0000 1.265 @@ -156,65 +156,64 @@ * in seconds after previous message is logged. After each flush, * we move to the next interval until we reach the largest. */ -int repeatinterval[] = {30, 120, 600}; /* # of secs before - * flush */ +int repeatinterval[] = {30, 120, 600}; /* # of secs before * flush */ -struct filed *Files; -struct filed consfile; +filed_t *Files; +filed_t consfile; -int Initialized = 0;/* set when we have initialized ourselves */ -int MarkInterval = 20 * 60; /* interval between marks in seconds */ -int MarkSeq = 0; /* mark sequence number */ -int WantDie = 0; -char *ConfFile = _PATH_MSYSLOG_CONF; /* configuration file */ +int Initialized = 0;/* set when we have initialized ourselves */ +int MarkInterval = 20 * 60; /* interval between marks in seconds */ +int MarkSeq = 0; /* mark sequence number */ +int WantDie = 0; +char *ConfFile = _PATH_MSYSLOG_CONF; /* configuration file */ #ifdef _PATH_LOGPID -char *pidfile = _PATH_LOGPID; +char *pidfile = _PATH_LOGPID; #else -char *pidfile = PID_DIR "/" PID_FILE; +char *pidfile = PID_DIR "/" PID_FILE; #endif -FILE *pidf; +FILE *pidf; #define MAX_PIDFILE_LOCK_TRIES 5 -char *ctty = "%classic -t CONSOLE " _PATH_CONSOLE; /* console path */ -int UseConsole = 1; -char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ -int Debug = 0; /* debug flag */ -int DaemonFlags = 0;/* running daemon flags */ -#define SYSLOGD_LOCKED_PIDFILE 0x01 /* pidfile is locked */ -#define SYSLOGD_MARK 0x02 /* call domark() */ -#define SYSLOGD_DIE 0x04 /* call die() */ -#define USE_LOCALDOMAIN 0x08 /* use hostname with local domain */ +char *ctty = "%classic -t CONSOLE " _PATH_CONSOLE; /* console path */ +int UseConsole = 1; +char LocalHostName[MAXHOSTNAMELEN]; /* our hostname */ +int Debug = 0; /* debug flag */ +int DaemonFlags = 0;/* running daemon flags */ +#define SYSLOGD_LOCKED_PIDFILE 0x01 /* pidfile is locked */ +#define SYSLOGD_MARK 0x02 /* call domark() */ +#define SYSLOGD_DIE 0x04 /* call die() */ +#define USE_LOCALDOMAIN 0x08 /* use hostname with local domain */ #define DONT_COLLAPSE 0x10 -char *libdir = NULL; -struct global globals = {NULL, NULL, NULL}; +char *libdir = NULL; +m_global_t globals = {NULL, NULL, NULL}; RETSIGTYPE domark(int); RETSIGTYPE reapchild(int); RETSIGTYPE init(int); RETSIGTYPE signal_handler(int); RETSIGTYPE dodie(int); -void die(int); -int cfline(char *, struct filed *, char *); -int decode(const char *, CODE *); -void markit(void); -void do_log(struct filed *, struct m_msg *); -int parse_lines(struct m_msg *, char *, size_t, int *); -void usage(void); -int imodule_create(struct i_module *, char *); -int omodule_create(char *, struct filed *, struct global *); -void logerror(char *); -void log_msgs(struct m_msg *); -int read_input(struct i_module *, int); +void die(int); +int cfline(char *, filed_t *, char *); +int decode(const char *, CODE *); +void markit(void); +void do_log(filed_t *, m_msg_t *); +int parse_lines(m_msg_t *, char *, size_t, int *); +void usage(void); +int imodule_create(i_module_t *, char *); +int omodule_create(char *, filed_t *, m_global_t *); +void logerror(char *); +void log_msgs(m_msg_t *); +int read_input(i_module_t *, int); -int resolv_domain(char *, int, char *); +int resolv_domain(char *, int, char *); -struct i_module Inputs; +i_module_t Inputs; /* * These three variables work in conjunction "poll_fd" is an array used by @@ -223,17 +222,24 @@ */ struct pollfd *poll_fd = NULL; /* an array of pollfd */ -struct i_module **poll_fd_modules = NULL; /* an array of pointers */ -int poll_fd_cnt = 0; +i_module_t **poll_fd_modules = NULL; /* an array of pointers */ +int poll_fd_cnt = 0; -int *unpoll_fd = NULL; /* an array of pollfd */ -struct i_module **unpoll_fd_modules = NULL; /* an array of pointers */ -int unpoll_fd_cnt = 0; +int *unpoll_fd = NULL; /* an array of pollfd */ +i_module_t **unpoll_fd_modules = NULL; /* an array of pointers */ +int unpoll_fd_cnt = 0; -struct m_msg *msg_list = NULL; +m_msg_t *msg_list = NULL; uint32_t msg_count = 0; uint32_t msg_save_max = 50; +/* fast hex to char conversion, to avoid printf */ +char hex_vals[] = "0123456789abcdef"; /* fijate si lo queres en minusculas */ +#define CONV_BIN2HEX(b,h,l) { \ + l = (hex_vals[b & 0x0f]) ; \ + h = (hex_vals[(b & 0xf0) >> 4]) ; \ + } + /* * main: @@ -246,35 +252,38 @@ #ifndef SIGALTSTACK_WITH_STACK_T struct sigaltstack alt_stack; #else - stack_t alt_stack; + stack_t alt_stack; #endif struct sigaction sa; - int ch; - int argcnt; - int default_inputs = 1; /* start default modules? */ + char *method; + int ch; + int argcnt; + int default_inputs = 1; /* start default modules? */ Inputs.next = NULL; Inputs.fd = -1; + method = "sha1"; + setlinebuf(stdout); /* - * Daemon options - * - * -d -debug <level> - * -i -input [input module name and args] - * -f -conf [configuration file] - * -P -pidfile [pid file] - * -m -markinterval [mark interval seconds] - * -c -noconsole - * -A -uselocaldomain - * -n -nodefault - * -C -nocollapse - * - * legacy options - * -u -unix - * -p -path -a [additional unix input module in /dev/log] - */ + * Daemon options + * + * -d -debug <level> + * -i -input [input module name and args] + * -f -conf [configuration file] + * -P -pidfile [pid file] + * -m -markinterval [mark interval seconds] + * -c -noconsole + * -A -uselocaldomain + * -n -nodefault + * -C -nocollapse + * + * legacy options + * -u -unix + * -p -path -a [additional unix input module in /dev/log] + */ /* * XXX: this should be sorted alphabetically (string and case) @@ -282,9 +291,9 @@ for (argcnt = 1; (ch = getxopt(argc, argv, " d!debug: i!input: " "f!conf: m!markinterval: P!pidfile: c!console A!localdomain " - "n!nodefault C!nocollapse h!help u!udp p!path a!add s!savemsgs:", - &argcnt)) != -1; argcnt++) { - char buf[512]; + "n!nodefault C!nocollapse h!help u!udp p!path a!add s!savemsgs:" + " H!method:", &argcnt)) != -1; argcnt++) { + char buf[512]; switch (ch) { case 'd': /* debug */ @@ -338,6 +347,10 @@ case 'C': DaemonFlags |= DONT_COLLAPSE; break; + case 'H': + method = optarg; + break; + case 's': msg_save_max = strtol(argv[argcnt], NULL, 10); break; @@ -398,7 +411,7 @@ } } if (!Debug) { - int fd; + int fd; /* go daemon and mimic daemon() */ switch (fork()) { @@ -470,8 +483,8 @@ /* took my process id away */ if (!Debug) { struct flock fl; - int lfd, tries, status; - char buf[1024]; + int lfd, tries, status; + char buf[1024]; fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; /* relative to bof */ @@ -562,8 +575,8 @@ * for an event on any of those file descriptors. */ for (;;) { - int count, ix; - int poll_timeout = 5000; /* milliseconds */ + int count, ix; + int poll_timeout = 5000; /* milliseconds */ if (DaemonFlags & SYSLOGD_MARK) markit(); @@ -587,7 +600,7 @@ /* timeout */ case 0: for (ix = 0; ix < unpoll_fd_cnt; ix++) { - struct i_module *current = unpoll_fd_modules[ix]; + i_module_t *current = unpoll_fd_modules[ix]; if (!current) { m_dprintf(MSYSLOG_SERIOUS, "syslogd: " @@ -618,7 +631,7 @@ default: m_dprintf(MSYSLOG_INFORMATIVE, "syslogd: [%d] poll events\n", count); for (ix = 0; ix < poll_fd_cnt || count < 1; ix++) { - struct i_module *current = poll_fd_modules[ix]; + i_module_t *current = poll_fd_modules[ix]; if (!current) { m_dprintf(MSYSLOG_SERIOUS, "syslogd: " @@ -648,10 +661,10 @@ */ int -read_input(struct i_module *im, int listen_fd) +read_input(i_module_t *im, int listen_fd) { - struct m_msg msg; /* avoid need to alloc first msg */ - struct m_msg *m; + m_msg_t msg; /* avoid need to alloc first msg */ + m_msg_t *m; int count; CLEAR_MSG(&msg); @@ -697,7 +710,7 @@ } void -add_host(struct m_msg *m) +add_host(m_msg_t *m) { /* add local host name */ strncpy(m->host, LocalHostName, sizeof (m->host) - 1); @@ -707,7 +720,7 @@ } void -set_date(struct m_msg *m) +set_date(m_msg_t *m) { time_t now; @@ -717,7 +730,7 @@ } void -set_tm(struct m_msg *m) +set_tm(m_msg_t *m) { m->vals[M_VAL_SEC] = m->tm.tm_sec; m->vals[M_VAL_MIN] = m->tm.tm_min; @@ -740,13 +753,13 @@ /* * parse_lines: * Get a sample msg structure, a buf with raw input, - * and parse it. Use as many m_msg structs as needed. + * and parse it. Use as many m_msg_t structs as needed. * Returns chars consumed from buf if messages were found. * Returns -1 if buf was exhausted without messages. */ int -parse_lines(struct m_msg *m, char *buf, size_t blen, int *count) +parse_lines(m_msg_t *m, char *buf, size_t blen, int *count) { char *p, *q; uint32_t fields, flags; @@ -917,7 +930,7 @@ /* are there remaining msgs to be parsed on this buf ? */ if (blen > b) { - /* fetch a new m_msg struct */ + /* fetch a new m_msg_t struct */ if ((m->next = get_mmsg()) == NULL) { m_dprintf(MSYSLOG_SERIOUS, "parse_lines: error getting" @@ -948,10 +961,10 @@ /* * make_log: - * makes simple m_msg and sends it + * makes simple m_msg_t and sends it */ void -make_log(struct m_msg *m, int pri, char *msg, char *host, int flags) +make_log(m_msg_t *m, int pri, char *msg, char *host, int flags) { CLEAR_MSG(m); @@ -994,11 +1007,11 @@ */ void -log_msgs(struct m_msg *m) +log_msgs(m_msg_t *m) { - register struct filed *f; - sigset_t mask, omask; - time_t now; + filed_t *f; + sigset_t mask, omask; + time_t now; sigemptyset(&mask); sigaddset(&mask, SIGALRM); @@ -1007,7 +1020,7 @@ sigprocmask(SIG_BLOCK, &mask, &omask); m_dprintf(MSYSLOG_INFORMATIVE, "log_msgs: pri 0%o, flags 0x%x, from " - "%s, msg %s\n", LOG_MAKEPRI(m->vals[M_VAL_FAC], m->vals[M_VAL_PRI]), + "%s, msg %s\n", LOG_MAKEPRI(m->vals[M_VAL_FAC], m->vals[M_VAL_PRI]), m->flags, m->host, m->msg); /* log the message to the particular outputs */ @@ -1054,8 +1067,8 @@ continue; /* - * suppress duplicate lines to this file - */ + * suppress duplicate lines to this file + */ if (!(DaemonFlags & DONT_COLLAPSE) && !(m->flags & M_FLAG_MARK) && m->mlen == f->prevmsg.mlen && !strcmp(m->msg, f->prevmsg.msg) && @@ -1067,11 +1080,11 @@ (long) (now - f->time), repeatinterval[f->repeatcount]); /* - * If domark would have logged this by now, - * flush it now (so we don't hold isolated messages), - * but back off so we'll flush less often - * in the future. - */ + * If domark would have logged this by now, + * flush it now (so we don't hold isolated messages), + * but back off so we'll flush less often + * in the future. + */ if (now > REPEATTIME(f)) { do_log(f, NULL); BACKOFF(f); @@ -1084,8 +1097,8 @@ do_log(f, NULL); /* - * Start counting again, save host data etc. - */ + * Start counting again, save host data etc. + */ f->prevcount = 0; f->repeatcount = 0; memcpy(&f->prevmsg, m, sizeof (f->prevmsg)); @@ -1104,14 +1117,14 @@ */ void -do_log(struct filed * f, struct m_msg *m) +do_log(filed_t * f, m_msg_t *m) { - struct m_msg repeatmsg; - struct o_module *om; + m_msg_t repeatmsg; + o_module_t *om; int ret; /* - * XXX: avoid m_msg variable + * XXX: avoid m_msg_t variable */ /* save time */ @@ -1143,9 +1156,9 @@ for (om = f->omod; om; om = om->next) { /* - * return code: - * The rule has "fired" if all its modules "fire". - */ + * return code: + * The rule has "fired" if all its modules "fire". + */ ret = (om->func->write) (f, m, om->ctx); @@ -1177,8 +1190,8 @@ RETSIGTYPE reapchild(int signo) { - int status; - int save_errno = errno; + int status; + int save_errno = errno; while (waitpid(-1, &status, WNOHANG) > 0); errno = save_errno; @@ -1199,9 +1212,9 @@ void markit(void) { - struct m_msg m; - struct filed *f; - time_t now; + m_msg_t m; + filed_t *f; + time_t now; time(&now); @@ -1238,8 +1251,8 @@ void logerror(char *type) { - struct m_msg m; - char buf[100]; + m_msg_t m; + char buf[100]; if (errno) snprintf(buf, sizeof(buf), "syslogd: %s: %s", @@ -1256,10 +1269,10 @@ void die(int signo) { - struct filed *f; - int was_initialized = Initialized; - char buf[100]; - struct i_module *im; + filed_t *f; + int was_initialized = Initialized; + char buf[100]; + i_module_t *im; Initialized = 0; /* Don't log SIGCHLDs */ @@ -1285,8 +1298,8 @@ CLOSE_FD(im->fd); if (!Debug && (DaemonFlags == SYSLOGD_LOCKED_PIDFILE)) { - struct flock fl; - int lfd; + struct flock fl; + int lfd; lfd = fileno(pidf); fl.l_type = F_UNLCK; @@ -1309,20 +1322,20 @@ RETSIGTYPE init(int signo) { - struct m_msg m; - int i; - FILE *cf; - struct filed *f, *fnext, **fnextp; - char *p; - char cline[LINE_MAX]; - char prog[NAME_MAX + 1]; - struct o_module *om, *omnext; + m_msg_t m; + FILE *cf; + int i; + filed_t *f, *fnext, **fnextp; + char *p; + char cline[LINE_MAX]; + char prog[NAME_MAX + 1]; + o_module_t *om, *omnext; m_dprintf(MSYSLOG_INFORMATIVE, "init\n"); /* - * Close all open log files. - */ + * Close all open log files. + */ Initialized = 0; @@ -1369,18 +1382,18 @@ /* open the configuration file */ if ((cf = fopen(ConfFile, "r")) == NULL) { m_dprintf(MSYSLOG_SERIOUS, "cannot open config: %s\n", ConfFile); - if ((*fnextp = (struct filed *) calloc(1, sizeof(*f))) + if ((*fnextp = (filed_t *) calloc(1, sizeof(*f))) == NULL) { - m_dprintf(MSYSLOG_CRITICAL, "calloc struct filed"); + m_dprintf(MSYSLOG_CRITICAL, "calloc filed_t"); exit(-1); } if (cfline("*.ERR\t/dev/console", *fnextp, "*") == -1) { m_dprintf(MSYSLOG_CRITICAL, "can't write to console"); exit(-1); } - if (((*fnextp)->next = (struct filed *) calloc(1, sizeof(*f))) + if (((*fnextp)->next = (filed_t *) calloc(1, sizeof(*f))) == NULL) { - m_dprintf(MSYSLOG_CRITICAL, "calloc struct filed"); + m_dprintf(MSYSLOG_CRITICAL, "calloc filed_t"); exit(-1); } if (cfline("*.PANIC\t*", (*fnextp)->next, "*") == -1) { @@ -1391,21 +1404,21 @@ return; } /* - * Foreach line in the conf table, open that file. - */ + * Foreach line in the conf table, open that file. + */ f = NULL; strncpy(prog, "*", 2); prog[sizeof(prog) - 1] = '\0'; while (fgets(cline, sizeof(cline), cf) != NULL) { - int clen; + int clen; /* - * check for end-of-section, comments, strip off trailing - * spaces and newline character. #!prog and !prog are treated - * specially: the following lines apply only to that program. - */ + * check for end-of-section, comments, strip off trailing + * spaces and newline character. #!prog and !prog are treated + * specially: the following lines apply only to that program. + */ for (p = cline; isspace((int) *p); ++p) continue; if (*p == '\0') @@ -1450,8 +1463,8 @@ break; } *p = '\0'; - if ((f = (struct filed *) calloc(1, sizeof(*f))) == NULL) { - m_dprintf(MSYSLOG_CRITICAL, "calloc struct filed"); + if ((f = (filed_t *) calloc(1, sizeof(*f))) == NULL) { + m_dprintf(MSYSLOG_CRITICAL, "calloc filed_t"); exit(-1); } if (cfline(cline, f, prog) == 1) { @@ -1502,13 +1515,13 @@ * Crack a configuration file line */ int -cfline(char *line, struct filed * f, char *prog) +cfline(char *line, filed_t * f, char *prog) { - register int i, j; - int pri, singlpri, ignorepri; - register char *p, *q; - char *bp; - char buf[MAXLINE + 1], ebuf[240]; + char buf[MAXLINE + 1], ebuf[240]; + char *p, *q; + char *bp; + int i, j; + int pri, singlpri, ignorepri; m_dprintf(MSYSLOG_INFORMATIVE, "cfline(\"%s\", f, \"%s\")\n", line, prog); @@ -1581,9 +1594,9 @@ return (-1); } /* - * Heavily modified to fit sysklogd - * This should be done with lex/yacc - */ + * Heavily modified to fit sysklogd + * This should be done with lex/yacc + */ /* scan facilities */ while (*p && !strchr("\t .;", *p)) { for (bp = buf; *p && !strchr("\t ,;.", *p);) @@ -1701,8 +1714,9 @@ int decode(const char *name, CODE * codetab) { - CODE *c; - char *p, buf[40]; + char buf[40]; + CODE *c; + char *p; if (isdigit((int) *name)) return (atoi(name)); @@ -1727,10 +1741,10 @@ /* * decode_name a numeric value to a symbolic name */ -char * +char * decode_val(int val, int codetab) { - CODE *c; + CODE *c; if (codetab == CODE_FACILITY) c = facilitynames; @@ -1752,11 +1766,11 @@ * grow by 50 * * params: fd file descriptor to watch - * im module functions and more + * im module functions and more */ int -watch_fd_input(char type, int fd, struct i_module * im) +watch_fd_input(char type, int fd, i_module_t * im) { if (fd < 0 || im == NULL) { m_dprintf(MSYSLOG_INFORMATIVE, "watch_fd_input: error on params" @@ -1781,9 +1795,9 @@ m_dprintf(MSYSLOG_CRITICAL, "realloc inputs: poll fd"); exit(-1); } - if ((poll_fd_modules = (struct i_module **) realloc( + if ((poll_fd_modules = (i_module_t **) realloc( poll_fd_modules, - (size_t) (poll_fd_cnt + 50) * sizeof(struct i_module *) + (size_t) (poll_fd_cnt + 50) * sizeof(i_module_t *) )) == NULL) { m_dprintf(MSYSLOG_CRITICAL, "realloc inputs: input modules"); exit(-1); @@ -1807,9 +1821,9 @@ m_dprintf(MSYSLOG_CRITICAL, "realloc inputs: unpoll fd"); exit(-1); } - if ((unpoll_fd_modules = (struct i_module **) realloc( + if ((unpoll_fd_modules = (i_module_t **) realloc( unpoll_fd_modules, - (size_t) (unpoll_fd_cnt + 50) * sizeof(struct i_module *) + (size_t) (unpoll_fd_cnt + 50) * sizeof(i_module_t *) )) == NULL) { m_dprintf(MSYSLOG_CRITICAL, "realloc inputs: input modules"); exit(-1); @@ -1827,7 +1841,7 @@ void unwatch_fd_input(char type, int fd) { - int ix; + int ix; m_dprintf(MSYSLOG_INFORMATIVE, "unwatch_fd_input: remove fd %d\n", fd); @@ -1906,8 +1920,8 @@ int m_dprintf(const int level, char const * fmt,...) { - int ret; - va_list var; + int ret; + va_list var; if (level >= Debug) return (1); @@ -1924,14 +1938,14 @@ * take a msg struct from available list, else alloc */ -struct m_msg * +m_msg_t * get_mmsg(void) { - struct m_msg *m; + m_msg_t *m; if (msg_list == NULL) { - m = (struct m_msg *) malloc(sizeof (*m)); + m = (m_msg_t *) malloc(sizeof (*m)); } else { @@ -1948,14 +1962,14 @@ /* * dispose_msgs - * Dispose struct m_msg + * Dispose m_msg_t * keep some on a list to avid constant alloc/free */ void -dispose_msgs(struct m_msg *msgs) +dispose_msgs(m_msg_t *msgs) { - struct m_msg *m; + m_msg_t *m; if (msgs == NULL) return; Index: syslogd.h =================================================================== RCS file: /cvsroot/msyslog/syslog/src/syslogd.h,v retrieving revision 1.124 retrieving revision 1.125 diff -u -d -r1.124 -r1.125 --- syslogd.h 15 Jun 2003 01:14:22 -0000 1.124 +++ syslogd.h 16 Jun 2003 19:18:39 -0000 1.125 @@ -203,7 +203,7 @@ uint32_t hlen; /* host length */ uint32_t plen; /* program (name) length */ uint32_t ulen; /* user (name) length */ -} m_msg; +} m_msg_t; #define CLEAR_MSG(m) { (m)->next = NULL; (m)->fields = 0; (m)->flags = 0; \ (m)->msg[0] = '\0'; (m)->host[0] = '\0'; \ @@ -217,9 +217,9 @@ } } -m_msg *get_mmsg(void); -void dispose_msgs(m_msg *); -int parse_lines(m_msg *, char *, size_t, int *); +m_msg_t *get_mmsg(void); +void dispose_msgs(m_msg_t *); +int parse_lines(m_msg_t *, char *, size_t, int *); /* * This structure represents the line rules @@ -234,17 +234,17 @@ u_short pmask[LOG_NFACILITIES+1]; /* priority mask */ char program[MAX_PROGNAME_SIZE]; /* program name */ /* XXX: this should be some short hash instead */ - m_msg prevmsg; /* last message logged */ + m_msg_t prevmsg; /* last message logged */ int prevcount; /* repetition cnt of prevline */ int repeatcount; /* number of "repeated" msgs */ - o_module *omod; /* module details */ -} filed; + o_module_t *omod; /* module details */ +} filed_t; typedef struct m_global { char *prog; /* program name */ char *FileListing; /* File Listing */ FILE *flist_des; /* File Listing descriptor */ -} m_global; +} m_global_t; void logerror(char *); void logmsg(int, char *, char *, int); @@ -256,19 +256,19 @@ typedef struct omodule { char *name; - int (*init) (int, char **, filed *, m_ global *, void **, char **); - int (*write) (filed *, m_msg *, void *); - int (*flush) (filed *, void *); - int (*close) (filed *, void *); -} omodule; + int (*init) (int, char **, filed_t *, m_global_t *, void **, char **); + int (*write) (filed_t *, m_msg_t *, void *); + int (*flush) (filed_t *, void *); + int (*close) (filed_t *, void *); +} omodule_t; typedef struct imodule { char *name; - int (*init) (i_module *, char **, int); - int (*read) (i_module *, int, m_msg *); - int (*close) (i_module *); /* close input, optional */ - int (*poll) (i_module *); -} imodule; + int (*init) (i_module_t *, char **, int); + int (*read) (i_module_t *, int, m_msg_t *); + int (*close) (i_module_t *); /* close input, optional */ + int (*poll) (i_module_t *); +} imodule_t; #define MAXREPEAT ((sizeof(repeatinterval) / sizeof(repeatinterval[0])) - 1) @@ -332,7 +332,7 @@ typedef struct _code { char *c_name; int c_val; -} CODE; +} CODE_t; CODE prioritynames[] = { |