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
17 /** Malloc's, checks for NULL, clears all memory bits and
20 * @param size How many bytes of memory to allocate
22 inline void* safe_malloc( int size );
24 /* 10M limit on buffers for overflow protection */
25 #define BUFFER_MAX_SIZE 10485760
27 // ---------------------------------------------------------------------------------
28 // Generic growing buffer. Add data all you want
29 // ---------------------------------------------------------------------------------
30 struct growing_buffer_struct {
35 typedef struct growing_buffer_struct growing_buffer;
37 growing_buffer* buffer_init( int initial_num_bytes);
38 int buffer_addchar(growing_buffer* gb, char c);
39 int buffer_add(growing_buffer* gb, char* c);
40 int buffer_reset( growing_buffer* gb);
41 char* buffer_data( growing_buffer* gb);
42 int buffer_free( growing_buffer* gb );
48 void get_timestamp( char buf_25chars[]);
50 // ---------------------------------------------------------------------------------
51 // Error handling interface.
52 // ---------------------------------------------------------------------------------
54 void fatal_handler( char* message, ...);
55 void warning_handler( char* message, ... );
56 void info_handler( char* message, ... );
58 // ---------------------------------------------------------------------------------
60 // ---------------------------------------------------------------------------------
61 struct config_reader_struct {
63 xmlXPathContextPtr xpathCx;
65 typedef struct config_reader_struct config_reader;
66 config_reader* conf_reader;
68 void config_reader_init( char* config_file );
70 void config_reader_free();
72 // allocastes a char*. FREE me.
73 char* config_value( const char* xpath_query, ... );