2023-05-29 19:46:05 +00:00
|
|
|
#ifndef LANDER
|
|
|
|
#define LANDER
|
|
|
|
|
2023-12-02 19:22:05 +00:00
|
|
|
#include "lnm/common.h"
|
|
|
|
#include "lnm/http/loop.h"
|
2023-11-03 13:10:14 +00:00
|
|
|
#include "lsm/store.h"
|
2023-05-29 19:46:05 +00:00
|
|
|
|
2023-11-12 13:48:55 +00:00
|
|
|
extern const char lander_key_charset[];
|
2023-05-29 21:26:15 +00:00
|
|
|
|
2023-10-30 20:14:06 +00:00
|
|
|
typedef struct lander_gctx {
|
|
|
|
const char *data_dir;
|
2023-11-03 13:10:14 +00:00
|
|
|
lsm_store *store;
|
2023-10-30 20:14:06 +00:00
|
|
|
} lander_gctx;
|
|
|
|
|
|
|
|
typedef struct lander_ctx {
|
2023-11-03 13:10:14 +00:00
|
|
|
lsm_entry_handle *entry;
|
2023-10-30 20:14:06 +00:00
|
|
|
} lander_ctx;
|
|
|
|
|
2023-11-08 12:42:46 +00:00
|
|
|
typedef enum lander_attr_type : uint8_t {
|
|
|
|
lander_attr_type_entry_type = 0,
|
|
|
|
lander_attr_type_content_type = 1,
|
|
|
|
lander_attr_type_url = 2,
|
2023-11-12 15:13:54 +00:00
|
|
|
lander_attr_type_file_name = 3,
|
2023-11-08 11:25:47 +00:00
|
|
|
} lander_attr_type;
|
|
|
|
|
2023-11-09 20:07:51 +00:00
|
|
|
typedef enum lander_entry_type : uint8_t {
|
2023-11-03 13:10:14 +00:00
|
|
|
lander_entry_type_redirect = 0,
|
|
|
|
lander_entry_type_paste = 1,
|
2023-11-12 12:57:11 +00:00
|
|
|
lander_entry_type_file = 2,
|
2023-11-03 13:10:14 +00:00
|
|
|
} lander_entry_type;
|
|
|
|
|
2023-10-30 20:14:06 +00:00
|
|
|
void *lander_gctx_init();
|
|
|
|
|
2023-12-02 19:22:05 +00:00
|
|
|
lnm_err lander_ctx_init(void **c_ctx, void *gctx);
|
2023-10-30 20:14:06 +00:00
|
|
|
|
|
|
|
void lander_ctx_reset(lander_ctx *ctx);
|
|
|
|
|
|
|
|
void lander_ctx_free(lander_ctx *ctx);
|
|
|
|
|
2023-12-02 19:22:05 +00:00
|
|
|
lnm_http_step_err lander_get_index(lnm_http_conn *conn);
|
2023-05-30 07:37:40 +00:00
|
|
|
|
2023-12-05 18:12:19 +00:00
|
|
|
lnm_http_step_err lander_get_entry(lnm_http_conn *conn);
|
2023-05-30 07:37:40 +00:00
|
|
|
|
2023-12-05 18:12:19 +00:00
|
|
|
lnm_http_step_err lander_post_redirect(lnm_http_conn *conn);
|
2023-05-29 19:46:05 +00:00
|
|
|
|
2023-12-05 18:36:54 +00:00
|
|
|
lnm_http_step_err lander_post_paste(lnm_http_conn *conn);
|
2023-05-30 08:17:46 +00:00
|
|
|
|
2023-12-05 18:36:54 +00:00
|
|
|
lnm_http_step_err lander_stream_body_to_entry(lnm_http_conn *conn);
|
2023-11-03 13:10:14 +00:00
|
|
|
|
2023-12-05 18:12:19 +00:00
|
|
|
lnm_http_step_err lander_post_redirect_body_to_attr(lnm_http_conn *conn);
|
2023-11-08 10:19:33 +00:00
|
|
|
|
2023-12-05 18:36:54 +00:00
|
|
|
lnm_http_step_err lander_remove_entry(lnm_http_conn *conn);
|
2023-11-12 12:43:21 +00:00
|
|
|
|
2023-12-05 18:36:54 +00:00
|
|
|
lnm_http_step_err lander_post_file(lnm_http_conn *conn);
|
2023-11-12 12:57:11 +00:00
|
|
|
|
2023-11-12 13:12:13 +00:00
|
|
|
/**
|
2023-11-12 15:13:54 +00:00
|
|
|
* Store the requested header as an attribute, if it's present.
|
2023-11-12 13:12:13 +00:00
|
|
|
*/
|
2023-12-05 18:36:54 +00:00
|
|
|
void lander_header_to_attr(lnm_http_loop_ctx *ctx, const char *header,
|
2023-11-12 15:13:54 +00:00
|
|
|
lander_attr_type attr_type);
|
2023-11-12 13:12:13 +00:00
|
|
|
|
2023-11-12 15:13:54 +00:00
|
|
|
/**
|
|
|
|
* Store the attribute's value as the provided header, if present.
|
|
|
|
*/
|
2023-12-05 18:12:19 +00:00
|
|
|
void lander_attr_to_header(lnm_http_loop_ctx *ctx, lander_attr_type attr_type,
|
|
|
|
lnm_http_header header_type);
|
2023-11-12 13:29:46 +00:00
|
|
|
|
2023-05-29 19:46:05 +00:00
|
|
|
#endif
|