From 064376146afad7af0b496014c59ba4b4f78d4c78 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Mon, 26 Aug 2024 12:41:30 -0500 Subject: sort networking code --- src/net/common.h | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/net/common.h (limited to 'src/net/common.h') diff --git a/src/net/common.h b/src/net/common.h new file mode 100644 index 0000000..04447f1 --- /dev/null +++ b/src/net/common.h @@ -0,0 +1,64 @@ +#ifndef __common_net_h +#define __common_net_h + +#include "lua5.4/lauxlib.h" +#include "lua5.4/lua.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../net.h" +#include "../lua.h" +#include "../io.h" +#include "../table.h" +#include "../types/str.h" +#include "../types/parray.h" + +#define max_con 200 +//2^42 +#define BUFFER_SIZE 20000 +#define HTTP_BUFFER_SIZE 4098 +#define max_content_length 200000 + +static int ports[65535] = { 0 }; +static parray_t* paths = NULL; + +enum file_status { + _ignore, BARRIER_READ, FILE_HEADER, FILE_BODY, NORMAL +}; + +struct file_parse { + enum file_status status; + str *current, *old, *boundary, *boundary_id; + int dash_count, table_idx; +}; + +typedef struct { + int fd; + int port; + lua_State* L; + struct sockaddr_in cli; +} thread_arg_struct; + +struct lchar { + char* c; + int len; + char req[20]; +}; + +struct sarray_t { + struct lchar** cs; + int len; +}; + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t con_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t lua_mutex = PTHREAD_MUTEX_INITIALIZER; + +#endif -- cgit v1.2.3