Changeset 3220ba84489b08d9570c58424d6b2237d100cdea

Show
Ignore:
Timestamp:
04/02/11 02:33:02 (4 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
  • src/noit_conf.c

    re838538 r3220ba8  
    5151 
    5252/* tmp hash impl, replace this with something nice */ 
     53static 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) 
    5362static noit_hash_table _tmp_config = NOIT_HASH_EMPTY; 
    5463static xmlDocPtr master_config = NULL; 
    5564static int config_include_cnt = -1; 
    56 static struct {  
     65static struct { 
    5766  xmlNodePtr insertion_point; 
    5867  xmlNodePtr old_children; 
     
    144153}; 
    145154 
     155void 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 
     164void 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 
    146175void noit_conf_xml_error_func(void *ctx, const char *format, ...) { 
    147176  struct timeval __now; 
     
    174203  int i; 
    175204  char keystr[256]; 
     205 
     206  xml_debug = noit_log_stream_find("debug/xml"); 
     207 
    176208  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); 
    179210  for(i = 0; config_info[i].key != NULL; i++) { 
    180211    snprintf(keystr, sizeof(keystr), config_info[i].key, toplevel); 
     
    719750                 int argc, char **argv, 
    720751                 noit_console_state_t *state, void *closure) { 
     752  XML2CONSOLE(ncct); 
    721753  if(noit_conf_load(master_config_file)) { 
     754    XML2LOG(xml_debug); 
    722755    nc_printf(ncct, "error loading config\n"); 
    723756    return -1; 
    724757  } 
     758  XML2LOG(xml_debug); 
    725759  return 0; 
    726760}