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); } - -