8 use open IO
=> ':utf8';
11 my $htsearchpath="/srv/www/cgi-bin/htsearch";
23 'config=s' => \
$config,
24 'format=s' => \
$format,
25 'method=s' => \
$method,
28 'docbook' => \
$docbook,
29 'indexdir=s' => \
$indexdir,
30 'maxnum=s' => \
$maxnum
34 print STDERR
"No index dir given.\n";
38 if ( !$lang ) { $lang = "en"; }
40 my $charset = langCharset
( $lang );
42 $words = encode
( $charset, $words );
44 if ( !open( HTSEARCH
, "-|", "$htsearchpath", "-c", "$indexdir/$config.conf",
45 "format=$format&method=$method&words=$words" ) )
47 print "Can't execute htsearch at '$htsearchpath'.\n";
51 my ($body,$liststart,$ref,$link,$error,$errorOut);
56 if ( /^<body/ ) { $body = 1; }
63 if ( /^<img src.*<a href="(.*)">(.*)<\/a>/ ) {
67 print STDERR
"REF: $ref LINK: $link\n";
69 $ref =~ s/file:\/\/localhost
//;
71 $ref =~ s/http:\/\/localhost\
//file
:\
//;
74 $ref =~ /help:\/\
/(.*)\/index
.docbook
/;
78 $link =~ s/apptitle/$app/;
81 print " <li><a href=\"$ref\">$link</a></li>\n";
83 if ( /^<h1>ht:\/\
/Dig error/ ) {
85 print "Htdig error:\n";
87 if ( $error && /^<pre>/ ) {
92 if ( /^<\/pre
>/ ) { $errorOut = 0; }
98 if ( $liststart ) { print "</ul>\n"; }
100 print "</body></html>\n";
102 if ( $?
!= 0 ) { exit $?
; }
106 # Return charset used for given language
110 if ( $lang eq "cz" || $lang eq "hu" ) {
112 } elsif ( $lang eq "kr" ) {