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

This commit is contained in:
Jef Roosens 2023-11-27 19:54:53 +01:00
parent 4c2b85d436
commit e04f6e170e
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 87 additions and 6 deletions

View file

@ -1,19 +1,26 @@
#ifndef LNM_HTTP_LOOP
#define LNM_HTTP_LOOP
#include "lnm/common.h"
#include <stdlib.h>
#define LNM_HTTP_MAX_REQ_HEADERS 32
#include "lnm/common.h"
#include "lnm/http/req.h"
typedef struct lnm_loop lnm_http_loop;
typedef struct lnm_conn lnm_http_conn;
typedef struct lnm_loop_conn lnm_http_conn;
typedef struct lnm_http_step lnm_http_step;
typedef struct lnm_http_route lnm_http_route;
typedef lnm_err (*lnm_http_step_fn)(lnm_http_conn *conn);
typedef enum lnm_step_err {
lnm_step_err_done = 0,
lnm_step_err_io_needed,
lnm_step_err_close,
} lnm_step_err;
typedef lnm_step_err (*lnm_http_step_fn)(lnm_http_conn *conn);
/**
* Initialize a new `lnm_http_loop`.
@ -66,10 +73,23 @@ void lnm_http_loop_route_add(lnm_http_loop *hl, lnm_http_route *route);
*/
typedef enum lnm_http_loop_state {
lnm_http_loop_state_parse_req = 0,
lnm_http_loop_state_route,
lnm_http_loop_state_steps,
} lnm_http_loop_state;
typedef struct lnm_http_loop_gctx {
struct {
lnm_http_route **arr;
size_t len;
} routes;
void *c;
} lnm_http_loop_gctx;
typedef struct lnm_http_loop_ctx {
lnm_http_loop_state state;
lnm_http_req req;
lnm_http_loop_gctx *g;
void *c;
} lnm_http_loop_ctx;
#endif

View file

@ -6,7 +6,8 @@
#include "picohttpparser.h"
#include "lnm/http/consts.h"
#include "lnm/http/loop.h"
#define LNM_HTTP_MAX_REQ_HEADERS 32
/**
* Represents the parsed HTTP request

View file

@ -15,7 +15,7 @@ typedef enum {
lnm_loop_state_end,
} lnm_loop_state;
typedef struct {
typedef struct lnm_loop_conn {
int fd;
lnm_loop_state state;
void *ctx;