/*************************************************************************** * query.c sample script to handle Method=GEt * * original: Rob McCool, NCSA HTTPD V. 1.3 * OS/2 port: Frankie Fan 7/11/94 * * $Header$ * * $Log$ **************************************************************************/ #include #include #include #include "util.h" typedef struct { char name[128]; char val[128]; } entry; void getword(char *word, char *line, char stop); char x2c(char *what); void unescape_url(char *url); void plustospace(char *str); void main(void) { entry entries[10000]; register int x, m = 0; char *cl; printf("Content-type: text/html%c%c", 10, 10); if (strcmp(getenv("REQUEST_METHOD"), "GET")) { printf("This script should be referenced with a METHOD of GET.\n"); printf("If you don't understand this, see this "); printf("forms overview.%c", 10); exit(1); } cl = getenv("QUERY_STRING"); if (cl == NULL) { printf("No query information to decode.\n"); exit(1); } for (x = 0; cl[0] != '\0'; x++) { m = x; getword(entries[x].val, cl, '&'); plustospace(entries[x].val); unescape_url(entries[x].val); getword(entries[x].name, entries[x].val, '='); } printf("

Query Results

"); printf("You submitted the following name/value pairs:

%c", 10); printf("

    %c", 10); for (x = 0; x <= m; x++) printf("
  • %s = %s%c", entries[x].name, entries[x].val, 10); printf("
%c", 10); }