Changeset 1933

Show
Ignore:
Timestamp:
05/06/07 23:33:47 (1 year ago)
Author:
karpet
Message:

perl bindings split \003 into array of strings, libswish3 pod auto-generated from source .h file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libswish3/trunk/bindings/perl/3.xs

    r1931 r1933  
    337337sp_nb_hash_to_phash(xmlBufferPtr buf, HV *phash, xmlChar *key) 
    338338{ 
    339  
    340 /* TODO: it'd be nice to split on \003 here and make each hash val an AV ref */ 
    341     dTHX; 
    342     hv_store(phash, key, strlen(key),  
    343              newSVpvn((char*)xmlBufferContent(buf), xmlBufferLength(buf)), 
    344              0); 
     339    dTHX; 
     340    AV* strings         = newAV(); 
     341    const xmlChar *str  = xmlBufferContent(buf); 
     342    const xmlChar *tmp; 
     343    int bump            = strlen(SWISH_META_CONNECTOR); 
     344    int len; 
     345     
     346    /* analogous to @strings = split(/SWISH_META_CONNECTOR/, str) */ 
     347    while((tmp = xmlStrstr(str, SWISH_META_CONNECTOR)) != NULL) 
     348    { 
     349        len = tmp - str; 
     350        if(len) 
     351            av_push(strings, newSVpvn(str, len)); 
     352             
     353        str = tmp + bump;  /* move the pointer up */ 
     354    } 
     355     
     356    /* if there was only one string, make sure it's in array */ 
     357    if (xmlBufferLength(buf) && av_len(strings) == -1) 
     358        av_push(strings, newSVpvn(xmlBufferContent(buf), xmlBufferLength(buf))); 
     359         
     360    hv_store(phash, key, strlen(key), (void*)newRV_inc((SV*)strings), 0); 
    345361} 
    346362 
     
    10311047     
    10321048     
     1049void 
     1050debug(self) 
     1051    swish_WordList * self; 
     1052     
     1053    CODE: 
     1054        swish_debug_wordlist( self ); 
     1055         
     1056 
    10331057 
    10341058void 
  • libswish3/trunk/bindings/perl/t/20metanames.t

    r1931 r1933  
    11use Test::More tests => 22; 
    22use Carp; 
    3 use Devel::Peek; 
    4 use Data::Dump qw( dump ); 
     3#use Devel::Peek; 
     4#use Data::Dump qw( dump ); 
    55 
    66#use Devel::Monitor qw(:all); 
     
    3939    my $data = shift; 
    4040 
    41     diag(dump($data->metanames)); 
    42     my $meta = $data->metanames; 
    43     for my $m (keys %$meta) 
    44     { 
    45         my @buf = split(/\003/, $meta->{$m}); 
    46         diag(dump \@buf); 
    47     } 
     41#    diag(dump($data->metanames)); 
     42#   $data->wordlist->debug; 
    4843 
    4944} 
  • libswish3/trunk/doc/Makefile.am

    r1913 r1933  
    66 
    77 
    8 $(srcdir)/libswish3.3 : $(top_srcdir)/doc/libswish3.3.pod 
     8$(srcdir)/libswish3.3 : $(top_srcdir)/doc/libswish3.3.pod.in 
    99        -rm -f $@ 
     10        -perl make_lib_pod.pl 
    1011        -pod2man --center="libswish3" --lax --release='$(VERSION)'  $(top_srcdir)/doc/libswish3.3.pod  > $@ 
    1112 
  • libswish3/trunk/src/libswish3/libswish3.h

    r1931 r1933  
    102102#define SWISH_PROP_MTIME           "swishlastmodified" 
    103103#define SWISH_PROP_DESCRIPTION     "swishdescription" 
    104 #define SWISH_PROP_CONNECTOR       " \3" 
    105 #define SWISH_META_CONNECTOR       " \3" 
     104#define SWISH_PROP_CONNECTOR       "\3" 
     105#define SWISH_META_CONNECTOR       "\3" 
    106106 
    107107/* utils */ 
     
    137137#endif 
    138138 
    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  
     139typedef struct swish_StringList         swish_StringList; 
     140typedef struct swish_Config             swish_Config; 
     141typedef struct swish_ConfigValue        swish_ConfigValue; 
     142typedef struct swish_DocInfo            swish_DocInfo; 
     143typedef struct swish_MetaStackElement   swish_MetaStackElement; 
     144typedef struct swish_MetaStackElement  *swish_MetaStackElementPtr; 
     145typedef struct swish_MetaStack          swish_MetaStack; 
     146typedef struct swish_Word               swish_Word; 
     147typedef struct swish_WordList           swish_WordList; 
     148typedef struct swish_ParseData          swish_ParseData; 
     149typedef struct swish_Tag                swish_Tag; 
     150typedef struct swish_TagStack           swish_TagStack; 
     151typedef struct swish_Analyzer           swish_Analyzer; 
     152typedef struct swish_Parser             swish_Parser; 
     153typedef struct swish_NamedBuffer        swish_NamedBuffer; 
     154 
     155/* 
     156=head2 Data Structures 
     157*/ 
    148158 
    149159struct swish_StringList 
     
    153163}; 
    154164 
    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; 
    208165 
    209166struct swish_Config 
     
    223180}; 
    224181 
    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; 
    266182 
    267183struct swish_NamedBuffer 
     
    369285}; 
    370286 
    371 /* public functions */ 
    372  
    373 /* parser styles -- main entry points */ 
     287/* 
     288=cut 
     289*/ 
     290 
     291/* 
     292=head2 Global Functions 
     293*/ 
     294void        swish_init(); 
     295void        swish_cleanup(); 
     296/* 
     297=cut 
     298*/ 
     299 
     300/* 
     301=head2 I/O Functions 
     302*/ 
     303xmlChar *   swish_slurp_stdin( long flen ); 
     304xmlChar *   swish_slurp_file_len( xmlChar *filename, long flen ); 
     305xmlChar *   swish_slurp_file( xmlChar *filename ); 
     306/* 
     307=cut 
     308*/ 
     309 
     310 
     311/* 
     312=head2 Hash Functions 
     313*/ 
     314int         swish_hash_add( xmlHashTablePtr hash, xmlChar *key, void * value ); 
     315int         swish_hash_replace( xmlHashTablePtr hash, xmlChar *key, void *value ); 
     316int         swish_hash_delete( xmlHashTablePtr hash, xmlChar *key ); 
     317xmlHashTablePtr swish_new_hash(int size); 
     318/* 
     319=cut 
     320*/ 
     321 
     322/* 
     323=head2 Memory Functions 
     324*/ 
     325void        swish_init_memory(); 
     326void *      swish_xrealloc(void *ptr, size_t size); 
     327void *      swish_xmalloc( size_t size ); 
     328void        swish_xfree( void *ptr ); 
     329void        swish_mem_debug(); 
     330xmlChar *   swish_xstrdup( const xmlChar * ptr ); 
     331xmlChar *   swish_xstrndup( const xmlChar * ptr, int len ); 
     332/* 
     333=cut 
     334*/ 
     335 
     336/* 
     337=head2 Time Functions 
     338*/ 
     339double      swish_time_elapsed(void); 
     340double      swish_time_cpu(void); 
     341char *      swish_print_time(double time); 
     342char *      swish_print_fine_time(double time); 
     343/* 
     344=cut 
     345*/ 
     346 
     347/* 
     348=head2 Error Functions 
     349*/ 
     350void        swish_set_error_handle( FILE *where ); 
     351void        swish_fatal_err(char *msg,...); 
     352void        swish_warn_err(char *msg,...); 
     353void        swish_debug_msg(char *msg,...); 
     354/* 
     355=cut 
     356*/ 
     357 
     358/* 
     359=head2 String Functions 
     360*/ 
     361void                swish_verify_utf8_locale(); 
     362int                 swish_is_ascii( xmlChar *str ); 
     363int                 swish_utf8_chr_len( xmlChar *utf8 ); 
     364wchar_t *           swish_locale_to_wchar(xmlChar * str); 
     365xmlChar *           swish_wchar_to_locale(wchar_t * str); 
     366wchar_t *           swish_wstr_tolower(wchar_t *s); 
     367xmlChar *           swish_str_tolower(xmlChar *s ); 
     368xmlChar *           swish_str_skip_ws(xmlChar *s); 
     369void                swish_str_trim_ws(xmlChar *string); 
     370void                swish_debug_wchars( const wchar_t * widechars ); 
     371int                 swish_wchar_t_comp(const void *s1, const void *s2); 
     372int                 swish_sort_wchar(wchar_t *s); 
     373swish_StringList *  swish_make_StringList(xmlChar * line); 
     374swish_StringList *  swish_init_StringList(); 
     375void                swish_free_StringList(swish_StringList * sl); 
     376/* 
     377=cut 
     378*/ 
     379 
     380 
     381/* 
     382=head2 Configuration Functions 
     383*/ 
     384swish_Config *  swish_init_config(); 
     385swish_Config *  swish_add_config( xmlChar * conf, swish_Config * config ); 
     386swish_Config *  swish_parse_config( xmlChar * conf, swish_Config * config ); 
     387swish_Config *  swish_parse_config_new( xmlChar * conf, swish_Config * config ); 
     388int             swish_debug_config( swish_Config * config ); 
     389xmlHashTablePtr swish_subconfig_hash( swish_Config * config, xmlChar *key); 
     390int             swish_config_value_exists( swish_Config * config, xmlChar *key, xmlChar *value ); 
     391xmlChar *       swish_get_config_value(swish_Config * config, xmlChar * key, xmlChar * value); 
     392void            swish_free_config(swish_Config * config); 
     393swish_ConfigValue * swish_keys( swish_Config * config, ... ); 
     394swish_ConfigValue * swish_value( swish_Config * config, xmlChar * key, ... ); 
     395swish_ConfigValue * swish_init_ConfigValue(); 
     396void                swish_free_ConfigValue( swish_ConfigValue * cv ); 
     397xmlHashTablePtr swish_mime_hash(); 
     398xmlChar *       swish_get_mime_type( swish_Config * config, xmlChar * fileext ); 
     399xmlChar *       swish_get_parser( swish_Config * config, xmlChar *mime ); 
     400/* 
     401=cut 
     402*/ 
     403 
     404/* 
     405=head2 Parser Functions 
     406*/ 
    374407swish_Parser *  swish_init_parser(  swish_Config * config,  
    375408                                    swish_Analyzer * analyzer,  
     
    386419                        xmlChar * buf,  
    387420                        void * stash  ); 
    388  
    389  
    390 /* word functions */ 
     421/* 
     422=cut 
     423*/ 
     424 
     425/* 
     426=head2 Token Functions  
     427*/ 
    391428void                swish_init_words(); 
    392429swish_WordList *    swish_init_wordlist(); 
     
    438475                                             
    439476void                swish_debug_wordlist( swish_WordList * list ); 
    440  
     477/* 
     478=cut 
     479*/ 
     480 
     481/* 
     482=head2 Analyzer Functions 
     483*/ 
    441484swish_Analyzer *    swish_init_analyzer( swish_Config * config ); 
    442485void                swish_free_analyzer( swish_Analyzer * analyzer ); 
    443  
    444  
    445 /* DocInfo struct functions */ 
     486/* 
     487=cut 
     488*/ 
     489 
     490/* 
     491=head2 DocInfo Functions 
     492*/ 
    446493swish_DocInfo *     swish_init_docinfo(); 
    447494void                swish_free_docinfo( swish_DocInfo * ptr ); 
     
    451498                                                    swish_ParseData *parse_data ); 
    452499void                swish_debug_docinfo( swish_DocInfo * docinfo ); 
    453  
    454  
    455 /* NamedBuffer functions */ 
    456  
     500xmlChar *           swish_get_file_ext( xmlChar *url ); 
     501/* 
     502=cut 
     503*/ 
     504 
     505/* 
     506=head2 Buffer Functions 
     507*/ 
    457508swish_NamedBuffer * swish_init_nb( swish_Config * config, xmlChar * configKey ); 
    458509void                swish_free_nb( swish_NamedBuffer * nb ); 
     
    472523                                         int autovivify); 
    473524void                swish_append_buffer( xmlBufferPtr buf, xmlChar * txt, int len ); 
    474  
    475  
    476  
     525/* 
     526=cut 
     527*/ 
    477528 
    478529