| 139 | | |
|---|
| 140 | | /* global init and cleanup functions -- call these in every linking program */ |
|---|
| 141 | | void swish_init(); |
|---|
| 142 | | void swish_cleanup(); |
|---|
| 143 | | |
|---|
| 144 | | |
|---|
| 145 | | /* utils */ |
|---|
| 146 | | typedef struct swish_StringList swish_StringList; |
|---|
| 147 | | |
|---|
| | 139 | typedef struct swish_StringList swish_StringList; |
|---|
| | 140 | typedef struct swish_Config swish_Config; |
|---|
| | 141 | typedef struct swish_ConfigValue swish_ConfigValue; |
|---|
| | 142 | typedef struct swish_DocInfo swish_DocInfo; |
|---|
| | 143 | typedef struct swish_MetaStackElement swish_MetaStackElement; |
|---|
| | 144 | typedef struct swish_MetaStackElement *swish_MetaStackElementPtr; |
|---|
| | 145 | typedef struct swish_MetaStack swish_MetaStack; |
|---|
| | 146 | typedef struct swish_Word swish_Word; |
|---|
| | 147 | typedef struct swish_WordList swish_WordList; |
|---|
| | 148 | typedef struct swish_ParseData swish_ParseData; |
|---|
| | 149 | typedef struct swish_Tag swish_Tag; |
|---|
| | 150 | typedef struct swish_TagStack swish_TagStack; |
|---|
| | 151 | typedef struct swish_Analyzer swish_Analyzer; |
|---|
| | 152 | typedef struct swish_Parser swish_Parser; |
|---|
| | 153 | typedef struct swish_NamedBuffer swish_NamedBuffer; |
|---|
| | 154 | |
|---|
| | 155 | /* |
|---|
| | 156 | =head2 Data Structures |
|---|
| | 157 | */ |
|---|
| 155 | | |
|---|
| 156 | | /* hash functions */ |
|---|
| 157 | | int swish_hash_add( xmlHashTablePtr hash, xmlChar *key, void * value ); |
|---|
| 158 | | int swish_hash_replace( xmlHashTablePtr hash, xmlChar *key, void *value ); |
|---|
| 159 | | int swish_hash_delete( xmlHashTablePtr hash, xmlChar *key ); |
|---|
| 160 | | xmlHashTablePtr swish_new_hash(int size); |
|---|
| 161 | | |
|---|
| 162 | | /* IO */ |
|---|
| 163 | | xmlChar * swish_slurp_stdin( long flen ); |
|---|
| 164 | | xmlChar * swish_slurp_file_len( xmlChar *filename, long flen ); |
|---|
| 165 | | xmlChar * swish_slurp_file( xmlChar *filename ); |
|---|
| 166 | | xmlChar * swish_get_file_ext( xmlChar *url ); |
|---|
| 167 | | |
|---|
| 168 | | /* memory functions */ |
|---|
| 169 | | void swish_init_memory(); |
|---|
| 170 | | void * swish_xrealloc(void *ptr, size_t size); |
|---|
| 171 | | void * swish_xmalloc( size_t size ); |
|---|
| 172 | | void swish_xfree( void *ptr ); |
|---|
| 173 | | void swish_mem_debug(); |
|---|
| 174 | | xmlChar * swish_xstrdup( const xmlChar * ptr ); |
|---|
| 175 | | xmlChar * swish_xstrndup( const xmlChar * ptr, int len ); |
|---|
| 176 | | |
|---|
| 177 | | /* time functions */ |
|---|
| 178 | | double swish_time_elapsed(void); |
|---|
| 179 | | double swish_time_cpu(void); |
|---|
| 180 | | char * swish_print_time(double time); |
|---|
| 181 | | char * swish_print_fine_time(double time); |
|---|
| 182 | | |
|---|
| 183 | | /* error functions */ |
|---|
| 184 | | void swish_set_error_handle( FILE *where ); |
|---|
| 185 | | void swish_fatal_err(char *msg,...); |
|---|
| 186 | | void swish_warn_err(char *msg,...); |
|---|
| 187 | | void swish_debug_msg(char *msg,...); |
|---|
| 188 | | |
|---|
| 189 | | /* string functions */ |
|---|
| 190 | | void swish_verify_utf8_locale(); |
|---|
| 191 | | int swish_is_ascii( xmlChar *str ); |
|---|
| 192 | | int swish_utf8_chr_len( xmlChar *utf8 ); |
|---|
| 193 | | wchar_t * swish_locale_to_wchar(xmlChar * str); |
|---|
| 194 | | xmlChar * swish_wchar_to_locale(wchar_t * str); |
|---|
| 195 | | wchar_t * swish_wstr_tolower(wchar_t *s); |
|---|
| 196 | | xmlChar * swish_str_tolower(xmlChar *s ); |
|---|
| 197 | | xmlChar * swish_str_skip_ws(xmlChar *s); |
|---|
| 198 | | void swish_str_trim_ws(xmlChar *string); |
|---|
| 199 | | void swish_debug_wchars( const wchar_t * widechars ); |
|---|
| 200 | | int swish_wchar_t_comp(const void *s1, const void *s2); |
|---|
| 201 | | int swish_sort_wchar(wchar_t *s); |
|---|
| 202 | | swish_StringList * swish_make_StringList(xmlChar * line); |
|---|
| 203 | | swish_StringList * swish_init_StringList(); |
|---|
| 204 | | void swish_free_StringList(swish_StringList * sl); |
|---|
| 205 | | |
|---|
| 206 | | typedef struct swish_Config swish_Config; |
|---|
| 207 | | typedef struct swish_ConfigValue swish_ConfigValue; |
|---|
| 225 | | |
|---|
| 226 | | /* configuration functions */ |
|---|
| 227 | | swish_Config * swish_init_config(); |
|---|
| 228 | | swish_Config * swish_add_config( xmlChar * conf, swish_Config * config ); |
|---|
| 229 | | swish_Config * swish_parse_config( xmlChar * conf, swish_Config * config ); |
|---|
| 230 | | swish_Config * swish_parse_config_new( xmlChar * conf, swish_Config * config ); |
|---|
| 231 | | int swish_debug_config( swish_Config * config ); |
|---|
| 232 | | xmlHashTablePtr swish_subconfig_hash( swish_Config * config, xmlChar *key); |
|---|
| 233 | | int swish_config_value_exists( swish_Config * config, xmlChar *key, xmlChar *value ); |
|---|
| 234 | | xmlChar * swish_get_config_value(swish_Config * config, xmlChar * key, xmlChar * value); |
|---|
| 235 | | void swish_free_config(swish_Config * config); |
|---|
| 236 | | |
|---|
| 237 | | /* accessors */ |
|---|
| 238 | | swish_ConfigValue * swish_keys( swish_Config * config, ... ); |
|---|
| 239 | | swish_ConfigValue * swish_value( swish_Config * config, xmlChar * key, ... ); |
|---|
| 240 | | swish_ConfigValue * swish_init_ConfigValue(); |
|---|
| 241 | | void swish_free_ConfigValue( swish_ConfigValue * cv ); |
|---|
| 242 | | |
|---|
| 243 | | /* TODO read_swishheader() and write_swishheader() */ |
|---|
| 244 | | |
|---|
| 245 | | /* MIME type and parser functions */ |
|---|
| 246 | | xmlHashTablePtr swish_mime_hash(); |
|---|
| 247 | | xmlChar * swish_get_mime_type( swish_Config * config, xmlChar * fileext ); |
|---|
| 248 | | xmlChar * swish_get_parser( swish_Config * config, xmlChar *mime ); |
|---|
| 249 | | |
|---|
| 250 | | |
|---|
| 251 | | |
|---|
| 252 | | /* we declare structs this 2-step way to make some C++ compilers happy */ |
|---|
| 253 | | |
|---|
| 254 | | typedef struct swish_DocInfo swish_DocInfo; |
|---|
| 255 | | typedef struct swish_MetaStackElement swish_MetaStackElement; |
|---|
| 256 | | typedef struct swish_MetaStackElement *swish_MetaStackElementPtr; |
|---|
| 257 | | typedef struct swish_MetaStack swish_MetaStack; |
|---|
| 258 | | typedef struct swish_Word swish_Word; |
|---|
| 259 | | typedef struct swish_WordList swish_WordList; |
|---|
| 260 | | typedef struct swish_ParseData swish_ParseData; |
|---|
| 261 | | typedef struct swish_Tag swish_Tag; |
|---|
| 262 | | typedef struct swish_TagStack swish_TagStack; |
|---|
| 263 | | typedef struct swish_Analyzer swish_Analyzer; |
|---|
| 264 | | typedef struct swish_Parser swish_Parser; |
|---|
| 265 | | typedef struct swish_NamedBuffer swish_NamedBuffer; |
|---|
| 371 | | /* public functions */ |
|---|
| 372 | | |
|---|
| 373 | | /* parser styles -- main entry points */ |
|---|
| | 287 | /* |
|---|
| | 288 | =cut |
|---|
| | 289 | */ |
|---|
| | 290 | |
|---|
| | 291 | /* |
|---|
| | 292 | =head2 Global Functions |
|---|
| | 293 | */ |
|---|
| | 294 | void swish_init(); |
|---|
| | 295 | void swish_cleanup(); |
|---|
| | 296 | /* |
|---|
| | 297 | =cut |
|---|
| | 298 | */ |
|---|
| | 299 | |
|---|
| | 300 | /* |
|---|
| | 301 | =head2 I/O Functions |
|---|
| | 302 | */ |
|---|
| | 303 | xmlChar * swish_slurp_stdin( long flen ); |
|---|
| | 304 | xmlChar * swish_slurp_file_len( xmlChar *filename, long flen ); |
|---|
| | 305 | xmlChar * swish_slurp_file( xmlChar *filename ); |
|---|
| | 306 | /* |
|---|
| | 307 | =cut |
|---|
| | 308 | */ |
|---|
| | 309 | |
|---|
| | 310 | |
|---|
| | 311 | /* |
|---|
| | 312 | =head2 Hash Functions |
|---|
| | 313 | */ |
|---|
| | 314 | int swish_hash_add( xmlHashTablePtr hash, xmlChar *key, void * value ); |
|---|
| | 315 | int swish_hash_replace( xmlHashTablePtr hash, xmlChar *key, void *value ); |
|---|
| | 316 | int swish_hash_delete( xmlHashTablePtr hash, xmlChar *key ); |
|---|
| | 317 | xmlHashTablePtr swish_new_hash(int size); |
|---|
| | 318 | /* |
|---|
| | 319 | =cut |
|---|
| | 320 | */ |
|---|
| | 321 | |
|---|
| | 322 | /* |
|---|
| | 323 | =head2 Memory Functions |
|---|
| | 324 | */ |
|---|
| | 325 | void swish_init_memory(); |
|---|
| | 326 | void * swish_xrealloc(void *ptr, size_t size); |
|---|
| | 327 | void * swish_xmalloc( size_t size ); |
|---|
| | 328 | void swish_xfree( void *ptr ); |
|---|
| | 329 | void swish_mem_debug(); |
|---|
| | 330 | xmlChar * swish_xstrdup( const xmlChar * ptr ); |
|---|
| | 331 | xmlChar * swish_xstrndup( const xmlChar * ptr, int len ); |
|---|
| | 332 | /* |
|---|
| | 333 | =cut |
|---|
| | 334 | */ |
|---|
| | 335 | |
|---|
| | 336 | /* |
|---|
| | 337 | =head2 Time Functions |
|---|
| | 338 | */ |
|---|
| | 339 | double swish_time_elapsed(void); |
|---|
| | 340 | double swish_time_cpu(void); |
|---|
| | 341 | char * swish_print_time(double time); |
|---|
| | 342 | char * swish_print_fine_time(double time); |
|---|
| | 343 | /* |
|---|
| | 344 | =cut |
|---|
| | 345 | */ |
|---|
| | 346 | |
|---|
| | 347 | /* |
|---|
| | 348 | =head2 Error Functions |
|---|
| | 349 | */ |
|---|
| | 350 | 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,...); |
|---|
| | 354 | /* |
|---|
| | 355 | =cut |
|---|
| | 356 | */ |
|---|
| | 357 | |
|---|
| | 358 | /* |
|---|
| | 359 | =head2 String Functions |
|---|
| | 360 | */ |
|---|
| | 361 | void swish_verify_utf8_locale(); |
|---|
| | 362 | int swish_is_ascii( xmlChar *str ); |
|---|
| | 363 | int swish_utf8_chr_len( xmlChar *utf8 ); |
|---|
| | 364 | wchar_t * swish_locale_to_wchar(xmlChar * str); |
|---|
| | 365 | xmlChar * swish_wchar_to_locale(wchar_t * str); |
|---|
| | 366 | wchar_t * swish_wstr_tolower(wchar_t *s); |
|---|
| | 367 | xmlChar * swish_str_tolower(xmlChar *s ); |
|---|
| | 368 | xmlChar * swish_str_skip_ws(xmlChar *s); |
|---|
| | 369 | void swish_str_trim_ws(xmlChar *string); |
|---|
| | 370 | void swish_debug_wchars( const wchar_t * widechars ); |
|---|
| | 371 | int swish_wchar_t_comp(const void *s1, const void *s2); |
|---|
| | 372 | int swish_sort_wchar(wchar_t *s); |
|---|
| | 373 | swish_StringList * swish_make_StringList(xmlChar * line); |
|---|
| | 374 | swish_StringList * swish_init_StringList(); |
|---|
| | 375 | void swish_free_StringList(swish_StringList * sl); |
|---|
| | 376 | /* |
|---|
| | 377 | =cut |
|---|
| | 378 | */ |
|---|
| | 379 | |
|---|
| | 380 | |
|---|
| | 381 | /* |
|---|
| | 382 | =head2 Configuration Functions |
|---|
| | 383 | */ |
|---|
| | 384 | swish_Config * swish_init_config(); |
|---|
| | 385 | swish_Config * swish_add_config( xmlChar * conf, swish_Config * config ); |
|---|
| | 386 | swish_Config * swish_parse_config( xmlChar * conf, swish_Config * config ); |
|---|
| | 387 | swish_Config * swish_parse_config_new( xmlChar * conf, swish_Config * config ); |
|---|
| | 388 | int swish_debug_config( swish_Config * config ); |
|---|
| | 389 | xmlHashTablePtr swish_subconfig_hash( swish_Config * config, xmlChar *key); |
|---|
| | 390 | int swish_config_value_exists( swish_Config * config, xmlChar *key, xmlChar *value ); |
|---|
| | 391 | xmlChar * swish_get_config_value(swish_Config * config, xmlChar * key, xmlChar * value); |
|---|
| | 392 | void swish_free_config(swish_Config * config); |
|---|
| | 393 | swish_ConfigValue * swish_keys( swish_Config * config, ... ); |
|---|
| | 394 | swish_ConfigValue * swish_value( swish_Config * config, xmlChar * key, ... ); |
|---|
| | 395 | swish_ConfigValue * swish_init_ConfigValue(); |
|---|
| | 396 | void swish_free_ConfigValue( swish_ConfigValue * cv ); |
|---|
| | 397 | xmlHashTablePtr swish_mime_hash(); |
|---|
| | 398 | xmlChar * swish_get_mime_type( swish_Config * config, xmlChar * fileext ); |
|---|
| | 399 | xmlChar * swish_get_parser( swish_Config * config, xmlChar *mime ); |
|---|
| | 400 | /* |
|---|
| | 401 | =cut |
|---|
| | 402 | */ |
|---|
| | 403 | |
|---|
| | 404 | /* |
|---|
| | 405 | =head2 Parser Functions |
|---|
| | 406 | */ |
|---|