From b1b96ba3e9df3c1c6c3e3ec25eb57dd786561b33 Mon Sep 17 00:00:00 2001 From: mallocnull Date: Mon, 16 Oct 2017 22:00:19 +0000 Subject: [PATCH] extremely private squids looking is deathing --- protocol | 30 ++++++++++++++++++++++++++++++ src/client/screen.h | 4 ++-- src/client/ui.c | 2 +- src/client/ui.h | 4 ++-- src/server/context.c | 25 +++++++++++++++++++++++++ src/server/context.h | 11 +++++++++++ src/server/server.c | 4 +--- 7 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 protocol create mode 100644 src/server/context.c create mode 100644 src/server/context.h diff --git a/protocol b/protocol new file mode 100644 index 0000000..8d60279 --- /dev/null +++ b/protocol @@ -0,0 +1,30 @@ +PROTOCOL + +this is almost a carbon copy of every other tcp/ip protocol i write +don't care enough to make it fancy + +packed values are msb + +byte n is b.sub n + +--- + +byte the zero: packet id +byte the one: region count +for 0 <= n < b.sub 1 + byte the byte after the last byte byte: + region length < 128: one byte + region length >= 128: two bytes, highest bit on msb always 1 + +byte the bytes after the header octet bytes: + raw body data shoved next to each other with no separation + +--- + +server -> client + + +--- + +client -> server + \ No newline at end of file diff --git a/src/client/screen.h b/src/client/screen.h index 8d2aacf..c79a2fc 100644 --- a/src/client/screen.h +++ b/src/client/screen.h @@ -1,5 +1,5 @@ -#ifndef SCREEN_H -#define SCREEN_H +#ifndef CLIENT_SCREEN_H +#define CLIENT_SCREEN_H #include #include diff --git a/src/client/ui.c b/src/client/ui.c index 287a7d8..5ba296b 100644 --- a/src/client/ui.c +++ b/src/client/ui.c @@ -4,7 +4,7 @@ struct { WINDOW *main_win; WINDOW *chat_win; WINDOW *info_win; -} ui_ctx; +} ctx; static void ui_draw_borders(); diff --git a/src/client/ui.h b/src/client/ui.h index 94cbada..99010f3 100644 --- a/src/client/ui.h +++ b/src/client/ui.h @@ -1,5 +1,5 @@ -#ifndef UI_H -#define UI_H +#ifndef CLIENT_UI_H +#define CLIENT_UI_H #include #include diff --git a/src/server/context.c b/src/server/context.c new file mode 100644 index 0000000..71d5929 --- /dev/null +++ b/src/server/context.c @@ -0,0 +1,25 @@ +#include "context.h" + +struct { + BOOL running; + pthread_t *thread; +} ctx; + +void server_context() { + while(ctx.running == TRUE) { + + } +} + +void server_context_start() { + if(ctx.running == TRUE) + return; + + pthread_create(ctx.thread, NULL, server_context, NULL); + ctx.running = TRUE; +} + +void server_context_stop() { + ctx.running = FALSE; + +} \ No newline at end of file diff --git a/src/server/context.h b/src/server/context.h new file mode 100644 index 0000000..8939abb --- /dev/null +++ b/src/server/context.h @@ -0,0 +1,11 @@ +#ifndef SERVER_CONTEXT_H +#define SERVER_CONTEXT_H + +#include +#include +#include "common.h" + +void server_context_start(); +void server_context_stop(); + +#endif \ No newline at end of file diff --git a/src/server/server.c b/src/server/server.c index c1364ec..a779e61 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -6,7 +6,7 @@ void server() { sock_set_timeout_us(sock, 0, 100); - + printf("awaiting connection...\r\n"); socket_t *conn = sock_accept(sock); @@ -21,5 +21,3 @@ void server() { sock_stop(sock); sock_free(sock); } - -