summaryrefslogtreecommitdiff
path: root/cgi/hello.c
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-10 11:16:07 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2019-02-10 11:16:07 +0800
commit9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3 (patch)
tree339de0698c13e1763d3361d70fb1266621025c91 /cgi/hello.c
downloadweb-9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3.tar.xz
Initial commit.
Diffstat (limited to 'cgi/hello.c')
-rw-r--r--cgi/hello.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/cgi/hello.c b/cgi/hello.c
new file mode 100644
index 0000000..440cf11
--- /dev/null
+++ b/cgi/hello.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <stdlib.h>
+int main(int argc,char **argv,char** envp)
+{
+ puts("Content-type: text/html\r\n\r\n");
+ puts("<code>hello cgi...<br>\nEnvironment variables:<br>\n");
+ for(char** env=envp;*env;++env){printf("%s<br>\n",*env);}
+ if(getenv("CONTENT_LENGTH"))
+ {
+ int len=atoi(getenv("CONTENT_LENGTH"));
+ char* buf=malloc(len+1);
+ fread(buf,1,len,stdin);
+ buf[len]=0;
+ printf("stdin:<br>\n");
+ puts(buf);
+ }
+ puts("</code>");
+ return 0;
+}