diff options
Diffstat (limited to 'src/clog.c')
-rw-r--r-- | src/clog.c | 51 |
1 files changed, 17 insertions, 34 deletions
@@ -86,8 +86,7 @@ int sql_render_posts(struct kore_pgsql *sql, struct post_query *pq); static void process_md_output(const MD_CHAR *, MD_SIZE size, void *); static int render_md(const char *, struct kore_buf *); -void -post_query_init(struct post_query *pq, enum content_type type, const char *id) { +void post_query_init(struct post_query *pq, enum content_type type, const char *id) { if (id != NULL) pq->id = kore_strdup(id); else @@ -99,8 +98,7 @@ post_query_init(struct post_query *pq, enum content_type type, const char *id) { pq->result = kore_buf_alloc(0); } -void -post_query_cleanup(struct post_query *pq) { +void post_query_cleanup(struct post_query *pq) { if (pq->id != NULL) kore_free((void *) pq->id); pq->id = NULL; @@ -110,8 +108,7 @@ post_query_cleanup(struct post_query *pq) { pq->result = NULL; } -int -validate_uuid(const char *uuid) { +int validate_uuid(const char *uuid) { int i = 0; if (strlen(uuid) != 36) @@ -135,8 +132,7 @@ validate_uuid(const char *uuid) { return KORE_RESULT_OK; } -enum content_type -get_content_type(struct http_request *req) { +enum content_type get_content_type(struct http_request *req) { int err = 0; const char *accept = NULL; @@ -151,8 +147,7 @@ get_content_type(struct http_request *req) { return HTML; } -int -http_ok_resp( +int http_ok_resp( struct http_request *req, enum content_type type, enum http_status_code status, @@ -191,8 +186,7 @@ http_ok_resp( return KORE_RESULT_OK; } -int -http_err_resp( +int http_err_resp( struct http_request *req, enum content_type type, enum http_status_code status @@ -229,17 +223,14 @@ http_err_resp( return KORE_RESULT_OK; } - -int -redirect(struct http_request *req) { +int redirect(struct http_request *req) { http_response_header(req, "Location", "/"); http_response(req, HTTP_STATUS_MOVED_PERMANENTLY, NULL, 0); return KORE_RESULT_OK; } -int -get_posts(struct http_request *req) { +int get_posts(struct http_request *req) { struct post_query pq; post_query_init(&pq, get_content_type(req), NULL); @@ -255,8 +246,7 @@ get_posts(struct http_request *req) { return KORE_RESULT_OK; } -int -get_posts_resource(struct http_request *req) { +int get_posts_resource(struct http_request *req) { int err = 0; struct post_query pq; @@ -287,8 +277,7 @@ out: ; return KORE_RESULT_OK; } -int -post_posts(struct http_request *req) { +int post_posts(struct http_request *req) { int err = 0; int status = HTTP_STATUS_CREATED; @@ -364,8 +353,7 @@ out: ; return KORE_RESULT_OK; } -int -sql_select_posts(struct post_query *pq) { +int sql_select_posts(struct post_query *pq) { int err = KORE_RESULT_OK; struct kore_pgsql sql; @@ -427,8 +415,7 @@ out: ; return err; } -int -delete_posts_resource(struct http_request *req) { +int delete_posts_resource(struct http_request *req) { int err = 0; enum content_type type = get_content_type(req); @@ -508,6 +495,7 @@ int sql_render_posts(struct kore_pgsql *sql, struct post_query *pq) { kore_buf_appendf( pq->result, (const char *) asset_post_html, + id, title, created_at, kore_buf_stringify(html_buf, NULL) @@ -520,8 +508,7 @@ int sql_render_posts(struct kore_pgsql *sql, struct post_query *pq) { return KORE_RESULT_OK; } -int -sql_insert_posts(const char *id, const char *title, const char *body) { +int sql_insert_posts(const char *id, const char *title, const char *body) { int err = KORE_RESULT_OK; struct kore_pgsql sql; @@ -554,8 +541,7 @@ out: ; return err; } -int -sql_delete_posts(const char *id) { +int sql_delete_posts(const char *id) { int err = KORE_RESULT_OK; struct kore_pgsql sql; @@ -586,8 +572,7 @@ out: ; return err; } -static int -render_md(const char *in, struct kore_buf *out) { +static int render_md(const char *in, struct kore_buf *out) { // Not a kore err. int err = 0; @@ -611,12 +596,10 @@ render_md(const char *in, struct kore_buf *out) { return KORE_RESULT_OK; } -static void -process_md_output(const MD_CHAR *html, MD_SIZE size, void *buf) { +static void process_md_output(const MD_CHAR *html, MD_SIZE size, void *buf) { kore_buf_append( (struct kore_buf *) buf, (const void *) html, (size_t) size ); } - |