level 4
dir005
楼主

protocol.c文件的头文件:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#if defined(_WIN32)
#else
#include <unistd.h>
#include <sys/file.h>
#endif
#include "config.h"
#include "httpd.h"
#include "httpd_priv.h"
protocol.c文件内的函数源码:
void _httpd_catFile(request *r, char *path)
{
intfd,
len;
charbuf[HTTP_MAX_LEN];
fd = open(path,O_RDONLY);
if (fd < 0)
return;
len = read(fd, buf, HTTP_MAX_LEN);
while(len > 0)
{
r->response.responseLength += len;
_httpd_net_write(r->clientSock, buf, len);
len = read(fd, buf, HTTP_MAX_LEN);
}
close(fd);
}
*********************************************************************