feat(lnm): start of event loop
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Jef Roosens 2023-11-21 22:39:59 +01:00
parent 20b6b593eb
commit 8a3be2b07c
Signed by: Jef Roosens
GPG key ID: 02D4C0997E74717B
4 changed files with 147 additions and 1 deletions

View file

@ -20,6 +20,8 @@
typedef enum {
lnm_err_ok = 0,
lnm_err_failed_alloc,
lnm_err_failed_network,
lnm_err_failed_poll,
} lnm_err;
#endif

View file

@ -1,11 +1,13 @@
#ifndef LNM_LOOP
#define LNM_LOOP
#include <stdint.h>
#include <stdlib.h>
#include "lnm/common.h"
#define LNM_LOOP_BUF_SIZE 4096
#define LNM_LOOP_INITIAL_CONNS 16
typedef enum {
lnm_loop_state_req = 0,
@ -33,10 +35,17 @@ typedef struct {
struct {
lnm_loop_conn **arr;
size_t len;
size_t open;
} conns;
void *gctx;
lnm_err (*ctx_init)(void **out, void *gctx);
void (*ctx_free)(void *ctx);
} lnm_loop;
lnm_err lnm_loop_init(lnm_loop **out, void *gctx,
lnm_err (*ctx_init)(void **out, void *gctx),
void (*ctx_free)(void *ctx));
lnm_err lnm_loop_run(lnm_loop *l, uint16_t port);
#endif