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>
18 #ifndef GENERIC_UTILS_H
19 #define GENERIC_UTILS_H
22 /** Malloc's, checks for NULL, clears all memory bits and
25 * @param size How many bytes of memory to allocate
27 inline void* safe_malloc( int size );
29 /* 10M limit on buffers for overflow protection */
30 #define BUFFER_MAX_SIZE 10485760
32 // ---------------------------------------------------------------------------------
33 // Generic growing buffer. Add data all you want
34 // ---------------------------------------------------------------------------------
35 struct growing_buffer_struct {
40 typedef struct growing_buffer_struct growing_buffer;
42 growing_buffer* buffer_init( int initial_num_bytes);
43 int buffer_addchar(growing_buffer* gb, char c);
44 int buffer_add(growing_buffer* gb, char* c);
45 int buffer_reset( growing_buffer* gb);
46 char* buffer_data( growing_buffer* gb);
47 int buffer_free( growing_buffer* gb );
53 void get_timestamp( char buf_25chars[]);
55 // ---------------------------------------------------------------------------------
56 // Error handling interface.
57 // ---------------------------------------------------------------------------------
59 void fatal_handler( char* message, ...);
60 void warning_handler( char* message, ... );
61 void info_handler( char* message, ... );
63 // ---------------------------------------------------------------------------------
65 // ---------------------------------------------------------------------------------
66 struct config_reader_struct {
68 xmlXPathContextPtr xpathCx;
70 typedef struct config_reader_struct config_reader;
71 config_reader* conf_reader;
73 void config_reader_init( char* config_file );
75 void config_reader_free();
77 // allocastes a char*. FREE me.
78 char* config_value( const char* xpath_query, ... );