misc: correctly proceed to thread-deletion in rb79-delete-post
[rb-79.git] / rb79-update-recent-page.c
blob8cc770f465b04507163a9b75ad7c849934a4e3bf
1 /*
2 * Copyright (c) 2017-2018, 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 usage(void)
36 printf("Usage: %s\n", program_name);
39 /* Do the thing */
40 int main(void)
42 int ret = EINVAL;
43 struct configuration conf = { 0 };
45 setlocale(LC_ALL, "");
46 srand(time(0));
47 conf = (struct configuration) {
48 /* */
49 .static_www_folder = static_www_folder, /* */
50 .work_path = work_path, /* */
51 .temp_dir_template = temp_dir_template, /* */
52 .trip_salt = trip_salt, /* */
53 .trip_salt_len = strlen(trip_salt), /* */
54 .boards = boards, /* */
55 .boards_num = NUM_OF(boards), /* */
56 .max_form_data_size = max_form_data_size, /* */
57 .max_file_size = max_file_size, /* */
58 .max_text_len = max_text_len, /* */
59 .filetypes = filetypes, /* */
60 .filetypes_num = NUM_OF(filetypes), /* */
61 .file_description_prog = file_description_prog, /* */
62 .headers = headers, /* */
63 .headers_num = NUM_OF(headers), /* */
64 .challenges = challenges, /* */
65 .challenges_num = NUM_OF(challenges), /* */
66 .wordfilter_inputs = wordfilter_inputs, /* */
67 .wordfilter_inputs_num = NUM_OF(wordfilter_inputs), /* */
70 /* Set up a minimal part of the system */
71 if (setup_locks(&conf) < 0) {
72 goto done;
75 if (setup_dbs(&conf) < 0) {
76 goto done;
79 if (setup_write_thread(&conf) < 0) {
80 goto done;
83 if (lock_acquire_recent() < 0) {
84 goto done;
87 ret = wt_write_recent_page();
88 lock_release_recent();
89 done:
90 clean_locks();
91 clean_dbs();
92 clean_write_thread();
94 return ret;