Indexing server extension 
Version 1.01a 
November 1993

 Many thanks to Ari Luotonen from CERN for his contribution of
 the extract-title command, and to Stefanie Hoefling for many hours 
 of debugging. -- Chris

Copyright
This code is free, but copyrighted. Unless explicitly stated otherwise, 
the code in these directories is the intellectual property of the 
Fraunhofer IGD. No liability whatsoever is accepted for any loss or 
damage of any kind resulting from any defect or inaccuracy in this 
information or code. 
You're free to use this code in any non-commercial product.

Installation
(If you receive this package as part of a HTML server distribution,
you probably won't have to worry about this.)
Type "make" in the "src" directory. If necessary, edit the Makefile
to set an ANSI compliant C compiler like "gcc". Make will produce
executable files in the "bin" directory.

Decide on where you want to put shell scripts and executables for
your server extension. Copy the files from the "bin" and the "script"
subdirectories to that directory. Edit the shell scripts (their names
start with "httpd_") and set the configuration variables like
"BINDIR" and "INDEXFILE".

Set up cron in such a way that httpd_mkindex is being called in
regular intervalls in order to create a precomputed index.
Set up the server software so that httpd_index is being
called up whenever an index query is being recognized.

Also, the server must be modified in such a way that the indexing script 
is being called up. For example, if you use the NCSA server, make the
following changes to "send_node" (I'm currently using 1.0a4):

#define INDEX_HACK
 /* 
  * this should actually come out of some conf file.. Chris :-) 
  */
#define INDEXSCRIPT "/whereever/the/indexscript/is/httpd_index"


/* GET */
void send_node(char *file, char *args, FILE *fd)
{
    struct stat finfo;

#ifdef INDEX_HACK /* <- begin of changes */
      /* Any keywords given? */
      if(args&&(strlen(args)>0)){
        FILE *f;
        int i;
        char buf[256];
        char keybuf[256];
        char *keys=args, *tmpfile;

       /* 1. Make a blank out of every "+" sign..  */
        char *p1, *p2;
        short int val;
        for(p1=keys, p2=keybuf;*p1;){
          switch(*p1){
          case '+' : *p2 = ' '; 
                     p1++; p2++;
                     break;
          case '%' : strncpy(p2,p1+1,2);
                     (void) sscanf(p2,"%hx",&val);
                     *p2 = (unsigned char)val;
                     p1+=3; p2++;
                     break;
          default:   *p2=*p1;
                     p2++; p1++;
                     break;
          }
        }
        *p2='\0';

        /* 2. create a temporary file name  */
        tmpfile = (char *)tmpnam(NULL);
        f = fopen(tmpfile,"wb+");
        if(f==NULL){
          char err[MAX_STRING_LEN];
          sprintf(err,"could not create temp file %s, error=",tmpfile);
				  strcat(err,strerror(errno));
          log_error(err);
        } else {
				  fclose(f);
				}

        /* 3. call up /bin/sh with indexscript */
        sprintf(buf,
				"/bin/sh %s %s %s > %s 2>/dev/console",
				INDEXSCRIPT,file,keybuf,tmpfile);
        system(buf);

        if(!(f=fopen(tmpfile,"r"))) {
				  char err[MAX_STRING_LEN];
          sprintf(err,
					  "couldn't open temp file %s for reading, error=",tmpfile);
				  strcat(err,strerror(errno));
          log_error(err);

          unmunge_name(tmpfile);
          die(FORBIDDEN,tmpfile,fd);
        }
        set_content_type(".html");
        send_fd(f,fd,"");
        unlink(tmpfile);

        return; /* we're done, then. */
      }
#endif  /* INDEX_HACK */ /* <- end of changes */
  ... 
  (Rest of function send_node)
That's all. 
Ooops.. and one more thing: make sure your documents contain the 
tag <ISINDEX> in the headers - otherwise you won't be able to
use indexing, since the browsing software probably will
disable index requests! In my humble opinion, it would be a 
good thing to have index capable servers automatically add
this tag, since it's more a server feature then a document
local property.

Bug reports
Please contact me if you have bug-reports or suggestions: 
Christian Neuss  
c/o Fraunhofer IGD  
Wilhelminenstr. 7  
64283 Darmstadt  
GERMANY
Fax: (+49)6151 155-199  
email:  neuss@igd.fhg.de

Have fun :-),
-- Chris

