disclaimer: please take this e-mail as README file to submited patch.

what is the patch doing:
------------------------
enabling htsearch to produce valid HTML content header in conjunction with
localized templates (i.e. if you use for example ISO-8859-2 in your
templates, corresponding "Content-type: text/html; charset=ISO-8859-2" is
produced by htsearch).

how it is done:
---------------
in defaults.cc new 'encoding' item is set (default is empty: ""). when non
empty value is used (in configuration file), then HTTP header is produced
as follows:

Content-type: text/html; charset=`config["encoding"]`

if encoding is not specified in config file, then "normal" Content-type
header is produced ("Content-type: text/html").

actual state:
-------------
raw functionality seems to be OK. documentation entries do not exists
(except comments in htdig.conf).

TODO
----
- documentation


please let me know whether it is usefull/correct/...

sincerely

peter hanecak

p.s.: if someone is interested in RPM package of htdig with this patch, he
can find it at http://www.megaloman.com/~hany/RPM/htdig.html (btw doors
2.2 release is glibc2.1 based, doors 1.2 is based on glibc2.0 ) - release
2 (release 1 with multilingual patch is obsolete)

===================================================================
  Peter Hanecak - production manager
  Mega & Loman, Stare grunty 52, 842 44 Bratislava, Slovakia
  tel., fax: +421-7-654 211 52
  [EMAIL PROTECTED], http://www.megaloman.com
  GPG pub.key: http://www.megaloman.com/gpg/hanecak-megaloman.txt
===================================================================
diff -uNr htdig-3.1.3.orig/htcommon/defaults.cc htdig-3.1.3/htcommon/defaults.cc
--- htdig-3.1.3.orig/htcommon/defaults.cc       Wed Sep 22 18:18:39 1999
+++ htdig-3.1.3/htcommon/defaults.cc    Tue Nov  2 15:28:38 1999
@@ -47,6 +47,7 @@
     {"doc_db",                         "${database_base}.docdb"},
     {"doc_index",                      "${database_base}.docs.index"},
     {"doc_list",                       "${database_base}.docs"},
+    {"encoding",                       ""},
     {"end_ellipses",                   "<b><tt> ...</tt></b>"},
     {"endings_affix_file",             "${common_dir}/english.aff"},
     {"endings_dictionary",             "${common_dir}/english.0"},
diff -uNr htdig-3.1.3.orig/htsearch/Display.cc htdig-3.1.3/htsearch/Display.cc
--- htdig-3.1.3.orig/htsearch/Display.cc        Wed Sep 22 18:18:44 1999
+++ htdig-3.1.3/htsearch/Display.cc     Tue Nov  2 15:42:51 1999
@@ -99,6 +99,7 @@
     if (number <= 0)
        number = 10;
     int                        startAt = (pageNumber - 1) * number;
+    char               *encoding = config["encoding"];
 
     if (config.Boolean("logging"))
     {
@@ -119,13 +120,19 @@
        // No matches.
        //
         delete matches;
-       cout << "Content-type: text/html\r\n\r\n";
+       if ( strcmp(encoding, "") == 0 )
+           cout << "Content-type: text/html\r\n\r\n";
+       else
+           cout << "Content-type: text/html; charset=" << encoding << "\r\n\r\n";
        displayNomatch();
        return;
     }
     // maxScore = match->getScore();   // now done in buildMatchList()
-       
-    cout << "Content-type: text/html\r\n\r\n";
+
+    if ( strcmp(encoding, "") == 0 )
+       cout << "Content-type: text/html\r\n\r\n";
+    else
+       cout << "Content-type: text/html; charset=" << encoding << "\r\n\r\n";
     String     wrap_file = config["search_results_wrapper"];
     String     *wrapper = 0;
     char       *header = 0, *footer = 0;
@@ -597,7 +604,12 @@
 void
 Display::displaySyntaxError(char *message)
 {
-    cout << "Content-type: text/html\r\n\r\n";
+    char               *encoding = config["encoding"];
+
+    if ( strcmp(encoding, "") == 0 )
+       cout << "Content-type: text/html\r\n\r\n";
+    else
+       cout << "Content-type: text/html; charset=" << encoding << "\r\n\r\n";
 
     setVariables(0, 0);
     vars.Add("SYNTAXERROR", new String(message));
diff -uNr htdig-3.1.3.orig/installdir/htdig.conf htdig-3.1.3/installdir/htdig.conf
--- htdig-3.1.3.orig/installdir/htdig.conf      Wed Sep 22 18:18:47 1999
+++ htdig-3.1.3/installdir/htdig.conf   Tue Nov  2 15:27:06 1999
@@ -115,6 +115,12 @@
 # template_name: long
 
 #
+# The following parameter change encoding header field of HTTP response
+# generated by htsearch. If your search results are in ISO-8859-1 character
+# set, leave this uncommented.
+#encoding:     ISO-8859-1
+
+#
 # The following are used to change the text for the page index.
 # The defaults are just boring text numbers.  These images spice
 # up the result pages quite a bit.  (Feel free to do whatever, though)

Reply via email to