home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / ftp.vapor.com / voyager / v295 / search_plugin_src.lzx / search.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-11  |  2.4 KB  |  109 lines

  1. #include <proto/exec.h>
  2. #include <proto/dos.h>
  3.  
  4. #include <string.h>
  5.  
  6. #define BUILDPLUGIN
  7. #include "v_plugin.h"
  8.  
  9. #include "rev.h"
  10.  
  11. // Move lib down the liblist (we're nice, aren't we?)
  12. long __asm __saveds __UserLibInit( register __a6 struct Library *libbase )
  13. {
  14.     libbase->lib_Node.ln_Pri = -128;
  15.     return( 0 );
  16. }
  17.  
  18. struct TagItem tags[]á= {
  19.  
  20.     VPLUG_Query_Version, VERSION,
  21.     VPLUG_Query_Revision, REVISION,
  22.     VPLUG_Query_Infostring, (ULONG)"Voyager simple SEARCH: plugin",
  23.     VPLUG_Query_Copyright, (ULONG)"(C) 1997 Oliver Wagner <owagner@vapor.com>, All Rights Reserved",
  24.  
  25.     VPLUG_Query_RegisterURLMethod, (ULONG)"SEARCH:",
  26.  
  27.     TAG_DONE
  28. };
  29.  
  30. struct TagItem * __asm __saveds VPLUG_Query( void )
  31. {
  32.     return tags;
  33. }
  34.  
  35. //    sprintf() replacement
  36. UWORD fmtfunc[] = {á0x16c0, 0x4e75 };
  37. void __stdargs sprintf( char *to, char *fmt, ... )
  38. {
  39.     RawDoFmt( fmt, &fmt + 1, (APTR)fmtfunc, to );
  40. }
  41.  
  42. #define QUERYFORM \
  43. "<BODY><TITLE>Voyager WebSearch</TITLE><BODY>"\
  44. "<center>"\
  45. "<hr>"\
  46. "<h1>Voyager WebSearch</h1>"\
  47. "<form action=search:>"\
  48. "<b>Enter search keywords:</b><br>"\
  49. "<input type=text name=keywords size=40><input type=submit Value=Start>"\
  50. "</FORM><hr>"\
  51. "<font size=-2>Voyager WebSearch Plugin " VERTAG "</font>"
  52.  
  53. #define RESPONSE \
  54. "<title>Voyager WebSearch RESULTS</title>"\
  55. "<frameset rows=*,*>"\
  56. "<frameset cols=*,*>"\
  57. "<frame src=http://altavista.digital.com/cgi-bin/query?pg=q&what=web&fmt=.&q=%s>"\
  58. "<frame src=http://www.webcrawler.com/cgi-bin/WebQuery?mode=compact&maxHits=50&searchText=%s>"\
  59. "</frameset>"\
  60. "<frameset cols=*,*>"\
  61. "<frame src=http://www.lycos.com/cgi-bin/pursuit?cat=lycos&query=%s&matchmode=and>"\
  62. "<frame src=http://search.yahoo.com/bin/search?p=%s>"\
  63. "</frameset>"\
  64. "</frameset>"
  65.  
  66. APTR __asm __saveds VPLUG_ProcessURLMethod( register __a0 STRPTR url )
  67. {
  68.     char *res, *p;
  69.  
  70.     res = AllocVec( 1024, 0 );
  71.     strcpy( res, "<TITLE>Search Error</TITLE><BODY><H2>Internal error" );
  72.  
  73.     // ok, check the stuff
  74.     p = strchr( url, ':' );
  75.     if( p++ )
  76.     {
  77.         p = stpblk( p );
  78.         if( !*p )
  79.         {
  80.             strcpy( res, QUERYFORM );
  81.         }
  82.         else
  83.         {
  84.             if( !strncmp( p, "?keywords=", 10 ) )
  85.                 p += 10;
  86.  
  87.             // ready to form response
  88.             sprintf( res, RESPONSE, p, p, p, p );
  89.         }
  90.     }
  91.  
  92.     return( res );
  93. }
  94.  
  95. STRPTR __asm __saveds VPLUG_GetURLData( register __a0 APTR urlhandle )
  96. {
  97.     return( urlhandle );
  98. }
  99.  
  100. STRPTR __asm __saveds VPLUG_GetURLMIMEType( register __a0 APTR urlhandle )
  101. {
  102.     return( "text/html" );
  103. }
  104.  
  105. void __asm __saveds VPLUG_FreeURLData( register __a0 APTR urlhandle )
  106. {
  107.     FreeVec( urlhandle );
  108. }
  109.