From 9d3c8c0e6e1a7ba43bf3dc19350d1dca68b657a3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 10 Feb 2019 11:16:07 +0800 Subject: Initial commit. --- cgi/hello.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 cgi/hello.c (limited to 'cgi/hello.c') 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 +#include +int main(int argc,char **argv,char** envp) +{ + puts("Content-type: text/html\r\n\r\n"); + puts("hello cgi...
\nEnvironment variables:
\n"); + for(char** env=envp;*env;++env){printf("%s
\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:
\n"); + puts(buf); + } + puts("
"); + return 0; +} -- cgit v1.2.3