Changeset 1952

Show
Ignore:
Timestamp:
10/26/07 00:17:00 (7 months ago)
Author:
karpet
Message:

rename messaging functions and add file, line and function name to output

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/src/libswish3/analyzer.c

    r1927 r1952  
    5151    { 
    5252        if (SWISH_DEBUG) 
    53             swish_debug_msg("skipping WordList"); 
     53            SWISH_DEBUG_MSG("skipping WordList"); 
    5454             
    5555        a->tokenize = 0; 
  • libswish3/trunk/src/libswish3/config.c

    r1927 r1952  
    6363{ 
    6464    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    65         swish_debug_msg("   freeing config %s => %s", key, (xmlChar *) payload); 
     65        SWISH_DEBUG_MSG("   freeing config %s => %s", key, (xmlChar *) payload); 
    6666 
    6767    swish_xfree((xmlChar *) payload); 
     
    7575    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    7676    { 
    77         swish_debug_msg(" freeing config %s =>", confName); 
    78         swish_debug_msg(" num of keys in config hash: %d", size); 
    79         swish_debug_msg(" ptr addr: 0x%x  %d", (int) payload, (int) payload); 
     77        SWISH_DEBUG_MSG(" freeing config %s =>", confName); 
     78        SWISH_DEBUG_MSG(" num of keys in config hash: %d", size); 
     79        SWISH_DEBUG_MSG(" ptr addr: 0x%x  %d", (int) payload, (int) payload); 
    8080    } 
    8181 
     
    9191    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    9292    { 
    93         swish_debug_msg("freeing config"); 
    94         swish_debug_msg("num of keys in config hash: %d", size); 
    95         swish_debug_msg("ptr addr: 0x%x  %d", (int) config, (int) config); 
     93        SWISH_DEBUG_MSG("freeing config"); 
     94        SWISH_DEBUG_MSG("num of keys in config hash: %d", size); 
     95        SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int) config, (int) config); 
    9696    } 
    9797 
     
    100100    if (config->stash != NULL) 
    101101    { 
    102         swish_warn_err("possible memory leak: config->stash was not freed"); 
     102        SWISH_WARN("possible memory leak: config->stash was not freed"); 
    103103    } 
    104104 
     
    119119 
    120120    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    121         swish_debug_msg("creating default config"); 
     121        SWISH_DEBUG_MSG("creating default config"); 
    122122 
    123123    /* create our object */ 
     
    358358    if (node_has_value(node) && !node_has_key(node)) 
    359359    { 
    360         swish_fatal_err("config node with value but no key: %s", node->name); 
     360        SWISH_CROAK("config node with value but no key: %s", node->name); 
    361361        return 0; 
    362362    } 
     
    422422        if (str == NULL) 
    423423        { 
    424             swish_warn_err("no value for config opt '%s'", node->name); 
     424            SWISH_WARN("no value for config opt '%s'", node->name); 
    425425            return NULL; 
    426426        } 
     
    450450        doc = xmlParseFile((const char *) conf); 
    451451        if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    452             swish_debug_msg("Parsing configuration file: %s", conf); 
     452            SWISH_DEBUG_MSG("Parsing configuration file: %s", conf); 
    453453    } 
    454454    else 
     
    456456        doc = xmlParseMemory((const char *) conf, xmlStrlen(conf)); 
    457457        if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    458             swish_debug_msg("Parsing configuration from memory"); 
     458            SWISH_DEBUG_MSG("Parsing configuration from memory"); 
    459459    } 
    460460 
    461461    if (doc == NULL) 
    462         swish_fatal_err("error: could not parse XML: %s", conf); 
     462        SWISH_CROAK("error: could not parse XML: %s", conf); 
    463463 
    464464    return doc; 
     
    530530    { 
    531531        xmlFreeDoc(doc); 
    532         swish_fatal_err("bad config format: malformed or missing '%s' toplevel tag", toptag); 
     532        SWISH_CROAK("bad config format: malformed or missing '%s' toplevel tag", toptag); 
    533533        return 0; 
    534534    } 
     
    574574                if (cv->multi)    /* already flagged as multi */ 
    575575                { 
    576                     swish_debug_msg("%s is an existing multi-config", node->name); 
     576                    SWISH_DEBUG_MSG("%s is an existing multi-config", node->name); 
    577577 
    578578                    add_multi_node_to_cv(node, cv); 
     
    581581                else 
    582582                { 
    583                     swish_debug_msg("%s exists but is not a multi-config", node->name); 
     583                    SWISH_DEBUG_MSG("%s exists but is not a multi-config", node->name); 
    584584 
    585585                    /* free the existing one and replace it with new 
     
    600600                if (is_multi(node)) 
    601601                { 
    602                     swish_debug_msg("%s is a new multi-config", node->name); 
     602                    SWISH_DEBUG_MSG("%s is a new multi-config", node->name); 
    603603                    cv->value = swish_new_hash(16); 
    604604                    add_multi_node_to_cv(node, cv); 
     
    608608                if (is_equal(node)) 
    609609                { 
    610                     swish_debug_msg("%s is an equal node", node->name); 
     610                    SWISH_DEBUG_MSG("%s is an equal node", node->name); 
    611611                    cv->equal = 1; 
    612612                } 
     
    665665 
    666666            if (!opt_arg) 
    667                 swish_fatal_err("no value for option tag '%s'", opt_name); 
     667                SWISH_CROAK("no value for option tag '%s'", opt_name); 
    668668 
    669669            /* append value/args to any existing names in config */ 
     
    675675                if (vhash == NULL) 
    676676                { 
    677                     swish_fatal_err("error with existing name in config: %s", opt_name); 
     677                    SWISH_CROAK("error with existing name in config: %s", opt_name); 
    678678                } 
    679679                else 
    680680                { 
    681681                    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    682                         swish_debug_msg(" >>> found existing name in config: %s", opt_name); 
     682                        SWISH_DEBUG_MSG(" >>> found existing name in config: %s", opt_name); 
    683683 
    684684                    name_seen = 1; 
     
    692692                vhash = xmlHashCreate(16);    /* values => args */ 
    693693                if (vhash == NULL) 
    694                     swish_fatal_err("error creating vhash"); 
     694                    SWISH_CROAK("error creating vhash"); 
    695695 
    696696            } 
     
    724724 
    725725                if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    726                     swish_debug_msg("config %s tmp_arg = %s  opt_type = %s", opt_name, tmp_arg, opt_type); 
     726                    SWISH_DEBUG_MSG("config %s tmp_arg = %s  opt_type = %s", opt_name, tmp_arg, opt_type); 
    727727 
    728728                tmp_value = opt_type ? swish_xstrdup(opt_type) : swish_xstrdup(tmp_arg); 
     
    741741                    free_tmp = 1; 
    742742                    if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    743                         swish_debug_msg("tolower str: >%s<", tmp_arg); 
     743                        SWISH_DEBUG_MSG("tolower str: >%s<", tmp_arg); 
    744744 
    745745                    tmp_arg = swish_str_tolower(tmp_arg); 
     
    748748 
    749749                if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    750                     swish_debug_msg("config %s tmp_arg = %s  tmp_value = %s", opt_name, tmp_arg, tmp_value); 
     750                    SWISH_DEBUG_MSG("config %s tmp_arg = %s  tmp_value = %s", opt_name, tmp_arg, tmp_value); 
    751751 
    752752                if (xmlHashLookup(vhash, tmp_arg)) 
     
    775775            { 
    776776                if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 
    777                     swish_debug_msg(" >>> adding %s to config hash ( name_seen = %d )", opt_name, name_seen); 
     777                    SWISH_DEBUG_MSG(" >>> adding %s to config hash ( name_seen = %d )", opt_name, name_seen); 
    778778 
    779779                swish_hash_add(config->conf, opt_name, vhash); 
     
    797797config_val_printer(xmlChar * val, xmlChar * str, xmlChar * key) 
    798798{ 
    799     swish_debug_msg("   %s => %s", key, val); 
     799    SWISH_DEBUG_MSG("   %s => %s", key, val); 
    800800} 
    801801 
     
    803803config_printer(xmlHashTablePtr vhash, xmlChar * str, xmlChar * key) 
    804804{ 
    805     swish_debug_msg(" Config %s:", key); 
     805    SWISH_DEBUG_MSG(" Config %s:", key); 
    806806 
    807807    xmlHashScan(vhash, (xmlHashScanner) config_val_printer, "vhash"); 
     
    816816    int             size = xmlHashSize(config->conf); 
    817817 
    818     swish_debug_msg("config->ref_cnt = %d", config->ref_cnt); 
    819     swish_debug_msg("config->stash address = 0x%x  %d", (int) config->stash, (int) config->stash); 
    820     swish_debug_msg("num of keys in config hash: %d", size); 
    821     swish_debug_msg("ptr addr: 0x%x  %d", (int) config->conf, (int) config->conf); 
     818    SWISH_DEBUG_MSG("config->ref_cnt = %d", config->ref_cnt); 
     819    SWISH_DEBUG_MSG("config->stash address = 0x%x  %d", (int) config->stash, (int) config->stash); 
     820    SWISH_DEBUG_MSG("num of keys in config hash: %d", size); 
     821    SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int) config->conf, (int) config->conf); 
    822822 
    823823    xmlHashScan(config->conf, (xmlHashScanner) config_printer, "opt name"); 
     
    836836    { 
    837837        /* why does this happen when value is a hashptr ? */ 
    838         swish_debug_msg("Config option '%s' has NULL value", key); 
     838        SWISH_DEBUG_MSG("Config option '%s' has NULL value", key); 
    839839    } 
    840840 
  • libswish3/trunk/src/libswish3/docinfo.c

    r1913 r1952  
    4040 
    4141    if (SWISH_DEBUG > 9) 
    42         swish_debug_msg("init'ing docinfo"); 
     42        SWISH_DEBUG_MSG("init'ing docinfo"); 
    4343     
    4444    swish_DocInfo *docinfo = swish_xmalloc( sizeof(swish_DocInfo) ); 
     
    5555    if (SWISH_DEBUG > 9) 
    5656    { 
    57         swish_debug_msg("docinfo all ready"); 
     57        SWISH_DEBUG_MSG("docinfo all ready"); 
    5858        swish_debug_docinfo( docinfo ); 
    5959    } 
     
    6767{     
    6868    if (SWISH_DEBUG > 9) 
    69         swish_debug_msg("freeing swish_DocInfo"); 
     69        SWISH_DEBUG_MSG("freeing swish_DocInfo"); 
    7070 
    7171    if (SWISH_DEBUG > 9) 
     
    7979    /* encoding and mime are malloced via xmlstrdup elsewhere */ 
    8080    if (SWISH_DEBUG > 9) 
    81         swish_debug_msg("freeing docinfo->encoding"); 
     81        SWISH_DEBUG_MSG("freeing docinfo->encoding"); 
    8282    swish_xfree(ptr->encoding); 
    8383    if (SWISH_DEBUG > 9) 
    84         swish_debug_msg("freeing docinfo->mime"); 
     84        SWISH_DEBUG_MSG("freeing docinfo->mime"); 
    8585    swish_xfree(ptr->mime); 
    8686    if (SWISH_DEBUG > 9) 
    87         swish_debug_msg("freeing docinfo->uri"); 
     87        SWISH_DEBUG_MSG("freeing docinfo->uri"); 
    8888    swish_xfree(ptr->uri); 
    8989    if (SWISH_DEBUG > 9) 
    90         swish_debug_msg("freeing docinfo->ext"); 
     90        SWISH_DEBUG_MSG("freeing docinfo->ext"); 
    9191    swish_xfree(ptr->ext); 
    9292    if (SWISH_DEBUG > 9) 
    93         swish_debug_msg("freeing docinfo->parser"); 
     93        SWISH_DEBUG_MSG("freeing docinfo->parser"); 
    9494    swish_xfree(ptr->parser); 
    9595    if (SWISH_DEBUG > 9) 
    96         swish_debug_msg("freeing docinfo ptr"); 
     96        SWISH_DEBUG_MSG("freeing docinfo ptr"); 
    9797    swish_xfree(ptr); 
    9898     
    9999    if (SWISH_DEBUG > 9) 
    100         swish_debug_msg("docinfo ptr is all freed"); 
     100        SWISH_DEBUG_MSG("docinfo ptr is all freed"); 
    101101} 
    102102 
     
    113113 
    114114    if (!docinfo->uri) 
    115         swish_fatal_err("Failed to return required header Content-Location:"); 
     115        SWISH_CROAK("Failed to return required header Content-Location:"); 
    116116 
    117117    if (docinfo->size == -1) 
    118         swish_fatal_err("Failed to return required header Content-Length: for doc '%s'", 
     118        SWISH_CROAK("Failed to return required header Content-Length: for doc '%s'", 
    119119                         docinfo->uri); 
    120120 
    121121/* might make this conditional on verbose level */ 
    122122    if (docinfo->size == 0)     
    123         swish_fatal_err("Found zero Content-Length for doc '%s'", docinfo->uri); 
     123        SWISH_CROAK("Found zero Content-Length for doc '%s'", docinfo->uri); 
    124124 
    125125    ext = swish_get_file_ext(docinfo->uri); 
     
    139139    if (!docinfo->mime) { 
    140140        if (SWISH_DEBUG > 5) 
    141             swish_debug_msg( "no MIME known. guessing based on uri extension '%s'", docinfo->ext); 
     141            SWISH_DEBUG_MSG( "no MIME known. guessing based on uri extension '%s'", docinfo->ext); 
    142142        docinfo->mime = swish_get_mime_type( config, docinfo->ext ); 
    143143    } 
     
    145145    { 
    146146        if ( SWISH_DEBUG > 9 ) 
    147             swish_debug_msg( "found MIME type in headers: '%s'", docinfo->mime); 
     147            SWISH_DEBUG_MSG( "found MIME type in headers: '%s'", docinfo->mime); 
    148148             
    149149    } 
     
    151151    if (!docinfo->parser) { 
    152152        if (SWISH_DEBUG > 5) 
    153             swish_debug_msg( "no parser defined in headers -- deducing from content type '%s'", docinfo->mime); 
     153            SWISH_DEBUG_MSG( "no parser defined in headers -- deducing from content type '%s'", docinfo->mime); 
    154154             
    155155        docinfo->parser = swish_get_parser( config, docinfo->mime ); 
     
    158158    { 
    159159        if (SWISH_DEBUG > 5) 
    160             swish_debug_msg( "found parser in headers: '%s'", docinfo->parser); 
     160            SWISH_DEBUG_MSG( "found parser in headers: '%s'", docinfo->parser); 
    161161             
    162162    } 
     
    185185    if ( stat_res == -1) 
    186186    { 
    187         swish_warn_err("Can't stat '%s': %s", filename, strerror(errno)); 
     187        SWISH_WARN("Can't stat '%s': %s", filename, strerror(errno)); 
    188188        return 0; 
    189189    } 
    190190                        
    191191    if (SWISH_DEBUG > 9) 
    192         swish_debug_msg("handling url %s", filename); 
     192        SWISH_DEBUG_MSG("handling url %s", filename); 
    193193         
    194194    if(i->uri != NULL) 
     
    200200     
    201201    if (SWISH_DEBUG > 9) 
    202         swish_debug_msg("handling mime"); 
     202        SWISH_DEBUG_MSG("handling mime"); 
    203203         
    204204    if(i->mime != NULL) 
     
    208208         
    209209    if (SWISH_DEBUG > 9) 
    210         swish_debug_msg("handling parser"); 
     210        SWISH_DEBUG_MSG("handling parser"); 
    211211         
    212212    if(i->parser != NULL) 
     
    229229            (struct tm *) localtime((time_t *)&(docinfo->mtime) )); 
    230230 
    231     swish_debug_msg("DocInfo"); 
    232     swish_debug_msg("  docinfo ptr: %lu",                  (unsigned long)docinfo); 
    233     //swish_debug_msg("  size of swish_DocInfo struct: %d", (int)sizeof(swish_DocInfo)); 
    234     //swish_debug_msg("  size of docinfo ptr: %d",           (int)sizeof(*docinfo)); 
    235     swish_debug_msg("  uri: %s (%d)", docinfo->uri,        (int)sizeof(docinfo->uri)); 
    236     swish_debug_msg("  doc size: %lu bytes (%d)",          (unsigned long)docinfo->size, (int)sizeof(docinfo->size)); 
    237     swish_debug_msg("  doc mtime: %lu (%d)",               (unsigned long)docinfo->mtime, (int)sizeof(docinfo->mtime)); 
    238     //swish_debug_msg("  size of mime: %d",                  (int)sizeof(docinfo->mime)); 
    239     //swish_debug_msg("  size of encoding: %d",              (int)sizeof(docinfo->encoding)); 
    240     swish_debug_msg("  mtime str: %s",                     h_mtime); 
    241     swish_debug_msg("  mime type: %s",                     docinfo->mime); 
    242     swish_debug_msg("  encoding: %s",                      docinfo->encoding); /* only known after parsing has started ... */ 
    243     swish_debug_msg("  file ext: %s",                      docinfo->ext); 
    244     swish_debug_msg("  parser: %s",                        docinfo->parser); 
    245     swish_debug_msg("  nwords: %d",                        docinfo->nwords); 
     231    SWISH_DEBUG_MSG("DocInfo"); 
     232    SWISH_DEBUG_MSG("  docinfo ptr: %lu",                  (unsigned long)docinfo); 
     233    //SWISH_DEBUG_MSG("  size of swish_DocInfo struct: %d", (int)sizeof(swish_DocInfo)); 
     234    //SWISH_DEBUG_MSG("  size of docinfo ptr: %d",           (int)sizeof(*docinfo)); 
     235    SWISH_DEBUG_MSG("  uri: %s (%d)", docinfo->uri,        (int)sizeof(docinfo->uri)); 
     236    SWISH_DEBUG_MSG("  doc size: %lu bytes (%d)",          (unsigned long)docinfo->size, (int)sizeof(docinfo->size)); 
     237    SWISH_DEBUG_MSG("  doc mtime: %lu (%d)",               (unsigned long)docinfo->mtime, (int)sizeof(docinfo->mtime)); 
     238    //SWISH_DEBUG_MSG("  size of mime: %d",                  (int)sizeof(docinfo->mime)); 
     239    //SWISH_DEBUG_MSG("  size of encoding: %d",              (int)sizeof(docinfo->encoding)); 
     240    SWISH_DEBUG_MSG("  mtime str: %s",                     h_mtime); 
     241    SWISH_DEBUG_MSG("  mime type: %s",                     docinfo->mime); 
     242    SWISH_DEBUG_MSG("  encoding: %s",                      docinfo->encoding); /* only known after parsing has started ... */ 
     243    SWISH_DEBUG_MSG("  file ext: %s",                      docinfo->ext); 
     244    SWISH_DEBUG_MSG("  parser: %s",                        docinfo->parser); 
     245    SWISH_DEBUG_MSG("  nwords: %d",                        docinfo->nwords); 
    246246     
    247247    swish_xfree( h_mtime );     
  • libswish3/trunk/src/libswish3/error.c

    r1913 r1952  
    4040} 
    4141 
    42 void swish_fatal_err(char *msgfmt,...) 
     42void swish_croak(const char *file, int line, const char *func, char *msgfmt,...) 
    4343{ 
    4444  va_list args; 
     
    4848 
    4949  va_start (args,msgfmt); 
    50   fprintf  (error_handle, "Swish ERROR: "); 
     50  fprintf  (error_handle, "Swish ERROR %s:%d %s: ", file, line, func); 
    5151  vfprintf (error_handle, msgfmt, args); 
    5252  fprintf  (error_handle, "\n"); 
     
    5959} 
    6060 
    61 void swish_warn_err(char *msgfmt,...) 
     61void swish_warn(const char *file, int line, const char *func, char *msgfmt,...) 
    6262{ 
    6363  va_list args; 
     
    6767 
    6868  va_start (args,msgfmt); 
    69   fprintf  (error_handle, "Swish WARNING: "); 
     69  fprintf  (error_handle, "Swish WARNING %s:%d %s: ", file, line, func); 
    7070  vfprintf (error_handle, msgfmt, args); 
    7171  fprintf  (error_handle, "\n"); 
     
    7373} 
    7474 
    75 void swish_debug_msg(char *msgfmt,...) 
     75void swish_debug(const char *file, int line, const char *func, char *msgfmt,...) 
    7676{ 
    7777  va_list args; 
     
    8181 
    8282  va_start (args,msgfmt); 
    83   fprintf  (error_handle, "Swish DEBUG: "); 
     83  fprintf  (error_handle, "Swish DEBUG %s:%d %s: ", file, line, func); 
    8484  vfprintf (error_handle, msgfmt, args); 
    8585  fprintf  (error_handle, "\n"); 
  • libswish3/trunk/src/libswish3/hash.c

    r1913 r1952  
    4242    ret = xmlHashAddEntry( hash, key, value ); 
    4343    if (ret == -1) 
    44         swish_fatal_err("xmlHashAddEntry for %s failed", key); 
     44        SWISH_CROAK("xmlHashAddEntry for %s failed", key); 
    4545                 
    4646    return ret; 
     
    5353    ret = xmlHashUpdateEntry(hash, key, value, (xmlHashDeallocator)free_hashval ); 
    5454    if (ret == -1) 
    55         swish_fatal_err("xmlHashUpdateEntry for %s failed", key); 
     55        SWISH_CROAK("xmlHashUpdateEntry for %s failed", key); 
    5656     
    5757    return ret; 
     
    6464    ret = xmlHashRemoveEntry(hash, key, (xmlHashDeallocator)free_hashval ); 
    6565    if (ret == -1) 
    66         swish_fatal_err("xmlHashRemoveEntry for %s failed", key); 
     66        SWISH_CROAK("xmlHashRemoveEntry for %s failed", key); 
    6767         
    6868    return ret; 
     
    7474    if (h == NULL) 
    7575    { 
    76         swish_fatal_err("error creating hash of size %d", size); 
     76        SWISH_CROAK("error creating hash of size %d", size); 
    7777        return NULL; 
    7878    } 
  • libswish3/trunk/src/libswish3/io.c

    r1935 r1952  
    6464 
    6565        if (j) 
    66             swish_warn_err
     66            SWISH_WARN
    6767                    "Substituted %d embedded null or connector character(s) in file '%s' with newline(s)\n", 
    6868                     j, filename); 
     
    8888    if (bytes_read != flen) 
    8989    { 
    90         swish_fatal_err("did not read expected bytes: %ld expected, %d read\n", flen, bytes_read); 
     90        SWISH_CROAK("did not read expected bytes: %ld expected, %d read\n", flen, bytes_read); 
    9191    } 
    9292    buffer[bytes_read] = '\0';    /* terminate the string */ 
     
    111111    { 
    112112        flen = SWISH_MAX_FILE_LEN; 
    113         swish_warn_err("max file len %ld exceeded - cannot read %ld bytes from %s", 
     113        SWISH_WARN("max file len %ld exceeded - cannot read %ld bytes from %s", 
    114114             SWISH_MAX_FILE_LEN, flen, filename); 
    115115 
     
    120120    if ((fp = fopen((char *) filename, "r")) == 0) 
    121121    { 
    122         swish_fatal_err("Error reading file %s: %s\n",  
     122        SWISH_CROAK("Error reading file %s: %s\n",  
    123123                            filename, strerror(errno)); 
    124124    } 
     
    128128    if (bytes_read != flen) 
    129129    { 
    130         swish_fatal_err("did not read expected bytes: %ld expected, %d read (%s)\n",  
     130        SWISH_CROAK("did not read expected bytes: %ld expected, %d read (%s)\n",  
    131131                            flen, bytes_read, strerror(errno)); 
    132132    } 
     
    135135    /* close the stream */ 
    136136    if (fclose(fp)) 
    137         swish_fatal_err("error closing filehandle for %s: %s\n",  
     137        SWISH_CROAK("error closing filehandle for %s: %s\n",  
    138138                            filename, strerror(errno)); 
    139139 
     
    152152    if (stat((char *) filename, &info)) 
    153153    { 
    154         swish_fatal_err("Can't stat %s: %s\n", filename, strerror(errno)); 
     154        SWISH_CROAK("Can't stat %s: %s\n", filename, strerror(errno)); 
    155155    } 
    156156    return swish_slurp_file_len(filename, info.st_size); 
  • libswish3/trunk/src/libswish3/libswish3.h

    r1934 r1952  
    133133#define SWISH_DEBUG_NAMEDBUFFER 15 
    134134 
     135#define SWISH_DEBUG_MSG(args...)                                    \ 
     136    swish_debug(__FILE__, __LINE__, __func__, args) 
     137 
     138#define SWISH_CROAK(args...)                                        \ 
     139    swish_croak(__FILE__, __LINE__, __func__, args) 
     140 
     141#define SWISH_WARN(args...)                                         \ 
     142    swish_warn(__FILE__, __LINE__, __func__, args) 
     143 
    135144#ifdef __cplusplus 
    136145extern "C" { 
     
    349358*/ 
    350359void        swish_set_error_handle( FILE *where ); 
    351 void        swish_fatal_err(char *msg,...); 
    352 void        swish_warn_err(char *msg,...); 
    353 void        swish_debug_msg(char *msg,...); 
     360void        swish_croak(const char *file, int line, const char *func, char *msg,...); 
     361void        swish_warn(const char *file, int line, const char *func, char *msg,...); 
     362void        swish_debug(const char *file, int line, const char *func, char *msg,...); 
    354363/* 
    355364=cut 
  • libswish3/trunk/src/libswish3/mem.c

    r1930 r1952  
    4848     
    4949    if ( new_ptr == NULL) 
    50         swish_fatal_err("Out of memory (could not reallocate %lu more bytes)!", (unsigned long)size); 
     50        SWISH_CROAK("Out of memory (could not reallocate %lu more bytes)!", (unsigned long)size); 
    5151 
    5252    return new_ptr; 
     
    5959         
    6060    if ( ptr == NULL ) 
    61         swish_fatal_err("Out of memory! Can't malloc %lu bytes", (unsigned long)size); 
     61        SWISH_CROAK("Out of memory! Can't malloc %lu bytes", (unsigned long)size); 
    6262             
    6363    memcount++; 
    6464    if ( SWISH_DEBUG > 20 ) 
    65         swish_debug_msg( "memcount = %ld", memcount); 
     65        SWISH_DEBUG_MSG( "memcount = %ld", memcount); 
    6666     
    6767    return ptr; 
     
    7272    memcount++; 
    7373    if ( SWISH_DEBUG > 20 ) 
    74         swish_debug_msg( "memcount = %ld", memcount); 
     74        SWISH_DEBUG_MSG( "memcount = %ld", memcount); 
    7575    return( xmlStrdup( ptr ) ); 
    7676} 
     
    8080    memcount++; 
    8181    if ( SWISH_DEBUG > 20 ) 
    82         swish_debug_msg( "memcount = %ld", memcount); 
     82        SWISH_DEBUG_MSG( "memcount = %ld", memcount); 
    8383    return( xmlStrndup( ptr, len ) ); 
    8484} 
     
    8888    if ( ptr == NULL ) 
    8989    { 
    90         swish_warn_err(" >>>>>>>>>>>>>> attempt to free NULL pointer <<<<<<<<<<<<<<"); 
     90        SWISH_WARN(" >>>>>>>>>>>>>> attempt to free NULL pointer <<<<<<<<<<<<<<"); 
    9191        return; 
    9292    } 
     
    9797     
    9898    if ( SWISH_DEBUG > 20 ) 
    99         swish_debug_msg( "memcount = %ld", memcount); 
     99        SWISH_DEBUG_MSG( "memcount = %ld", memcount); 
    100100} 
    101101 
    102102void swish_mem_debug() 
    103103{ 
    104     //swish_debug_msg("memcount = %ld", memcount); 
     104    //SWISH_DEBUG_MSG("memcount = %ld", memcount); 
    105105    if (memcount > 0) 
    106         swish_warn_err("memory error: %ld more swish_xmalloc()s or swish_xstrdup()s than swish_xfree()s",  
     106        SWISH_WARN("memory error: %ld more swish_xmalloc()s or swish_xstrdup()s than swish_xfree()s",  
    107107                        memcount); 
    108108     
    109109    if (memcount < 0) 
    110         swish_warn_err("memory error: too many swish_xfree()s %d", memcount); 
     110        SWISH_WARN("memory error: too many swish_xfree()s %d", memcount); 
    111111} 
  • libswish3/trunk/src/libswish3/mime_types.c

    r1913 r1952  
    224224    if ( mime == NULL ) 
    225225    { 
    226         swish_warn_err("No MIME type known for '%s' -- using '%s'", fileext, SWISH_DEFAULT_MIME ); 
     226        SWISH_WARN("No MIME type known for '%s' -- using '%s'", fileext, SWISH_DEFAULT_MIME ); 
    227227        mime = swish_xstrdup( (xmlChar *)SWISH_DEFAULT_MIME ); 
    228228    } 
     
    242242     
    243243    if (SWISH_DEBUG > 9) 
    244         swish_debug_msg("using parser '%s' based on MIME '%s'", parser, mime ); 
     244        SWISH_DEBUG_MSG("using parser '%s' based on MIME '%s'", parser, mime ); 
    245245     
    246246    deftype = xmlHashLookup( parsers, (xmlChar *)SWISH_DEFAULT_PARSER ); /* error check?? */ 
     
    248248    if ( parser == NULL ) 
    249249    { 
    250         swish_warn_err("No parser for MIME '%s' -- using '%s'", mime, deftype); 
     250        SWISH_WARN("No parser for MIME '%s' -- using '%s'", mime, deftype); 
    251251        parser = deftype;      
    252252    } 
  • libswish3/trunk/src/libswish3/namedbuffer.c

    r1930 r1952  
    4444    if (xmlHashLookup(hash, name)) 
    4545    { 
    46         swish_warn_err("%s is already in NamedBuffer hash -- ignoring", name); 
     46        SWISH_WARN("%s is already in NamedBuffer hash -- ignoring", name); 
    4747        return; 
    4848    } 
     
    5050 
    5151    if (SWISH_DEBUG  == SWISH_DEBUG_NAMEDBUFFER) 
    52         swish_debug_msg("  adding %s to NamedBuffer\n", name); 
     52        SWISH_DEBUG_MSG("  adding %s to NamedBuffer\n", name); 
    5353     
    5454    swish_hash_add(hash, name, xmlBufferCreateSize((size_t)SWISH_BUFFER_CHUNK_SIZE)); 
     
    5959{ 
    6060    if (SWISH_DEBUG == SWISH_DEBUG_NAMEDBUFFER) 
    61         swish_debug_msg(" freeing NamedBuffer %s\n", name); 
     61        SWISH_DEBUG_MSG(" freeing NamedBuffer %s\n", name); 
    6262 
    6363    xmlBufferFree(buffer); 
     
    8686     
    8787    if (nb->ref_cnt > 0) 
    88         swish_warn_err("freeing NamedBuffer with ref_cnt > 0 (%d)", nb->ref_cnt); 
     88        SWISH_WARN("freeing NamedBuffer with ref_cnt > 0 (%d)", nb->ref_cnt); 
    8989         
    9090    if (nb->stash != NULL) 
    91         swish_warn_err("freeing NamedBuffer with non-null stash"); 
     91        SWISH_WARN("freeing NamedBuffer with non-null stash"); 
    9292         
    9393    swish_xfree(nb); 
     
    9898print_buffer(xmlBufferPtr buffer, xmlChar * label, xmlChar * name) 
    9999{ 
    100     swish_debug_msg("%s:\n<%s>%s</%s>", label, name, xmlBufferContent(buffer), name); 
     100    SWISH_DEBUG_MSG("%s:\n<%s>%s</%s>", label, name, xmlBufferContent(buffer), name); 
    101101} 
    102102 
     
    146146         
    147147        if (!buf) 
    148             swish_fatal_err("%s is not a named buffer", name); 
     148            SWISH_CROAK("%s is not a named buffer", name); 
    149149             
    150150    } 
     
    159159    if(cleanwsp) 
    160160    { 
    161         //swish_debug_msg("before cleanwsp: '%s'", str); 
     161        //SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); 
    162162        nowhitesp = swish_str_skip_ws(str); 
    163163        swish_str_trim_ws(nowhitesp); 
    164         //swish_debug_msg("after  cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); 
     164        //SWISH_DEBUG_MSG("after  cleanwsp: adding '%s' to buffer '%s'", nowhitesp, name); 
    165165        swish_append_buffer(buf, nowhitesp, xmlStrlen(nowhitesp)); 
    166166    } 
    167167    else 
    168168    { 
    169         //swish_debug_msg("adding '%s' to buffer '%s'", str, name); 
     169        //SWISH_DEBUG_MSG("adding '%s' to buffer '%s'", str, name); 
    170170        swish_append_buffer(buf, str, len); 
    171171    } 
     
    184184    if (buf == NULL) 
    185185    { 
    186         swish_fatal_err("bad news. buf ptr is NULL"); 
     186        SWISH_CROAK("bad news. buf ptr is NULL"); 
    187187    } 
    188188 
     
    190190    if (ret) 
    191191    { 
    192         swish_fatal_err("problem adding \n>>%s<<\n length %d to buffer. Err: %d",  
     192        SWISH_CROAK("problem adding \n>>%s<<\n length %d to buffer. Err: %d",  
    193193                        txt, txtlen, ret); 
    194194    } 
  • libswish3/trunk/src/libswish3/parser.c

    r1934 r1952  
    232232             
    233233                if ( SWISH_DEBUG > 3 ) 
    234                     swish_debug_msg("%d HTML attr: %s", i, atts[i]); 
     234                    SWISH_DEBUG_MSG("%d HTML attr: %s", i, atts[i]); 
    235235                 
    236236                if( xmlStrEqual(atts[i], (xmlChar*)"name")) 
    237237                { 
    238                     //swish_debug_msg("found name: %s", atts[i+1]); 
     238                    //SWISH_DEBUG_MSG("found name: %s", atts[i+1]); 
    239239                    metaname = (xmlChar*)atts[i+1]; 
    240240                } 
     
    242242                else if ( xmlStrEqual(atts[i], (xmlChar*)"content")) 
    243243                { 
    244                     //swish_debug_msg("found content: %s", atts[i+1]); 
     244                    //SWISH_DEBUG_MSG("found content: %s", atts[i+1]); 
    245245                    metacontent = (xmlChar*)atts[i+1]; 
    246246                } 
     
    252252        { 
    253253            if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    254                 swish_debug_msg("found HTML meta: %s => %s", metaname, metacontent); 
     254                SWISH_DEBUG_MSG("found HTML meta: %s => %s", metaname, metacontent); 
    255255                 
    256256            /* do not match across metas */ 
     
    299299    if (alias) 
    300300    { 
    301         //swish_debug_msg("%s alias -> %s", swishtag, alias); 
     301        //SWISH_DEBUG_MSG("%s alias -> %s", swishtag, alias); 
    302302        swish_xfree(swishtag); 
    303303        swishtag = swish_xstrdup(alias); 
     
    315315     
    316316    if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    317         swish_debug_msg("buffer is >>%s<< before flush, word_pos = %d",  
     317        SWISH_DEBUG_MSG("buffer is >>%s<< before flush, word_pos = %d",  
    318318            xmlBufferContent(parse_data->buf_ptr), parse_data->word_pos); 
    319319 
     
    368368 
    369369    if (SWISH_DEBUG > 2) 
    370         swish_debug_msg("startDocument()"); 
     370        SWISH_DEBUG_MSG("startDocument()"); 
    371371 
    372372} 
     
    379379 
    380380    if (SWISH_DEBUG > 2) 
    381         swish_debug_msg("endDocument()"); 
     381        SWISH_DEBUG_MSG("endDocument()"); 
    382382 
    383383    /* whatever's left */ 
     
    440440 
    441441    if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    442         swish_debug_msg("checking config for '%s' in watched tags", parse_data->tag); 
     442        SWISH_DEBUG_MSG("checking config for '%s' in watched tags", parse_data->tag); 
    443443 
    444444 
     
    447447    { 
    448448        if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    449             swish_debug_msg(" %s = new property", parse_data->tag); 
     449            SWISH_DEBUG_MSG(" %s = new property", parse_data->tag); 
    450450 
    451451        add_stack_to_prop_buf(NULL, parse_data); 
     
    454454        parse_data->propstack = push_tag_stack(parse_data->propstack, parse_data->tag); 
    455455 
    456         /* swish_debug_msg("%s pushed ok unto propstack", parse_data->tag);  */ 
     456        /* SWISH_DEBUG_MSG("%s pushed ok unto propstack", parse_data->tag);  */ 
    457457    } 
    458458 
     
    461461    { 
    462462        if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    463             swish_debug_msg(" %s = new metaname", parse_data->tag); 
     463            SWISH_DEBUG_MSG(" %s = new metaname", parse_data->tag); 
    464464                                
    465465        flush_buffer( parse_data, parse_data->metastack->head->name, parse_data->metastack->flat ); 
     
    469469     
    470470    if (SWISH_DEBUG == SWISH_DEBUG_PARSER) 
    471         swish_debug_msg("config check for '%s' done", parse_data->tag); 
     471        SWISH_DEBUG_MSG("config check for '%s' done", parse_data->tag); 
    472472 
    473473 
     
    489489 
    490490    if (SWISH_DEBUG > 2) 
    491         swish_debug_msg(" endElement(%s) (%s)", (xmlChar *) tag, parse_data->tag); 
     491        SWISH_DEBUG_MSG(" endElement(%s) (%s)", (xmlChar *) tag, parse_data->tag); 
    492492 
    493493    if ((context = pop_tag_stack_on_match(parse_data->propstack, parse_data->tag)) != NULL) 
    494494    { 
    495         //swish_debug_msg("popped %s from propstack", context); 
     495        //SWISH_DEBUG_MSG("popped %s from propstack", context); 
    496496        add_stack_to_prop_buf(parse_data->tag, parse_data); 
    497497        xmlBufferEmpty(parse_data->prop_buf); 
     
    501501    if ((context = pop_tag_stack_on_match(parse_data->metastack, parse_data->tag)) != NULL) 
    502502    { 
    503         /* swish_debug_msg("popped %s from metastack", parse_data->tag); */ 
     503        /* SWISH_DEBUG_MSG("popped %s from metastack", parse_data->tag); */ 
    504504        flush_buffer(parse_data, parse_data->tag, context); 
    505505        swish_xfree(context); 
     
    525525 
    526526    /* 
    527      * swish_debug_msg( "sizeof output buf is %d; len was %d\n", sizeof(output), 
     527     * SWISH_DEBUG_MSG( "sizeof output buf is %d; len was %d\n", sizeof(output), 
    528528     * len ); 
    529529     */ 
    530530 
    531     /* swish_debug_msg( "characters"); */ 
     531    /* SWISH_DEBUG_MSG( "characters"); */ 
    532532 
    533533    for (i = 0; i < len; i++) 
     
    545545    if (parse_data->bump_word && xmlBufferLength(parse_data->prop_buf)) 
    546546    { 
    547         //swish_debug_msg("   appending ' ' to prop_buf"); 
     547        //SWISH_DEBUG_MSG("   appending ' ' to prop_buf"); 
    548548        swish_append_buffer(parse_data->prop_buf, (xmlChar*)" ", 1); 
    549549    } 
    550550     
    551     //swish_debug_msg("   appending '%s' to prop_buf", output); 
     551    //SWISH_DEBUG_MSG("   appending '%s' to prop_buf", output); 
    552552    swish_append_buffer(parse_data->prop_buf, output, len); 
    553553 
     
    561561{ 
    562562    if (SWISH_DEBUG > 2) 
    563         swish_debug_msg(" >> mycharacters()"); 
     563        SWISH_DEBUG_MSG(" >> mycharacters()"); 
    564564 
    565565    buffer_characters(parse_data, ch, len); 
     
    591591        return; 
    592592         
    593     swish_warn_err("libxml2 error:"); 
     593    SWISH_WARN("libxml2 error:"); 
    594594 
    59