/* NAME: output.c Purpose: To write the form input to a file and an HTML doc. Date: 02/12/96 Author: LoneWolf (Mosh Teitelbaum) */ #include #ifndef NO_STDLIB_H #include #else char *getenv(); #endif #define MAX_ENTRIES 10000 /* Define limit of form fields */ typedef struct { char *name; char *val; } entry; /* Functions defs req'd for util.c*/ char *makeword(char *line, char stop); /* Used to seperate word/val pairs*/ char *fmakeword(FILE *f, char stop, int *len); char x2c(char *what); /* Used to convert hex to char */ void unescape_url(char *url); /* Used to "unescape" esc'd chars */ void plustospace(char *str); /* Converts pluses to spaces */ main(int argc, char *argv[]) { entry entries[MAX_ENTRIES]; /* Array to store name/val pais */ register int x, m = 0; /* Counters */ int cl; /* Length of form input */ cl = atoi(getenv("CONTENT_LENGTH")); for(x=0;cl && (!feof(stdin));x++) { m=x; /* INC counter and Separate */ entries[x].val = fmakeword(stdin,'&',&cl); /* name/val pair by '&' */ plustospace(entries[x].val); /* Convert pluses to spaces */ unescape_url(entries[x].val); /* "Unescape" special chars */ entries[x].name = makeword(entries[x].val,'='); /* Sepearate entry to name/val */ } /* Print HTML header and doc info */ printf ("Content-type: text/html%c%c", 10, 10); printf ("%c%c", 10, 10); printf ("%c", 10); printf ("Form Input...%c%c%c", 10, 10, 10); printf ("%c

%c
Form Input...%c", 10, 10, 10); printf ("

%c%c", 10, 10); printf ("
%c%c", 10, 10, 10); x = 0; /* Print all name/val pairs */ while (x <= m) { printf ("%s-->%s
", entries[x].name, entries[x].val); x++; } printf ("<- Back to Index
%c%c", 10, 10); printf ("
%c%c%c", 10, 10, 10); printf ("Hacked together by LoneWolf"); printf (" (Mosh Teitelbaum).

%c", 10); printf ("%c%c", 10, 10); printf ("%c%c", 10, 10); return 0; }