Changeset 2106
- Timestamp:
- 03/30/08 22:55:55 (2 months ago)
- Files:
-
- libswish3/trunk/src/libswish3/config.c (modified) (3 diffs)
- libswish3/trunk/src/libswish3/header.c (modified) (4 diffs)
- libswish3/trunk/src/libswish3/libswish3.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
libswish3/trunk/src/libswish3/config.c
r2104 r2106 181 181 } 182 182 183 swish_ConfigFlags * 184 swish_init_config_flags( 185 ) 186 { 187 swish_ConfigFlags *flags; 188 int i; 189 190 flags = swish_xmalloc(sizeof(swish_ConfigFlags)); 191 flags->tokenize = 1; 192 193 /* set all defaults to 0 */ 194 for(i=0; i<SWISH_MAX_IDS; i++) { 195 flags->meta_ids[i] = 0; 196 } 197 for(i=0; i<SWISH_MAX_IDS; i++) { 198 flags->prop_ids[i] = 0; 199 } 200 201 return flags; 202 } 203 204 205 183 206 /* init config object */ 184 185 207 swish_Config * 186 208 swish_init_config( … … 195 217 /* the hashes will automatically grow as needed so we init with sane starting size */ 196 218 config = swish_xmalloc(sizeof(swish_Config)); 197 config->flags = swish_ xmalloc(sizeof(swish_ConfigFlags));219 config->flags = swish_init_config_flags(); 198 220 config->misc = swish_init_hash(8); 199 221 config->metanames = swish_init_hash(8); … … 205 227 config->ref_cnt = 0; 206 228 config->stash = NULL; 207 208 /* misc default flags */209 config->flags->tokenize = 1;210 229 211 230 if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { libswish3/trunk/src/libswish3/header.c
r2103 r2106 108 108 xmlChar *name 109 109 ); 110 static void 111 test_meta_unique_ids( 112 swish_MetaName *meta, 113 swish_Config *c, 114 xmlChar *name 115 ); 116 static void 117 test_prop_unique_ids( 118 swish_Property *prop, 119 swish_Config *c, 120 xmlChar *name 121 ); 110 122 static headmaker *init_headmaker( 111 123 ); … … 744 756 } 745 757 758 static void 759 test_meta_unique_ids( 760 swish_MetaName *meta, 761 swish_Config *c, 762 xmlChar *name 763 ) 764 { 765 c->flags->meta_ids[ meta->id ]++; 766 } 767 768 static void 769 test_prop_unique_ids( 770 swish_Property *prop, 771 swish_Config *c, 772 xmlChar *name 773 ) 774 { 775 c->flags->prop_ids[ prop->id ]++; 776 } 777 778 void 779 swish_config_test_unique_ids( 780 swish_Config *c 781 ) 782 { 783 int i; 784 xmlHashScan(c->metanames, (xmlHashScanner) test_meta_unique_ids, c); 785 xmlHashScan(c->properties, (xmlHashScanner) test_prop_unique_ids, c); 786 for(i=0; i<SWISH_MAX_IDS; i++) { 787 if (c->flags->meta_ids[i] > 1) { 788 SWISH_WARN("meta id %d == %d", i, c->flags->meta_ids[i]); 789 } 790 if (c->flags->prop_ids[i] > 1) { 791 SWISH_WARN("prop id %d == %d", i, c->flags->prop_ids[i]); 792 } 793 794 /* set back to 0 in case we are called again */ 795 c->flags->prop_ids[i] = 0; 796 c->flags->meta_ids[i] = 0; 797 } 798 } 799 746 800 static headmaker * 747 801 init_headmaker( … … 769 823 h = init_headmaker(); 770 824 read_header(filename, h); 825 826 /* test that all the alias_for links resolve ok */ 827 swish_config_test_alias_fors(h->config); 828 829 /* make sure ids are all unique */ 830 swish_config_test_unique_ids(h->config); 831 771 832 swish_debug_config(h->config); 772 833 swish_free_config(h->config); … … 794 855 swish_xfree(h); 795 856 796 /* nowtest that all the alias_for links resolve ok */857 /* test that all the alias_for links resolve ok */ 797 858 swish_config_test_alias_fors(c); 859 860 /* make sure ids are all unique */ 861 swish_config_test_unique_ids(c); 798 862 799 863 return 1; libswish3/trunk/src/libswish3/libswish3.h
r2097 r2106 29 29 #include <libxml/xmlstring.h> 30 30 31 #define SWISH_LIB_VERSION "0.1.0"32 #define SWISH_VERSION "3.0.0"33 #define SWISH_BUFFER_CHUNK_SIZE 1000034 #define SWISH_MAXSTRLEN 200035 #define SWISH_MAX_HEADERS 636 #define SWISH_RD_BUFFER_SIZE 6535637 #define SWISH_MAX_WORD_LEN 25638 #define SWISH_MIN_WORD_LEN 139 40 #define SWISH_STACK_SIZE 255 /* starting size for metaname/tag stack */41 42 43 #define SWISH_CONTRACTIONS 1 44 45 #define SWISH_SPECIAL_ARG 146 #define SWISH_MAX_SORT_STRING_LEN 10047 48 #define SWISH_DATE_FORMAT_STRING "%Y-%m-%d %H:%M:%S %Z"49 #define SWISH_URL_LENGTH 25531 #define SWISH_LIB_VERSION "0.1.0" 32 #define SWISH_VERSION "3.0.0" 33 #define SWISH_BUFFER_CHUNK_SIZE 10000 34 #define SWISH_MAXSTRLEN 2000 35 #define SWISH_MAX_HEADERS 6 36 #define SWISH_RD_BUFFER_SIZE 65356 37 #define SWISH_MAX_WORD_LEN 256 38 #define SWISH_MIN_WORD_LEN 1 39 40 #define SWISH_STACK_SIZE 255 /* starting size for metaname/tag stack */ 41 42 #define SWISH_CONTRACTIONS 1 43 44 #define SWISH_MAX_IDS 1024 45 #define SWISH_SPECIAL_ARG 1 46 #define SWISH_MAX_SORT_STRING_LEN 100 47 48 #define SWISH_DATE_FORMAT_STRING "%Y-%m-%d %H:%M:%S %Z" 49 #define SWISH_URL_LENGTH 255 50 50 51 51 /* default config hash key names */ … … 245 245 { 246 246 boolean tokenize; 247 boolean meta_ids[SWISH_MAX_IDS]; 248 boolean prop_ids[SWISH_MAX_IDS]; 247 249 248 250 }; … … 488 490 xmlChar * swish_get_mime_type( swish_Config * config, xmlChar * fileext ); 489 491 xmlChar * swish_get_parser( swish_Config * config, xmlChar *mime ); 492 void swish_config_test_unique_ids( swish_Config *c ); 493 void swish_config_test_alias_fors( swish_Config *c ); 490 494 /* 491 495 =cut
