/* NAME: submitform.c Purpose: To write the form input to 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 */ char entryval[21]; /* holds val of entry field */ int bold; /* If submit =bold, bold=1, else 0*/ 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 */ } x =0; while (x <= m) { /* Parse entries */ if (! strcmp (entries[x].name, "entry")) strcpy (entryval, entries[x].val); else if (! strcmp (entries[x].name, "bold")) bold = 1; else if (! strcmp (entries[x].name, "italics")) bold = 0; x++; } /* 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); if (bold) { printf ("You entered \"%s\" in the text field

%c", entryval, 10); printf ("And you pushed the normal button, so the text above is bold.

%c", 10); } else { printf ("You entered \"%s\" in the text field

%c", entryval, 10); printf ("And you pushed the personalized button, so the text above is italicized.

%c", 10); } printf ("<- Back to the INPUT page
%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; }