misc: a few portability tweaks
[rb-79.git] / rb79-update-recent-page.c
blobb2a5cf322a31185211661b7f0630bb265dfbf6da
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 .trip_salt = trip_salt, /* */
52 .trip_salt_len = strlen(trip_salt), /* */
53 .boards = boards, /* */
54 .boards_num = NUM_OF(boards), /* */
55 .max_form_data_size = max_form_data_size, /* */
56 .max_file_size = max_file_size, /* */
57 .max_text_len = max_text_len, /* */
58 .filetypes = filetypes, /* */
59 .filetypes_num = NUM_OF(filetypes), /* */
60 .file_description_prog = file_description_prog, /* */
61 .headers = headers, /* */
62 .headers_num = NUM_OF(headers), /* */
63 .challenges = challenges, /* */
64 .challenges_num = NUM_OF(challenges), /* */
65 .wordfilter_inputs = wordfilter_inputs, /* */
66 .wordfilter_inputs_num = NUM_OF(wordfilter_inputs), /* */
69 /* Set up a minimal part of the system */
70 if (setup_locks(&conf) < 0) {
71 goto done;
74 if (setup_dbs(&conf) < 0) {
75 goto done;
78 if (setup_write_thread(&conf) < 0) {
79 goto done;
82 if (lock_acquire_recent() < 0) {
83 goto done;
86 ret = wt_write_recent_page();
87 lock_release_recent();
88 done:
89 clean_locks();
90 clean_dbs();
91 clean_write_thread();
93 return ret;