diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-04-05 17:53:27 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-04-07 00:03:28 +0200 |
commit | ebabaa69c0a3ba992895c7a66729e81e0923d5f1 (patch) | |
tree | 39b4a5b90a4f51c98486e8a00898e983b8878a12 /src/server.c |
Initial commit.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/server.c')
-rw-r--r-- | src/server.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/server.c b/src/server.c new file mode 100644 index 0000000..61664c5 --- /dev/null +++ b/src/server.c @@ -0,0 +1,38 @@ +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "server.h" + + +server_ctx * +server_init_ctx(server_ctx *ctx, init_cb init_fn) +{ + if (!ctx) + ctx = (server_ctx *) malloc(sizeof(*ctx)); + assert(ctx); + + memset(ctx, 0, sizeof(*ctx)); + if (!init_fn(ctx)) + return NULL; + + return ctx; +} + +int server_validate_ctx(server_ctx *ctx) +{ + assert(ctx); + assert(ctx->server_cbs.on_connect && ctx->server_cbs.on_disconnect + && ctx->server_cbs.mainloop); + assert(ctx->server_cbs.on_free && ctx->server_cbs.on_listen + && ctx->server_cbs.on_shutdown); + return 0; +} + +int server_mainloop(server_ctx *ctx) +{ + while (1) { + sleep(1); + } + return 0; +} |