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[]);
56 double get_timestamp_millis();
58 // ---------------------------------------------------------------------------------
59 // Error handling interface.
60 // ---------------------------------------------------------------------------------
62 void fatal_handler( char* message, ...);
63 void warning_handler( char* message, ... );
64 void info_handler( char* message, ... );
65 void debug_handler( char* message, ... );
67 /** If we return 0 either the log level is less than LOG_ERROR
68 * or we could not open the log file
70 int log_init( int log_level, char* log_file );
72 // ---------------------------------------------------------------------------------
74 // ---------------------------------------------------------------------------------
75 struct config_reader_struct {
77 xmlXPathContextPtr xpathCx;
79 struct config_reader_struct* next;
81 typedef struct config_reader_struct config_reader;
82 config_reader* conf_reader;
84 //void config_reader_init( char* config_file );
85 void config_reader_init( char* name, char* config_file );
87 void config_reader_free();
89 // allocastes a char*. FREE me.
90 //char* config_value( const char* xpath_query, ... );
91 char* config_value( const char* config_name, const char* xp_query, ... );
92 //char* config_value( config_reader* reader, const char* xp_query, ... );