C写的处理method=get表单的cgi程序
时间:2007-01-04
来源:互联网
index.html的大致内容:
11 <table border="0">
12 <tr><td width="350"></td><td width="350"></td><td
width="350"></td></tr>
13 <!-- 序章-死灵法师 -->
14 <tr><td colspan="3"
align="center">序章-死灵法师</td></tr>
15 <tr>
16 <td width="33%" align="center">
17 <button type="submit" name="filename"
value="000_001">序章上 前夜</button>
main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4
5 #define BUF_N 512
6 #define PATH "../xiedu/"
7
8 static inline void
9 begin(void)
10 {
11 fprintf(stdout,"Content-type:text/html\n\n");
12 fprintf(stdout,"<html><title>亵渎</title>\n");
13 return;
14 }
15 static inline void
16 end(void)
17 {
18 fprintf(stdout,"</html>");
19 return;
20 }
21 static void
22 content(const char * const path)
23 {
24 FILE * fp = fopen(path,"rb");
25 char * buf = NULL;
26 if( NULL == fp ){
27 fprintf(stdout,"%d:打开错误</br>\n",__LINE__);
39 free(buf);
40 fclose(fp);
41 return;
42 }
43 int
44 main(int argc,char **argv)
45 {
46 int i,n=0;
47 begin();
48 /* method = get */
49 if( getenv("QUERY_STRING" ) ){
50 char *t=NULL;
51 if( NULL == (t=(char *)malloc(sizeof(char)*BUF_N)) ){
52 end();
53 exit(-1);
54 }
55 sprintf(t,"%s",PATH);
56 strcat(t,strstr((char *)getenv("QUERY_STRING"),"=")+1);
57 /*
58 fprintf(stdout,"打开文件:%s</br>\n",t);
59 */
60 content(t);
61 free(t);
62 }
63 end();
64 return 0;
65 }
11 <table border="0">
12 <tr><td width="350"></td><td width="350"></td><td
width="350"></td></tr>
13 <!-- 序章-死灵法师 -->
14 <tr><td colspan="3"
align="center">序章-死灵法师</td></tr>
15 <tr>
16 <td width="33%" align="center">
17 <button type="submit" name="filename"
value="000_001">序章上 前夜</button>
main.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4
5 #define BUF_N 512
6 #define PATH "../xiedu/"
7
8 static inline void
9 begin(void)
10 {
11 fprintf(stdout,"Content-type:text/html\n\n");
12 fprintf(stdout,"<html><title>亵渎</title>\n");
13 return;
14 }
15 static inline void
16 end(void)
17 {
18 fprintf(stdout,"</html>");
19 return;
20 }
21 static void
22 content(const char * const path)
23 {
24 FILE * fp = fopen(path,"rb");
25 char * buf = NULL;
26 if( NULL == fp ){
27 fprintf(stdout,"%d:打开错误</br>\n",__LINE__);
39 free(buf);
40 fclose(fp);
41 return;
42 }
43 int
44 main(int argc,char **argv)
45 {
46 int i,n=0;
47 begin();
48 /* method = get */
49 if( getenv("QUERY_STRING" ) ){
50 char *t=NULL;
51 if( NULL == (t=(char *)malloc(sizeof(char)*BUF_N)) ){
52 end();
53 exit(-1);
54 }
55 sprintf(t,"%s",PATH);
56 strcat(t,strstr((char *)getenv("QUERY_STRING"),"=")+1);
57 /*
58 fprintf(stdout,"打开文件:%s</br>\n",t);
59 */
60 content(t);
61 free(t);
62 }
63 end();
64 return 0;
65 }
作者: 洗脚 发布时间: 2007-01-04
这个比较奇
作者: leehui1983 发布时间: 2007-01-04
好原始的处理方法,:L
作者: cator 发布时间: 2007-01-04
:$ php还没用顺手
作者: 洗脚 发布时间: 2007-01-04
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28