HTML and CSS Reference
In-Depth Information
Your application must retrieve this variable and extract from it the para-
meter name/value pairs. Fortunately, most servers come with a set of
utility routines that perform this task for you, so a simple C program
that just dumps the parameters might look like this:
#include <stdio.h>
#include <stdlib.h>
#define MAX_ENTRIES 10000
typedef struct {char *name;
char *val;
} entry;
char *makeword(char *line, char stop);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
main(int argc, char *argv[])
{ entry entries[MAX_ENTRIES];
int num_entries, i;
char *query_string;
/* Get the value of the QUERY_STRING environment variable */
query_string = getenv("QUERY_STRING");
/* Extract the parameters, building a table of entries */
for (num_entries = 0; query_string[0]; num_entries++) {
entries[num_entries].val = makeword(query_string, '&');
plustospace(entries[num_entries].val);
unescape_url(entries[num_entries].val);
entries[num_entries].name =
makeword(entries[num_entries].val, '=');
}
/* Spit out the HTML boilerplate */
 
Search WWH ::




Custom Search