diff options
author | Dmitri Pal <dpal@redhat.com> | 2009-02-24 13:52:53 -0500 |
---|---|---|
committer | Dmitri Pal <dpal@redhat.com> | 2009-02-24 13:52:53 -0500 |
commit | 27d15caafe401160fcc62829a3460a52cd45d429 (patch) | |
tree | fb86574351e262937355b48959c9ca73889fae0d | |
parent | ef8d8570dcf44d723868df339223b132b19121c3 (diff) | |
download | elapi_draft-27d15caafe401160fcc62829a3460a52cd45d429.tar.gz elapi_draft-27d15caafe401160fcc62829a3460a52cd45d429.tar.xz elapi_draft-27d15caafe401160fcc62829a3460a52cd45d429.zip |
Adding missed commits.
-rw-r--r-- | Makefile.am | 3 | ||||
-rw-r--r-- | collection/Makefile.am | 10 | ||||
-rw-r--r-- | collection/elapi_collection_ut.c | 3 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | ini/elapi_ini.c | 4 | ||||
-rw-r--r-- | ini/elapi_ini.h | 3 | ||||
-rw-r--r-- | sinks/syslog/elapi_sink_syslog.c | 59 |
7 files changed, 54 insertions, 43 deletions
diff --git a/Makefile.am b/Makefile.am index 3d99c97..087fb4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,2 +1 @@ -#SUBDIRS = collection dispatcher ini tools sinks -SUBDIRS = tools collection +SUBDIRS = collection ini sinks dispatcher diff --git a/collection/Makefile.am b/collection/Makefile.am index 6c33534..3cad327 100644 --- a/collection/Makefile.am +++ b/collection/Makefile.am @@ -1,6 +1,10 @@ -lib_LIBRARIES = libelapi_collection.a -libelapi_collection_a_SOURCES = elapi_collection.c elapi_util.c +DEBUG_FLAGS=@DEBUG_VAR@ + +AM_CPPFLAGS = -I/usr/include/libxml2 $(DEBUG_FLAGS) +topdir=.. +noinst_LIBRARIES = libelapi_collection.a +libelapi_collection_a_SOURCES = elapi_collection.c elapi_util.c elapi_tools.c elapi_collection.h elapi_util.h elapi_debug.h elapi_tools.h noinst_PROGRAMS = elapi_collection_ut elapi_collection_ut_SOURCES = elapi_collection_ut.c -elapi_collection_ut_LDADD = libelapi_collection.a -lm -lz -lxml2 libelapi_tools.a +elapi_collection_ut_LDADD = libelapi_collection.a -lm -lz -lxml2 diff --git a/collection/elapi_collection_ut.c b/collection/elapi_collection_ut.c index 9ee5261..a7f55d5 100644 --- a/collection/elapi_collection_ut.c +++ b/collection/elapi_collection_ut.c @@ -483,8 +483,7 @@ int mixed_collection_test() /* Some negative tests */ /* Can't add attributes to the referenced collection */ error = add_int_property(event,"host","session",500); - if(error == 0) printf("Error was able to add property to referenced collection.\n"); - printf("Expected error %d\n",error); + if(error != 0) printf("Error was NOT able to add property to a referenced collection.\n"); printf("Attempt to delete non-existent property.\n"); diff --git a/configure.ac b/configure.ac index 26350f2..a71ec1f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,20 @@ AC_INIT([elapi], [0.0], [dpal@redhat.com]) AC_CONFIG_SRCDIR([collection/elapi_collection.c]) +AC_CONFIG_AUX_DIR([build]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC -AC_PROG_RANLIB -#AC_PROG_LIBTOOL +AC_PROG_LIBTOOL #AM_GNU_GETTEXT([external]) AC_PROG_INSTALL AC_CONFIG_HEADERS([config.h]) -#AC_CONFIG_FILES([Makefile collection/Makefile dispatcher/Makefile ini/Makefile tools/Makefile sinks/Makefile sinks/stderr/Makefile sinks/syslog/Makefile]) -AC_CONFIG_FILES([Makefile tools/Makefile collection/Makefile]) +DEBUG_VAR= +AC_ARG_ENABLE([debug],[AS_HELP_STRING([--enable-debug],[enable debug build])],[],[debug_build=no]) +AS_IF([test "x$debug_build" != xno],[AC_SUBST([DEBUG_VAR],[-DELAPI_LOG_DEBUG])]) + +AC_CONFIG_FILES([Makefile collection/Makefile ini/Makefile sinks/Makefile sinks/stderr/Makefile sinks/syslog/Makefile dispatcher/Makefile ]) AC_OUTPUT + + + + diff --git a/ini/elapi_ini.c b/ini/elapi_ini.c index acea402..ed6b4c7 100644 --- a/ini/elapi_ini.c +++ b/ini/elapi_ini.c @@ -590,14 +590,12 @@ int get_value_from_config(void *value, int type, char *section, char *name, - struct collection_item *ini_config, - int &found) + struct collection_item *ini_config) { int error = EOK; struct collection_item *section_handle = (struct collection_item *)(NULL); char *to_find; char default_section[] = INI_DEFAULT_SECTION; - struct val_extruct pass_in; DEBUG_STRING("get_value_from_config", "Entry"); diff --git a/ini/elapi_ini.h b/ini/elapi_ini.h index 450105b..10460f7 100644 --- a/ini/elapi_ini.h +++ b/ini/elapi_ini.h @@ -19,8 +19,7 @@ int get_value_from_config(void *value, /* Pointer to th int type, /* Expected type of the result */ char *section, /* Section to search in */ char *name, /* Value to look for */ - struct collection_item *ini_config, /* Config handle */ - int *found); /* Will update the provided location with 1 in the property was found. */ + struct collection_item *ini_config); /* Config handle */ /* read ini file and create collection out of it factoring in the env variables */ /* int ini_to_collection_env(char *filename, struct collection_item **ini_config, char *ENV prefix); */ diff --git a/sinks/syslog/elapi_sink_syslog.c b/sinks/syslog/elapi_sink_syslog.c index d3a669d..cd20597 100644 --- a/sinks/syslog/elapi_sink_syslog.c +++ b/sinks/syslog/elapi_sink_syslog.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <errno.h> #include <malloc.h> +#include <syslog.h> #include "elapi_sink.h" #include "elapi_collection.h" #include "elapi_debug.h" @@ -11,12 +12,12 @@ /* FIXME - this should be taken from the config.h generated by autotools */ #define SYSLOG_RETRY 60 -#define syslog_audit_config "/home/dpal/IPA/Code/elapi/etc/syslog_defaults.conf" -#define syslog_audit_dir "/home/dpal/IPA/Code/elapi/etc/syslog_defaults.d" +#define syslog_audit_config "/etc/elapi/syslog_defaults.conf" +#define syslog_audit_dir "/etc/elapi/syslog_defaults.d" /* FIXME there is currently no code * to make sure we do not call syslog functions from multiple dispatchers. - * We probably should create a mutext at the load of the library and + * We probably should create a mutex at the load of the library and * set a flag when the init function is called the first time * and not call the openlog any more times. * But I guess syslog can deal with this internally. @@ -26,11 +27,11 @@ struct syslog_event { struct serial_data sd; int priority; -} +}; /* Default conmfiguration for syslog */ -struct syslog_config { +struct syslog_conf { int option; int facility; int level; @@ -47,11 +48,12 @@ static int init_config(struct data_descriptor *dblock) int *facility_cfg = (int *)(NULL); int *level_cfg = (int *)(NULL); char *ident_cfg = NULL; + int error; DEBUG_STRING("init_config","Entry"); /* Allocate configuration data */ - conf_data = (struct syslog_conf *)(malloc(sizeof(struct syslog_config))); + conf_data = (struct syslog_conf *)(malloc(sizeof(struct syslog_conf))); if(conf_data == (struct syslog_conf *)(NULL)) return errno; /* Read configuration from the configuration file if any */ @@ -68,7 +70,7 @@ static int init_config(struct data_descriptor *dblock) DEBUG_STRING("Identity",conf_data->ident); /* Update defaults with settings from the file */ - error = get_value_from_config((void *)(&option_cfg),ELAPI_TYPE_INT, INI_DEFAULT_SECTION,"option",file_config); + error = get_value_from_config((void *)(&option_cfg),ELAPI_TYPE_INTEGER, INI_DEFAULT_SECTION,"option",file_config); if(error != EOK) { /* There is fundamentally something wrong */ DEBUG_NUMBER("Attempt to get option returned error",error); @@ -78,10 +80,10 @@ static int init_config(struct data_descriptor *dblock) /* Get the value */ if(option_cfg != (int *)(NULL)) { conf_data->option = *option_cfg; - free((void *)(option_cfg); + free((void *)(option_cfg)); } - error = get_value_from_config((void *)(&facility_cfg),ELAPI_TYPE_INT, INI_DEFAULT_SECTION,"facility",file_config); + error = get_value_from_config((void *)(&facility_cfg),ELAPI_TYPE_INTEGER, INI_DEFAULT_SECTION,"facility",file_config); if(error != EOK) { /* There is fundamentally something wrong */ DEBUG_NUMBER("Attempt to get option returned error",error); @@ -91,10 +93,10 @@ static int init_config(struct data_descriptor *dblock) /* Get the value */ if(facility_cfg != (int *)(NULL)) { conf_data->facility = *facility_cfg; - free((void *)(facility_cfg); + free((void *)(facility_cfg)); } - error = get_value_from_config((void *)(&level_cfg),ELAPI_TYPE_INT, INI_DEFAULT_SECTION,"level",file_config); + error = get_value_from_config((void *)(&level_cfg),ELAPI_TYPE_INTEGER, INI_DEFAULT_SECTION,"level",file_config); if(error != EOK) { /* There is fundamentally something wrong */ DEBUG_NUMBER("Attempt to get option returned error",error); @@ -104,7 +106,7 @@ static int init_config(struct data_descriptor *dblock) /* Get the value */ if(level_cfg != (int *)(NULL)) { conf_data->level = *level_cfg; - free((void *)(level_cfg); + free((void *)(level_cfg)); } error = get_value_from_config((void *)(&ident_cfg),ELAPI_TYPE_STRING, INI_DEFAULT_SECTION,"identity",file_config); @@ -116,8 +118,7 @@ static int init_config(struct data_descriptor *dblock) /* Get the value */ if(ident_cfg != (char *)(NULL)) { - conf_data->ident = *ident_cfg; - free((void *)(ident_cfg); + conf_data->ident = ident_cfg; } @@ -157,7 +158,7 @@ static int syslog_sink_init(struct data_descriptor *dblock) dblock->internal_data = (void *)(event_storage); /* Prepare the configuration data block */ - if((error = init_config(dblock)) { + if((error = init_config(dblock))) { DEBUG_NUMBER("Failed to init config",error); free(dblock->internal_data); dblock->internal_data = NULL; @@ -176,7 +177,7 @@ static int syslog_sink_init(struct data_descriptor *dblock) static int syslog_sink_format(struct data_descriptor *dblock,struct collection_item *event) { struct syslog_event *event_storage; - struct syslog_config *config; + struct syslog_conf *config; int error = EOK; @@ -184,8 +185,8 @@ static int syslog_sink_format(struct data_descriptor *dblock,struct collection_i DEBUG_NUMBER("DBLOCK in format",dblock); DEBUG_NUMBER("internal data in format",dblock->internal_data); - event_storage = (struct event_storage *)(dblock->internal_data); - config = (struct event_storage *)(dblock->config); + event_storage = (struct syslog_event *)(dblock->internal_data); + config = (struct syslog_conf *)(dblock->config); event_storage->priority = config->level | config->facility; @@ -195,7 +196,7 @@ static int syslog_sink_format(struct data_descriptor *dblock,struct collection_i /* Traverse collection */ - error = traverse_collection(event,ELAPI_TRAVERSE_DEFAULT | ELAPI_TRAVERSE_END ,serialize,(void *)(event_storage->sd)); + error = traverse_collection(event,ELAPI_TRAVERSE_DEFAULT | ELAPI_TRAVERSE_END ,serialize,(void *)(&(event_storage->sd))); if(error) { DEBUG_NUMBER("traverse_collection returned error",error); return error; @@ -210,12 +211,12 @@ static int syslog_sink_format(struct data_descriptor *dblock,struct collection_i static void syslog_sink_cleanup(struct data_descriptor *dblock) { struct syslog_event *event_storage; - struct syslog_config *config; + struct syslog_conf *config; DEBUG_STRING("syslog_sink_cleanup","Entry"); - event_storage = (struct event_storage *)(dblock->internal_data); - config = (struct event_storage *)(dblock->config); + event_storage = (struct syslog_event *)(dblock->internal_data); + config = (struct syslog_conf *)(dblock->config); if(event_storage->sd.buffer != NULL) { free(event_storage->sd.buffer); @@ -232,11 +233,15 @@ static void syslog_sink_cleanup(struct data_descriptor *dblock) /* Close facility */ static void syslog_sink_close(struct data_descriptor *dblock) { + struct syslog_conf *config; + DEBUG_STRING("syslog_sink_close","Entry"); if(dblock->internal_data != NULL) { syslog_sink_cleanup(dblock); free(dblock->internal_data); + config = (struct syslog_conf *)(dblock->config); + if(config->ident != NULL) free(config->ident); free(dblock->config); dblock->internal_data=NULL; dblock->config=NULL; @@ -251,18 +256,18 @@ static void syslog_sink_close(struct data_descriptor *dblock) static int syslog_sink_submit(struct data_descriptor *dblock) { struct syslog_event *event_storage; - struct syslog_config *config; + struct syslog_conf *config; DEBUG_STRING("syslog_sink_submit","Entry"); DEBUG_NUMBER("DBLOCK in submit",dblock); DEBUG_NUMBER("internal data in submit",dblock->internal_data); - event_storage = (struct serial_data *)(dblock->internal_data); - config = (struct event_storage *)(dblock->config); + event_storage = (struct syslog_event *)(dblock->internal_data); + config = (struct syslog_conf *)(dblock->config); - DEBUG_STRING("OUTPUT:",event_storage->db.buffer); + DEBUG_STRING("OUTPUT:",event_storage->sd.buffer); - fprintf(stderr,"%s %d %s\n",config->ident, event_storage->priority, event_storage->db.buffer); + fprintf(stderr,"%s %d %s\n",config->ident, event_storage->priority, event_storage->sd.buffer); syslog_sink_cleanup(dblock); |