Changeset 1952
- Timestamp:
- 10/26/07 00:17:00 (7 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/analyzer.c (modified) (1 diff)
- libswish3/trunk/src/libswish3/config.c (modified) (25 diffs)
- libswish3/trunk/src/libswish3/docinfo.c (modified) (13 diffs)
- libswish3/trunk/src/libswish3/error.c (modified) (6 diffs)
- libswish3/trunk/src/libswish3/hash.c (modified) (4 diffs)
- libswish3/trunk/src/libswish3/io.c (modified) (7 diffs)
- libswish3/trunk/src/libswish3/libswish3.h (modified) (2 diffs)
- libswish3/trunk/src/libswish3/mem.c (modified) (6 diffs)
- libswish3/trunk/src/libswish3/mime_types.c (modified) (3 diffs)
- libswish3/trunk/src/libswish3/namedbuffer.c (modified) (9 diffs)
- libswish3/trunk/src/libswish3/parser.c (modified) (89 diffs)
- libswish3/trunk/src/libswish3/string.c (modified) (11 diffs)
- libswish3/trunk/src/libswish3/words.c (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/analyzer.c
r1927 r1952 51 51 { 52 52 if (SWISH_DEBUG) 53 swish_debug_msg("skipping WordList");53 SWISH_DEBUG_MSG("skipping WordList"); 54 54 55 55 a->tokenize = 0; libswish3/trunk/src/libswish3/config.c
r1927 r1952 63 63 { 64 64 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); 66 66 67 67 swish_xfree((xmlChar *) payload); … … 75 75 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 76 76 { 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); 80 80 } 81 81 … … 91 91 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 92 92 { 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); 96 96 } 97 97 … … 100 100 if (config->stash != NULL) 101 101 { 102 swish_warn_err("possible memory leak: config->stash was not freed");102 SWISH_WARN("possible memory leak: config->stash was not freed"); 103 103 } 104 104 … … 119 119 120 120 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 121 swish_debug_msg("creating default config");121 SWISH_DEBUG_MSG("creating default config"); 122 122 123 123 /* create our object */ … … 358 358 if (node_has_value(node) && !node_has_key(node)) 359 359 { 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); 361 361 return 0; 362 362 } … … 422 422 if (str == NULL) 423 423 { 424 swish_warn_err("no value for config opt '%s'", node->name);424 SWISH_WARN("no value for config opt '%s'", node->name); 425 425 return NULL; 426 426 } … … 450 450 doc = xmlParseFile((const char *) conf); 451 451 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 452 swish_debug_msg("Parsing configuration file: %s", conf);452 SWISH_DEBUG_MSG("Parsing configuration file: %s", conf); 453 453 } 454 454 else … … 456 456 doc = xmlParseMemory((const char *) conf, xmlStrlen(conf)); 457 457 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 458 swish_debug_msg("Parsing configuration from memory");458 SWISH_DEBUG_MSG("Parsing configuration from memory"); 459 459 } 460 460 461 461 if (doc == NULL) 462 swish_fatal_err("error: could not parse XML: %s", conf);462 SWISH_CROAK("error: could not parse XML: %s", conf); 463 463 464 464 return doc; … … 530 530 { 531 531 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); 533 533 return 0; 534 534 } … … 574 574 if (cv->multi) /* already flagged as multi */ 575 575 { 576 swish_debug_msg("%s is an existing multi-config", node->name);576 SWISH_DEBUG_MSG("%s is an existing multi-config", node->name); 577 577 578 578 add_multi_node_to_cv(node, cv); … … 581 581 else 582 582 { 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); 584 584 585 585 /* free the existing one and replace it with new … … 600 600 if (is_multi(node)) 601 601 { 602 swish_debug_msg("%s is a new multi-config", node->name);602 SWISH_DEBUG_MSG("%s is a new multi-config", node->name); 603 603 cv->value = swish_new_hash(16); 604 604 add_multi_node_to_cv(node, cv); … … 608 608 if (is_equal(node)) 609 609 { 610 swish_debug_msg("%s is an equal node", node->name);610 SWISH_DEBUG_MSG("%s is an equal node", node->name); 611 611 cv->equal = 1; 612 612 } … … 665 665 666 666 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); 668 668 669 669 /* append value/args to any existing names in config */ … … 675 675 if (vhash == NULL) 676 676 { 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); 678 678 } 679 679 else 680 680 { 681 681 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); 683 683 684 684 name_seen = 1; … … 692 692 vhash = xmlHashCreate(16); /* values => args */ 693 693 if (vhash == NULL) 694 swish_fatal_err("error creating vhash");694 SWISH_CROAK("error creating vhash"); 695 695 696 696 } … … 724 724 725 725 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); 727 727 728 728 tmp_value = opt_type ? swish_xstrdup(opt_type) : swish_xstrdup(tmp_arg); … … 741 741 free_tmp = 1; 742 742 if (SWISH_DEBUG == SWISH_DEBUG_CONFIG) 743 swish_debug_msg("tolower str: >%s<", tmp_arg);743 SWISH_DEBUG_MSG("tolower str: >%s<", tmp_arg); 744 744 745 745 tmp_arg = swish_str_tolower(tmp_arg); … … 748 748 749 749 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); 751 751 752 752 if (xmlHashLookup(vhash, tmp_arg)) … … 775 775 { 776 776 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); 778 778 779 779 swish_hash_add(config->conf, opt_name, vhash); … … 797 797 config_val_printer(xmlChar * val, xmlChar * str, xmlChar * key) 798 798 { 799 swish_debug_msg(" %s => %s", key, val);799 SWISH_DEBUG_MSG(" %s => %s", key, val); 800 800 } 801 801 … … 803 803 config_printer(xmlHashTablePtr vhash, xmlChar * str, xmlChar * key) 804 804 { 805 swish_debug_msg(" Config %s:", key);805 SWISH_DEBUG_MSG(" Config %s:", key); 806 806 807 807 xmlHashScan(vhash, (xmlHashScanner) config_val_printer, "vhash"); … … 816 816 int size = xmlHashSize(config->conf); 817 817 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); 822 822 823 823 xmlHashScan(config->conf, (xmlHashScanner) config_printer, "opt name"); … … 836 836 { 837 837 /* 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); 839 839 } 840 840 libswish3/trunk/src/libswish3/docinfo.c
r1913 r1952 40 40 41 41 if (SWISH_DEBUG > 9) 42 swish_debug_msg("init'ing docinfo");42 SWISH_DEBUG_MSG("init'ing docinfo"); 43 43 44 44 swish_DocInfo *docinfo = swish_xmalloc( sizeof(swish_DocInfo) ); … … 55 55 if (SWISH_DEBUG > 9) 56 56 { 57 swish_debug_msg("docinfo all ready");57 SWISH_DEBUG_MSG("docinfo all ready"); 58 58 swish_debug_docinfo( docinfo ); 59 59 } … … 67 67 { 68 68 if (SWISH_DEBUG > 9) 69 swish_debug_msg("freeing swish_DocInfo");69 SWISH_DEBUG_MSG("freeing swish_DocInfo"); 70 70 71 71 if (SWISH_DEBUG > 9) … … 79 79 /* encoding and mime are malloced via xmlstrdup elsewhere */ 80 80 if (SWISH_DEBUG > 9) 81 swish_debug_msg("freeing docinfo->encoding");81 SWISH_DEBUG_MSG("freeing docinfo->encoding"); 82 82 swish_xfree(ptr->encoding); 83 83 if (SWISH_DEBUG > 9) 84 swish_debug_msg("freeing docinfo->mime");84 SWISH_DEBUG_MSG("freeing docinfo->mime"); 85 85 swish_xfree(ptr->mime); 86 86 if (SWISH_DEBUG > 9) 87 swish_debug_msg("freeing docinfo->uri");87 SWISH_DEBUG_MSG("freeing docinfo->uri"); 88 88 swish_xfree(ptr->uri); 89 89 if (SWISH_DEBUG > 9) 90 swish_debug_msg("freeing docinfo->ext");90 SWISH_DEBUG_MSG("freeing docinfo->ext"); 91 91 swish_xfree(ptr->ext); 92 92 if (SWISH_DEBUG > 9) 93 swish_debug_msg("freeing docinfo->parser");93 SWISH_DEBUG_MSG("freeing docinfo->parser"); 94 94 swish_xfree(ptr->parser); 95 95 if (SWISH_DEBUG > 9) 96 swish_debug_msg("freeing docinfo ptr");96 SWISH_DEBUG_MSG("freeing docinfo ptr"); 97 97 swish_xfree(ptr); 98 98 99 99 if (SWISH_DEBUG > 9) 100 swish_debug_msg("docinfo ptr is all freed");100 SWISH_DEBUG_MSG("docinfo ptr is all freed"); 101 101 } 102 102 … … 113 113 114 114 if (!docinfo->uri) 115 swish_fatal_err("Failed to return required header Content-Location:");115 SWISH_CROAK("Failed to return required header Content-Location:"); 116 116 117 117 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'", 119 119 docinfo->uri); 120 120 121 121 /* might make this conditional on verbose level */ 122 122 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); 124 124 125 125 ext = swish_get_file_ext(docinfo->uri); … … 139 139 if (!docinfo->mime) { 140 140 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); 142 142 docinfo->mime = swish_get_mime_type( config, docinfo->ext ); 143 143 } … … 145 145 { 146 146 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); 148 148 149 149 } … … 151 151 if (!docinfo->parser) { 152 152 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); 154 154 155 155 docinfo->parser = swish_get_parser( config, docinfo->mime ); … … 158 158 { 159 159 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); 161 161 162 162 } … … 185 185 if ( stat_res == -1) 186 186 { 187 swish_warn_err("Can't stat '%s': %s", filename, strerror(errno));187 SWISH_WARN("Can't stat '%s': %s", filename, strerror(errno)); 188 188 return 0; 189 189 } 190 190 191 191 if (SWISH_DEBUG > 9) 192 swish_debug_msg("handling url %s", filename);192 SWISH_DEBUG_MSG("handling url %s", filename); 193 193 194 194 if(i->uri != NULL) … … 200 200 201 201 if (SWISH_DEBUG > 9) 202 swish_debug_msg("handling mime");202 SWISH_DEBUG_MSG("handling mime"); 203 203 204 204 if(i->mime != NULL) … … 208 208 209 209 if (SWISH_DEBUG > 9) 210 swish_debug_msg("handling parser");210 SWISH_DEBUG_MSG("handling parser"); 211 211 212 212 if(i->parser != NULL) … … 229 229 (struct tm *) localtime((time_t *)&(docinfo->mtime) )); 230 230 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); 246 246 247 247 swish_xfree( h_mtime ); libswish3/trunk/src/libswish3/error.c
r1913 r1952 40 40 } 41 41 42 void swish_ fatal_err(char *msgfmt,...)42 void swish_croak(const char *file, int line, const char *func, char *msgfmt,...) 43 43 { 44 44 va_list args; … … 48 48 49 49 va_start (args,msgfmt); 50 fprintf (error_handle, "Swish ERROR : ");50 fprintf (error_handle, "Swish ERROR %s:%d %s: ", file, line, func); 51 51 vfprintf (error_handle, msgfmt, args); 52 52 fprintf (error_handle, "\n"); … … 59 59 } 60 60 61 void swish_warn _err(char *msgfmt,...)61 void swish_warn(const char *file, int line, const char *func, char *msgfmt,...) 62 62 { 63 63 va_list args; … … 67 67 68 68 va_start (args,msgfmt); 69 fprintf (error_handle, "Swish WARNING : ");69 fprintf (error_handle, "Swish WARNING %s:%d %s: ", file, line, func); 70 70 vfprintf (error_handle, msgfmt, args); 71 71 fprintf (error_handle, "\n"); … … 73 73 } 74 74 75 void swish_debug _msg(char *msgfmt,...)75 void swish_debug(const char *file, int line, const char *func, char *msgfmt,...) 76 76 { 77 77 va_list args; … … 81 81 82 82 va_start (args,msgfmt); 83 fprintf (error_handle, "Swish DEBUG : ");83 fprintf (error_handle, "Swish DEBUG %s:%d %s: ", file, line, func); 84 84 vfprintf (error_handle, msgfmt, args); 85 85 fprintf (error_handle, "\n"); libswish3/trunk/src/libswish3/hash.c
r1913 r1952 42 42 ret = xmlHashAddEntry( hash, key, value ); 43 43 if (ret == -1) 44 swish_fatal_err("xmlHashAddEntry for %s failed", key);44 SWISH_CROAK("xmlHashAddEntry for %s failed", key); 45 45 46 46 return ret; … … 53 53 ret = xmlHashUpdateEntry(hash, key, value, (xmlHashDeallocator)free_hashval ); 54 54 if (ret == -1) 55 swish_fatal_err("xmlHashUpdateEntry for %s failed", key);55 SWISH_CROAK("xmlHashUpdateEntry for %s failed", key); 56 56 57 57 return ret; … … 64 64 ret = xmlHashRemoveEntry(hash, key, (xmlHashDeallocator)free_hashval ); 65 65 if (ret == -1) 66 swish_fatal_err("xmlHashRemoveEntry for %s failed", key);66 SWISH_CROAK("xmlHashRemoveEntry for %s failed", key); 67 67 68 68 return ret; … … 74 74 if (h == NULL) 75 75 { 76 swish_fatal_err("error creating hash of size %d", size);76 SWISH_CROAK("error creating hash of size %d", size); 77 77 return NULL; 78 78 } libswish3/trunk/src/libswish3/io.c
r1935 r1952 64 64 65 65 if (j) 66 swish_warn_err(66 SWISH_WARN( 67 67 "Substituted %d embedded null or connector character(s) in file '%s' with newline(s)\n", 68 68 j, filename); … … 88 88 if (bytes_read != flen) 89 89 { 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); 91 91 } 92 92 buffer[bytes_read] = '\0'; /* terminate the string */ … … 111 111 { 112 112 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", 114 114 SWISH_MAX_FILE_LEN, flen, filename); 115 115 … … 120 120 if ((fp = fopen((char *) filename, "r")) == 0) 121 121 { 122 swish_fatal_err("Error reading file %s: %s\n",122 SWISH_CROAK("Error reading file %s: %s\n", 123 123 filename, strerror(errno)); 124 124 } … … 128 128 if (bytes_read != flen) 129 129 { 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", 131 131 flen, bytes_read, strerror(errno)); 132 132 } … … 135 135 /* close the stream */ 136 136 if (fclose(fp)) 137 swish_fatal_err("error closing filehandle for %s: %s\n",137 SWISH_CROAK("error closing filehandle for %s: %s\n", 138 138 filename, strerror(errno)); 139 139 … … 152 152 if (stat((char *) filename, &info)) 153 153 { 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)); 155 155 } 156 156 return swish_slurp_file_len(filename, info.st_size); libswish3/trunk/src/libswish3/libswish3.h
r1934 r1952 133 133 #define SWISH_DEBUG_NAMEDBUFFER 15 134 134 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 135 144 #ifdef __cplusplus 136 145 extern "C" { … … 349 358 */ 350 359 void 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,...);360 void swish_croak(const char *file, int line, const char *func, char *msg,...); 361 void swish_warn(const char *file, int line, const char *func, char *msg,...); 362 void swish_debug(const char *file, int line, const char *func, char *msg,...); 354 363 /* 355 364 =cut libswish3/trunk/src/libswish3/mem.c
r1930 r1952 48 48 49 49 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); 51 51 52 52 return new_ptr; … … 59 59 60 60 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); 62 62 63 63 memcount++; 64 64 if ( SWISH_DEBUG > 20 ) 65 swish_debug_msg( "memcount = %ld", memcount);65 SWISH_DEBUG_MSG( "memcount = %ld", memcount); 66 66 67 67 return ptr; … … 72 72 memcount++; 73 73 if ( SWISH_DEBUG > 20 ) 74 swish_debug_msg( "memcount = %ld", memcount);74 SWISH_DEBUG_MSG( "memcount = %ld", memcount); 75 75 return( xmlStrdup( ptr ) ); 76 76 } … … 80 80 memcount++; 81 81 if ( SWISH_DEBUG > 20 ) 82 swish_debug_msg( "memcount = %ld", memcount);82 SWISH_DEBUG_MSG( "memcount = %ld", memcount); 83 83 return( xmlStrndup( ptr, len ) ); 84 84 } … … 88 88 if ( ptr == NULL ) 89 89 { 90 swish_warn_err(" >>>>>>>>>>>>>> attempt to free NULL pointer <<<<<<<<<<<<<<");90 SWISH_WARN(" >>>>>>>>>>>>>> attempt to free NULL pointer <<<<<<<<<<<<<<"); 91 91 return; 92 92 } … … 97 97 98 98 if ( SWISH_DEBUG > 20 ) 99 swish_debug_msg( "memcount = %ld", memcount);99 SWISH_DEBUG_MSG( "memcount = %ld", memcount); 100 100 } 101 101 102 102 void swish_mem_debug() 103 103 { 104 // swish_debug_msg("memcount = %ld", memcount);104 //SWISH_DEBUG_MSG("memcount = %ld", memcount); 105 105 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", 107 107 memcount); 108 108 109 109 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); 111 111 } libswish3/trunk/src/libswish3/mime_types.c
r1913 r1952 224 224 if ( mime == NULL ) 225 225 { 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 ); 227 227 mime = swish_xstrdup( (xmlChar *)SWISH_DEFAULT_MIME ); 228 228 } … … 242 242 243 243 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 ); 245 245 246 246 deftype = xmlHashLookup( parsers, (xmlChar *)SWISH_DEFAULT_PARSER ); /* error check?? */ … … 248 248 if ( parser == NULL ) 249 249 { 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); 251 251 parser = deftype; 252 252 } libswish3/trunk/src/libswish3/namedbuffer.c
r1930 r1952 44 44 if (xmlHashLookup(hash, name)) 45 45 { 46 swish_warn_err("%s is already in NamedBuffer hash -- ignoring", name);46 SWISH_WARN("%s is already in NamedBuffer hash -- ignoring", name); 47 47 return; 48 48 } … … 50 50 51 51 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); 53 53 54 54 swish_hash_add(hash, name, xmlBufferCreateSize((size_t)SWISH_BUFFER_CHUNK_SIZE)); … … 59 59 { 60 60 if (SWISH_DEBUG == SWISH_DEBUG_NAMEDBUFFER) 61 swish_debug_msg(" freeing NamedBuffer %s\n", name);61 SWISH_DEBUG_MSG(" freeing NamedBuffer %s\n", name); 62 62 63 63 xmlBufferFree(buffer); … … 86 86 87 87 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); 89 89 90 90 if (nb->stash != NULL) 91 swish_warn_err("freeing NamedBuffer with non-null stash");91 SWISH_WARN("freeing NamedBuffer with non-null stash"); 92 92 93 93 swish_xfree(nb); … … 98 98 print_buffer(xmlBufferPtr buffer, xmlChar * label, xmlChar * name) 99 99 { 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); 101 101 } 102 102 … … 146 146 147 147 if (!buf) 148 swish_fatal_err("%s is not a named buffer", name);148 SWISH_CROAK("%s is not a named buffer", name); 149 149 150 150 } … … 159 159 if(cleanwsp) 160 160 { 161 // swish_debug_msg("before cleanwsp: '%s'", str);161 //SWISH_DEBUG_MSG("before cleanwsp: '%s'", str); 162 162 nowhitesp = swish_str_skip_ws(str); 163 163 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); 165 165 swish_append_buffer(buf, nowhitesp, xmlStrlen(nowhitesp)); 166 166 } 167 167 else 168 168 { 169 // swish_debug_msg("adding '%s' to buffer '%s'", str, name);169 //SWISH_DEBUG_MSG("adding '%s' to buffer '%s'", str, name); 170 170 swish_append_buffer(buf, str, len); 171 171 } … … 184 184 if (buf == NULL) 185 185 { 186 swish_fatal_err("bad news. buf ptr is NULL");186 SWISH_CROAK("bad news. buf ptr is NULL"); 187 187 } 188 188 … … 190 190 if (ret) 191 191 { 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", 193 193 txt, txtlen, ret); 194 194 } libswish3/trunk/src/libswish3/parser.c
r1934 r1952 232 232 233 233 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]); 235 235 236 236 if( xmlStrEqual(atts[i], (xmlChar*)"name")) 237 237 { 238 // swish_debug_msg("found name: %s", atts[i+1]);238 //SWISH_DEBUG_MSG("found name: %s", atts[i+1]); 239 239 metaname = (xmlChar*)atts[i+1]; 240 240 } … … 242 242 else if ( xmlStrEqual(atts[i], (xmlChar*)"content")) 243 243 { 244 // swish_debug_msg("found content: %s", atts[i+1]);244 //SWISH_DEBUG_MSG("found content: %s", atts[i+1]); 245 245 metacontent = (xmlChar*)atts[i+1]; 246 246 } … … 252 252 { 253 253 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); 255 255 256 256 /* do not match across metas */ … … 299 299 if (alias) 300 300 { 301 // swish_debug_msg("%s alias -> %s", swishtag, alias);301 //SWISH_DEBUG_MSG("%s alias -> %s", swishtag, alias); 302 302 swish_xfree(swishtag); 303 303 swishtag = swish_xstrdup(alias); … … 315 315 316 316 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", 318 318 xmlBufferContent(parse_data->buf_ptr), parse_data->word_pos); 319 319 … … 368 368 369 369 if (SWISH_DEBUG > 2) 370 swish_debug_msg("startDocument()");370 SWISH_DEBUG_MSG("startDocument()"); 371 371 372 372 } … … 379 379 380 380 if (SWISH_DEBUG > 2) 381 swish_debug_msg("endDocument()");381 SWISH_DEBUG_MSG("endDocument()"); 382 382 383 383 /* whatever's left */ … … 440 440 441 441 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); 443 443 444 444 … … 447 447 { 448 448 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); 450 450 451 451 add_stack_to_prop_buf(NULL, parse_data); … … 454 454 parse_data->propstack = push_tag_stack(parse_data->propstack, parse_data->tag); 455 455 456 /* swish_debug_msg("%s pushed ok unto propstack", parse_data->tag); */456 /* SWISH_DEBUG_MSG("%s pushed ok unto propstack", parse_data->tag); */ 457 457 } 458 458 … … 461 461 { 462 462 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); 464 464 465 465 flush_buffer( parse_data, parse_data->metastack->head->name, parse_data->metastack->flat ); … … 469 469 470 470 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); 472 472 473 473 … … 489 489 490 490 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); 492 492 493 493 if ((context = pop_tag_stack_on_match(parse_data->propstack, parse_data->tag)) != NULL) 494 494 { 495 // swish_debug_msg("popped %s from propstack", context);495 //SWISH_DEBUG_MSG("popped %s from propstack", context); 496 496 add_stack_to_prop_buf(parse_data->tag, parse_data); 497 497 xmlBufferEmpty(parse_data->prop_buf); … … 501 501 if ((context = pop_tag_stack_on_match(parse_data->metastack, parse_data->tag)) != NULL) 502 502 { 503 /* swish_debug_msg("popped %s from metastack", parse_data->tag); */503 /* SWISH_DEBUG_MSG("popped %s from metastack", parse_data->tag); */ 504 504 flush_buffer(parse_data, parse_data->tag, context); 505 505 swish_xfree(context); … … 525 525 526 526 /* 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), 528 528 * len ); 529 529 */ 530 530 531 /* swish_debug_msg( "characters"); */531 /* SWISH_DEBUG_MSG( "characters"); */ 532 532 533 533 for (i = 0; i < len; i++) … … 545 545 if (parse_data->bump_word && xmlBufferLength(parse_data->prop_buf)) 546 546 { 547 // swish_debug_msg(" appending ' ' to prop_buf");547 //SWISH_DEBUG_MSG(" appending ' ' to prop_buf"); 548 548 swish_append_buffer(parse_data->prop_buf, (xmlChar*)" ", 1); 549 549 } 550 550 551 // swish_debug_msg(" appending '%s' to prop_buf", output);551 //SWISH_DEBUG_MSG(" appending '%s' to prop_buf", output); 552 552 swish_append_buffer(parse_data->prop_buf, output, len); 553 553 … … 561 561 { 562 562 if (SWISH_DEBUG > 2) 563 swish_debug_msg(" >> mycharacters()");563 SWISH_DEBUG_MSG(" >> mycharacters()"); 564 564 565 565 buffer_characters(parse_data, ch, len); … … 591 591 return; 592 592 593 swish_warn_err("libxml2 error:");593 SWISH_WARN("libxml2 error:"); 594 594 59
