#include #include "Srch.h" #include "web.h" main() { char query[256]; /* user query */ char type[256]; /* query type */ getentry entries[8]; /* arguments from the user via http */ int i, x; /* for general use */ strcpy(query, "\0"); /* initialize user query as NULL */ i = ProcessGetMethod( entries ); printf("content-type: text/html\n\n"); /* HTML Header */ /* extract user's requirements */ for (x=0; x<=i; x++) { if (!strcasecmp(entries[x].name, "query")) { strcpy(query, entries[x].val); continue; } if (!strcasecmp(entries[x].name, "type")) { strcpy(type, entries[x].val); continue; } } WebSearch(query, type); exit(0); } int ltrim(String) char *String; { char *Source, *Dest; if (String[0] != ' ') return; Dest = String; Source = String + 1; while (*Source == ' ') Source++; while (*Source) { *Dest++ = *Source++; } *Dest = *Source; } int rtrim(String) char *String; { int len; char *ptr; len = strlen(String); ptr = (char *) (String + len - 1); while (1) { if ((*ptr == ' ') || (*ptr == '\n') || (*ptr == '\t')) { *ptr = '\0'; if (len == 1) break; ptr--; } else break; } *(ptr + 1) = '\0'; } int trim(String) { ltrim(String); rtrim(String); }