1 |
adcroft |
1.1 |
/* |
2 |
|
|
$Id: keychar_out.c,v 1.8 2002/08/22 22:58:39 whmoseley Exp $ |
3 |
|
|
** |
4 |
|
|
** This program and library is free software; you can redistribute it and/or |
5 |
|
|
** modify it under the terms of the GNU (Library) General Public License |
6 |
|
|
** as published by the Free Software Foundation; either version 2 |
7 |
|
|
** of the License, or any later version. |
8 |
|
|
** |
9 |
|
|
** This program is distributed in the hope that it will be useful, |
10 |
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
|
|
** GNU (Library) General Public License for more details. |
13 |
|
|
** |
14 |
|
|
** You should have received a copy of the GNU (Library) General Public License |
15 |
|
|
** along with this program; if not, write to the Free Software |
16 |
|
|
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
17 |
|
|
** |
18 |
|
|
** |
19 |
|
|
** |
20 |
|
|
** 2001-03-20 rasc own module for this routine (from swish.c) |
21 |
|
|
** |
22 |
|
|
*/ |
23 |
|
|
|
24 |
|
|
#include "swish.h" |
25 |
|
|
#include "string.h" |
26 |
|
|
#include "error.h" |
27 |
|
|
#include "mem.h" |
28 |
|
|
#include "search.h" |
29 |
|
|
#include "result_output.h" |
30 |
|
|
#include "db.h" |
31 |
|
|
#include "keychar_out.h" |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
|
36 |
|
|
/* |
37 |
|
|
** ---------------------------------------------- |
38 |
|
|
** |
39 |
|
|
** Module code starts here |
40 |
|
|
** |
41 |
|
|
** ---------------------------------------------- |
42 |
|
|
*/ |
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
/* |
47 |
|
|
-- output all indexed words starting with character "keychar" |
48 |
|
|
-- keychar == '*' prints all words |
49 |
|
|
*/ |
50 |
|
|
|
51 |
|
|
|
52 |
|
|
void OutputKeyChar (SWISH *sw, int keychar) |
53 |
|
|
{ |
54 |
|
|
IndexFILE *tmpindexlist; |
55 |
|
|
int keychar2; |
56 |
|
|
char *keywords; |
57 |
|
|
|
58 |
|
|
if ( !SwishAttach(sw) ) |
59 |
|
|
SwishAbortLastError( sw ); |
60 |
|
|
|
61 |
|
|
resultHeaderOut(sw,1, "%s\n", INDEXHEADER); |
62 |
|
|
/* print out "original" search words */ |
63 |
|
|
for(tmpindexlist=sw->indexlist;tmpindexlist;tmpindexlist=tmpindexlist->next) |
64 |
|
|
{ |
65 |
|
|
resultHeaderOut(sw,1, "%s:",tmpindexlist->line); |
66 |
|
|
if(keychar=='*') |
67 |
|
|
{ |
68 |
|
|
for(keychar2=1;keychar2<256;keychar2++) |
69 |
|
|
{ |
70 |
|
|
keywords=getfilewords(sw,(unsigned char )keychar2,tmpindexlist); |
71 |
|
|
for(;keywords && keywords[0];keywords+=strlen(keywords)+1) |
72 |
|
|
resultHeaderOut(sw,1, " %s",keywords); |
73 |
|
|
} |
74 |
|
|
} else { |
75 |
|
|
keywords=getfilewords(sw,keychar,tmpindexlist); |
76 |
|
|
for(;keywords && keywords[0];keywords+=strlen(keywords)+1) |
77 |
|
|
resultHeaderOut(sw,1, " %s",keywords); |
78 |
|
|
} |
79 |
|
|
resultHeaderOut(sw,1, "\n"); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
return; |
83 |
|
|
} |
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|