From ef8d8570dcf44d723868df339223b132b19121c3 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Tue, 24 Feb 2009 13:39:26 -0500 Subject: Changed tree. Added all folders to build. --- collection/elapi_debug.h | 35 +++++++++ collection/elapi_tools.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++ collection/elapi_tools.h | 27 +++++++ dispatcher/Makefile.am | 12 +++ ini/Makefile.am | 11 +++ ini/elapi_ini_ut | Bin 7392 -> 0 bytes sinks/stderr/Makefile.am | 7 ++ sinks/syslog/Makefile.am | 9 +++ tools/Makefile.am | 3 - tools/elapi_tools.c | 192 ----------------------------------------------- tools/elapi_tools.h | 27 ------- util/elapi_debug.h | 35 --------- 12 files changed, 293 insertions(+), 257 deletions(-) create mode 100644 collection/elapi_debug.h create mode 100644 collection/elapi_tools.c create mode 100644 collection/elapi_tools.h create mode 100644 dispatcher/Makefile.am create mode 100644 ini/Makefile.am delete mode 100755 ini/elapi_ini_ut create mode 100644 sinks/stderr/Makefile.am create mode 100644 sinks/syslog/Makefile.am delete mode 100644 tools/Makefile.am delete mode 100644 tools/elapi_tools.c delete mode 100644 tools/elapi_tools.h delete mode 100644 util/elapi_debug.h diff --git a/collection/elapi_debug.h b/collection/elapi_debug.h new file mode 100644 index 0000000..3da0685 --- /dev/null +++ b/collection/elapi_debug.h @@ -0,0 +1,35 @@ +/* Copyright */ + +#ifndef ELAPI_DEBUG_H +#define ELAPI_DEBUG_H + +#ifdef ELAPI_LOG_DEBUG +#include +#endif + +#ifdef ELAPI_LOG_DEBUG +#define DEBUG_STRING(message,str) printf("[DEBUG] %23s (%4d) %s %s\n",__FILE__,__LINE__,message,str); +#else +#define DEBUG_STRING(message,str) ; +#endif + +#ifdef ELAPI_LOG_DEBUG +#define DEBUG_NUMBER(message,number) printf("[DEBUG] %23s (%4d) %s %lu\n",__FILE__,__LINE__,message,(unsigned long int)(number)); +#else +#define DEBUG_NUMBER(message,number) ; +#endif + +#ifdef ELAPI_LOG_DEBUG +#define DEBUG_DOUBLE(message,number) printf("[DEBUG] %23s (%4d) %s %e\n",__FILE__,__LINE__,message,(double)(number)); +#else +#define DEBUG_DOUBLE(message,number) ; +#endif + +#ifdef ELAPI_LOG_DEBUG +#define DEBUG_ASSERT(expression) expression ? ; : printf("ASSERTION FAILED\n"); +#else +#define DEBUG_ASSERT(expression) ; +#endif + + +#endif diff --git a/collection/elapi_tools.c b/collection/elapi_tools.c new file mode 100644 index 0000000..d1d00c0 --- /dev/null +++ b/collection/elapi_tools.c @@ -0,0 +1,192 @@ +/* Copyright */ + +#include +#include +#include "elapi_collection.h" +#include "elapi_debug.h" +#include "elapi_util.h" +#include "elapi_tools.h" + +/* Debug handle */ +int debug_handle(char *property, + int property_len, + int type, + void *data, + int length, + void *custom_data, + int *dummy) +{ + int i; + int nest_level; + + DEBUG_STRING("debug_handle","Entry."); + + + nest_level = *(int *)(custom_data); + DEBUG_NUMBER("We are getting this pointer:",custom_data); + DEBUG_NUMBER("Nest level:",nest_level); + + switch(type) { + case ELAPI_TYPE_STRING: + printf("%*s %s[%d] str: %s (%d)\n", + (nest_level-1)*4,"", + property, + length, + (char *)(data), + (int)(nest_level)); + break; + case ELAPI_TYPE_BINARY: + printf("%*s %s[%d] bin: ", + (nest_level-1)*4,"", + property, + length); + for(i=0;icount, + ((struct collection_header *)(data))->reference_count); + for(i=0;iproperty); + + flag |= ELAPI_TRAVERSE_END; + + printf("Traverse flags %d\n",flag); + + /* Traverse collection */ + error = traverse_collection(handle,flag,debug_handle,(void *)(&nest_level)); + if(error) printf("Error debuging collection %d\n",error); + + DEBUG_STRING("debug_collection","Exit."); + return error; +} + +/* Print the collection using default serialization */ +int print_collection(struct collection_item *handle) +{ + struct serial_data buf_data; + int error = EOK; + + printf("COLLECTION:\n"); + + buf_data.buffer=NULL; + buf_data.length=0; + buf_data.size=0; + buf_data.nest_level=0; + + /* Traverse collection */ + error = traverse_collection(handle,ELAPI_TRAVERSE_DEFAULT | ELAPI_TRAVERSE_END ,serialize,(void *)(&buf_data)); + if(error) printf("Error traversing collection %d\n",error); + else printf("%s\n",buf_data.buffer); + + free(buf_data.buffer); + + return error; +} + + +/* Find and print one item using default serialization */ +int print_item(struct collection_item *handle, char *name) +{ + struct serial_data buf_data; + int error = EOK; + + printf("FIND ITEM:\n"); + + buf_data.buffer=NULL; + buf_data.length=0; + buf_data.size=0; + buf_data.nest_level=0; + + error = get_item_and_do(handle, name, ELAPI_TYPE_ANY,ELAPI_TRAVERSE_DEFAULT, serialize,&buf_data); + if(error) printf("Error searching collection %d\n",error); + else { + if(buf_data.buffer != NULL) { + if(buf_data.length> 0) buf_data.length--; + *(buf_data.buffer+buf_data.length)= '\0', + printf("%s\n",buf_data.buffer); + free(buf_data.buffer); + } + else printf("Name %s is not found in the collection %s.\n",name,handle->property); + } + return error; +} + + diff --git a/collection/elapi_tools.h b/collection/elapi_tools.h new file mode 100644 index 0000000..fd9bf63 --- /dev/null +++ b/collection/elapi_tools.h @@ -0,0 +1,27 @@ +/* Copyright */ + +#ifndef ELAPI_TOOLS_H +#define ELAPI_TOOLS_H + +#include "elapi_collection.h" + +/* Debug handle */ +int debug_handle(char *property, + int property_len, + int type, + void *data, + int length, + void *custom_data, + int *dummy); + +/* Print collection for debugging purposes */ +int debug_collection(struct collection_item *handle,int flag); + +/* Print the collection using default serialization */ +int print_collection(struct collection_item *handle); + + +/* Find and print one item using default serialization */ +int print_item(struct collection_item *handle, char *name); + +#endif diff --git a/dispatcher/Makefile.am b/dispatcher/Makefile.am new file mode 100644 index 0000000..ea5b5ff --- /dev/null +++ b/dispatcher/Makefile.am @@ -0,0 +1,12 @@ +DEBUG_FLAGS=@DEBUG_VAR@ + +AM_CPPFLAGS = -I$(srcdir)/../collection -I$(srcdir)/../sinks -I/usr/include/libxml2 $(DEBUG_FLAGS) +common_headers=elapi_collection.h elapi_debug.h elapi_tools.h elapi_dispatcher.h elapi_sink.h + +noinst_LIBRARIES = libelapi_dispatcher.a +libelapi_dispatcher_a_SOURCES = elapi_dispatcher.c $(common_headers) + +noinst_PROGRAMS = elapi_dispatcher_ut +elapi_dispatcher_ut_SOURCES = elapi_dispatcher_ut.c $(common_headers) +elapi_dispatcher_ut_LDADD = libelapi_dispatcher.a ../ini/libelapi_ini.a -lm -lz -lxml2 ../collection/libelapi_collection.a \ +../sinks/stderr/libelapi_sink_stderr.la ../sinks/syslog/libelapi_sink_syslog.la diff --git a/ini/Makefile.am b/ini/Makefile.am new file mode 100644 index 0000000..7e50b8d --- /dev/null +++ b/ini/Makefile.am @@ -0,0 +1,11 @@ +DEBUG_FLAGS=@DEBUG_VAR@ + +AM_CPPFLAGS = -I$(srcdir)/../collection $(DEBUG_FLAGS) +common_headers=elapi_ini.h elapi_collection.h elapi_debug.h elapi_tools.h + +noinst_LIBRARIES = libelapi_ini.a +libelapi_ini_a_SOURCES = elapi_ini.c $(common_headers) + +noinst_PROGRAMS = elapi_ini_ut +elapi_ini_ut_SOURCES = elapi_ini_ut.c $(common_headers) +elapi_ini_ut_LDADD = libelapi_ini.a -lm -lz -lxml2 ../collection/libelapi_collection.a diff --git a/ini/elapi_ini_ut b/ini/elapi_ini_ut deleted file mode 100755 index 18deb77..0000000 Binary files a/ini/elapi_ini_ut and /dev/null differ diff --git a/sinks/stderr/Makefile.am b/sinks/stderr/Makefile.am new file mode 100644 index 0000000..7c77e5c --- /dev/null +++ b/sinks/stderr/Makefile.am @@ -0,0 +1,7 @@ +topdir=../.. +DEBUG_FLAGS=@DEBUG_VAR@ +AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../../collection -I/usr/include/libxml2 $(DEBUG_FLAGS) + +lib_LTLIBRARIES = libelapi_sink_stderr.la +libelapi_sink_stderr_la_SOURCES = elapi_sink_stderr.c +include_HEADERS = ../elapi_sink.h diff --git a/sinks/syslog/Makefile.am b/sinks/syslog/Makefile.am new file mode 100644 index 0000000..67b3ca2 --- /dev/null +++ b/sinks/syslog/Makefile.am @@ -0,0 +1,9 @@ +topdir=../.. +DEBUG_FLAGS=@DEBUG_VAR@ +AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../../collection -I$(srcdir)/../../ini -I/usr/include/libxml2 $(DEBUG_FLAGS) + + +lib_LTLIBRARIES = libelapi_sink_syslog.la +libelapi_sink_syslog_la_SOURCES = elapi_sink_syslog.c $(topdir)/ini/elapi_ini.c + +include_HEADERS = ../elapi_sink.h diff --git a/tools/Makefile.am b/tools/Makefile.am deleted file mode 100644 index 620da70..0000000 --- a/tools/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -lib_LIBRARIES = libelapi_tools.a -libelapi_tools_a_SOURCES = elapi_tools.c - diff --git a/tools/elapi_tools.c b/tools/elapi_tools.c deleted file mode 100644 index d1d00c0..0000000 --- a/tools/elapi_tools.c +++ /dev/null @@ -1,192 +0,0 @@ -/* Copyright */ - -#include -#include -#include "elapi_collection.h" -#include "elapi_debug.h" -#include "elapi_util.h" -#include "elapi_tools.h" - -/* Debug handle */ -int debug_handle(char *property, - int property_len, - int type, - void *data, - int length, - void *custom_data, - int *dummy) -{ - int i; - int nest_level; - - DEBUG_STRING("debug_handle","Entry."); - - - nest_level = *(int *)(custom_data); - DEBUG_NUMBER("We are getting this pointer:",custom_data); - DEBUG_NUMBER("Nest level:",nest_level); - - switch(type) { - case ELAPI_TYPE_STRING: - printf("%*s %s[%d] str: %s (%d)\n", - (nest_level-1)*4,"", - property, - length, - (char *)(data), - (int)(nest_level)); - break; - case ELAPI_TYPE_BINARY: - printf("%*s %s[%d] bin: ", - (nest_level-1)*4,"", - property, - length); - for(i=0;icount, - ((struct collection_header *)(data))->reference_count); - for(i=0;iproperty); - - flag |= ELAPI_TRAVERSE_END; - - printf("Traverse flags %d\n",flag); - - /* Traverse collection */ - error = traverse_collection(handle,flag,debug_handle,(void *)(&nest_level)); - if(error) printf("Error debuging collection %d\n",error); - - DEBUG_STRING("debug_collection","Exit."); - return error; -} - -/* Print the collection using default serialization */ -int print_collection(struct collection_item *handle) -{ - struct serial_data buf_data; - int error = EOK; - - printf("COLLECTION:\n"); - - buf_data.buffer=NULL; - buf_data.length=0; - buf_data.size=0; - buf_data.nest_level=0; - - /* Traverse collection */ - error = traverse_collection(handle,ELAPI_TRAVERSE_DEFAULT | ELAPI_TRAVERSE_END ,serialize,(void *)(&buf_data)); - if(error) printf("Error traversing collection %d\n",error); - else printf("%s\n",buf_data.buffer); - - free(buf_data.buffer); - - return error; -} - - -/* Find and print one item using default serialization */ -int print_item(struct collection_item *handle, char *name) -{ - struct serial_data buf_data; - int error = EOK; - - printf("FIND ITEM:\n"); - - buf_data.buffer=NULL; - buf_data.length=0; - buf_data.size=0; - buf_data.nest_level=0; - - error = get_item_and_do(handle, name, ELAPI_TYPE_ANY,ELAPI_TRAVERSE_DEFAULT, serialize,&buf_data); - if(error) printf("Error searching collection %d\n",error); - else { - if(buf_data.buffer != NULL) { - if(buf_data.length> 0) buf_data.length--; - *(buf_data.buffer+buf_data.length)= '\0', - printf("%s\n",buf_data.buffer); - free(buf_data.buffer); - } - else printf("Name %s is not found in the collection %s.\n",name,handle->property); - } - return error; -} - - diff --git a/tools/elapi_tools.h b/tools/elapi_tools.h deleted file mode 100644 index fd9bf63..0000000 --- a/tools/elapi_tools.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright */ - -#ifndef ELAPI_TOOLS_H -#define ELAPI_TOOLS_H - -#include "elapi_collection.h" - -/* Debug handle */ -int debug_handle(char *property, - int property_len, - int type, - void *data, - int length, - void *custom_data, - int *dummy); - -/* Print collection for debugging purposes */ -int debug_collection(struct collection_item *handle,int flag); - -/* Print the collection using default serialization */ -int print_collection(struct collection_item *handle); - - -/* Find and print one item using default serialization */ -int print_item(struct collection_item *handle, char *name); - -#endif diff --git a/util/elapi_debug.h b/util/elapi_debug.h deleted file mode 100644 index 3da0685..0000000 --- a/util/elapi_debug.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright */ - -#ifndef ELAPI_DEBUG_H -#define ELAPI_DEBUG_H - -#ifdef ELAPI_LOG_DEBUG -#include -#endif - -#ifdef ELAPI_LOG_DEBUG -#define DEBUG_STRING(message,str) printf("[DEBUG] %23s (%4d) %s %s\n",__FILE__,__LINE__,message,str); -#else -#define DEBUG_STRING(message,str) ; -#endif - -#ifdef ELAPI_LOG_DEBUG -#define DEBUG_NUMBER(message,number) printf("[DEBUG] %23s (%4d) %s %lu\n",__FILE__,__LINE__,message,(unsigned long int)(number)); -#else -#define DEBUG_NUMBER(message,number) ; -#endif - -#ifdef ELAPI_LOG_DEBUG -#define DEBUG_DOUBLE(message,number) printf("[DEBUG] %23s (%4d) %s %e\n",__FILE__,__LINE__,message,(double)(number)); -#else -#define DEBUG_DOUBLE(message,number) ; -#endif - -#ifdef ELAPI_LOG_DEBUG -#define DEBUG_ASSERT(expression) expression ? ; : printf("ASSERTION FAILED\n"); -#else -#define DEBUG_ASSERT(expression) ; -#endif - - -#endif -- cgit