aboutsummaryrefslogtreecommitdiff
path: root/src/net/common.h
diff options
context:
space:
mode:
authoramelia squires <[email protected]>2024-08-26 12:41:30 -0500
committeramelia squires <[email protected]>2024-08-26 12:42:47 -0500
commit064376146afad7af0b496014c59ba4b4f78d4c78 (patch)
tree408852199d1e7cd5cfc628319671622ab8f51558 /src/net/common.h
parentb093eebff0f8c6dedc49c62747049fe7e464c8f3 (diff)
sort networking code
Diffstat (limited to 'src/net/common.h')
-rw-r--r--src/net/common.h64
1 files changed, 64 insertions, 0 deletions
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 <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#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