server: implement -s bans
[rb-79.git] / rb79-update-recent-page.c
blob5d446a2d0b8e313c70c6051a086761b4bc62e324
1 /*
2 * Copyright (c) 2017-2020, De Rais <derais@cock.li>
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
18 #include <errno.h>
19 #include <locale.h>
20 #include <stdint.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <time.h>
26 #include "macros.h"
27 #include "rb79.h"
29 #include "config.h"
31 const char *program_name = "rb79-update-recent-page";
33 /* Show usage message, do not exit */
34 void
35 usage(void)
37 printf("Usage: %s\n", program_name);
40 /* Do the thing */
41 int
42 main(void)
44 int ret = EINVAL;
45 struct configuration conf = { 0 };
47 setlocale(LC_ALL, "");
48 srand(time(0));
49 conf = (struct configuration) {
50 /* */
51 .static_www_folder = static_www_folder, /* */
52 .work_path = work_path, /* */
53 .temp_dir_template = temp_dir_template, /* */
54 .trip_salt = trip_salt, /* */
55 .trip_salt_len = strlen(trip_salt), /* */
56 .boards = boards, /* */
57 .boards_num = NUM_OF(boards), /* */
58 .max_form_data_size = max_form_data_size, /* */
59 .max_file_size = max_file_size, /* */
60 .max_text_len = max_text_len, /* */
61 .filetypes = filetypes, /* */
62 .filetypes_num = NUM_OF(filetypes), /* */
63 .file_description_prog = file_description_prog, /* */
64 .headers = headers, /* */
65 .headers_num = NUM_OF(headers), /* */
66 .challenges = challenges, /* */
67 .challenges_num = NUM_OF(challenges), /* */
68 .wordfilter_inputs = wordfilter_inputs, /* */
69 .wordfilter_inputs_num = NUM_OF(wordfilter_inputs), /* */
70 .forbidden_inputs = forbidden_inputs, /* */
71 .forbidden_inputs_num = NUM_OF(forbidden_inputs), /* */
74 /* Set up a minimal part of the system */
75 if (setup_locks(&conf) < 0) {
76 goto done;
79 if (setup_dbs(&conf) < 0) {
80 goto done;
83 if (setup_write_thread(&conf) < 0) {
84 goto done;
87 if (lock_acquire_recent() < 0) {
88 goto done;
91 ret = wt_write_recent_page();
92 lock_release_recent();
93 done:
94 clean_locks();
95 clean_dbs();
96 clean_write_thread();
98 return ret;