summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-02-26 19:13:29 -0500
committerDmitri Pal <dpal@redhat.com>2009-02-26 19:13:29 -0500
commit15f299ca2e6902cb4ba784f5923cf910f96173a8 (patch)
tree41de0babf5ea48137738b40057969c51be587da6
parentc20626a18afc1545f1fbc58907529ba743bb0843 (diff)
downloadelapi_draft-15f299ca2e6902cb4ba784f5923cf910f96173a8.tar.gz
elapi_draft-15f299ca2e6902cb4ba784f5923cf910f96173a8.tar.xz
elapi_draft-15f299ca2e6902cb4ba784f5923cf910f96173a8.zip
Testing complete. High level API works.
-rw-r--r--collection/elapi_collection.c16
-rw-r--r--collection/elapi_util.c88
-rw-r--r--dispatcher/elapi_api.c4
-rw-r--r--dispatcher/elapi_dispatcher.c2
-rw-r--r--dispatcher/elapi_dispatcher_ut.c63
-rw-r--r--etc/file_defaults.d/my_app1.conf2
-rw-r--r--etc/file_defaults.d/my_app2.conf2
-rw-r--r--sinks/file/elapi_sink_file.c28
-rw-r--r--sinks/syslog/elapi_sink_syslog.c2
9 files changed, 130 insertions, 77 deletions
diff --git a/collection/elapi_collection.c b/collection/elapi_collection.c
index 7045130..8d28eed 100644
--- a/collection/elapi_collection.c
+++ b/collection/elapi_collection.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
+#include <time.h>
#include "elapi_collection.h"
#include "elapi_debug.h"
@@ -37,7 +38,7 @@
/* Potential subjest for management with libtools */
-#define DATE_FORMAT "%+"
+#define DATE_FORMAT "%c"
#define TIME_ARRAY_SIZE 100
@@ -1334,20 +1335,23 @@ int set_timestamp(struct collection_item *ci,struct collection_item **timestr_re
int len;
struct collection_item *timestr = (struct collection_item *)(NULL);
struct collection_item *timeint = (struct collection_item *)(NULL);
+ int error = EOK;
DEBUG_STRING("set_timestamp","Entry point");
utctime = time(NULL);
localtime_r(&utctime,&time_struct);
- len = strftime(time_array, TIME_ARRAY_SIZE, date_format, &time_struct);
+ len = strftime(time_array, TIME_ARRAY_SIZE, DATE_FORMAT, &time_struct);
if(len == 0) {
DEBUG_STRING("add_time","CODING ERROR - INCREASE THE BUFFER");
return EMSGSIZE;
}
+ DEBUG_STRING("Timestamp:",time_array);
+
/* Check if we have the timestamp item already */
- error = get_item(event, TS_NAME, ELAPI_TYPE_STRING,ELAPI_TRAVERSE_IGNORE,&timestr);
+ error = get_item(ci, TS_NAME, ELAPI_TYPE_STRING,ELAPI_TRAVERSE_IGNORE,&timestr);
if(error) {
DEBUG_NUMBER("search failed with error:",error);
return error;
@@ -1366,7 +1370,7 @@ int set_timestamp(struct collection_item *ci,struct collection_item **timestr_re
}
else {
/* Add timestamp to the collection */
- error = add_str_property_with_ref(event,NULL, TS_NAME,time_array,len+1,timestr_ref);
+ error = add_str_property_with_ref(ci,NULL, TS_NAME,time_array,len+1,timestr_ref);
if(error) {
DEBUG_NUMBER("failed to add timestamp property:",error);
return error;
@@ -1374,7 +1378,7 @@ int set_timestamp(struct collection_item *ci,struct collection_item **timestr_re
}
/* Check if we have the time item already */
- error = get_item(event, T_NAME, ELAPI_TYPE_INTEGER,ELAPI_TRAVERSE_IGNORE,&timeint);
+ error = get_item(ci, T_NAME, ELAPI_TYPE_INTEGER,ELAPI_TRAVERSE_IGNORE,&timeint);
if(error) {
DEBUG_NUMBER("search failed with error:",error);
return error;
@@ -1387,7 +1391,7 @@ int set_timestamp(struct collection_item *ci,struct collection_item **timestr_re
}
else {
/* Add time to the collection */
- error = add_int_property_with_ref(event,NULL, T_NAME,utctime,timeint_ref);
+ error = add_int_property_with_ref(ci,NULL, T_NAME,utctime,timeint_ref);
if(error) {
DEBUG_NUMBER("failed to add time property:",error);
return error;
diff --git a/collection/elapi_util.c b/collection/elapi_util.c
index b5fbf59..09c99a6 100644
--- a/collection/elapi_util.c
+++ b/collection/elapi_util.c
@@ -26,6 +26,9 @@
#include "elapi_debug.h"
#include "elapi_util.h"
+#ifndef MAX
+#define MAX(a,b) a > b ? a : b
+#endif
/* Internal defines used in different places */
#define UNKNOWN "<unknown:>"
@@ -541,8 +544,10 @@ static int extract_item(char *start,
int *index)
{
char *end;
+ int error = EOK;
DEBUG_STRING("extract_item","Entry point");
+ DEBUG_STRING("Start:",start);
start++;
end = start;
@@ -550,6 +555,9 @@ static int extract_item(char *start,
if(*end == '\0') return EINVAL;
+ DEBUG_STRING("End:",end);
+ DEBUG_NUMBER("Length:",end-start);
+
*end = '\0';
error = get_item(event,start,ELAPI_TYPE_ANY,
ELAPI_TRAVERSE_DEFAULT,item);
@@ -581,6 +589,7 @@ int sprintf_item(struct serial_data *data,
DEBUG_NUMBER("Buffer len: ", data->length);
DEBUG_NUMBER("Buffer size: ", data->size);
DEBUG_STRING("Buffer: ", data->buffer);
+ DEBUG_STRING("Using format: ", one_format);
if(one_format!=NULL) len_format = strlen(one_format);
@@ -594,15 +603,15 @@ int sprintf_item(struct serial_data *data,
data->length++;
for(i=0;i<item->length;i++) sprintf(data->buffer+data->length+i*2,"%02X",*((unsigned char *)(item->data+i)));
data->length+=item->length*2;
- *(buf_data->buffer+buf_data->length) = '\'';
- buf_data->length++
- *(buf_data->buffer+buf_data->length) = '\0';
+ *(data->buffer+data->length) = '\'';
+ data->length++;
+ *(data->buffer+data->length) = '\0';
}
else {
/* For other types use a version of sprintf, but determine format first */
switch(item->type) {
- case ELAPI_TYPE_STRING: if((len_format > 0) && (*(one_format+len_format-1) == 's') fmt=one_format;
+ case ELAPI_TYPE_STRING: if((len_format > 0) && (*(one_format+len_format-1) == 's')) fmt=one_format;
else fmt = formats[FMT_STRING];
break;
case ELAPI_TYPE_INTEGER: if((len_format > 0) && (*(one_format+len_format-1) != 's')) fmt=one_format;
@@ -638,8 +647,8 @@ int sprintf_item(struct serial_data *data,
return EOK;
}
- start = buf_data->buffer+buf_data->length;
- block = buf_data->size-buf_data->length-1;
+ start = data->buffer+data->length;
+ block = data->size-data->length-1;
while (1) {
switch(item->type) {
@@ -666,21 +675,24 @@ int sprintf_item(struct serial_data *data,
return EOK;
}
+ DEBUG_NUMBER("snprintf returned:",len);
/* Did it fit? */
if (len > -1 && len < block) break;
/* Else try again with more space. Based on printf example. */
- if (len > -1) block = MAX(n+1,BLOCK_SIZE);
+ if (len > -1) block = MAX(len+1,BLOCK_SIZE);
else block = MAX(block *2,BLOCK_SIZE);
+ DEBUG_NUMBER("Need to gorw by:",block);
+
if((error=grow_buffer(data,block))) return error;
}
/* Adjust length */
- buf_data->length+=len;
- *(buf_data->buffer+buf_data->length) = '\0';
+ data->length+=len;
+ *(data->buffer+data->length) = '\0';
}
- DEBUG_STRING("Data: ",buf_data->buffer);
+ DEBUG_STRING("Data: ",data->buffer);
DEBUG_STRING("sprintf_item","Exit point");
return EOK;
@@ -691,7 +703,8 @@ int sprintf_item(struct serial_data *data,
static int add_time(struct serial_data *data,
struct collection_item *event)
{
- struct collection_item *timestamp;
+ struct collection_item *timestamp = (struct collection_item *)(NULL);
+ int error = EOK;
DEBUG_STRING("add_time","Entry point");
@@ -723,6 +736,7 @@ static int process_item(struct serial_data *data,
char *end;
int block;
struct collection_item *item = (struct collection_item *)(NULL);
+ int error = EOK;
DEBUG_STRING("process_item","Entry point");
@@ -757,7 +771,7 @@ static int process_item(struct serial_data *data,
}
/* Then put the piece we could not find */
- error = put_marker(data,start+1,*index-(start-format_str)-2);
+ error = put_marker(data,start+1,*index-(start-format_str)-1);
}
if(error) {
DEBUG_NUMBER("put_marker/add_time returned error:",error);
@@ -796,6 +810,12 @@ int serialize_with_format(struct collection_item *event,
int i=0;
char *one_format;
int brk;
+ char *start;
+ char *end;
+ int block;
+ int error = EOK;
+ int len;
+ char *dup;
DEBUG_STRING("serialize_with_format","Entry point");
@@ -810,19 +830,32 @@ int serialize_with_format(struct collection_item *event,
data->size = BLOCK_SIZE;
data->length = 0;
+ /* Create a copy so we can change it if needed */
+ len = strlen(format_str);
+ errno = 0;
+ dup = malloc(len+1);
+ if(dup == NULL) {
+ DEBUG_NUMBER("Out of memory",errno);
+ free(data->buffer);
+ data->buffer=NULL;
+ return ENOMEM;
+ }
+ memcpy(dup,format_str,len+1);
+
/* Create buffer for format specifier */
errno = 0;
one_format = malloc(len+1);
if(one_format == NULL) {
DEBUG_NUMBER("Out of memory",errno);
- free(data->buffer);
+ free(data->buffer);
+ free(dup);
data->buffer=NULL;
return ENOMEM;
}
while(1) {
/* Copy characters directly into output */
- start = format_str+i;
+ start = dup+i;
end = start;
block = 0;
while((*end != '%') && (*end != '\0')) end++;
@@ -835,6 +868,7 @@ int serialize_with_format(struct collection_item *event,
free(data->buffer);
data->buffer=NULL;
free(one_format);
+ free(dup);
return ENOMEM;
}
}
@@ -845,33 +879,35 @@ int serialize_with_format(struct collection_item *event,
i+=block+1;
/* Here we are at the beginning of the string after % */
- DEBUG_STRING("Format after %:",format_str+i);
+ DEBUG_STRING("Format after %:",dup+i);
/* Handle special case */
- if(*(format_str+i) == '%') {
+ if(*(dup+i) == '%') {
error = put_marker(data,"%",1);
if(error) {
DEBUG_NUMBER("put_marker returned error:",error);
free(data->buffer);
data->buffer=NULL;
free(one_format);
+ free(dup);
return error;
}
i++;
- DEBUG_STRING("Format after processing %%:",format_str+i);
+ DEBUG_STRING("Format after processing %%:",dup+i);
continue;
}
/* We are here in case there is a real format token */
- if(*(format_str+i) == '(') {
+ if(*(dup+i) == '(') {
/* This is our special case when we have a event item specifier () */
brk = 0;
- error = process_item(data,format_str,&i,event,NULL,&brk);
+ error = process_item(data,dup,&i,event,NULL,&brk);
if(error) {
DEBUG_NUMBER("put_marker bad format returned error:",error);
free(data->buffer);
data->buffer=NULL;
free(one_format);
+ free(dup);
return error;
}
if(brk) break;
@@ -879,7 +915,7 @@ int serialize_with_format(struct collection_item *event,
}
/* There is a format specifier ! */
- start = format_str+i;
+ start = dup+i-1;
end = start;
block = 0;
while((*end != '(') && (*end != '\0')) end++;
@@ -893,6 +929,7 @@ int serialize_with_format(struct collection_item *event,
free(data->buffer);
data->buffer=NULL;
free(one_format);
+ free(dup);
return error;
}
/* We are done */
@@ -900,25 +937,28 @@ int serialize_with_format(struct collection_item *event,
}
/* We are here becuase we have a valid (hopefully) format */
- block = end - start - 1;
+ block = end - start;
memcpy(one_format,start,block);
*(one_format+block) = '\0';
- i = end - format_str;
+ i = end - dup;
brk = 0;
- error = process_item(data,format_str,&i,event,one_format);
+ error = process_item(data,dup,&i,event,one_format,&brk);
if(error) {
DEBUG_NUMBER("put_marker bad format returned error:",error);
free(data->buffer);
data->buffer=NULL;
free(one_format);
+ free(dup);
return error;
}
if(brk) break;
- DEBUG_STRING("Format after another item:",format_str+i);
+ DEBUG_STRING("Format after another item:",dup+i);
}
+ free(one_format);
+ free(dup);
/* Out of the loop */
DEBUG_STRING("serialize_with_format","Success Exit");
return EOK;
diff --git a/dispatcher/elapi_api.c b/dispatcher/elapi_api.c
index b89ac7d..919dee2 100644
--- a/dispatcher/elapi_api.c
+++ b/dispatcher/elapi_api.c
@@ -29,7 +29,7 @@
#include "elapi_collection.h"
#include "elapi_sink.h"
-const char event_name[] = "event";
+char event_name[] = "event";
/* Pointer to default global dispatcher */
struct dispatcher_handle *global_dispatcher = (struct dispatcher_handle *)(NULL);
@@ -110,6 +110,6 @@ int create_event(struct collection_item **event,char *name)
void log_event(char *format_string,struct collection_item *event)
{
DEBUG_STRING("log_event","Entry");
- log_audit_event(global_dispatcher, event, format_string);
+ log_audit_event(global_dispatcher, format_string, event);
DEBUG_STRING("log_event","Entry");
}
diff --git a/dispatcher/elapi_dispatcher.c b/dispatcher/elapi_dispatcher.c
index 27a3eca..ad943c4 100644
--- a/dispatcher/elapi_dispatcher.c
+++ b/dispatcher/elapi_dispatcher.c
@@ -428,7 +428,7 @@ static int default_router(char *sink,
char *previous_sink,
int previous_status,
struct collection_item *event,
- char *format_string
+ char *format_string,
struct sink_descriptor *sink_data,
void *custom_data,
int *error)
diff --git a/dispatcher/elapi_dispatcher_ut.c b/dispatcher/elapi_dispatcher_ut.c
index aa0a041..d0f846c 100644
--- a/dispatcher/elapi_dispatcher_ut.c
+++ b/dispatcher/elapi_dispatcher_ut.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <malloc.h>
+#include <errno.h>
#include "elapi_dispatcher.h"
#include "elapi_collection.h"
#include "elapi_debug.h"
@@ -124,19 +125,17 @@ int construct_event()
return EOK;
}
-int high_level_test()
+int high_level_test(char *app)
{
int error = EOK;
- struct dispatcher_handle *dispatcher;
- struct dispatcher_handle *dispatcher2;
char *sinks[]= { "foo", "stderr", "file", NULL };
- char bin[] = { '\1','\2','\3','\4','\5','\6','\7','\8' };
+ char bin[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
printf("High level test start\n");
printf("%s","=================\nOpening audit\n");
- error = open_audit("my_app1",sinks);
- if(error!) {
+ error = open_audit(app,sinks);
+ if(error) {
printf("open_audit returned %d\n", error);
return error;
}
@@ -144,7 +143,7 @@ int high_level_test()
printf("%s","=================\nAdding syslog - first time - expect success\n");
error = alter_audit_dispatcher(get_dispatcher(),"syslog",ELAPI_SINK_ACTION_ADD);
- if(error != 0) {
+ if(error) {
printf("Expected success got failure %d\n",error);
return error;
}
@@ -158,9 +157,17 @@ int high_level_test()
}
else printf("Expected error : %d\n",error);
- printf("%s","=================\nAdding syslog - first time - expect success\n");
- error = alter_audit_dispatcher(get_dispatcher(),"foo",ELAPI_SINK_ACTION_DELETE);
- if(error != 0) {
+ printf("%s","=================\nDeleting stderr\n");
+ error = alter_audit_dispatcher(get_dispatcher(),"stderr",ELAPI_SINK_ACTION_DELETE);
+ if(error) {
+ printf("Expected success got failure %d\n",error);
+ return error;
+ }
+ else printf("Success : %d\n",error);
+
+ printf("%s","=================\nAdding stderr back\n");
+ error = alter_audit_dispatcher(get_dispatcher(),"stderr",ELAPI_SINK_ACTION_ADD);
+ if(error) {
printf("Expected success got failure %d\n",error);
return error;
}
@@ -170,7 +177,7 @@ int high_level_test()
if((error=create_event(&event,"test_event")) ||
(error=add_str_property(event,NULL,"name","some name",0)) ||
(error=add_int_property(event,NULL,"number",-100)) ||
- (error=add_binary_property(event,NULL,"binary",bin,8)) ||
+ (error=add_binary_property(event,NULL,"bin",bin,8)) ||
(error=add_double_property(event,NULL,"double",3.141592))) {
printf("Failed to create collection. Error %d\n",error);
return error;
@@ -201,7 +208,7 @@ int high_level_test()
destroy_collection(event);
- close_audit(void);
+ close_audit();
printf("Low level test end\n");
return error;
@@ -212,11 +219,13 @@ int low_level_test()
{
int error = EOK;
char *sinks[]= { "foo", "stderr", "bar", NULL };
+ struct dispatcher_handle *dispatcher;
+ struct dispatcher_handle *dispatcher2;
printf("Low level test start\n");
error = create_audit_dispatcher(&dispatcher,"my_app",sinks,NULL,NULL);
- if(error!) {
+ if(error) {
printf("create_audit_dispatcher returned %d\n", error);
return error;
}
@@ -246,33 +255,33 @@ int low_level_test()
printf("%s","=================\nSeries of negative test cases.\n");
/* Deleting non exisintg sink */
error = alter_audit_dispatcher(dispatcher,"far2",ELAPI_SINK_ACTION_DELETE);
- if(error == 0) printf("%s","Expected failure got success\n");
+ if(!error) printf("%s","Expected failure got success\n");
else printf("Expected failure. Error : %d\n",error);
/* Editing non exisintg sink */
error = alter_audit_dispatcher(dispatcher,"far2",ELAPI_SINK_ACTION_ENABLE);
- if(error == 0) printf("%s","Expected failure got success\n");
+ if(!error) printf("%s","Expected failure got success\n");
else printf("Expected failure. Error : %d\n",error);
/* Adding duplicate */
error = alter_audit_dispatcher(dispatcher,"bar",ELAPI_SINK_ACTION_ADD);
- if(error == 0) printf("%s","Expected failure got success\n");
+ if(!error) printf("%s","Expected failure got success\n");
else printf("Expected failure. Error : %d\n",error);
/* Adding new */
printf("%s","=================\nAdding syslog - first time - expect success\n");
error = alter_audit_dispatcher(dispatcher,"syslog",ELAPI_SINK_ACTION_ADD);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
/* Delete */
error = alter_audit_dispatcher(dispatcher,"stderr",ELAPI_SINK_ACTION_DELETE);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
/* Enable */
error = alter_audit_dispatcher(dispatcher,"syslog",ELAPI_SINK_ACTION_ENABLE);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
/* Log event into syslog */
@@ -291,35 +300,35 @@ int low_level_test()
/* Pulse */
error = alter_audit_dispatcher(dispatcher,"syslog",ELAPI_SINK_ACTION_PULSE);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
printf("%s","=================\nCreating another dispatcher - expect success\n");
error = create_audit_dispatcher(&dispatcher2,"my_app",sinks,NULL,NULL);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
printf("%s","=================\nAdding syslog sink to it - expect failure\n");
error = alter_audit_dispatcher(dispatcher2,"syslog",ELAPI_SINK_ACTION_ADD);
- if(error == 0) printf("%s","Expected failure got success\n");
+ if(!error) printf("%s","Expected failure got success\n");
else printf("Expected failure. Error : %d\n",error);
/* Delete */
error = alter_audit_dispatcher(dispatcher,"syslog",ELAPI_SINK_ACTION_DELETE);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
printf("%s","=================\nAdding syslog sink to it - now expect success\n");
error = alter_audit_dispatcher(dispatcher2,"syslog",ELAPI_SINK_ACTION_ADD);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
/* Disable */
error = alter_audit_dispatcher(dispatcher2,"syslog",ELAPI_SINK_ACTION_DISABLE);
- if(error != 0) printf("Expected success got failure %d\n",error);
+ if(error) printf("Expected success got failure %d\n",error);
else printf("Success : %d\n",error);
destroy_audit_dispatcher(dispatcher);
@@ -341,11 +350,11 @@ int main()
printf("Low level test returned: %d\n",error);
if(error) return error;
- error = high_level_test();
+ error = high_level_test("my_app1");
printf("High level test first run returned: %d\n",error);
if(error) return error;
- error = high_level_test();
+ error = high_level_test("my_app2");
printf("High level test second run returned: %d\n",error);
return error;
diff --git a/etc/file_defaults.d/my_app1.conf b/etc/file_defaults.d/my_app1.conf
index 32cdfaf..53f58f9 100644
--- a/etc/file_defaults.d/my_app1.conf
+++ b/etc/file_defaults.d/my_app1.conf
@@ -1,7 +1,7 @@
; This is the test application configuration
; Log into the given file:
-file_name=/tmp/log1
+file_name="/tmp/log1"
; Open once and keep open (default is 1)
diff --git a/etc/file_defaults.d/my_app2.conf b/etc/file_defaults.d/my_app2.conf
index da3a8a0..8240e07 100644
--- a/etc/file_defaults.d/my_app2.conf
+++ b/etc/file_defaults.d/my_app2.conf
@@ -1,7 +1,7 @@
; This is the test application configuration
; Log into the given file:
-file_name=/tmp/log2
+file_name="/tmp/log2"
; Open once and keep open (default is 1)
diff --git a/sinks/file/elapi_sink_file.c b/sinks/file/elapi_sink_file.c
index 660aba3..2d50b4f 100644
--- a/sinks/file/elapi_sink_file.c
+++ b/sinks/file/elapi_sink_file.c
@@ -112,9 +112,9 @@ static int init_config(struct data_descriptor *dblock)
dblock->config = (void *)(conf_data);
if((conf_data->file_name != NULL) && (conf_data->keep_open != 0)) {
- file_conf->file = fopen(conf_data->file_name,"w");
+ conf_data->file = fopen(conf_data->file_name,"w");
}
- else conf_data->file_name = stderr;
+ else conf_data->file = stderr;
DEBUG_STRING("init_config","Entry");
return EOK;
@@ -132,8 +132,8 @@ static int file_sink_init(struct data_descriptor *dblock)
/* Prepare the block where the format function will store its data */
errno = 0;
dblock->internal_data = NULL;
- event_storage = (struct serail_data *)(malloc(sizeof(struct serial_data)));
- if(event_storage == (struct serail_data *)(NULL)) return errno;
+ event_storage = (struct serial_data *)(malloc(sizeof(struct serial_data)));
+ if(event_storage == (struct serial_data *)(NULL)) return errno;
event_storage->buffer = NULL;
event_storage->size = 0;
@@ -199,7 +199,7 @@ static void file_sink_cleanup(struct data_descriptor *dblock)
DEBUG_STRING("file_sink_cleanup","Entry");
- event_storage = (struct file_event *)(dblock->internal_data);
+ event_storage = (struct serial_data *)(dblock->internal_data);
if(event_storage->buffer != NULL) {
free(event_storage->buffer);
@@ -215,7 +215,7 @@ static void file_sink_cleanup(struct data_descriptor *dblock)
/* Close facility */
static void file_sink_close(struct data_descriptor *dblock)
{
- struct file_conf *config;
+ struct file_conf *conf_data;
DEBUG_STRING("file_sink_close","Entry");
@@ -226,13 +226,13 @@ static void file_sink_close(struct data_descriptor *dblock)
}
if(dblock->config != NULL) {
- config = (struct file_conf *)(dblock->config);
+ conf_data = (struct file_conf *)(dblock->config);
if((conf_data->file_name != NULL) && (conf_data->keep_open != 0)) {
- close(file_conf->file);
+ close(conf_data->file);
}
- if(config->file_name != NULL) free(config->file_name);
+ if(conf_data->file_name != NULL) free(conf_data->file_name);
free(dblock->config);
dblock->config=NULL;
}
@@ -245,25 +245,25 @@ static void file_sink_close(struct data_descriptor *dblock)
static int file_sink_submit(struct data_descriptor *dblock)
{
struct serial_data *event_storage;
- struct file_conf *config;
+ struct file_conf *conf_data;
DEBUG_STRING("file_sink_submit","Entry");
DEBUG_NUMBER("DBLOCK in submit",dblock);
DEBUG_NUMBER("internal data in submit",dblock->internal_data);
event_storage = (struct file_event *)(dblock->internal_data);
- config = (struct file_conf *)(dblock->config);
+ conf_data = (struct file_conf *)(dblock->config);
DEBUG_STRING("OUTPUT:",event_storage->buffer);
if((conf_data->file_name != NULL) && (conf_data->keep_open == 0)) {
- file_conf->file = fopen(conf_data->file_name,"w");
+ conf_data->file = fopen(conf_data->file_name,"w");
}
- fprintf(file_conf->file, "%s\n", event_storage->buffer);
+ fprintf(conf_data->file, "%s\n", event_storage->buffer);
if((conf_data->file_name != NULL) && (conf_data->keep_open == 0)) {
- close(file_conf->file);
+ close(conf_data->file);
}
file_sink_cleanup(dblock);
diff --git a/sinks/syslog/elapi_sink_syslog.c b/sinks/syslog/elapi_sink_syslog.c
index eb1585e..ab3d3d2 100644
--- a/sinks/syslog/elapi_sink_syslog.c
+++ b/sinks/syslog/elapi_sink_syslog.c
@@ -212,7 +212,7 @@ static int syslog_sink_format(struct data_descriptor *dblock,
{
struct syslog_event *event_storage;
struct syslog_conf *config;
- struct collection_item *item;
+ struct collection_item *item = (struct collection_item *)(NULL);
int error = EOK;
DEBUG_STRING("syslog_sink_format","Entry");