📄 postform.c
字号:
/* Author: M. L. Liu, based on a NCSA CGI tutorial sample.
This is the source code for postForm.cgi, for the simple
form example. It is invoked from postForm.html, and
generates a dynamic web page which displays the name-
value pairs obtained from postForm.html.
This program uses the NCSA CGI library for processing a
query string obtained via the POST method.
*/
#include <stdio.h>
#ifndef NO_STDLIB_H
#include <stdlib.h>
#else
char *getenv();
#endif
#define MAX_ENTRIES 10000
typedef struct {
char *name;
char *val;
} entry;
char *makeword(char *line, char stop);
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
main(int argc, char *argv[]) {
entry entries[MAX_ENTRIES];
register int x,m=0;
int cl;
printf("Content-type: text/html%c%c",10,10);
if(strcmp(getenv("REQUEST_METHOD"),"POST")) {
printf("This script should be referenced ",
"with a METHOD of POST.\n");
exit(1);
}
if(strcmp(getenv("CONTENT_TYPE"),
"application/x-www-form-urlencoded")) {
printf("The query string does not contain ",
"URL-encoded data \n");
exit(1);
}
cl = atoi(getenv("CONTENT_LENGTH"));
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries[x].val = fmakeword(stdin,'&',&cl);
plustospace(entries[x].val);
unescape_url(entries[x].val);
entries[x].name = makeword(entries[x].val,'=');
}
printf("<body bgcolor=\"#FFFF99\">");
printf("<H1>Query Results</H1>");
printf("You submitted the following name/value pairs:",
"<p>%c",10);
printf("<ul>%c",10);
for(x=0; x <= m; x++)
printf("<li> <code>%s = %s</code>\n",entries[x].name,
entries[x].val);
printf("</body>");
printf("</html>");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -