summaryrefslogtreecommitdiff
path: root/cgi/hello.c
blob: 440cf118f081663db6b22e55e4d46fc684c5acd9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
}