Changeset 3220ba84489b08d9570c58424d6b2237d100cdea
- Timestamp:
- 04/02/11 02:33:02
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1301711582 +0000
- git-parent:
[3cfca66607e6f2a06868e5de051d304db5e73585]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1301711582 +0000
- Message:
fixes #361
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re838538 |
r3220ba8 |
|
| 51 | 51 | |
|---|
| 52 | 52 | /* tmp hash impl, replace this with something nice */ |
|---|
| | 53 | static noit_log_stream_t xml_debug = NULL; |
|---|
| | 54 | #define XML2LOG(log) do { \ |
|---|
| | 55 | xmlSetGenericErrorFunc(log, noit_conf_xml_error_func); \ |
|---|
| | 56 | xmlSetStructuredErrorFunc(log, noit_conf_xml_error_ext_func); \ |
|---|
| | 57 | } while(0) |
|---|
| | 58 | #define XML2CONSOLE(ncct) do { \ |
|---|
| | 59 | xmlSetGenericErrorFunc(ncct, noit_conf_xml_console_error_func); \ |
|---|
| | 60 | xmlSetStructuredErrorFunc(ncct, noit_conf_xml_console_error_ext_func); \ |
|---|
| | 61 | } while(0) |
|---|
| 53 | 62 | static noit_hash_table _tmp_config = NOIT_HASH_EMPTY; |
|---|
| 54 | 63 | static xmlDocPtr master_config = NULL; |
|---|
| 55 | 64 | static int config_include_cnt = -1; |
|---|
| 56 | | static struct { |
|---|
| | 65 | static struct { |
|---|
| 57 | 66 | xmlNodePtr insertion_point; |
|---|
| 58 | 67 | xmlNodePtr old_children; |
|---|
| … | … | |
| 144 | 153 | }; |
|---|
| 145 | 154 | |
|---|
| | 155 | void noit_conf_xml_console_error_func(void *ctx, const char *format, ...) { |
|---|
| | 156 | noit_console_closure_t ncct = ctx; |
|---|
| | 157 | va_list arg; |
|---|
| | 158 | if(!ncct) return; |
|---|
| | 159 | va_start(arg, format); |
|---|
| | 160 | nc_vprintf(ncct, format, arg); |
|---|
| | 161 | va_end(arg); |
|---|
| | 162 | } |
|---|
| | 163 | |
|---|
| | 164 | void noit_conf_xml_console_error_ext_func(void *ctx, xmlErrorPtr err) { |
|---|
| | 165 | noit_console_closure_t ncct = ctx; |
|---|
| | 166 | if(!ctx) return; |
|---|
| | 167 | if(err->file) |
|---|
| | 168 | nc_printf(ncct, "XML error [%d/%d] in %s on line %d %s\n", |
|---|
| | 169 | err->domain, err->code, err->file, err->line, err->message); |
|---|
| | 170 | else |
|---|
| | 171 | nc_printf(ncct, "XML error [%d/%d] %s\n", |
|---|
| | 172 | err->domain, err->code, err->message); |
|---|
| | 173 | } |
|---|
| | 174 | |
|---|
| 146 | 175 | void noit_conf_xml_error_func(void *ctx, const char *format, ...) { |
|---|
| 147 | 176 | struct timeval __now; |
|---|
| … | … | |
| 174 | 203 | int i; |
|---|
| 175 | 204 | char keystr[256]; |
|---|
| | 205 | |
|---|
| | 206 | xml_debug = noit_log_stream_find("debug/xml"); |
|---|
| | 207 | |
|---|
| 176 | 208 | COMPILE_CHECKER(name, "^[-_\\.:/a-zA-Z0-9]+$"); |
|---|
| 177 | | xmlSetGenericErrorFunc(noit_error, noit_conf_xml_error_func); |
|---|
| 178 | | xmlSetStructuredErrorFunc(noit_error, noit_conf_xml_error_ext_func); |
|---|
| | 209 | XML2LOG(noit_error); |
|---|
| 179 | 210 | for(i = 0; config_info[i].key != NULL; i++) { |
|---|
| 180 | 211 | snprintf(keystr, sizeof(keystr), config_info[i].key, toplevel); |
|---|
| … | … | |
| 719 | 750 | int argc, char **argv, |
|---|
| 720 | 751 | noit_console_state_t *state, void *closure) { |
|---|
| | 752 | XML2CONSOLE(ncct); |
|---|
| 721 | 753 | if(noit_conf_load(master_config_file)) { |
|---|
| | 754 | XML2LOG(xml_debug); |
|---|
| 722 | 755 | nc_printf(ncct, "error loading config\n"); |
|---|
| 723 | 756 | return -1; |
|---|
| 724 | 757 | } |
|---|
| | 758 | XML2LOG(xml_debug); |
|---|
| 725 | 759 | return 0; |
|---|
| 726 | 760 | } |
|---|