home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include "util.h"
- #define MAILER "/usr/ucb/mail"
- #define USER "you@youraddress.edu"
- #define SUBJECT "Webpage_Reply"
- #define LF 10
- #define MAX_ENT 10000 /* max number of variables
- that can be sent from form*/
- #define FROM 0
- #define EMAIL 1
- #define USUBJECT 2
- #define BODY 3
- 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 *mdata, *log;
-
- 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,'=');
- }
-
- /* put together e-mail address */
-
- sprintf(address, "%s -s %s %s",
- MAILER, SUBJECT, USER);
-
- /* open pipe to mailer */
-
- if (!(mdata=popen(address,"w"))){
- printf("<h1>Unable to open mail pipe</h1>%c",LF);
- exit(-1); }
-
- /* send data to mailer */
-
- fprintf(mdata,"Subject: %s%c%c",entries[USUBJECT].val,LF,LF);
- fprintf(mdata,"%s %c",entries[BODY].val,LF);
- fprintf(mdata,"%c%cMessage Sender:
- %s",LF,LF,entries[FROM].val);
- fprintf(mdata,"%c%cEmail: %s",LF,LF,entries[EMAIL].val);
-
- /* put together HTML confirmation for mosaic user */
-
- printf("Content-type: text/html%c%c",LF,LF);
-
- printf("<h1>Mail sent!</h1> %c",LF);
- printf("<h2>If you included an e-mail address you should
- receive
- a reply shortly.</h2>");
- printf("content follows:<p><hr>%c",LF);
-
- for(index=0; index <= marker; index++)
- printf("%s: %s<p>",entries[index].name,
- entries[index].val);
- printf("<p><a href=\"http://found.cs.nyu.edu/\">RETURN</a><p>");
-
- pclose(mdata);
- exit(0);
- }
-
-