From fea1356c5e3651dac98b6e505901983e9d02ce01 Mon Sep 17 00:00:00 2001 From: yaworsky Date: Mon, 24 Oct 2005 12:55:16 +0000 Subject: Prepared for various destination types. --- daemon/syslogd.h | 112 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 46 deletions(-) (limited to 'daemon/syslogd.h') diff --git a/daemon/syslogd.h b/daemon/syslogd.h index 65dc042..8919ede 100644 --- a/daemon/syslogd.h +++ b/daemon/syslogd.h @@ -51,6 +51,43 @@ extern gchar *mark_message; extern int hold; extern gchar *logdir; +/* listener */ +enum listener_status +{ + LSNR_ERROR, + LSNR_SHUTDOWN, + LSNR_GOT_MESSAGE +}; + +struct raw_message +{ + gchar *msg; + struct sockaddr_in sender_addr; + struct source *source; +}; + +extern gboolean init_listener(); +extern void fini_listener(); +extern enum listener_status listener( struct raw_message** msg ); +extern void log_internal( int pri, char* fmt, ... ); + +/* message */ +struct message +{ + LONG refcount; + struct source *source; + gchar *sender; + int facility; + int priority; + gchar *timestamp; + gchar *hostname; + gchar *program; + gchar *message; +}; + +extern void reference_message( struct message* msg ); +extern void release_message( struct message* msg ); + /* sources, destinations, filters and logpaths */ enum source_type { @@ -66,6 +103,12 @@ struct source struct sockaddr_in udp; }; +enum destination_type +{ + DT_UNDEFINED, + DT_FILE +}; + enum rotation_period { RP_UNDEFINED = 0, @@ -75,12 +118,9 @@ enum rotation_period RP_MONTHLY }; -struct destination +struct destination_file { - gchar *name; - gchar *file; - GList *file_writers; - CRITICAL_SECTION cs_file_writers; + gchar *name_pattern; enum rotation_period rotate; int size; int backlogs; @@ -90,6 +130,25 @@ struct destination gchar *compressoptions; }; +struct destination; + +typedef void (*dest_put)( struct destination* destination, struct message* message ); +typedef void (*dest_finalize)( struct destination* destination ); + +struct destination +{ + gchar *name; + enum destination_type type; + union + { + struct destination_file file; + } u; + void *extra; + /* methods */ + dest_put put; + dest_finalize fini; +}; + struct filter { gchar *name; @@ -111,6 +170,8 @@ extern GList *logpaths; extern gboolean read_configuration(); +extern gboolean init_destination_file( struct destination* destination ); + /* queue */ struct fifo_item { @@ -129,47 +190,6 @@ extern void fifo_destroy( struct fifo* queue ); extern void fifo_push( struct fifo* queue, void* data ); extern void* fifo_pop( struct fifo* queue ); -/* listener */ -enum listener_status -{ - LSNR_ERROR, - LSNR_SHUTDOWN, - LSNR_GOT_MESSAGE -}; - -struct raw_message -{ - gchar *msg; - struct sockaddr_in sender_addr; - struct source *source; -}; - -extern gboolean init_listener(); -extern void fini_listener(); -extern enum listener_status listener( struct raw_message** msg ); -extern void log_internal( int pri, char* fmt, ... ); - -/* message */ -struct message -{ - LONG refcount; - struct source *source; - gchar *sender; - int facility; - int priority; - gchar *timestamp; - gchar *hostname; - gchar *program; - gchar *message; -}; - -extern void reference_message( struct message* msg ); -extern void release_message( struct message* msg ); - -/* writer */ -extern void fini_writer(); -extern void write_message( struct message* msg, struct destination* destination ); - /* logrotate */ extern void rotate_logfile( const gchar* pathname, struct destination* destination ); -- cgit v1.2.3