日期:2014-05-16 浏览次数:20662 次
sprintf(buf, "HTTP/1.0 200 ok\r\n");
rio_writen(fd, buf, strlen(buf));
sprintf(buf, "Server:Tiny web server\r\n");
rio_writen(fd, buf, strlen(buf));
sprintf(buf, "cgiargs:%s\r\n",cgiargs);
rio_writen(fd, buf, strlen(buf));
if(fork() == 0)
{
//set cgi vars here
setenv("QUERY_STRING", cgiargs, 1);
dup2(fd, STDOUT_FILENO);
execve(filename, NULL, NULL);
}
wait(NULL)
char *buf, *p;
char arg1[10], arg2[10];
char content[MAXLINE];
int n1 = 0, n2 = 0;
int flag = 0;
if((buf = getenv("QUERY_STRING")) != NULL)
{
p = strchr(buf, '&');
*p = '\0';
strcpy(arg1, buf);
strcpy(arg2, p+1);
n1 = atoi(arg1);
n2 = atoi(arg2);
flag = 1;
}