/************************************************************************ ** 预编译宏说明 ** _WIN32: 在32位windows下 ** _UCOS: 在ucos2.52下 ** _ZLGIP: TCP/IP协议为zlg/ip ** _WINFS: windows下的文件系统 ** _NOFS: 无文件系统 *************************************************************************/ #ifndef SHRINK_H #define SHRINK_H #include #include #include #ifdef _WIN32 #include #include #include #include #include #pragma comment(lib,"ws2_32") #endif #ifdef _UCOS #include "..\lua\lua.h" #include "..\lua\lualib.h" #include "..\lua\lauxlib.h" #endif #ifdef _NOFS #include "staticpages.h" #endif #ifdef _ZLGIP #include "config.h" #include "../include/cfg_net.h" #endif #include "defines.h" #include "globals.h" //main server void* server(void * pr); void errstatus(struct request *pr, int status, const char *descr,const char *headers, const char *fmt, ...); void parse(struct request * pr,const char * buf); void parsehead(struct request * pr,char * buf); void clean(struct request * pr); void deal(struct request * pr); void deal_get(struct request * pr); void deal_post(struct request * pr); void deal_defaultpage(struct request * pr); int ncasecmp(const char *s1, const char *s2, size_t len); //cgi int iscgi(const char * path); void deal_cgi(struct request * pr); void setcgienv(struct request * pr, char * env); //file void deal_file(struct request * pr); int isfile(struct request * pr); //thread pool void TP_create(struct TP_threadpool *ptp, int minn,int maxn,int mini,int maxi); void TP_myworking(struct TP_threadpool *ptp, TP_Work_Fun fun, void * args); void TP_initlist(struct TP_nodelist * nodelist); void TP_listadd(struct TP_nodelist * pnodelist, struct TP_node * pnode); void TP_listdel(struct TP_nodelist * pnodelist, struct TP_node * pnode); //file system interface fshandle fs_open(const char* path,int flag,int method); int fs_read(fshandle handle, void *buffer, unsigned int count ); int fs_write(fshandle handle, const void *buffer, unsigned int count); int fs_close(fshandle handle); //communication interface void comm_open(struct comm * pcom); void comm_bind(struct comm * pcom, int port); void comm_accept(struct comm com,struct comm * pcom); int comm_read(struct comm com_r, char *buf, size_t len); int comm_write(struct comm com_r, const char *buf, size_t len); void comm_close(struct comm com); #ifdef _WIN32 DWORD WINAPI TP_working(void* args); #elif _UCOS void TP_working(void* pdata); #endif static int TP_getidlethread(struct TP_threadpool *ptp, struct TP_node **ppnode); static void TP_initnode(struct TP_node * node, struct TP_threadpool * ptp); #ifdef _UCOS int cginame2no(const char* name); void LEDCGI(void* pdata); void CPUStatCGI(void* pdata); void ADCCGI(void* pdata); void FilesCGI(void* pdata); void LuaParse(void* pdata); #endif //初始化ws void shrink_init(struct comm *pcom); //结束ws void shrink_finish(struct comm com); //设置port void shrink_setport(struct comm *pcom, int port); //轮询 void shrink_poll(struct comm com); #endif