home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / docs / src / search.cgi < prev    next >
Text File  |  1996-11-20  |  2KB  |  68 lines

  1. #!/bin/sh
  2.  
  3. search=`echo "$QUERY_STRING" | cut -d= -f2-`
  4.  
  5. echo "Content-type: text/html"
  6. echo ""
  7. echo "<HTML>"
  8. echo "<TITLE>AROS - The Amiga Replacement OS - Search results for $search</TITLE>"
  9. echo "<H1>Search results for <I>$search</I></H1>"
  10. #echo "<PRE>"
  11. #pwd
  12. #printenv
  13. #echo "</PRE>"
  14.  
  15. glimpse -H /home/digulla/AROS/docs/html -i $search | \
  16. sort | \
  17. gawk 'BEGIN { IGNORECASE=1; count=0; } \
  18.  { \
  19.     if (!count) print "<DL>"; \
  20.     count ++; \
  21.     match($0,/[^:]+:/);
  22.     file=substr($0,RSTART,RLENGTH-1); \
  23.     gsub(/\/home\/digulla\/AROS\/docs\/html\//,"",file); \
  24.     printf ("<DT><A HREF=\"../%s\">%s</A>\n<DD>", file, file); \
  25.     line=substr($0,RSTART+RLENGTH+1); \
  26.     gsub("^[ \t]+","",line); \
  27.     gsub("[ \t]+$","",line); \
  28.     rest=line; \
  29.     line=""; \
  30.     inhref=0; \
  31.                                 \
  32.     while (rest!="")                                        \
  33.     {                                \
  34.     if (match(rest,/<[^>]+>/))                        \
  35.     {                            \
  36.         prefix=substr(rest,1,RSTART-1);                 \
  37.         tag=substr(rest,RSTART,RLENGTH);                \
  38.         rest=substr(rest,RSTART+RLENGTH);               \
  39.                                 \
  40.         gsub(/'$search'/,"<B>&</B>",prefix);            \
  41.         line=line prefix;                    \
  42.         if (tag=="</A>" && inhref)                      \
  43.         {                            \
  44.         line=line tag;                    \
  45.         inhref=0;                    \
  46.         }                            \
  47.         else if (match(tag,/^<A[ \t]+HREF/))            \
  48.         {                            \
  49.         inhref=1;                    \
  50.         line=line tag;                    \
  51.         }                            \
  52.     }                            \
  53.     else                            \
  54.     {                            \
  55.         gsub(/'$search'/,"<B>&</B>",rest);              \
  56.         line=line rest;                    \
  57.         rest="";                                        \
  58.     }                            \
  59.     }                                \
  60.     \
  61.     if (inhref) line=line"...</A>"; \
  62.     print "<DD>..." line "..." \
  63. } \
  64. END { if (!count) print "No matches"; else print "</DL>"; }'
  65. echo "</DL>"
  66. echo "</BODY></HTML>"
  67.  
  68.