📄 test_post.c
字号:
#include <stdio.h>#include <stdlib.h>#define MAX_ARG 150#define MAX_CONTENT 1024int main(){ int content_length = atoi(getenv("CONTENT_LENGTH")); char content[MAX_CONTENT]; fgets(content, content_length + 1, stdin); char para1[MAX_ARG], para2[MAX_ARG]; char value1[MAX_ARG], value2[MAX_ARG]; /* parse '&' */ char *p = strchr(content, '&'); *p = '\0'; strcpy(para1, content); strcpy(para2, p + 1); /* parse the first '=' */ p = strchr(para1, '='); *p = '\0'; strcpy(value1, p + 1); /* parse the second '=' */ p = strchr(para2, '='); *p = '\0'; strcpy(value2, p + 1); printf("Content-type: text/html\n\n"); printf("<HTML><HEAD><TITLE>CGI TEST RESULT</TITLE></HEAD>\n"); printf("<BODY><H2>Get test string from POST</H2><PRE>\n"); printf("The first parameter is: %s\n<p>", para1); printf("The first value is: %s\n<p>", value1); printf("The second parameter is: %s\n<p>", para2); printf("The second value is: %s\n<p>", value2); printf("</PRE></BODY></HTML>\n"); fflush(stdout); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -