1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#ifdef _WIN32 //add -lws2_32
#include <winsock2.h>
//#define socklen_t __socklen_t
//#define close closesocket
typedef int socklen_t;
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#define closesocket close
#endif
#include "lua.h"
#include "types/str.h"
#include "types/parray.h"
#include <stdint.h>
int l_listen(lua_State*);
int64_t recv_full_buffer(int client_fd, char** _buffer, int* header_eof, int* state);
int parse_header(char* buffer, int header_eof, parray_t** _table);
void i_write_header(lua_State* L, int header_top, str** _resp, char* content, size_t len);
void client_fd_errors(int client_fd);
int content_disposition(str* src, parray_t** _dest);
//int rolling_file_parse(lua_State* L, int* files_idx, int* body_idx, char* buffer, str* content_type, size_t blen, struct file_parse* _content);
void* handle_client(void *_arg);
int start_serv(lua_State* L, int port);
//
static char* http_codes[600] = {0};
static const luaL_Reg net_function_list [] = {
{"listen",l_listen},
{NULL,NULL}
};
|