Changeset 2103

Show
Ignore:
Timestamp:
03/27/08 23:35:21 (2 months ago)
Author:
karpet
Message:

whitespace only. again.

I am now using gnu indent rather than the original bsd version. My opts are below:

--no-blank-lines-after-declarations
--blank-lines-after-procedures
--no-blank-lines-after-commas
--break-before-boolean-operator
//--break-function-decl-args
//--break-function-decl-args-end
// long options above do not work. use short below instead.
-bfda
-bfde
--braces-on-if-line
--brace-indent4
--braces-after-struct-decl-line
--dont-cuddle-else
--comment-delimiters-on-blank-lines
--else-endif-column1
--no-space-after-casts
--declaration-indentation4
--paren-indentation4
--dont-format-first-column-comments
--dont-format-comments
--ignore-newlines

--line-length80
--indent-level4
--parameter-indentation5
--continue-at-parentheses
--no-space-after-function-call-names
--no-space-after-parentheses
--procnames-start-lines
--space-after-for
--space-after-if
--space-after-while
--dont-star-comments
--swallow-optional-blank-lines
--no-tabs

-TxmlChar?
-Tswish_ParserData
-Tswish_Config
-Tswish_3
-Tswish_Analyzer
-Tswish_Parser
-Tswish_DocInfo
-Tswish_TagStack
-Tswish_MetaName
-Tswish_Property

Files:

