home *** CD-ROM | disk | FTP | other *** search
- /* This program parses a form that contains 3 input fields: a name
- suggestion for
- my expected new baby, a sex which could be male/female/either,
- and a comment
- the suggestions are added to a database that I╒m keeping until I
- actually have to
- name the kid. */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include "util.h"
- #define LF 10
- #define MAX_ENT 100
- #define NAME 0
- #define SEX 1
- #define COMMENT 2
- #define NAMES "/usr/pub/names"
- typedef struct {
- char *name;
- char *val;
- } entry;
-
- void main(int argc, char *argv[])
- {
-
- entry entries[MAX_ENT];
- int cont_len,index,marker;
- char address[256];
- FILE *names;
-
- index=marker=0;
-
- cont_len = atoi(getenv("CONTENT_LENGTH"));
- for(index=0;cont_len&& (!feof(stdin));index++)
- {
- marker=index;
- entries[index].val = fmakeword(stdin,'&',&cont_len);
- plustospace(entries[index].val);
- unescape_url(entries[index].val);
- entries[index].name = makeword(entries[index].val,'=');
- }
- printf("Content-type: text/html%c%c",LF,LF);
- names = fopen(NAMES, "a");
-
- fprintf(names,"%s\t\t%s\t%s\n",entries[NAME].val,entries[SEX].val,
- entries[COMMENT].val);
- fclose(names);
- system("/usr/bin/sort /shaggy.a/downing/pub/names >
- /shaggy.a/downing/pu
- b/tmp");
- system("/usr/bin/mv /shaggy.a/downing/pub/tmp
- /shaggy.a/downing/pub/names");
- printf("<h1>Thanks for your suggestion!</h1> %c",LF);
- printf("<h2>I will take the name \"%s\" into serious
- consideration!<p>",entries[NAME].val);
- printf("<a
- href=\"http://found.cs.nyu.edu/shaggy.a/downing/pub/names\">"
- );
- printf("List of names</a><p>");
- printf("<a
- href=\"http://found.cs.nyu.edu/downing\">return</a><p>");
- exit(0);
- }
-
-