lander/include/lander.h

92 lines
2.4 KiB
C
Raw Permalink Normal View History

#ifndef LANDER
#define LANDER
#include "lnm/common.h"
#include "lnm/http/loop.h"
#include "lsm/store.h"
2023-11-12 14:48:55 +01:00
extern const char lander_key_charset[];
typedef struct lander_gctx {
const char *data_dir;
lsm_store *store;
} lander_gctx;
typedef struct lander_ctx {
union {
lsm_write_handle *write;
lsm_read_handle *read;
} entry;
bool write;
} lander_ctx;
typedef enum lander_attr_type : uint8_t {
lander_attr_type_entry_type = 0,
lander_attr_type_content_type = 1,
lander_attr_type_url = 2,
lander_attr_type_file_name = 3,
} lander_attr_type;
typedef enum lander_entry_type : uint8_t {
lander_entry_type_redirect = 0,
lander_entry_type_paste = 1,
lander_entry_type_file = 2,
lander_entry_type_placeholder = 3,
} lander_entry_type;
void *lander_gctx_init();
lnm_err lander_ctx_init(void **c_ctx, void *gctx);
void lander_ctx_reset(lander_ctx *ctx);
void lander_ctx_free(lander_ctx *ctx);
lnm_http_step_err lander_get_index(lnm_http_conn *conn);
lnm_http_step_err lander_get_entry(lnm_http_conn *conn);
lnm_http_step_err lander_post_redirect(lnm_http_conn *conn);
lnm_http_step_err lander_post_redirect_secure(lnm_http_conn *conn);
lnm_http_step_err lander_post_paste(lnm_http_conn *conn);
2023-05-30 10:17:46 +02:00
lnm_http_step_err lander_post_paste_secure(lnm_http_conn *conn);
lnm_http_step_err lander_stream_body_to_entry(lnm_http_conn *conn);
lnm_http_step_err lander_commit_entry(lnm_http_conn *conn);
lnm_http_step_err lander_post_redirect_body_to_attr(lnm_http_conn *conn);
lnm_http_step_err lander_remove_entry(lnm_http_conn *conn);
2023-11-12 13:43:21 +01:00
lnm_http_step_err lander_post_file(lnm_http_conn *conn);
lnm_http_step_err lander_post_file_secure(lnm_http_conn *conn);
lnm_http_step_err lander_post_placeholder(lnm_http_conn *conn);
lnm_http_step_err lander_post_placeholder_secure(lnm_http_conn *conn);
/**
* Step that authenticates requests. If the key of the request is for a
* placeholder entry, authentication is granted without an api key.
*/
lnm_http_step_err lander_auth_or_placeholder(lnm_http_conn *conn);
/**
* Store the requested header as an attribute, if it's present.
*/
void lander_header_to_attr(lnm_http_loop_ctx *ctx, const char *header,
lander_attr_type attr_type);
/**
* Store the attribute's value as the provided header, if present.
*/
void lander_attr_to_header(lnm_http_loop_ctx *ctx, lander_attr_type attr_type,
lnm_http_header header_type);
#endif