Legend:

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

    r2101 r2103  
    2525#include "libswish3.h" 
    2626 
    27 extern int      SWISH_DEBUG; 
     27extern int SWISH_DEBUG; 
    2828 
    2929swish_Analyzer * 
    30 swish_init_analyzer(swish_Config *config) 
     30swish_init_analyzer( 
     31    swish_Config *config 
     32
    3133{ 
    3234    swish_Analyzer *a; 
     
    6466 
    6567void 
    66 swish_free_analyzer(swish_Analyzer *a) 
     68swish_free_analyzer( 
     69    swish_Analyzer *a 
     70
    6771{ 
    6872    if (a->ref_cnt != 0) { 
  • libswish3/trunk/src/libswish3/config.c

    r2101 r2103  
     1 
    12/* 
    23 * This file is part of libswish3 
     
    3435#include "libswish3.h" 
    3536 
    36 extern int      SWISH_DEBUG; 
    37  
    38 void 
    39                 swish_free_config(swish_Config *config); 
    40 swish_Config   * 
    41                 swish_init_config(); 
    42 void 
    43                 swish_config_set_default(swish_Config *config); 
    44 swish_Config   * 
    45                 swish_add_config(xmlChar *conf, swish_Config *config); 
    46 swish_Config   * 
    47                 swish_parse_config(xmlChar *conf, swish_Config *config); 
    48 void 
    49                 swish_debug_config(swish_Config *config); 
    50 void 
    51                 swish_config_merge(swish_Config *config1, swish_Config *config2); 
    52 static void 
    53                 free_string(xmlChar *payload, xmlChar *key); 
    54 static void 
    55                 free_props(swish_Property * prop, xmlChar *propname); 
    56 static void 
    57                 free_metas(swish_MetaName * meta, xmlChar *metaname); 
    58 static void 
    59                 config_printer(xmlChar *val, xmlChar *str, xmlChar *key); 
    60 static void 
    61                 property_printer(swish_Property * prop, xmlChar *str, xmlChar *propname); 
    62 static void 
    63                 metaname_printer(swish_MetaName * meta, xmlChar *str, xmlChar *metaname); 
    64 static void 
    65 copy_property( 
    66           swish_Property * prop2, 
    67           xmlHashTablePtr props1, 
    68           xmlChar *prop2name 
    69 ); 
    70 static void 
    71                 merge_properties(xmlHashTablePtr props1, xmlHashTablePtr props2); 
    72 static void 
    73 copy_metaname( 
    74           swish_MetaName * meta2, 
    75           xmlHashTablePtr metas1, 
    76           xmlChar *meta2name 
    77 ); 
    78 static void 
    79                 merge_metanames(xmlHashTablePtr metas1, xmlHashTablePtr metas2); 
    80  
    81 static void 
    82 free_string(xmlChar *payload, xmlChar *key) 
     37extern int SWISH_DEBUG; 
     38 
     39void swish_free_config( 
     40    swish_Config *config 
     41); 
     42swish_Config *swish_init_config( 
     43); 
     44void swish_config_set_default( 
     45    swish_Config *config 
     46); 
     47swish_Config *swish_add_config( 
     48    xmlChar *conf, 
     49    swish_Config *config 
     50); 
     51swish_Config *swish_parse_config( 
     52    xmlChar *conf, 
     53    swish_Config *config 
     54); 
     55void swish_debug_config( 
     56    swish_Config *config 
     57); 
     58void swish_config_merge( 
     59    swish_Config *config1, 
     60    swish_Config *config2 
     61); 
     62static void free_string( 
     63    xmlChar *payload, 
     64    xmlChar *key 
     65); 
     66static void free_props( 
     67    swish_Property *prop, 
     68    xmlChar *propname 
     69); 
     70static void free_metas( 
     71    swish_MetaName *meta, 
     72    xmlChar *metaname 
     73); 
     74static void config_printer( 
     75    xmlChar *val, 
     76    xmlChar *str, 
     77    xmlChar *key 
     78); 
     79static void property_printer( 
     80    swish_Property *prop, 
     81    xmlChar *str, 
     82    xmlChar *propname 
     83); 
     84static void metaname_printer( 
     85    swish_MetaName *meta, 
     86    xmlChar *str, 
     87    xmlChar *metaname 
     88); 
     89static void copy_property( 
     90    swish_Property *prop2, 
     91    xmlHashTablePtr props1, 
     92    xmlChar *prop2name 
     93); 
     94static void merge_properties( 
     95    xmlHashTablePtr props1, 
     96    xmlHashTablePtr props2 
     97); 
     98static void copy_metaname( 
     99    swish_MetaName *meta2, 
     100    xmlHashTablePtr metas1, 
     101    xmlChar *meta2name 
     102); 
     103static void merge_metanames( 
     104    xmlHashTablePtr metas1, 
     105    xmlHashTablePtr metas2 
     106); 
     107 
     108static void 
     109free_string( 
     110    xmlChar *payload, 
     111    xmlChar *key 
     112
    83113{ 
    84114    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) 
     
    89119 
    90120static void 
    91 free_props(swish_Property * prop, xmlChar *propname) 
     121free_props( 
     122    swish_Property *prop, 
     123    xmlChar *propname 
     124
    92125{ 
    93126    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) { 
    94127        SWISH_DEBUG_MSG("   freeing config->prop %s", propname); 
    95         swish_debug_property((swish_Property *) prop); 
     128        swish_debug_property((swish_Property *)prop); 
    96129    } 
    97130    prop->ref_cnt--; 
     
    102135 
    103136static void 
    104 free_metas(swish_MetaName * meta, xmlChar *metaname) 
     137free_metas( 
     138    swish_MetaName *meta, 
     139    xmlChar *metaname 
     140
    105141{ 
    106142    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) { 
    107143        SWISH_DEBUG_MSG("   freeing config->meta %s", metaname); 
    108         swish_debug_metaname((swish_MetaName *) meta); 
     144        swish_debug_metaname((swish_MetaName *)meta); 
    109145    } 
    110146    meta->ref_cnt--; 
     
    115151 
    116152void 
    117 swish_free_config(swish_Config *config) 
     153swish_free_config( 
     154    swish_Config *config 
     155
    118156{ 
    119157    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 
    120158        SWISH_DEBUG_MSG("freeing config"); 
    121         SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int) config, (int) config); 
     159        SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int)config, (int)config); 
    122160    } 
    123161 
     
    142180} 
    143181 
    144  
    145  
    146182/* init config object */ 
    147183 
    148 swish_Config   * 
    149 swish_init_config() 
    150 
    151     swish_Config   *config; 
     184swish_Config * 
     185swish_init_config( 
     186
     187
     188    swish_Config *config; 
    152189 
    153190    if (SWISH_DEBUG & SWISH_DEBUG_MEMORY) { 
     
    176213 
    177214void 
    178 swish_config_set_default(swish_Config *config) 
     215swish_config_set_default( 
     216    swish_Config *config 
     217
    179218{ 
    180219    swish_Property *tmpprop; 
     
    190229 
    191230/* metanames */ 
    192     swish_hash_add( 
    193                config->metanames, 
    194                (xmlChar *) SWISH_DEFAULT_METANAME, 
    195                swish_init_metaname(swish_xstrdup((xmlChar *) SWISH_DEFAULT_METANAME)) 
     231    swish_hash_add(config->metanames, (xmlChar *)SWISH_DEFAULT_METANAME, 
     232                   swish_init_metaname(swish_xstrdup 
     233                                       ((xmlChar *)SWISH_DEFAULT_METANAME)) 
    196234        ); 
    197     swish_hash_add( 
    198                config->metanames, 
    199                (xmlChar *) SWISH_TITLE_METANAME, 
    200                swish_init_metaname(swish_xstrdup((xmlChar *) SWISH_TITLE_METANAME)) 
     235    swish_hash_add(config->metanames, (xmlChar *)SWISH_TITLE_METANAME, 
     236                   swish_init_metaname(swish_xstrdup 
     237                                       ((xmlChar *)SWISH_TITLE_METANAME)) 
    201238        ); 
    202239 
     
    204241       a little awkward, but saves var names. 
    205242*/ 
    206     tmpmeta = swish_hash_fetch(config->metanames, (xmlChar *) SWISH_DEFAULT_METANAME); 
     243    tmpmeta = 
     244        swish_hash_fetch(config->metanames, (xmlChar *)SWISH_DEFAULT_METANAME); 
    207245    tmpmeta->ref_cnt++; 
    208246    tmpmeta->id = SWISH_META_DEFAULT_ID; 
    209     tmpmeta = swish_hash_fetch(config->metanames, (xmlChar *) SWISH_TITLE_METANAME); 
     247    tmpmeta = 
     248        swish_hash_fetch(config->metanames, (xmlChar *)SWISH_TITLE_METANAME); 
    210249    tmpmeta->ref_cnt++; 
    211250    tmpmeta->id = SWISH_META_TITLE_ID; 
    212251 
    213  
    214252/* parsers */ 
    215     swish_hash_add( 
    216                config->parsers, 
    217                (xmlChar *) "text/plain", 
    218                swish_xstrdup((xmlChar *) SWISH_PARSER_TXT)); 
    219     swish_hash_add( 
    220                config->parsers, 
    221                (xmlChar *) "text/xml", 
    222                swish_xstrdup((xmlChar *) SWISH_PARSER_XML)); 
    223     swish_hash_add( 
    224                config->parsers, 
    225                (xmlChar *) "text/html", 
    226                swish_xstrdup((xmlChar *) SWISH_PARSER_HTML)); 
    227     swish_hash_add( 
    228                config->parsers, 
    229                (xmlChar *) SWISH_DEFAULT_PARSER, 
    230                swish_xstrdup((xmlChar *) SWISH_DEFAULT_PARSER_TYPE)); 
    231  
     253    swish_hash_add(config->parsers, (xmlChar *)"text/plain", 
     254                   swish_xstrdup((xmlChar *)SWISH_PARSER_TXT)); 
     255    swish_hash_add(config->parsers, (xmlChar *)"text/xml", 
     256                   swish_xstrdup((xmlChar *)SWISH_PARSER_XML)); 
     257    swish_hash_add(config->parsers, (xmlChar *)"text/html", 
     258                   swish_xstrdup((xmlChar *)SWISH_PARSER_HTML)); 
     259    swish_hash_add(config->parsers, (xmlChar *)SWISH_DEFAULT_PARSER, 
     260                   swish_xstrdup((xmlChar *)SWISH_DEFAULT_PARSER_TYPE)); 
    232261 
    233262/* index */ 
    234     swish_hash_add( 
    235                config->index, 
    236                (xmlChar *) SWISH_INDEX_FORMAT, 
    237                swish_xstrdup((xmlChar *) SWISH_INDEX_FILEFORMAT)); 
    238     swish_hash_add( 
    239                config->index, 
    240                (xmlChar *) SWISH_INDEX_NAME, 
    241                swish_xstrdup((xmlChar *) SWISH_INDEX_FILENAME)); 
    242     swish_hash_add( 
    243                config->index, 
    244                (xmlChar *) SWISH_INDEX_LOCALE, 
    245                swish_xstrdup((xmlChar *) setlocale(LC_ALL, ""))); 
    246  
     263    swish_hash_add(config->index, (xmlChar *)SWISH_INDEX_FORMAT, 
     264                   swish_xstrdup((xmlChar *)SWISH_INDEX_FILEFORMAT)); 
     265    swish_hash_add(config->index, (xmlChar *)SWISH_INDEX_NAME, 
     266                   swish_xstrdup((xmlChar *)SWISH_INDEX_FILENAME)); 
     267    swish_hash_add(config->index, (xmlChar *)SWISH_INDEX_LOCALE, 
     268                   swish_xstrdup((xmlChar *)setlocale(LC_ALL, ""))); 
    247269 
    248270/* properties */ 
    249     swish_hash_add( 
    250                config->properties, 
    251                (xmlChar *) SWISH_PROP_DESCRIPTION, 
    252                swish_init_property(swish_xstrdup((xmlChar *) SWISH_PROP_DESCRIPTION)) 
     271    swish_hash_add(config->properties, (xmlChar *)SWISH_PROP_DESCRIPTION, 
     272                   swish_init_property(swish_xstrdup 
     273                                       ((xmlChar *)SWISH_PROP_DESCRIPTION)) 
    253274        ); 
    254     swish_hash_add( 
    255                config->properties, 
    256                (xmlChar *) SWISH_PROP_TITLE, 
    257                swish_init_property(swish_xstrdup((xmlChar *) SWISH_PROP_TITLE)) 
     275    swish_hash_add(config->properties, (xmlChar *)SWISH_PROP_TITLE, 
     276                   swish_init_property(swish_xstrdup 
     277                                       ((xmlChar *)SWISH_PROP_TITLE)) 
    258278        ); 
    259279 
    260280/* same deal as metanames above */ 
    261     tmpprop = swish_hash_fetch(config->properties, (xmlChar *) SWISH_PROP_DESCRIPTION); 
     281    tmpprop = 
     282        swish_hash_fetch(config->properties, (xmlChar *)SWISH_PROP_DESCRIPTION); 
    262283    tmpprop->ref_cnt++; 
    263284    tmpprop->id = SWISH_PROP_DESCRIPTION_ID; 
    264     tmpprop = swish_hash_fetch(config->properties, (xmlChar *) SWISH_PROP_TITLE); 
     285    tmpprop = swish_hash_fetch(config->properties, (xmlChar *)SWISH_PROP_TITLE); 
    265286    tmpprop->ref_cnt++; 
    266287    tmpprop->id = SWISH_PROP_TITLE_ID; 
    267288 
    268  
    269289/* aliases: other names a tag might be known as, for matching properties and 
    270290     * metanames */ 
    271     swish_hash_add( 
    272                config->tag_aliases, 
    273                (xmlChar *) SWISH_TITLE_TAG, 
    274                swish_xstrdup((xmlChar *) SWISH_TITLE_METANAME)); 
    275     swish_hash_add( 
    276                config->tag_aliases, 
    277                (xmlChar *) SWISH_BODY_TAG, 
    278                swish_xstrdup((xmlChar *) SWISH_PROP_DESCRIPTION)); 
    279  
     291    swish_hash_add(config->tag_aliases, (xmlChar *)SWISH_TITLE_TAG, 
     292                   swish_xstrdup((xmlChar *)SWISH_TITLE_METANAME)); 
     293    swish_hash_add(config->tag_aliases, (xmlChar *)SWISH_BODY_TAG, 
     294                   swish_xstrdup((xmlChar *)SWISH_PROP_DESCRIPTION)); 
    280295 
    281296    if (SWISH_DEBUG & SWISH_DEBUG_CONFIG) { 
     
    286301} 
    287302 
    288 swish_Config   * 
    289 swish_add_config(xmlChar *conf, swish_Config *config) 
     303swish_Config * 
     304swish_add_config( 
     305    xmlChar *conf, 
     306    swish_Config *config 
     307
    290308{ 
    291309 
     
    298316} 
    299317 
    300 swish_Config   * 
    301 swish_parse_config(xmlChar *conf, swish_Config *config) 
    302 
    303     swish_merge_config_with_header((char *) conf, config); 
     318swish_Config * 
     319swish_parse_config( 
     320    xmlChar *conf, 
     321    swish_Config *config 
     322
     323
     324    swish_merge_config_with_header((char *)conf, config); 
    304325    return config; 
    305326} 
    306327 
    307  
    308 static void 
    309 config_printer(xmlChar *val, xmlChar *str, xmlChar *key) 
     328static void 
     329config_printer( 
     330    xmlChar *val, 
     331    xmlChar *str, 
     332    xmlChar *key 
     333
    310334{ 
    311335    SWISH_DEBUG_MSG(" %s:  %s => %s", str, key, val); 
     
    313337 
    314338static void 
    315 property_printer(swish_Property * prop, xmlChar *str, xmlChar *propname) 
     339property_printer( 
     340    swish_Property *prop, 
     341    xmlChar *str, 
     342    xmlChar *propname 
     343
    316344{ 
    317345    SWISH_DEBUG_MSG(" %s:  %s =>", str, propname); 
     
    320348 
    321349static void 
    322 metaname_printer(swish_MetaName * meta, xmlChar *str, xmlChar *metaname) 
     350metaname_printer( 
     351    swish_MetaName *meta, 
     352    xmlChar *str, 
     353    xmlChar *metaname 
     354
    323355{ 
    324356    SWISH_DEBUG_MSG(" %s:  %s =>", str, metaname); 
     
    328360/* PUBLIC */ 
    329361void 
    330 swish_debug_config(swish_Config *config) 
     362swish_debug_config( 
     363    swish_Config *config 
     364
    331365{ 
    332366    SWISH_DEBUG_MSG("config->ref_cnt = %d", config->ref_cnt); 
    333     SWISH_DEBUG_MSG("config->stash address = 0x%x  %d", (int) config->stash, (int) config->stash); 
    334     SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int) config, (int) config); 
     367    SWISH_DEBUG_MSG("config->stash address = 0x%x  %d", (int)config->stash, 
     368                    (int)config->stash); 
     369    SWISH_DEBUG_MSG("ptr addr: 0x%x  %d", (int)config, (int)config); 
    335370 
    336371    xmlHashScan(config->misc, (xmlHashScanner) config_printer, "misc conf"); 
    337     xmlHashScan(config->properties, (xmlHashScanner) property_printer, "properties"); 
    338     xmlHashScan(config->metanames, (xmlHashScanner) metaname_printer, "metanames"); 
     372    xmlHashScan(config->properties, (xmlHashScanner) property_printer, 
     373                "properties"); 
     374    xmlHashScan(config->metanames, (xmlHashScanner) metaname_printer, 
     375                "metanames"); 
    339376    xmlHashScan(config->parsers, (xmlHashScanner) config_printer, "parsers"); 
    340377    xmlHashScan(config->mimes, (xmlHashScanner) config_printer, "mimes"); 
    341378    xmlHashScan(config->index, (xmlHashScanner) config_printer, "index"); 
    342     xmlHashScan(config->tag_aliases, (xmlHashScanner) config_printer, "tag_aliases"); 
     379    xmlHashScan(config->tag_aliases, (xmlHashScanner) config_printer, 
     380                "tag_aliases"); 
    343381} 
    344382 
    345383static void 
    346384copy_property( 
    347           swish_Property * prop2, 
    348           xmlHashTablePtr props1, 
    349           xmlChar *prop2name 
     385    swish_Property *prop2, 
     386    xmlHashTablePtr props1, 
     387    xmlChar *prop2name 
    350388) 
    351389{ 
    352390    swish_Property *prop1; 
    353     boolean         in_hash; 
     391    boolean in_hash; 
    354392 
    355393    if (swish_hash_exists(props1, prop2name)) { 
     
    387425 
    388426static void 
    389 merge_properties(xmlHashTablePtr props1, xmlHashTablePtr props2) 
     427merge_properties( 
     428    xmlHashTablePtr props1, 
     429    xmlHashTablePtr props2 
     430
    390431{ 
    391432    xmlHashScan(props2, (xmlHashScanner) copy_property, props1); 
     
    394435static void 
    395436copy_metaname( 
    396           swish_MetaName * meta2, 
    397           xmlHashTablePtr metas1, 
    398           xmlChar *meta2name 
     437    swish_MetaName *meta2, 
     438    xmlHashTablePtr metas1, 
     439    xmlChar *meta2name 
    399440) 
    400441{ 
    401442    swish_MetaName *meta1; 
    402     boolean         in_hash; 
     443    boolean in_hash; 
     444 
    403445    if (swish_hash_exists(metas1, meta2name)) { 
    404446        meta1 = swish_hash_fetch(metas1, meta2name); 
     
    430472 
    431473static void 
    432 merge_metanames(xmlHashTablePtr metas1, xmlHashTablePtr metas2) 
     474merge_metanames( 
     475    xmlHashTablePtr metas1, 
     476    xmlHashTablePtr metas2 
     477
    433478{ 
    434479    xmlHashScan(metas2, (xmlHashScanner) copy_metaname, metas1); 
     
    436481 
    437482void 
    438 swish_config_merge(swish_Config *config1, swish_Config *config2) 
     483swish_config_merge( 
     484    swish_Config *config1, 
     485    swish_Config *config2 
     486
    439487{ 
    440488 
  • libswish3/trunk/src/libswish3/docinfo.c

    r2101 r2103  
    2828#include <stdlib.h> 
    2929 
    30 extern int      errno; 
     30extern int errno; 
    3131 
    3232#include "libswish3.h" 
    3333 
    34 extern int      SWISH_DEBUG; 
    35  
    36 /* PUBLIC */ 
    37 swish_DocInfo  * 
    38 swish_init_docinfo() 
     34extern int SWISH_DEBUG; 
     35 
     36/* PUBLIC */ 
     37swish_DocInfo * 
     38swish_init_docinfo( 
     39
    3940{ 
    4041 
     
    4243        SWISH_DEBUG_MSG("init'ing docinfo"); 
    4344 
    44     swish_DocInfo *docinfo = swish_xmalloc(sizeof(swish_DocInfo)); 
     45    swish_DocInfo *docinfo = swish_xmalloc(sizeof(swish_DocInfo)); 
    4546    docinfo->ref_cnt = 0; 
    4647    docinfo->nwords = 0; 
    4748    docinfo->mtime = 0; 
    4849    docinfo->size = 0; 
    49     docinfo->encoding = swish_xstrdup((xmlChar *) SWISH_DEFAULT_ENCODING); 
     50    docinfo->encoding = swish_xstrdup((xmlChar *)SWISH_DEFAULT_ENCODING); 
    5051    docinfo->uri = NULL; 
    5152    docinfo->mime = NULL; 
     
    6465/* PUBLIC */ 
    6566void 
    66 swish_free_docinfo(swish_DocInfo *ptr) 
     67swish_free_docinfo( 
     68    swish_DocInfo *ptr 
     69
    6770{ 
    6871    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) 
     
    7174    if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) 
    7275        swish_debug_docinfo(ptr); 
    73  
    7476 
    7577    if (ptr->ref_cnt != 0) { 
     
    7779    } 
    7880 
    79     ptr->nwords = 0;    /* why is this required? */ 
     81    ptr->nwords = 0;            /* why is this required? */ 
    8082    ptr->mtime = 0; 
    8183    ptr->size = 0; 
     
    115117 
    116118int 
    117 swish_check_docinfo(swish_DocInfo *docinfo, swish_Config *config) 
    118 
    119     int             ok; 
    120     xmlChar        *ext; 
     119swish_check_docinfo( 
     120    swish_DocInfo *docinfo, 
     121    swish_Config *config 
     122
     123
     124    int ok; 
     125    xmlChar *ext; 
    121126 
    122127    ok = 1; 
     
    129134 
    130135    if (docinfo->size == -1) 
    131         SWISH_CROAK("Failed to return required header Content-Length: for doc '%s'", 
    132                 docinfo->uri); 
     136        SWISH_CROAK 
     137            ("Failed to return required header Content-Length: for doc '%s'", 
     138             docinfo->uri); 
    133139 
    134140/* might make this conditional on verbose level */ 
     
    143149            docinfo->ext = swish_xstrdup(ext); 
    144150        else 
    145             docinfo->ext = swish_xstrdup((xmlChar *) "none"); 
     151            docinfo->ext = swish_xstrdup((xmlChar *)"none"); 
    146152 
    147153    } 
     
    151157    if (!docinfo->mime) { 
    152158        if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) 
    153             SWISH_DEBUG_MSG("no MIME known. guessing based on uri extension '%s'", docinfo->ext); 
     159            SWISH_DEBUG_MSG 
     160                ("no MIME known. guessing based on uri extension '%s'", 
     161                 docinfo->ext); 
    154162        docinfo->mime = swish_get_mime_type(config, docinfo->ext); 
    155163    } 
     
    162170    if (!docinfo->parser) { 
    163171        if (SWISH_DEBUG & SWISH_DEBUG_DOCINFO) 
    164             SWISH_DEBUG_MSG("no parser defined in headers -- deducing from content type '%s'", docinfo->mime); 
     172            SWISH_DEBUG_MSG 
     173                ("no parser defined in headers -- deducing from content type '%s'", 
     174                 docinfo->mime); 
    165175 
    166176        docinfo->parser = swish_get_parser(config, docinfo->mime); 
     
    181191/* PUBLIC */ 
    182192int 
    183 swish_docinfo_from_filesystem(xmlChar *filename, swish_DocInfo *i, swish_ParserData *parser_data) 
    184 
    185     struct stat     info; 
    186     int             stat_res; 
     193swish_docinfo_from_filesystem( 
     194    xmlChar *filename, 
     195    swish_DocInfo *i, 
     196    swish_ParserData *parser_data 
     197
     198
     199    struct stat info; 
     200    int stat_res; 
    187201 
    188202    if (i->ext != NULL) 
     
    191205    i->ext = swish_get_file_ext(filename); 
    192206 
    193     stat_res = stat((char *) filename, &info); 
     207    stat_res = stat((char *)filename, &info); 
    194208 
    195209    if (stat_res == -1) { 
     
    230244/* PUBLIC */ 
    231245void 
    232 swish_debug_docinfo(swish_DocInfo *docinfo) 
    233 
    234     xmlChar        *h_mtime = swish_xmalloc(30); 
    235     strftime((char *) h_mtime, 
    236          (unsigned long) 30, 
    237         SWISH_DATE_FORMAT_STRING, 
    238          (struct tm *) localtime((time_t *) & (docinfo->mtime))); 
     246swish_debug_docinfo( 
     247    swish_DocInfo *docinfo 
     248
     249
     250    xmlChar *h_mtime = swish_xmalloc(30); 
     251    strftime((char *)h_mtime, (unsigned long)30, SWISH_DATE_FORMAT_STRING, 
     252             (struct tm *)localtime((time_t *) & (docinfo->mtime))); 
    239253 
    240254    SWISH_DEBUG_MSG("DocInfo"); 
    241     SWISH_DEBUG_MSG("  docinfo ptr: %lu", (unsigned long) docinfo); 
     255    SWISH_DEBUG_MSG("  docinfo ptr: %lu", (unsigned long)docinfo); 
    242256/* SWISH_DEBUG_MSG("  size of swish_DocInfo struct: %d", (int)sizeof(swish_DocInfo)); */ 
    243257/* SWISH_DEBUG_MSG("  size of docinfo ptr: %d",           (int)sizeof(*docinfo)); */ 
    244     SWISH_DEBUG_MSG("  uri: %s (%d)", docinfo->uri, (int) sizeof(docinfo->uri)); 
    245     SWISH_DEBUG_MSG("  doc size: %lu bytes (%d)", (unsigned long) docinfo->size, (int) sizeof(docinfo->size)); 
    246     SWISH_DEBUG_MSG("  doc mtime: %lu (%d)", (unsigned long) docinfo->mtime, (int) sizeof(docinfo->mtime)); 
     258    SWISH_DEBUG_MSG("  uri: %s (%d)", docinfo->uri, (int)sizeof(docinfo->uri)); 
     259    SWISH_DEBUG_MSG("  doc size: %lu bytes (%d)", (unsigned long)docinfo->size, 
     260                    (int)sizeof(docinfo->size)); 
     261    SWISH_DEBUG_MSG("  doc mtime: %lu (%d)", (unsigned long)docinfo->mtime, 
     262                    (int)sizeof(docinfo->mtime)); 
    247263/* SWISH_DEBUG_MSG("  size of mime: %d",                  (int)sizeof(docinfo->mime)); */ 
    248264/* SWISH_DEBUG_MSG("  size of encoding: %d",              (int)sizeof(docinfo->encoding)); */ 
    249265    SWISH_DEBUG_MSG("  mtime str: %s", h_mtime); 
    250266    SWISH_DEBUG_MSG("  mime type: %s", docinfo->mime); 
    251     SWISH_DEBUG_MSG("  encoding: %s", docinfo->encoding);    /* only known after parsing has 
    252                                    started ... */ 
     267    SWISH_DEBUG_MSG("  encoding: %s", docinfo->encoding);       /* only known after parsing has 
     268                                                                   started ... */ 
    253269    SWISH_DEBUG_MSG("  file ext: %s", docinfo->ext); 
    254270    SWISH_DEBUG_MSG("  parser: %s", docinfo->parser); 
  • libswish3/trunk/src/libswish3/error.c

    r2101 r2103  
    3030#include "libswish3.h" 
    3131 
    32 extern int      SWISH_DEBUG; 
     32extern int SWISH_DEBUG; 
    3333 
     34static FILE *error_handle = NULL; 
    3435 
    35 static FILE    *error_handle = NULL; 
    36  
    37 void  
    38 swish_set_error_handle(FILE * where
     36void 
     37swish_set_error_handle( 
     38    FILE * where 
     39
    3940{ 
    4041    error_handle = where; 
    4142} 
    4243 
    43 void  
    44 swish_croak(const char *file, int line, const char *func, char *msgfmt,...) 
     44void 
     45swish_croak( 
     46    const char *file, 
     47    int line, 
     48    const char *func, 
     49    char *msgfmt, 
     50    ... 
     51
    4552{ 
    46     va_list         args; 
     53    va_list args; 
    4754 
    4855    if (!error_handle) 
     
    6168} 
    6269 
    63 void  
    64 swish_warn(const char *file, int line, const char *func, char *msgfmt,...) 
     70void 
     71swish_warn( 
     72    const char *file, 
     73    int line, 
     74    const char *func, 
     75    char *msgfmt, 
     76    ... 
     77
    6578{ 
    66     va_list         args; 
     79    va_list args; 
    6780 
    6881    if (!error_handle) 
     
    7689} 
    7790 
    78 void  
    79 swish_debug(const char *file, int line, const char *func, char *msgfmt,...) 
     91void 
     92swish_debug( 
     93    const char *file, 
     94    int line, 
     95    const char *func, 
     96    char *msgfmt, 
     97    ... 
     98
    8099{ 
    81     va_list         args; 
     100    va_list args; 
    82101 
    83102    if (!error_handle) 
  • libswish3/trunk/src/libswish3/getruntime.c

    r2101 r2103  
    1818Boston, MA 02111-1307, USA. 
    1919*/ 
    20  
    2120 
    2221#include "acconfig.h" 
     
    7372 
    7473cpu_seconds 
    75 get_cpu_secs() 
     74get_cpu_secs( 
     75
    7676{ 
    7777#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H) 
    78     struct rusage   rusage; 
    79     cpu_seconds     secs; 
     78    struct rusage rusage; 
     79    cpu_seconds secs; 
    8080 
    8181    getrusage(0, &rusage); 
     
    8989    return secs; 
    9090 
    91  
    92 #else                /* ! HAVE_GETRUSAGE */ 
     91#else /* ! HAVE_GETRUSAGE */ 
    9392#ifdef HAVE_TIMES 
    9493 
     
    9796/* Again, these are clock_t, which may overflow, but under linux it's 1/100 second so about 6000 hours */ 
    9897 
    99     struct tms      tms; 
     98    struct tms tms; 
    10099 
    101100    times(&tms); 
     
    103102    return (cpu_seconds) ((tms.tms_utime + tms.tms_stime) / GNU_HZ); 
    104103 
    105  
    106 #else                /* ! HAVE_TIMES */ 
     104#else /* ! HAVE_TIMES */ 
    107105/* Fall back on clock and hope it's correctly implemented. */ 
    108106/* clock() returns clock_t, which seems to be a long.  On Linux CLOCKS_PER_SEC is 10^6 */ 
    109107/* so expect an overflow at about 35 minutes. */ 
    110108 
    111     clock_t         t = clock(); 
     109    clock_t t = clock(); 
    112110    if (t < 0) 
    113111        t = 0; 
     
    115113    return (cpu_seconds) (t / CLOCKS_PER_SEC); 
    116114 
    117 #endif                /* HAVE_TIMES */ 
    118 #endif                /* HAVE_GETRUSAGE */ 
     115#endif /* HAVE_TIMES */ 
     116#endif /* HAVE_GETRUSAGE */ 
    119117} 
  • libswish3/trunk/src/libswish3/hash.c

    r2101 r2103  
    1818*/ 
    1919 
    20  
    2120/* wrappers to common functions in libxml2 hash */ 
    2221 
     
    2524#include "libswish3.h" 
    2625 
    27 extern int      SWISH_DEBUG; 
     26extern int SWISH_DEBUG; 
    2827 
    29 int             swish_hash_add(xmlHashTablePtr hash, xmlChar *key, void *value); 
    30 int 
    31                 swish_hash_replace(xmlHashTablePtr hash, xmlChar *key, void *value); 
    32 int 
    33                 swish_hash_delete(xmlHashTablePtr hash, xmlChar *key); 
    34 boolean 
    35 swish_hash_exists(xmlHashTablePtr hash, xmlChar *key); 
    36 void           * 
    37                 swish_hash_fetch(xmlHashTablePtr hash, xmlChar *key); 
    38 xmlHashTablePtr 
    39 swish_init_hash(int size); 
    40 void 
    41                 swish_hash_merge(xmlHashTablePtr hash1, xmlHashTablePtr hash2); 
    42 static void     free_hashval(void *val, xmlChar *key); 
     28int swish_hash_add( 
     29    xmlHashTablePtr hash, 
     30    xmlChar *key, 
     31    void *value 
     32); 
     33int swish_hash_replace( 
     34    xmlHashTablePtr hash, 
     35    xmlChar *key, 
     36    void *value 
     37); 
     38int swish_hash_delete( 
     39    xmlHashTablePtr hash, 
     40    xmlChar *key 
     41); 
     42boolean swish_hash_exists( 
     43    xmlHashTablePtr hash, 
     44    xmlChar *key 
     45); 
     46void *swish_hash_fetch( 
     47    xmlHashTablePtr hash, 
     48    xmlChar *key 
     49); 
     50xmlHashTablePtr swish_init_hash( 
     51    int size 
     52); 
     53void swish_hash_merge( 
     54    xmlHashTablePtr hash1, 
     55    xmlHashTablePtr hash2 
     56); 
     57static void free_hashval( 
     58    void *val, 
     59    xmlChar *key 
     60); 
     61static void merge_hashes( 
     62    xmlChar *value, 
     63    xmlHashTablePtr hash1, 
     64    xmlChar *key 
     65); 
     66 
    4367static void 
    44                 merge_hashes(xmlChar *value, xmlHashTablePtr hash1, xmlChar *key); 
    45  
    46  
    47 static void  
    48 free_hashval(void *val, xmlChar *key) 
     68free_hashval( 
     69    void *val, 
     70    xmlChar *key 
     71
    4972{ 
    5073    if (SWISH_DEBUG > 10) 
    51         printf("freeing %s from hash key %s\n", (xmlChar *) val, key); 
     74        printf("freeing %s from hash key %s\n", (xmlChar *)val, key); 
    5275 
    5376    swish_xfree(val); 
    5477} 
    5578 
    56  
    57 int  
    58 swish_hash_add(xmlHashTablePtr hash, xmlChar *key, void *value) 
     79int 
     80swish_hash_add( 
     81    xmlHashTablePtr hash, 
     82    xmlChar *key, 
     83    void *value 
     84
    5985{ 
    60     int             ret; 
     86    int ret; 
    6187    ret = xmlHashAddEntry(hash, key, value); 
    6288    if (ret == -1) 
     
    6793 
    6894int 
    69 swish_hash_replace(xmlHashTablePtr hash, xmlChar *key, void *value) 
     95swish_hash_replace( 
     96    xmlHashTablePtr hash, 
     97    xmlChar *key, 
     98    void *value 
     99
    70100{ 
    71     int             ret; 
    72     ret = xmlHashUpdateEntry(hash, key, value, (xmlHashDeallocator) free_hashval); 
     101    int ret; 
     102    ret = 
     103        xmlHashUpdateEntry(hash, key, value, (xmlHashDeallocator) free_hashval); 
    73104    if (ret == -1) 
    74105        SWISH_CROAK("xmlHashUpdateEntry for %s failed", key); 
     
    78109 
    79110int 
    80 swish_hash_delete(xmlHashTablePtr hash, xmlChar *key) 
     111swish_hash_delete( 
     112    xmlHashTablePtr hash, 
     113    xmlChar *key 
     114
    81115{ 
    82     int             ret; 
     116    int ret; 
    83117    ret = xmlHashRemoveEntry(hash, key, (xmlHashDeallocator) free_hashval); 
    84118    if (ret == -1) 
     
    89123 
    90124boolean 
    91 swish_hash_exists(xmlHashTablePtr hash, xmlChar *key) 
     125swish_hash_exists( 
     126    xmlHashTablePtr hash, 
     127    xmlChar *key 
     128
    92129{ 
    93130    return xmlHashLookup(hash, key) ? 1 : 0; 
    94131} 
    95132 
    96 void           * 
    97 swish_hash_fetch(xmlHashTablePtr hash, xmlChar *key) 
     133void * 
     134swish_hash_fetch( 
     135    xmlHashTablePtr hash, 
     136    xmlChar *key 
     137
    98138{ 
    99139    return xmlHashLookup(hash, key); 
     
    101141 
    102142xmlHashTablePtr 
    103 swish_init_hash(int size) 
     143swish_init_hash( 
     144    int size 
     145
    104146{ 
    105147    xmlHashTablePtr h; 
     
    115157 
    116158static void 
    117 merge_hashes(xmlChar *value, xmlHashTablePtr hash1, xmlChar *key) 
     159merge_hashes( 
     160    xmlChar *value, 
     161    xmlHashTablePtr hash1, 
     162    xmlChar *key 
     163
    118164{ 
    119165    if (swish_hash_exists(hash1, key)) { 
     
    126172 
    127173void 
    128 swish_hash_merge(xmlHashTablePtr hash1, xmlHashTablePtr hash2) 
     174swish_hash_merge( 
     175    xmlHashTablePtr hash1, 
     176    xmlHashTablePtr hash2 
     177
    129178{ 
    130179    xmlHashScan(hash2, (xmlHashScanner) merge_hashes, hash1); 
  • libswish3/trunk/src/libswish3/header.c

    r2101 r2103  
    2525#include "libswish3.h" 
    2626 
    27 extern int      SWISH_DEBUG; 
     27extern int SWISH_DEBUG; 
    2828 
    2929/* local struct to ease passing around flags/state */ 
    30 typedef struct { 
    31     boolean         isprops; 
    32     boolean         ismetas; 
    33     boolean         isindex; 
    34     boolean         isparser; 
    35     boolean         isalias; 
    36     boolean         ismime; 
    37     const xmlChar  *parent_name; 
    38     swish_Config   *config; 
    39     boolean         is_valid; 
    40     unsigned int    prop_id; 
    41     unsigned int    meta_id; 
    42 }               headmaker; 
    43  
    44 typedef struct { 
    45     void           *thing1; 
    46     void           *thing2; 
    47     void           *thing3; 
    48 }               things; 
     30typedef struct 
     31
     32    boolean isprops; 
     33    boolean ismetas; 
     34    boolean isindex; 
     35    boolean isparser; 
     36    boolean isalias; 
     37    boolean ismime; 
     38    const xmlChar *parent_name; 
     39    swish_Config *config; 
     40    boolean is_valid; 
     41    unsigned int prop_id; 
     42    unsigned int meta_id; 
     43} headmaker; 
     44 
     45typedef struct 
     46
     47    void *thing1; 
     48    void *thing2; 
     49    void *thing3; 
     50} things; 
     51 
     52static void read_metaname_aliases( 
     53    xmlChar *str, 
     54    headmaker * h, 
     55    swish_MetaName *meta 
     56); 
     57static void read_metaname_attr( 
     58    const xmlChar *attr, 
     59    const xmlChar *attr_val, 
     60    swish_MetaName *meta, 
     61    headmaker * h 
     62); 
     63static void read_metaname( 
     64    xmlTextReaderPtr reader, 
     65  &