Changeset 7

Show
Ignore:
Timestamp:
12/13/00 02:14:33 (8 years ago)
Author:
whmoseley
Message:

Adjusted Makefile.in for install and install-lib, and to pass libdir
to src/configure
Added README INSTALL and SWISH-PERL docs -- initial edit
Rewrote perl/test.pl

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/swish-e/Makefile.in

    r5 r7  
    22# 
    33# Bas Meijer, bas@antraciet.com 11 Dec 2000 
     4 
     5# $Id$ 
    46 
    57SHELL = /bin/sh 
     
    79VPATH       = $(srcdir) 
    810prefix      = @prefix@ 
     11exec_prefix  = @exec_prefix@ 
    912bindir      = $(prefix)/bin 
    1013mandir      = $(prefix)/man/man1 
     
    1619swish-e:         
    1720        echo 'making swish-e' 
    18         (cd src;./configure --quiet --prefix=$(prefix) ;make;cd ..) 
     21        (cd src;./configure --quiet --prefix=$(prefix) --libdir=$(libdir) ;make;cd ..) 
    1922        echo 'swish-e done' 
    2023swish-search: swish-e 
     
    2528# 
    2629clean: 
    27         rm -f src/swish-e src/swish-search src/*.o \ 
     30        rm -f src/swish-e src/swish-search src/libswish-e.a src/*.o \ 
    2831        src/index.swish src/Makefile Makefile  
    2932 
     
    3235        rm -f src/config.cache src/config.log \ 
    3336                 src/config.status 
    34         rm -f src/swish-e src/swish-search src/*.o \ 
    35         src/index.swish src/Makefile Makefile  
     37        rm -f src/swish-e src/swish-search src/libswish-e.a src/*.o \ 
     38        src/index.swish src/Makefile Makefile \ 
     39        src/testlib 
    3640 
    3741test: 
     
    4953        ../src/swish-e -f ./test.index -w 'meta3="three little pigs"' | grep -v '^#'; ) 
    5054 
     55install: 
     56        cp src/swish-e $(bindir)/swish-e 
     57 
     58install-lib: 
     59        cp src/libswish-e.a $(libdir)/libswish-e.a 
     60 
  • trunk/swish-e/perl/SWISHE.xs

    r2 r7  
    5656        XPUSHs(sv_2mortal(newSVpv(result->filename,0))); 
    5757        XPUSHs(sv_2mortal(newSVpv(result->title,0))); 
     58        XPUSHs(sv_2mortal(newSVpv(result->summary,0))); 
    5859        XPUSHs(sv_2mortal(newSViv(result->start))); 
    5960        XPUSHs(sv_2mortal(newSViv(result->size))); 
  • trunk/swish-e/perl/test.pl

    r2 r7  
    1 #!/usr/local/bin/perl 
     1#!/usr/local/bin/perl -w 
    22 
    3 use SWISHE
     3    use strict
    44 
    5 #$properties='prop1 prop2 prop3'; 
    6 #$sortspec='prop1 asc prop2 desc'; 
    7 $searchstring='meta1=metatest1'; 
     5=pod 
     6    Test script for the SWISHE library 
     7    please see perldoc README-PERL for more information 
     8    $Id$ 
     9=cut 
    810 
    9 $indexfilename1='../tests/test.index'; 
    10 $indexfilename2='../tests/test.index'; 
    11 #$indexfilename2='another.index'; 
    12 $indexfilename="$indexfilename1"; 
    13 # To search for several index just put them together 
    14 $indexfilename="$indexfilename1 $indexfilename2"; 
    15  
    16 #Stemming sample 
    17 $word="parking"; 
    18 $stem_word=SwishStem($word); 
    19 print "$word is stemmed as $stem_word\n"; 
     11    # Import symbols 
     12    use SWISHE; 
    2013 
    2114 
    22 unless($handle=SWISHE::SwishOpen($indexfilename)) 
    23 
    24         print "Could not open index files\n"; 
    25         die; 
     15    # In this test we will use the same index twice 
     16     
     17    my $indexfilename1 = '../tests/test.index'; 
     18    my $indexfilename2 = $indexfilename1; 
     19 
     20    die "Index file '$indexfilename1' not found!  Did you run make test?\n" 
     21        unless -e $indexfilename1; 
     22 
     23    my $indexfiles = $indexfilename1;         
     24 
     25 
     26    # To search for several indexes just put them together 
     27    #my $indexfiles = "$indexfilename1 $indexfilename2"; 
     28 
     29 
     30    # Open the index files 
     31     
     32    my $handle = SwishOpen( $indexfiles ) 
     33        or die "Failed to open '$indexfiles'"; 
     34 
     35 
     36    # Get a few headers from the index files 
     37 
     38    my @headers = qw/WordCharacters BeginCharacters EndCharacters/; 
     39    push @headers, 'Indexed on'; 
     40   
     41    for ( @headers ) { 
     42        print_header("Header '$_'"); 
     43 
     44        my @h =  SwishHeaderParameter( $handle, $_ ); 
     45        print "$_ for index 0 is $h[0]\n"; 
     46    } 
     47 
     48 
     49    # Define a few searches 
     50 
     51    my @searches = ( 
     52        { 
     53            title   => 'Normal search', 
     54            query   => 'test', 
     55            props   => '', 
     56            sort    => '', 
     57            context => 1,   # Search the entire file 
     58        }, 
     59        { 
     60            title   => 'MetaTag search 1', 
     61            query   => 'meta1=metatest1', 
     62            props   => 'meta1 meta2 meta3', 
     63            sort    => '', 
     64            context => 1,   # Search the entire file 
     65        }, 
     66        { 
     67            title   => 'MetaTag search 2', 
     68            query   => 'meta2=metatest2', 
     69            props   => 'meta1 meta2 meta3', 
     70            sort    => '', 
     71            context => 1,   # Search the entire file 
     72        }, 
     73        { 
     74            title   => 'XML Search', 
     75            query   => 'meta3=metatest3', 
     76            props   => 'meta1 meta2 meta3', 
     77            sort    => '', 
     78            context => 1,   # Search the entire file 
     79        }, 
     80        { 
     81            title   => 'Phrase Search', 
     82            query   => 'meta3="three little pigs"', 
     83            props   => 'meta1 meta2 meta3', 
     84            sort    => '', 
     85            context => 1,   # Search the entire file 
     86        }, 
     87        { 
     88            title   => 'Advanced search', 
     89            query   => 'test or meta1=m* or meta2=m* or meta3=m*', 
     90            props   => 'meta1 meta2 meta3', 
     91            sort    => '', 
     92            context => 1,   # Search the entire file 
     93        }, 
     94    ); 
     95 
     96    my @settings = qw/query context props sort/; 
     97 
     98    print_header("*** Now searching ****"); 
     99    print "Note that some META names have embedded newlines.\n"; 
     100 
     101 
     102    for my $search ( @searches ) { 
     103        print_header( "$search->{title} - Query: '$search->{query}'" ); 
     104               
     105        my $num_results = SwishSearch( $handle, @{$search}{ @settings } ); 
     106 
     107        print "# Number of results = $num_results\n\n"; 
     108 
     109        unless ( $num_results ) { 
     110            print "No Results\n"; 
     111 
     112            my $error = SwishError( $handle ); 
     113            print "Error number: $error\n" if $error; 
     114 
     115            next; 
     116        } 
     117 
     118        while( my($rank,$index,$file,$title,$summary,$start,$size,@props) = SwishNext( $handle )) { 
     119            print join( ' ', 
     120                  $rank, 
     121                  $index, 
     122                  $file, 
     123                  qq["$title"], 
     124                  qq["$summary"], 
     125                  $start, 
     126                  $size, 
     127                  map{ qq["$_"] } @props, 
     128                  ),"\n"; 
     129        } 
     130    } 
     131 
     132    print_header('Other Functions'); 
     133 
     134 
     135 
     136    my @stemwords = qw/parking libaries library librarians money monies running runs is/; 
     137    print "\nStemming:\n"; 
     138    print "    '$_' => '" . SwishStem( $_ ) . "'\n" for @stemwords; 
     139    print "\n"; 
     140 
     141    my @stopwords = SwishStopWords( $handle, $indexfilename1 ); 
     142    print 'Stopwords: ', 
     143          ( @stopwords ? join(', ', @stopwords) : '** None **' ), 
     144          "\n\n"; 
     145 
     146 
     147    my $letter = 't'; 
     148    my @keywords = SwishWords( $handle, $indexfilename1, $letter); 
     149 
     150    print "List of keywords that start with the letter '$letter':\n", 
     151          join("\n", @keywords), 
     152          "\n\n"; 
     153 
     154 
     155 
     156    SwishClose( $handle ); 
     157 
     158sub print_header { 
     159    print "\n", '-' x length( $_[0] ),"\n", 
     160          $_[0], 
     161          "\n", '-' x length( $_[0] ),"\n"; 
    26162} 
    27163 
    28 # Need some info from header ? Here is how 
    29 # Since we have open two files, two values are returned 
    30 @wordchars=SWISHE::SwishHeaderParameter($handle,"WordCharacters"); 
    31 print "WordCharacters 0 = @wordchars[0]\n"; 
    32 print "WordCharacters 1 = @wordchars[1]\n"; 
    33164 
    34 @beginchars=SWISHE::SwishHeaderParameter($handle,"BeginCharacters"); 
    35 print "BeginCharacters 0 = @beginchars[0]\n"; 
    36 print "BeginCharacters 1 = @beginchars[1]\n"; 
    37  
    38 @endchars=SWISHE::SwishHeaderParameter($handle,"EndCharacters"); 
    39 print "EndCharacters 0 = @endchars[0]\n"; 
    40 print "EndCharacters 1 = @endchars[1]\n"; 
    41  
    42 @ignorefirstchar=SWISHE::SwishHeaderParameter($handle,"IgnoreFirstChar"); 
    43 print "IgnoreFirstChar 0 = @ignorefirstchar[0]\n"; 
    44 print "IgnoreFirstChar 1 = @ignorefirstchar[1]\n"; 
    45  
    46 @ignorelastchar=SWISHE::SwishHeaderParameter($handle,"IgnoreLastChar"); 
    47 print "IgnoreLastChar 0 = @ignorelastchar[0]\n"; 
    48 print "IgnoreLastChar 1 = @ignorelastchar[1]\n"; 
    49  
    50 @indexedon=SWISHE::SwishHeaderParameter($handle,"Indexed on"); 
    51 print "Indexed on 0 = @indexedon[0]\n"; 
    52 print "Indexed on 1 = @indexedon[1]\n"; 
    53  
    54 @description=SWISHE::SwishHeaderParameter($handle,"Description"); 
    55 print "Description 0 = @description[0]\n"; 
    56 print "Description 1 = @description[1]\n"; 
    57  
    58 @indexpointer=SWISHE::SwishHeaderParameter($handle,"IndexPointer"); 
    59 print "IndexPointer 0 = @indexpointer[0]\n"; 
    60 print "IndexPointer 1 = @indexpointer[1]\n"; 
    61  
    62 @indexadmin=SWISHE::SwishHeaderParameter($handle,"IndexAdmin"); 
    63 print "IndexAdmin 0 = @indexadmin[0]\n"; 
    64 print "IndexAdmin 1 = @indexadmin[1]\n"; 
    65  
    66 @stemming=SWISHE::SwishHeaderParameter($handle,"Stemming"); 
    67 print "Stemming 0 = @stemming[0]\n"; 
    68 print "Stemming 1 = @stemming[1]\n"; 
    69  
    70 @soundex=SWISHE::SwishHeaderParameter($handle,"Soundex"); 
    71 print "Soundex 0 = @soundex[0]\n"; 
    72 print "Soundex 1 = @soundex[1]\n"; 
    73  
    74 # Do you want know the stopwords? Here is how 
    75 @stopwords=SWISHE::SwishStopWords($handle,$indexfilename1); 
    76 print "StopWords ="; 
    77 for($i=0;@stopwords[$i];$i++) 
    78 { 
    79         print " @stopwords[$i]" 
    80 } 
    81 print "\n"; 
    82  
    83 # Do you want know the indexeded words starting with 't'? Here is how 
    84 @keywords=SWISHE::SwishWords($handle,$indexfilename1,"t"); 
    85 print "KeyWords ="; 
    86 for($i=0;@keywords[$i];$i++) 
    87 { 
    88         print " @keywords[$i]" 
    89 } 
    90 print "\n"; 
    91  
    92 $structure=1; 
    93  
    94 # Uncomment for an endless loop 
    95 #while (<>) 
    96 #{ 
    97 $num_results=SwishSearch($handle,$searchstring,$structure,$properties,$sortspec); 
    98  
    99 if ($num_results<0)  
    100 { 
    101         print "Search error: $num_results\n"; 
    102 } else{  
    103         print "Search Results: $num_results\n"; 
    104 } 
    105  
    106 while(($rank,$indexfile,$filename,$title,$start,$size,$prop1,$prop2,$prop3)=SWISHE::SwishNext($handle)) 
    107 { 
    108    print "$rank $indexfile $filename \"$title\" $start $size \"$prop1\" \"$prop2\" \"$prop3\"\n"; 
    109 } 
    110 # Uncomment for an endless loop 
    111 #} 
    112  
    113 SWISHE::SwishClose($handle); 
  • trunk/swish-e/src/Makefile.in

    r6 r7  
    1010# Several ideas from a Makefile by Christian Lindig <lindig@ips.cs.tu-bs.de>   
    1111# 
     12# $Id$ 
     13 
    1214NAME = swish-e 
    1315# C compiler 
     
    1719prefix = @prefix@ 
    1820bindir = $(prefix)/bin 
    19 libdir = $(prefix)/lib 
     21exec_prefix  = @exec_prefix@ 
     22libdir = @libdir@ 
    2023mandir = $(prefix)/man 
    2124man1dir = $(mandir)/man1 
     
    4144OBJS=   check.o file.o index.o search.o error.o methods.o\ 
    4245        hash.o list.o mem.o string.o merge.o swish2.o stemmer.o \ 
    43         soundex.o docprop.o compress.o deflate.o xml.o txt.o
     46        soundex.o docprop.o compress.o deflate.o xml.o txt.o html.o
    4447        $(FILESYSTEM_OBJS) $(HTTP_OBJS) 
    4548 
     
    9093$(OBJS):        Makefile config.h swish.h 
    9194 
    92 install:         
     95install: 
     96        cp swish-e $(bindir)/swish-e 
     97 
     98install-lib:     
    9399        cp libswish-e.a $(libdir)/libswish-e.a 
    94100 
     
    110116 list.h 
    111117hash.o: hash.c swish.h config.h hash.h mem.h string.h 
     118html.o: html.c swish.h mem.h html.h 
    112119http.o: http.c swish.h config.h index.h hash.h string.h mem.h file.h \ 
    113  http.h httpserver.h 
     120 http.h httpserver.h html.h 
    114121httpserver.o: httpserver.c swish.h config.h string.h mem.h http.h \ 
    115122 httpserver.h 
  • trunk/swish-e/src/check.c

    r2 r7  
    216216        return NODOCTYPE; 
    217217} 
     218 
     219 
     220struct StoreDescription *hasdescription(int doctype, struct StoreDescription *sd) 
     221{ 
     222        while(sd) 
     223        { 
     224                if(sd->DocType==doctype) 
     225                        return sd; 
     226                sd=sd->next; 
     227        } 
     228        return NULL; 
     229} 
  • trunk/swish-e/src/check.h

    r2 r7  
    2727char *hasfilter _AP((char *filename, struct filter *filterlist)); 
    2828int getdoctype _AP((char *filename, struct IndexContents *indexcontents)); 
     29struct StoreDescription *hasdescription _AP ((int, struct StoreDescription *)); 
  • trunk/swish-e/src/compress.c

    r2 r7  
    211211        } 
    212212                 
    213         buffer=buildFileEntry(filep->fi.filename, filep->fi.title, filep->fi.start, filep->fi.size, sw->fp_file_write, &filep->docProperties, filep->fi.lookup_path,&sz_buffer); 
     213        buffer=buildFileEntry(filep->fi.filename, filep->fi.title, filep->fi.summary, filep->fi.start, filep->fi.size, sw->fp_file_write, &filep->docProperties, filep->fi.lookup_path,&sz_buffer); 
    214214        tmp=sz_buffer+1; 
    215215        compress1(tmp,sw->fp_file_write);   /* Write len */ 
     
    228228{ 
    229229struct file *fi; 
    230 int len,len1,len2,begin,bytes,lookup_path; 
     230int len,len1,len2,len3,begin,bytes,lookup_path; 
    231231char *buffer,*p; 
    232 char *buf1,*buf2
     232char *buf1,*buf2,*buf3
    233233        fi=(struct file *)emalloc(sizeof(struct file)); 
    234234        if (!sw->fp_file_read) 
     
    253253        uncompress3(len2,p);   /* Read length of title */ 
    254254        if(!len2)     /* filename == title */ 
    255                 buf2=estrdup(buf1)
     255                buf2=buf1
    256256        else { 
    257257                buf2 = emalloc(len2); 
     
    259259                p+=len2; 
    260260        } 
     261        uncompress3(len3,p);   /* Read length of summary */ 
     262        if(!len3)     /* No summary */ 
     263                buf3=NULL; 
     264        else { 
     265                buf3 = emalloc(len3); 
     266                memcpy(buf3,p,len3);     /* Read summary */ 
     267                p+=len3; 
     268        } 
    261269        uncompress3(begin,p);           /* Read start */ 
    262270        begin--; 
     
    267275        fi->fi.filename = buf1; 
    268276        fi->fi.title = buf2; 
     277        fi->fi.summary = buf3; 
    269278        fi->fi.start = begin; 
    270279        fi->fi.size = bytes; 
  • trunk/swish-e/src/file.c

    r2 r7  
    317317int DocType=0; 
    318318struct IndexContents *ic; 
     319struct StoreDescription *sd; 
    319320IndexFILE *indexf=NULL; 
    320321         
     
    527528                                sw->indexcontents=ic; 
    528529                        } else progerr("IndexContents requires at least two values"); 
     530                } 
     531                else if ((c = (char *)lstrstr(line,"StoreDescription")) !=0) { 
     532                        c += strlen("StoreDescription"); 
     533                        sl=parse_line(c); 
     534                        if(sl && (sl->n==2 || sl->n==3)) { 
     535                                if(strcasecmp(sl->word[0],"TXT")==0) { 
     536                                        DocType=TXT; 
     537                                } 
     538                                else if(strcasecmp(sl->word[0],"HTML")==0) { 
     539                                        DocType=HTML; 
     540                                } 
     541                                else if(strcasecmp(sl->word[0],"XML")==0) { 
     542                                        DocType=XML; 
     543                                } 
     544                                else if(strcasecmp(sl->word[0],"MULTITXT")==0) { 
     545                                        DocType=MULTITXT; 
     546                                } 
     547                                else if(strcasecmp(sl->word[0],"WML")==0) { 
     548                                        DocType=WML; 
     549                                } else progerr("Unknown document type in StoreDescription"); 
     550                                sd=(struct StoreDescription *)emalloc(sizeof(struct StoreDescription)); 
     551                                sd->DocType=DocType; 
     552                                sd->size=0; 
     553                                sd->field=NULL; 
     554                                i=1; 
     555 
     556                                if(sl->word[i][0]=='<' && sl->word[i][strlen(sl->word[i])-1]=='>') 
     557                                { 
     558                                        sl->word[i][strlen(sl->word[i])-1]='\0'; 
     559                                        sd->field=estrdup(sl->word[i]+1); 
     560                                        i++; 
     561                                }  
     562                                if(i<sl->n && isnumstring(sl->word[i])) 
     563                                { 
     564                                        sd->size=atoi(sl->word[i]); 
     565                                } 
     566                                if(sl->n==2 && !sd->field && !sd->size) 
     567                                        progerr("Second parameter of StoreDescription must be <fieldname> or a number"); 
     568                                if(sl->n==3 && sd->field && !sd->size) 
     569                                        progerr("Third parameter of StoreDescription must be empty or a number"); 
     570                                if(sw->storedescription) 
     571                                        sd->next=sw->storedescription; 
     572                                else 
     573                                        sd->next=NULL; 
     574                                sw->storedescription=sd; 
     575                        } else progerr("StoreDescription requires two or three values"); 
    529576                } 
    530577                else if ((c = (char *)lstrstr(line,"DefaultContents")) !=0) { 
     
    858905  -- return: (FileProp *) 
    859906  -- A failed stat returns an empty (default) structure 
     907 
     908  -- 2000-12 
     909  -- Added StoreDescription 
    860910*/ 
    861911 
     
    878928  fprop->index_no_content = 0;        /* former: was indextitleonly! */ 
    879929  fprop->filterprog = NULL;           /* Default = No Filter */ 
     930  fprop->stordesc = NULL;             /* Default = No summary */ 
    880931 
    881932  fprop->real_path = real_path; 
    882933  fprop->work_path = (work_file) ? work_file : real_path; 
    883   /* -- also possible: a save copy of pathes using estrdup(), 
    884      -- but IMO not necessarry [to discuss...] $$ 
    885    */ 
    886  
    887934 
    888935  /* -- Get Properties of File 
     
    893940  fprop->mtime = stbuf.st_mtime; 
    894941 
    895  
    896  
    897942  /* -- get Doc Type as is in IndexContents or Defaultcontents 
    898943     -- doctypes by jruiz 
     
    917962  fprop->filterprog = hasfilter (fprop->real_path,sw->filterlist); 
    918963 
     964  fprop->stordesc = hasdescription (fprop->doctype,sw->storedescription); 
    919965 
    920966 
  • trunk/swish-e/src/fs.c

    r2 r7  
    103103int lens; 
    104104char *s,*p; 
    105 int lentitle; 
    106 char *title,*tmptitle; 
    107105DOCENTRYARRAY *sortfilelist, *sortdirlist; 
    108106struct swline *tmplist; 
     
    139137 
    140138        s=(char *)emalloc((lens=MAXFILELEN) + 1); 
    141         title=(char *)emalloc((lentitle=MAXTITLELEN) + 1); 
    142139 
    143140        dfd = opendir(dir); 
     
    205202                                continue;  
    206203                         
    207 /* $$$--- should the following be better in "html.c or whatever" (countwords_html) routine? 
    208 */ 
    209                         if (ishtml(sw,s)) { 
    210                                 title=SafeStrCopy(title, (char *) (tmptitle=parsetitle(s, s)),&lentitle); 
    211                                 efree(tmptitle); 
    212                                 if (!isoktitle(sw,title)) 
    213                                         continue; 
    214                         } 
    215                         else { 
    216                                 if ((p=strrchr(s, '/'))) 
    217                                         { title=SafeStrCopy(title,p + 1,&lentitle); } 
    218                                 else 
    219                                         { title=SafeStrCopy(title, s,&lentitle); } 
    220                         } 
    221204                        sortfilelist = (DOCENTRYARRAY *) 
    222                                 addsortentry(sortfilelist, s, title); 
     205                                addsortentry(sortfilelist, s); 
    223206                } 
    224207                else { 
    225208                        sortdirlist = (DOCENTRYARRAY *) 
    226                                 addsortentry(sortdirlist, s, s); 
    227                 } 
    228         } 
    229          
    230         efree(title); 
     209                                addsortentry(sortdirlist, s); 
     210                } 
     211        } 
     212         
    231213        efree(s); 
    232214 
     
    244226int badfile; 
    245227char *t; 
    246 int lentitle; 
    247 char *title,*tmptitle; 
    248 DOCENTRY *fileentry; 
     228char *filename; 
    249229struct swline *tmplist; 
    250230         
     
    298278         
    299279 
    300 /* $$$--- should the following be better in html.c (countwords_html) routine? 
    301 */ 
    302  
    303         title=(char *) emalloc((lentitle=MAXSTRLEN)+1); 
    304         if (ishtml(sw,path)) { 
    305                 title = SafeStrCopy(title, (char *) (tmptitle=parsetitle(path, path)),&lentitle); 
    306                 efree(tmptitle); 
    307                 if (!isoktitle(sw,title)) { 
    308                         efree(title); 
    309                         return; 
    310                 } 
    311         } 
    312         else { 
    313                 if ((t = strrchr(path, '/')) != NULL) 
    314                         { title=SafeStrCopy(title, t + 1,&lentitle); } 
    315                 else 
    316                         { title=SafeStrCopy(title, path, &lentitle); } 
    317         } 
    318          
    319         fileentry = (DOCENTRY *) emalloc(sizeof(DOCENTRY)); 
    320         fileentry->filename = (char *) estrdup(path); 
    321                 /* Dup title to not to waste memory */ 
    322         fileentry->title = (char *) estrdup(title); 
    323  
    324         efree(title); 
    325  
    326         printfile(sw,fileentry); 
     280        filename = (char *) estrdup(path); 
     281 
     282        printfile(sw,filename); 
    327283} 
    328284 
     
    331287*/ 
    332288 
    333 void printfile(SWISH *sw, DOCENTRY *e) 
     289void printfile(SWISH *sw, char *filename) 
    334290{ 
    335291char     *s; 
     
    337293         
    338294 
    339         if (e != NULL) { 
     295        if (filename) { 
    340296                if (sw->verbose == 3) { 
    341                         if ((s = (char *) strrchr(e->filename, '/')) == NULL) 
    342                                 printf("  %s", e->filename); 
     297                        if ((s = (char *) strrchr(filename, '/')) == NULL) 
     298                                printf("  %s", filename); 
    343299                        else 
    344300                                printf("  %s", s + 1); 
     
    347303 
    348304 
    349                 fprop = file_properties (e->filename, e->filename, sw); 
    350                 do_index_file(sw,fprop,e->title); 
     305                fprop = file_properties (filename, filename, sw); 
     306                do_index_file(sw,fprop); 
    351307 
    352308 
    353309                free_file_properties (fprop); 
    354                 efree(e->filename); 
    355                 efree(e->title); 
    356                 efree(e); 
     310                efree(filename); 
    357311        } 
    358312} 
     
    367321        if(e) { 
    368322                for(i=0;i<e->currentsize;i++)  
    369                         printfile(sw, e->dlist[i]); 
    370         /* free the array and dlist */ 
    371                 efree(e->dlist); 
     323                        printfile(sw, e->filenames[i]); 
     324        /* free the array and filenames */ 
     325                efree(e->filenames); 
    372326                efree(e); 
    373327        }        
     
    385339                for(i=0;i<e->currentsize;i++) { 
    386340                        if (sw->verbose == 3) 
    387                                 printf("\nIn dir \"%s\":\n", e->dlist[i]->filename); 
     341                                printf("\nIn dir \"%s\":\n", e->filenames[i]); 
    388342                        else if (sw->verbose == 2) 
    389                                 printf("Checking dir \"%s\"...\n",e->dlist[i]->filename); 
    390                         indexadir(sw,e->dlist[i]->filename); 
    391                         efree(e->dlist[i]->filename); 
    392                         efree(e->dlist[i]->title); 
    393                         efree(e->dlist[i]); 
    394                 } 
    395                 efree(e->dlist); 
     343                                printf("Checking dir \"%s\"...\n",e->filenames[i]); 
     344                        indexadir(sw,e->filenames[i]); 
     345                        efree(e->filenames[i]); 
     346                } 
     347                efree(e->filenames); 
    396348                efree(e); 
    397349        } 
     
    399351 
    400352 
    401  
    402 /* This checks is a filename has one of the following suffixes: 
    403 ** "htm", "HTM", "html", "HTML", "shtml", "SHTML". 
    404 */ 
    405 /* 09/00 Jose Ruiz 
    406 ** Modified to handle IndexContents and DefaultContents directives */ 
    407 int ishtml(sw,filename) 
    408 SWISH *sw; 
    409 char *filename; 
    410 { 
    411 char *c,*suffix; 
    412 int DocType; 
    413         if(!filename) return 0; 
    414  
    415         c = (char *) strrchr(filename, '.'); 
    416          
    417         if (!c || c[1]=='\0') return 0; 
    418          
    419         suffix=c+1; 
    420                 /* 09/00 Jose Ruiz */ 
    421                 /* get DocType based in IndexContents or Defaultcontents */ 
    422         if((DocType=getdoctype(filename,sw->indexcontents))==NODOCTYPE && sw->DefaultDocType!=NODOCTYPE) 
    423                 DocType=sw->DefaultDocType; 
    424         if(DocType==HTML) return 1; 
    425         else if(DocType==NODOCTYPE) { 
    426                         /* IndexContents and DefaultContents not specified */ 
    427                         /* So, use the old method for compatibility reasons */ 
    428                 if (!strncmp(suffix, "htm", 3)) return 1; 
    429                 else if (!strncmp(suffix, "HTM", 3)) return 1; 
    430                 else if (!strncmp(suffix, "shtml", 5)) return 1; 
    431                 else if (!strncmp(suffix, "SHTML", 5)) return 1; 
    432         } 
    433         return 0; 
    434 } 
    435  
    436 /* Check if a particular title (read: file!) should be ignored 
    437 ** according to the settings in the configuration file. 
    438 */ 
    439  
    440 int isoktitle(sw,title) 
    441 SWISH *sw; 
    442 char *title; 
    443 { 
    444         int badfile; 
    445         struct swline *tmplist; 
    446          
    447         badfile = 0; 
    448         tmplist = sw->titconlist; 
    449         while (tmplist != NULL) { 
    450                 if (matchARegex(title, tmplist->line)) { 
    451                         badfile = 1; 
    452                         break; 
    453                 } 
    454                 tmplist = tmplist->next; 
    455         } 
    456         if (badfile) 
    457                 return 0; 
    458         else 
    459                 return 1; 
    460 } 
    461353 
    462354/********************************************************/ 
  • trunk/swish-e/src/fs.h

    r2 r7  
    55void indexadir(SWISH *, char *); 
    66void indexafile(SWISH *, char *); 
    7 void printfile(SWISH *, DOCENTRY *); 
     7void printfile(SWISH *, char *); 
    88void printfiles(SWISH *, DOCENTRYARRAY *); 
    99void printdirs(SWISH *, DOCENTRYARRAY *); 
    10 int ishtml(SWISH *,char *); 
    11 int isoktitle(SWISH *,char *); 
    1210 
  • trunk/swish-e/src/http.c

    r2 r7  
    5656#include "xml.h" 
    5757#include "txt.h" 
     58#include "html.h" 
    5859 
    5960typedef struct urldepth { 
     
    453454 
    454455 
    455                         do_index_file(sw,fprop,fprop->real_path); 
     456                        do_index_file(sw,fprop); 
    456457         
    457458 
  • trunk/swish-e/src/index.c

    r2 r7  
    9191** $$ swish-e was originally designed to index html only. So the routines 
    9292** $$ are for historically reasons scattered 
    93 ** $$ (e.g. isoktitle (), is okhtml() etc.) 
     93** $$ (e.g. isoktitle (), is ishtml() etc.) 
     94** 
     95** 2000-12 Jose Ruiz 
     96** obsolete routine ishtml removed 
     97** isoktitle moved to html.c 
    9498** 
    9599*/ 
     
    115119 
    116120 
    117  
    118  
    119  
    120  
    121  
    122121/* 
    123122   -- Start the real indexing process for a file. 
     
    131130*/ 
    132131 
    133 void do_index_file (SWISH *sw, FileProp *fprop, char *title
     132void do_index_file (SWISH *sw, FileProp *fprop
    134133{ 
    135134int      wordcount; 
     
    137136char     *rd_buffer=NULL;       /* complete file read into buffer */ 
    138137 
    139  
    140 /* $$  title is obsolete and has to be removed form all parent subroutines! 
    141    $$  title has to retrieved from the countwordsroutines if necessary 
    142    $$  also DocEntry is not needed in parent subroutines.... (IMO) - rasc 2000-11 
    143    $$ to be discussed... (Jose should we remove this?) 
    144  */      
    145 printf ("obsolete title (same as fprop path information?): %s\n",title); 
    146  
    147138        wordcount = -1; 
    148139        filtercmd = NULL; 
    149          
    150140 
    151141        if (fprop->work_path) { 
     
    186176                      case TXT: 
    187177                        if(sw->verbose == 3) printf(" - Using TXT filter - "); 
    188                         wordcount = countwords_TXT(sw, fprop,title, rd_buffer);  
     178                        wordcount = countwords_TXT(sw, fprop, rd_buffer);  
    189179                        break; 
    190180 
    191181                      case HTML: 
    192182                        if(sw->verbose == 3) printf(" - Using HTML filter - "); 
    193                         wordcount = countwords(sw, fprop, title, rd_buffer);  
     183                        wordcount = countwords_HTML(sw, fprop, rd_buffer);  
    194184                        break; 
    195185 
    196186                      case XML: 
    197187                        if(sw->verbose == 3) printf(" - Using XML filter - "); 
    198                         wordcount = countwords_XML(sw, fprop, title,rd_buffer);  
     188                        wordcount = countwords_XML(sw, fprop, rd_buffer);  
    199189                        break; 
    200190 
    201191                      case MULTITXT: 
    202192                        if(sw->verbose == 3) printf(" - Using MULTITXT filter - "); 
    203                         wordcount = countwords(sw, fprop, title, rd_buffer);  
     193                        wordcount = countwords_HTML(sw, fprop, rd_buffer);  
    204194                        break; 
    205195 
    206196                      case WML: 
    207197                        if(sw->verbose == 3) printf(" - Using WML filter - "); 
    208                         wordcount = countwords(sw, fprop, title, rd_buffer);  
     198                        wordcount = countwords_HTML(sw, fprop, rd_buffer);  
    209199                        break; 
    210200 
    211201                      default: 
    212202                        if(sw->verbose == 3) printf(" - Using DEFAULT filter - "); 
    213                         wordcount = countwords(sw, fprop, title, rd_buffer);  
     203                        wordcount = countwords_HTML(sw, fprop, rd_buffer);  
    214204                        break; 
    215205                    } 
     
    230220                        else if (wordcount == 0)  
    231221                                printf(" (no words)\n"); 
    232                         else 
     222                        else if (wordcount == -1) 
    233223                                printf(" (not opened)\n"); 
     224                        else if (wordcount == -2) 
     225                                printf(" (title is not ok)\n"); 
    234226                        fflush(stdout); 
    235227                } 
     
    247239*/ 
    248240 
    249 DOCENTRYARRAY *addsortentry(e, filename, title
     241DOCENTRYARRAY *addsorten