From 6f7953269ba9d5e49051492aeda5ea76d69a2b99 Mon Sep 17 00:00:00 2001 From: De Rais Date: Sat, 16 May 2020 01:37:59 -0400 Subject: [PATCH] misc: bump copyright years And for lack of any real changes, re-format everything. --- locks.c | 20 +++++++++++------ multipart.c | 17 +++++++++------ preconditions.c | 19 ++++++++++------ rb79-ban-ip.c | 8 ++++--- rb79-delete-post.c | 8 ++++--- rb79-moderate-post.c | 8 ++++--- rb79-server.c | 47 +++++++++++++++++++++++++--------------- rb79-update-recent-page.c | 8 ++++--- rb79-view-thread.c | 18 +++++++++------- sanitize-comment.c | 55 +++++++++++++++++++++++++++-------------------- sanitize-file.c | 31 +++++++++++++++----------- tripcodes.c | 16 ++++++++------ util.c | 17 +++++++++------ write-thread.c | 42 +++++++++++++++++++++--------------- 14 files changed, 190 insertions(+), 124 deletions(-) diff --git a/locks.c b/locks.c index 1199754..439541d 100644 --- a/locks.c +++ b/locks.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -42,7 +42,8 @@ static int lock_recent; * * - Any other function in this file may be safely called. */ -int setup_locks(const struct configuration *conf) +int +setup_locks(const struct configuration *conf) { int ret = -1; char *path = 0; @@ -138,7 +139,8 @@ done: * * - The lock for board_idx is now held by this program. */ -int lock_acquire(size_t board_idx) +int +lock_acquire(size_t board_idx) { int ret = -1; @@ -171,7 +173,8 @@ done: * * - The lock for the recent page is now held by this program. */ -int lock_acquire_recent(void) +int +lock_acquire_recent(void) { int ret = -1; @@ -205,7 +208,8 @@ done: * * - The lock for board_idx is now not held by this program. */ -int lock_release(size_t board_idx) +int +lock_release(size_t board_idx) { if (!lock_table || lock_table[board_idx] < 0) { @@ -233,7 +237,8 @@ int lock_release(size_t board_idx) * * - The lock for the recent page is now not held by this program. */ -int lock_release_recent(void) +int +lock_release_recent(void) { if (lock_recent < 0) { return 0; @@ -258,7 +263,8 @@ int lock_release_recent(void) * * - setup_locks() can be safely called again. */ -int clean_locks(void) +int +clean_locks(void) { if (!lock_table) { return 0; diff --git a/multipart.c b/multipart.c index 10990d4..7186480 100644 --- a/multipart.c +++ b/multipart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -33,7 +33,8 @@ struct gmime_cb_data { }; /* Initialize GMime */ -int setup_multipart(void) +int +setup_multipart(void) { g_mime_init(0); @@ -41,8 +42,8 @@ int setup_multipart(void) } /* Callback to add things - get stuff out of mime so we can strcmp() it */ -static void record_argument(GMimeObject *parent, GMimeObject *part, gpointer - user_data) +static void +record_argument(GMimeObject *parent, GMimeObject *part, gpointer user_data) { UNUSED(parent); struct gmime_cb_data *d = (struct gmime_cb_data *) user_data; @@ -174,8 +175,9 @@ static void record_argument(GMimeObject *parent, GMimeObject *part, gpointer * This is segmented off because, one day, I want to go full NIH. * No pre/postconditions until then. */ -int multipart_decompose(const char *full_data, size_t full_data_len, struct - post_cmd *post_cmd) +int +multipart_decompose(const char *full_data, size_t full_data_len, struct + post_cmd *post_cmd) { GMimeStream *s = 0; GMimeParser *p = 0; @@ -229,7 +231,8 @@ done: } /* Tear down GMime */ -int clean_multipart(void) +int +clean_multipart(void) { g_mime_shutdown(); diff --git a/preconditions.c b/preconditions.c index fbd1779..1ed0ec8 100644 --- a/preconditions.c +++ b/preconditions.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -29,7 +29,8 @@ #include "rb79.h" /* Try and acquire all lock files, in order */ -static int try_get_all_lock_files(size_t num_boards) +static int +try_get_all_lock_files(size_t num_boards) { for (size_t j = 0; j < num_boards; ++j) { if (lock_acquire(j) < 0) { @@ -41,7 +42,8 @@ static int try_get_all_lock_files(size_t num_boards) } /* Try and release all lock files, in order */ -static int try_drop_all_lock_files(size_t num_boards) +static int +try_drop_all_lock_files(size_t num_boards) { for (size_t j = 0; j < num_boards; ++j) { lock_release(j); @@ -51,7 +53,8 @@ static int try_drop_all_lock_files(size_t num_boards) } /* Make sure we can write to the directory where all the www files will be */ -static int try_write_work_dir(const char *work_dir) +static int +try_write_work_dir(const char *work_dir) { int ret = -1; @@ -71,8 +74,9 @@ done: } /* Make sure we can write to the directory where all the www files will be */ -static int try_write_www_dir(const struct board *boards, size_t boards_num, - const char *static_www_folder) +static int +try_write_www_dir(const struct board *boards, size_t boards_num, const + char *static_www_folder) { int ret = -1; size_t len = 0; @@ -272,7 +276,8 @@ done: * - The ZZZ_setup() functions in other files have all been called, * and all returned successfully. */ -int preconditions_check(const struct configuration *conf) +int +preconditions_check(const struct configuration *conf) { int ret = -1; size_t j = 0; diff --git a/rb79-ban-ip.c b/rb79-ban-ip.c index cdbba7f..3e97023 100644 --- a/rb79-ban-ip.c +++ b/rb79-ban-ip.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -33,7 +33,8 @@ const char *program_name = "rb79-ban-ip"; /* Show usage message, do not exit */ -void usage(void) +void +usage(void) { size_t len = strlen(program_name); @@ -48,7 +49,8 @@ void usage(void) } /* Do the thing */ -int main(int argc, char **argv) +int +main(int argc, char **argv) { int ret = EINVAL; struct configuration conf = { 0 }; diff --git a/rb79-delete-post.c b/rb79-delete-post.c index 0f9f5ea..d69f630 100644 --- a/rb79-delete-post.c +++ b/rb79-delete-post.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -32,7 +32,8 @@ const char *program_name = "rb79-delete-post"; /* Show usage message, do not exit */ -void usage(void) +void +usage(void) { size_t len = strlen(program_name); @@ -41,7 +42,8 @@ void usage(void) } /* Do the thing */ -int main(int argc, char **argv) +int +main(int argc, char **argv) { int ret = EINVAL; struct configuration conf = { 0 }; diff --git a/rb79-moderate-post.c b/rb79-moderate-post.c index 0c3e855..66f758c 100644 --- a/rb79-moderate-post.c +++ b/rb79-moderate-post.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -32,7 +32,8 @@ const char *program_name = "rb79-moderate-post"; /* Show usage message, do not exit */ -void usage(void) +void +usage(void) { size_t len = strlen(program_name); @@ -45,7 +46,8 @@ void usage(void) } /* Do the thing */ -int main(int argc, char **argv) +int +main(int argc, char **argv) { int ret = EINVAL; struct configuration conf = { 0 }; diff --git a/rb79-server.c b/rb79-server.c index ebef808..be6175f 100644 --- a/rb79-server.c +++ b/rb79-server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -35,7 +35,8 @@ const char *program_name = "rb79-server"; /* Print out a page saying the request was malformed (400) */ -static int report_bad_request(FCGX_Request *r, const char *reason) +static int +report_bad_request(FCGX_Request *r, const char *reason) { if (!reason) { reason = "That's not a real request. That's all we know."; @@ -47,7 +48,8 @@ static int report_bad_request(FCGX_Request *r, const char *reason) } /* Print out a page saying they failed the CAPTCHA (403) */ -static int report_bad_challenge(FCGX_Request *r) +static int +report_bad_challenge(FCGX_Request *r) { FCGX_FPrintF(r->out, BAD_CHALLENGE_FMT); @@ -55,7 +57,8 @@ static int report_bad_challenge(FCGX_Request *r) } /* Print out a BANNED page (403) */ -static int report_ban(FCGX_Request *r, char *ban_until, char *ban_reason) +static int +report_ban(FCGX_Request *r, char *ban_until, char *ban_reason) { FCGX_FPrintF(r->out, BAN_FMT, UBSAFES(ban_until), UBSAFES(ban_reason)); @@ -63,7 +66,8 @@ static int report_ban(FCGX_Request *r, char *ban_until, char *ban_reason) } /* Print out a BAD METHOD page (405) */ -static int report_bad_method(FCGX_Request *r) +static int +report_bad_method(FCGX_Request *r) { FCGX_FPrintF(r->out, BAD_METHOD_FMT); @@ -71,7 +75,8 @@ static int report_bad_method(FCGX_Request *r) } /* Print out a FILE TOO LARGE page (413) */ -static int report_too_large(FCGX_Request *r, const char *large_thing) +static int +report_too_large(FCGX_Request *r, const char *large_thing) { FCGX_FPrintF(r->out, TOO_LARGE_FMT, UBSAFES(large_thing)); @@ -79,7 +84,8 @@ static int report_too_large(FCGX_Request *r, const char *large_thing) } /* Print out a page saying they're posting too fast (429) */ -static int report_cooldown(FCGX_Request *r, char *cooldown_length) +static int +report_cooldown(FCGX_Request *r, char *cooldown_length) { FCGX_FPrintF(r->out, COOLDOWN_FMT, UBSAFES(cooldown_length)); @@ -87,7 +93,8 @@ static int report_cooldown(FCGX_Request *r, char *cooldown_length) } /* Print out an INTERNAL ERROR page (500) */ -static int report_internal_error(FCGX_Request *r) +static int +report_internal_error(FCGX_Request *r) { FCGX_FPrintF(r->out, INTERNAL_ERROR_FMT); @@ -95,7 +102,8 @@ static int report_internal_error(FCGX_Request *r) } /* Print out a POST SUCCESSFUL page (200) */ -static int report_post_successful(FCGX_Request *r, const char *buf) +static int +report_post_successful(FCGX_Request *r, const char *buf) { FCGX_FPrintF(r->out, POST_SUCCESSFUL_FMT, buf); @@ -103,7 +111,8 @@ static int report_post_successful(FCGX_Request *r, const char *buf) } /* Make sure every board has a page (really only for brand-new boards) */ -static int board_pages_init(struct configuration *conf) +static int +board_pages_init(struct configuration *conf) { int ret = -1; uintmax_t *thread_ids = 0; @@ -139,7 +148,8 @@ done: } /* Free what needs to be freed */ -static void clean_post_cmd(struct post_cmd *p) +static void +clean_post_cmd(struct post_cmd *p) { if (!p) { return; @@ -174,9 +184,9 @@ static void clean_post_cmd(struct post_cmd *p) } /* The bulk of work for processing a post */ -static void handle_op_or_reply(struct configuration *conf, FCGX_Request *r, - struct post_cmd *pc, const char *ip, size_t - parent_thread) +static void +handle_op_or_reply(struct configuration *conf, FCGX_Request *r, struct + post_cmd *pc, const char *ip, size_t parent_thread) { char *buf = 0; char *abs_file_path = 0; @@ -417,7 +427,8 @@ done: } /* Rebuild every thread and every board */ -static void handle_rebuild (struct configuration *conf, FCGX_Request *r) +static void +handle_rebuild (struct configuration *conf, FCGX_Request *r) { uint_fast8_t had_errors = util_rebuild(conf); @@ -429,7 +440,8 @@ static void handle_rebuild (struct configuration *conf, FCGX_Request *r) } /* Figure out what they want us to do */ -static void handle(struct configuration *conf, FCGX_Request *r) +static void +handle(struct configuration *conf, FCGX_Request *r) { char *p = 0; char *content_type = 0; @@ -718,7 +730,8 @@ done: } /* Do the thing */ -int main(void) +int +main(void) { int ret = 1; FCGX_Request r = { 0 }; diff --git a/rb79-update-recent-page.c b/rb79-update-recent-page.c index 8cc770f..4979189 100644 --- a/rb79-update-recent-page.c +++ b/rb79-update-recent-page.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -31,13 +31,15 @@ const char *program_name = "rb79-update-recent-page"; /* Show usage message, do not exit */ -void usage(void) +void +usage(void) { printf("Usage: %s\n", program_name); } /* Do the thing */ -int main(void) +int +main(void) { int ret = EINVAL; struct configuration conf = { 0 }; diff --git a/rb79-view-thread.c b/rb79-view-thread.c index 113296f..efd9fc8 100644 --- a/rb79-view-thread.c +++ b/rb79-view-thread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -35,7 +35,8 @@ const char *program_name = "rb79-view-thread"; static uint_fast8_t use_color = 1; /* Show usage message, do not exit */ -void usage(void) +void +usage(void) { size_t len = strlen(program_name); @@ -45,11 +46,11 @@ void usage(void) } /* Print out enough of a post to give the mod information */ -int print_post(struct prepared_post *p, FILE *f, uint_fast8_t is_op, - uint_fast8_t is_summary, uint_fast8_t is_recent, const - char *board_name, - uintmax_t in_thread, uintmax_t total_posts_in_thread, - uint_fast8_t hr_before) +int +print_post(struct prepared_post *p, FILE *f, uint_fast8_t is_op, uint_fast8_t + is_summary, uint_fast8_t is_recent, const char *board_name, uintmax_t + in_thread, + uintmax_t total_posts_in_thread, uint_fast8_t hr_before) { char *time_str = util_iso8601_from_time_t(p->now); unsigned char out_hash[9] = { 0 }; @@ -111,7 +112,8 @@ done: } /* Do the thing */ -int main(int argc, char **argv) +int +main(int argc, char **argv) { int ret = EINVAL; struct configuration conf = { 0 }; diff --git a/sanitize-comment.c b/sanitize-comment.c index 4bae692..6346a69 100644 --- a/sanitize-comment.c +++ b/sanitize-comment.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -73,7 +73,8 @@ static pcre2_code *format_replacements; * - Returns -1 (0) [1] if *key_v is less than (equal to) [greater * than] *tr_v's starting range. */ -static int match_translate(const void *key_v, const void *tr_v) +static int +match_translate(const void *key_v, const void *tr_v) { const wchar_t *key = key_v; const struct translate *tr = tr_v; @@ -105,8 +106,8 @@ static int match_translate(const void *key_v, const void *tr_v) * - The contents of str have been appended to *buf (and *idx * includes this). */ -static int append_str(char **buf, size_t *idx, size_t *sz, const char *str, - size_t str_len) +static int +append_str(char **buf, size_t *idx, size_t *sz, const char *str, size_t str_len) { if (str_len + *idx >= *sz) { void *newmem = 0; @@ -138,8 +139,8 @@ static int append_str(char **buf, size_t *idx, size_t *sz, const char *str, } /* Dummy function for when I can't be bothered to strlen(). */ -static int append_const_str(char **buf, size_t *idx, size_t *len, const - char *str) +static int +append_const_str(char **buf, size_t *idx, size_t *len, const char *str) { return append_str(buf, idx, len, str, strlen(str)); } @@ -161,7 +162,8 @@ static int append_const_str(char **buf, size_t *idx, size_t *len, const * * - c has been appended to *buf (and *idx includes this). */ -static int append_char(char **buf, size_t *idx, size_t *len, char c) +static int +append_char(char **buf, size_t *idx, size_t *len, char c) { if (1 + *idx >= *len) { void *newmem = 0; @@ -209,7 +211,8 @@ static int append_char(char **buf, size_t *idx, size_t *len, char c) * - An HTML-escaped sequence like { has been appended to * *buf (and *idx includes this). */ -static int append_wchar_escaped(char **buf, size_t *idx, size_t *sz, wchar_t wc) +static int +append_wchar_escaped(char **buf, size_t *idx, size_t *sz, wchar_t wc) { size_t l = snprintf(0, 0, "&#%ld;", (long) wc); @@ -254,7 +257,8 @@ static int append_wchar_escaped(char **buf, size_t *idx, size_t *sz, wchar_t wc) * * - (*map)[j] = k. */ -static int set_position_mapping(size_t **map, size_t *len, size_t j, size_t k) +static int +set_position_mapping(size_t **map, size_t *len, size_t j, size_t k) { if (j + 1 >= *len) { void *newmem = 0; @@ -312,8 +316,9 @@ static int set_position_mapping(size_t **map, size_t *len, size_t j, size_t k) * * - If necessary, *out_len has been updated. */ -static int to_html(const char *in, const size_t in_len, size_t in_idx, - char **out, size_t *out_len, size_t *out_idx) +static int +to_html(const char *in, const size_t in_len, size_t in_idx, char **out, + size_t *out_len, size_t *out_idx) { int ret = -1; wchar_t wc = 0; @@ -413,9 +418,9 @@ done: * * - (*position_map)[*out_len] = in_len. */ -static int to_scannable(const char *in, size_t in_len, char **out, - size_t *out_len, size_t **out_position_map, - size_t *out_position_map_len) +static int +to_scannable(const char *in, size_t in_len, char **out, size_t *out_len, + size_t **out_position_map, size_t *out_position_map_len) { int ret = -1; wchar_t wc = 0; @@ -549,10 +554,10 @@ done: * - *out represents raw, except in those sections of scannable * where a wordfilter matched. */ -static int wordfilter_to_html(const char *raw, const size_t raw_len, const - char *scannable, const size_t scannable_len, - size_t *position_map, char **out, - size_t *out_len) +static int +wordfilter_to_html(const char *raw, const size_t raw_len, const char *scannable, + const size_t scannable_len, size_t *position_map, char **out, + size_t *out_len) { int ret = -1; @@ -769,8 +774,9 @@ done: * markup (and HTML escaped), suitable for outputting into an * HTML file. */ -static int insert_html_tags(const char *in, size_t in_len, const char *board, - char **out, size_t *out_len) +static int +insert_html_tags(const char *in, size_t in_len, const char *board, char **out, + size_t *out_len) { int ret = -1; size_t in_idx = 0; @@ -1035,7 +1041,8 @@ done: * - The prepared_XYZ fields of *pc have been filled out, and each * is valid ASCII text, with Unicode codepoints. */ -int st_sanitize_text(struct post_cmd *pc, int *our_fault) +int +st_sanitize_text(struct post_cmd *pc, int *our_fault) { int ret = -1; size_t out_idx = 0; @@ -1184,7 +1191,8 @@ done: * * - Any other function in this file may be safely called. */ -int setup_sanitize_comment(const struct configuration *conf) +int +setup_sanitize_comment(const struct configuration *conf) { /* * Check that the locale/libc/whatever is set up so that @@ -1303,7 +1311,8 @@ done: * * - setup_sanitize_comment() can be safely called again. */ -int clean_sanitize_comment(void) +int +clean_sanitize_comment(void) { for (size_t j = 0; j < wordfilters_num; ++j) { pcre2_code_free(wordfilters[j].code); diff --git a/sanitize-file.c b/sanitize-file.c index eb0f693..7aa9faa 100644 --- a/sanitize-file.c +++ b/sanitize-file.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -51,7 +51,8 @@ static size_t max_static_thumb_len; * * - Any other function in this file may be safely called. */ -int setup_sanitize_file(const struct configuration *in_conf) +int +setup_sanitize_file(const struct configuration *in_conf) { conf = in_conf; max_static_thumb_len = 1; @@ -115,8 +116,9 @@ int setup_sanitize_file(const struct configuration *in_conf) * MIME type corresponds to an entry in allowed_filetypes, * *out_filetype is that entry. If not, *out_filetype is 0. */ -int sf_check_mime_type(const char *buf, size_t len, const struct - filetype **out_filetype) +int +sf_check_mime_type(const char *buf, size_t len, const struct + filetype **out_filetype) { const char *mime = 0; @@ -177,8 +179,9 @@ int sf_check_mime_type(const char *buf, size_t len, const struct * - *out_description is a string of length *out_len, and is * suitable for inclusion directly into HTML. */ -int sf_describe_file(const char *mimetype, const char *filepath, - char **out_description, size_t *out_description_len) +int +sf_describe_file(const char *mimetype, const char *filepath, + char **out_description, size_t *out_description_len) { /* XXX: do we need to do any signal magic here? */ int ret = -1; @@ -304,12 +307,13 @@ done: * * - Otherwise, *out_thumb_path is a copy of filetype.static_thumbnail. */ -int sf_install_files(size_t board_idx, const char *buf, size_t len, time_t *now, - const struct filetype *filetype, char **out_abs_path, - char **out_path, - size_t *out_path_len, char **out_thumb_path, - size_t *out_thumb_path_len, - int *our_fault) +int +sf_install_files(size_t board_idx, const char *buf, size_t len, time_t *now, + const struct filetype *filetype, char **out_abs_path, + char **out_path, + size_t *out_path_len, char **out_thumb_path, + size_t *out_thumb_path_len, + int *our_fault) { int ret = -1; size_t abs_path_len = snprintf(0, 0, "%s/%s/src/%ju.%s", @@ -536,7 +540,8 @@ done: * * - setup_sanitize_file() can safely be called again. */ -int clean_sanitize_file(void) +int +clean_sanitize_file(void) { /* XXX: is this safe if errors in setup_sanitize_file()? */ magic_close(mime_cookie); diff --git a/tripcodes.c b/tripcodes.c index afc7724..73aa0ee 100644 --- a/tripcodes.c +++ b/tripcodes.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -47,7 +47,8 @@ static const char *base64_elts = * * - Any other function in this file may be safely called. */ -int setup_tripcodes(const struct configuration *in_conf) +int +setup_tripcodes(const struct configuration *in_conf) { conf = in_conf; @@ -74,8 +75,9 @@ int setup_tripcodes(const struct configuration *in_conf) * - The contents of *out are the base64 encoding of the first * in_len bytes of in. */ -static int base64_encode(const unsigned char *in, size_t in_len, char **out, - size_t *out_len) +static int +base64_encode(const unsigned char *in, size_t in_len, char **out, + size_t *out_len) { int ret = -1; size_t built_len = in_len * 4 / 3 + 3; @@ -138,7 +140,8 @@ done: * - If p->raw.name was of the form "foo#bar", p->raw.tripcode is * determined by the key "bar". p->raw.tripcode_len is appropriate. */ -int tripcodes_calculate(struct post_cmd *p) +int +tripcodes_calculate(struct post_cmd *p) { int ret = -1; char *trip_phrase_start = 0; @@ -213,7 +216,8 @@ done: * * - setup_tripcodes() can be safely called again. */ -int clean_tripcodes(void) +int +clean_tripcodes(void) { conf = 0; diff --git a/util.c b/util.c index 6254077..6d67bb8 100644 --- a/util.c +++ b/util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -21,10 +21,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include #include "macros.h" #include "rb79.h" @@ -48,7 +48,8 @@ * - Either a string in ISO 8601 format has been returned, or 0 * has been returned and an error message has been logged. */ -char * util_iso8601_from_time_t(time_t t) +char * +util_iso8601_from_time_t(time_t t) { /* * XXX: If this becomes multithreaded, we have bigger @@ -80,7 +81,8 @@ char * util_iso8601_from_time_t(time_t t) } /* Put an IP address into a range-comparable form */ -int util_normalize_ip(const char *in, char **out) +int +util_normalize_ip(const char *in, char **out) { int ret = -1; size_t built_len = 0; @@ -168,7 +170,8 @@ done: * Note: this ACQUIRES all locks, which means it must be called * with NO LOCKS acquired */ -int util_rebuild(struct configuration *conf) +int +util_rebuild(struct configuration *conf) { uint_fast8_t had_errors = 0; diff --git a/write-thread.c b/write-thread.c index bf103b8..150414b 100644 --- a/write-thread.c +++ b/write-thread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, De Rais + * Copyright (c) 2017-2020, De Rais * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -74,7 +74,8 @@ static pcre2_code *variables; * - *out contains the full contents of * ${static_www_folder}/_templates/${local_name}. */ -static int slurp_file(const char *local_name, char **out) +static int +slurp_file(const char *local_name, char **out) { int ret = -1; FILE *f = 0; @@ -126,7 +127,6 @@ static int slurp_file(const char *local_name, char **out) } (*out)[len] = 0; - ret = 0; done: @@ -154,7 +154,8 @@ done: * * - Any other function in this file may be safely called. */ -int setup_write_thread(const struct configuration *in_conf) +int +setup_write_thread(const struct configuration *in_conf) { conf = in_conf; @@ -164,6 +165,7 @@ int setup_write_thread(const struct configuration *in_conf) if (!board_page) { ERROR_MESSAGE("Could not read board page template"); + return -1; } @@ -222,8 +224,9 @@ int setup_write_thread(const struct configuration *in_conf) * * - Those files have been unlink()'d. */ -int wt_remove_files(const char *system_full_path, size_t system_full_path_len, - const char *system_thumb_path, size_t system_thumb_path_len) +int +wt_remove_files(const char *system_full_path, size_t system_full_path_len, const + char *system_thumb_path, size_t system_thumb_path_len) { int ret = -1; char *abs_full_path = 0; @@ -321,7 +324,8 @@ done: * - The folder for thread id (e.g. * ${static_www_folder}/m/res/${thread_id}) no longer exists. */ -int wt_remove_thread_page(size_t board_idx, uintmax_t thread_id) +int +wt_remove_thread_page(size_t board_idx, uintmax_t thread_id) { int ret = -1; char *index_path = 0; @@ -393,8 +397,9 @@ done: * has been written out, representing the current state of the * board thread, for n = 0 to however many there should be. */ -int wt_write_board(size_t board_idx, uintmax_t *thread_ids, size_t - thread_ids_num, size_t board_pages_num) +int +wt_write_board(size_t board_idx, uintmax_t *thread_ids, size_t thread_ids_num, + size_t board_pages_num) { int ret = -1; FILE *f = 0; @@ -665,11 +670,11 @@ done: * - the contents of p have been written to f, which returned no * errors. The format is not precisely defined. */ -int wt_write_post(struct prepared_post *p, FILE *f, uint_fast8_t is_op, - uint_fast8_t is_summary, uint_fast8_t is_recent, const - char *board_name, - uintmax_t in_thread, uintmax_t total_posts_in_thread, - uint_fast8_t hr_before) +int +wt_write_post(struct prepared_post *p, FILE *f, uint_fast8_t is_op, uint_fast8_t + is_summary, uint_fast8_t is_recent, const char *board_name, + uintmax_t in_thread, + uintmax_t total_posts_in_thread, uint_fast8_t hr_before) { int ret = -1; char *human_readable_time = util_iso8601_from_time_t(p->now); @@ -824,7 +829,8 @@ done: * - A file at ${static_www_folder}/recent/index.html has been * written out, representing the last few posts on the site. */ -int wt_write_recent_page(void) +int +wt_write_recent_page(void) { int ret = -1; size_t idx = 0; @@ -975,7 +981,8 @@ done: * has been written out, representing the recent state of the * thread. */ -int wt_write_thread(size_t board_idx, uintmax_t thread) +int +wt_write_thread(size_t board_idx, uintmax_t thread) { int ret = -1; size_t idx = 0; @@ -1154,7 +1161,8 @@ done: * * - setup_write_thread() can be safely called again. */ -void clean_write_thread(void) +void +clean_write_thread(void) { conf = 0; free(board_page); -- 2.11.4.GIT