/* 原创文章 转载请附上原链接: https://www.cnblogs.com/jiujue/p/10707153.html */
自己实现的如有缺漏欢迎提出
直接代码 一切皆在代码中
首先是 主函数文件 和 头文件
头文件:
1 #ifndef _HEAD_H_ 2 #define _HEAD_H_ 3 4 #include<stdio.h> 5 #include<string.h> 6 #include<stdlib.h> 7 #include<time.h> 8 #include<math.h> 9 #include <fcntl.h> 10 #include <ctype.h> 11 #include <dirent.h> 12 #include <unistd.h> 13 #include <event2/event.h> 14 #include <event2/listener.h> 15 #include <event2/bufferevent.h> 16 #include <sys/socket.h> 17 #include <sys/types.h> 18 #include <sys/stat.h> 19 #include <arpa/inet.h> 20 21 int judge_type_dir_or_nondir(const char* name); 22 int send_dir_asheml(struct bufferevent *bufev, char *dirname, void *arg); 23 struct evconnlistener* libev_start(struct event_base*base, const char* Ip,int Port); 24 int send_html_head(struct bufferevent* bufev, int stat_no, const char* stat_desc, char* type); 25 const char *get_file_type(const char *name); 26 int send_file(struct bufferevent *bufev,char* file); 27 28 #endif