6 /* libxml stuff for the config reader */
7 #include <libxml/xmlmemory.h>
8 #include <libxml/parser.h>
9 #include <libxml/xpath.h>
10 #include <libxml/xpathInternals.h>
11 #include <libxml/tree.h>
13 #ifndef GENERIC_UTILS_H
14 #define GENERIC_UTILS_H
22 #define equals(a,b) !strcmp(a,b)
24 /** Malloc's, checks for NULL, clears all memory bits and
27 * @param size How many bytes of memory to allocate
29 inline void* safe_malloc( int size );
31 /* 10M limit on buffers for overflow protection */
32 #define BUFFER_MAX_SIZE 10485760
34 // ---------------------------------------------------------------------------------
35 // Generic growing buffer. Add data all you want
36 // ---------------------------------------------------------------------------------
37 struct growing_buffer_struct {
42 typedef struct growing_buffer_struct growing_buffer;
44 growing_buffer* buffer_init( int initial_num_bytes);
45 int buffer_addchar(growing_buffer* gb, char c);
46 int buffer_add(growing_buffer* gb, char* c);
47 int buffer_reset( growing_buffer* gb);
48 char* buffer_data( growing_buffer* gb);
49 int buffer_free( growing_buffer* gb );
55 void get_timestamp( char buf_36chars[]);
57 // ---------------------------------------------------------------------------------
58 // Error handling interface.
59 // ---------------------------------------------------------------------------------
61 void fatal_handler( char* message, ...);
62 void warning_handler( char* message, ... );
63 void info_handler( char* message, ... );
64 void debug_handler( char* message, ... );
66 /** If we return 0 either the log level is less than LOG_ERROR
67 * or we could not open the log file
69 int log_init( int log_level, char* log_file );
71 // ---------------------------------------------------------------------------------
73 // ---------------------------------------------------------------------------------
74 struct config_reader_struct {
76 xmlXPathContextPtr xpathCx;
78 struct config_reader_struct* next;
80 typedef struct config_reader_struct config_reader;
81 config_reader* conf_reader;
83 //void config_reader_init( char* config_file );
84 void config_reader_init( char* name, char* config_file );
86 void config_reader_free();
88 // allocastes a char*. FREE me.
89 //char* config_value( const char* xpath_query, ... );
90 char* config_value( const char* config_name, const char* xp_query, ... );
91 //char* config_value( config_reader* reader, const char* xp_query, ... );