diff options
Diffstat (limited to 'other/bootstrap_daemon/src')
-rw-r--r-- | other/bootstrap_daemon/src/command_line_arguments.c | 14 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/log.h | 10 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/log_backend_stdout.h | 2 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/log_backend_syslog.c | 4 | ||||
-rw-r--r-- | other/bootstrap_daemon/src/log_backend_syslog.h | 2 |
5 files changed, 18 insertions, 14 deletions
diff --git a/other/bootstrap_daemon/src/command_line_arguments.c b/other/bootstrap_daemon/src/command_line_arguments.c index d9747932..d76bc655 100644 --- a/other/bootstrap_daemon/src/command_line_arguments.c +++ b/other/bootstrap_daemon/src/command_line_arguments.c | |||
@@ -73,13 +73,13 @@ void handle_command_line_arguments(int argc, char *argv[], char **cfg_file_path, | |||
73 | 73 | ||
74 | opterr = 0; | 74 | opterr = 0; |
75 | 75 | ||
76 | static struct option long_options[] = { | 76 | static const struct option long_options[] = { |
77 | {"config", required_argument, 0, 'c'}, // required option | 77 | {"config", required_argument, nullptr, 'c'}, // required option |
78 | {"foreground", no_argument, 0, 'f'}, | 78 | {"foreground", no_argument, nullptr, 'f'}, |
79 | {"help", no_argument, 0, 'h'}, | 79 | {"help", no_argument, nullptr, 'h'}, |
80 | {"log-backend", required_argument, 0, 'l'}, // optional, defaults to syslog | 80 | {"log-backend", required_argument, nullptr, 'l'}, // optional, defaults to syslog |
81 | {"version", no_argument, 0, 'v'}, | 81 | {"version", no_argument, nullptr, 'v'}, |
82 | {0, 0, 0, 0 } | 82 | {nullptr, 0, nullptr, 0 } |
83 | }; | 83 | }; |
84 | 84 | ||
85 | bool cfg_file_path_set = false; | 85 | bool cfg_file_path_set = false; |
diff --git a/other/bootstrap_daemon/src/log.h b/other/bootstrap_daemon/src/log.h index ab7cd30b..a810d997 100644 --- a/other/bootstrap_daemon/src/log.h +++ b/other/bootstrap_daemon/src/log.h | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | #include <stdbool.h> | 28 | #include <stdbool.h> |
29 | 29 | ||
30 | #include "../../../toxcore/ccompat.h" | ||
31 | |||
30 | typedef enum LOG_BACKEND { | 32 | typedef enum LOG_BACKEND { |
31 | LOG_BACKEND_STDOUT, | 33 | LOG_BACKEND_STDOUT, |
32 | LOG_BACKEND_SYSLOG | 34 | LOG_BACKEND_SYSLOG |
@@ -41,13 +43,13 @@ typedef enum LOG_LEVEL { | |||
41 | /** | 43 | /** |
42 | * Initializes logger. | 44 | * Initializes logger. |
43 | * @param backend Specifies which backend to use. | 45 | * @param backend Specifies which backend to use. |
44 | * @return true on success, flase if log is already opened. | 46 | * @return true on success, false if log is already opened. |
45 | */ | 47 | */ |
46 | bool log_open(LOG_BACKEND backend); | 48 | bool log_open(LOG_BACKEND backend); |
47 | 49 | ||
48 | /** | 50 | /** |
49 | * Releases all used resources by the logger. | 51 | * Releases all used resources by the logger. |
50 | * @return true on success, flase if log is already closed. | 52 | * @return true on success, false if log is already closed. |
51 | */ | 53 | */ |
52 | bool log_close(void); | 54 | bool log_close(void); |
53 | 55 | ||
@@ -56,9 +58,9 @@ bool log_close(void); | |||
56 | * @param level Log level to use. | 58 | * @param level Log level to use. |
57 | * @param format printf-like format string. | 59 | * @param format printf-like format string. |
58 | * @param ... Zero or more arguments, similar to printf function. | 60 | * @param ... Zero or more arguments, similar to printf function. |
59 | * @return true on success, flase if log is closed. | 61 | * @return true on success, false if log is closed. |
60 | */ | 62 | */ |
61 | bool log_write(LOG_LEVEL level, const char *format, ...); | 63 | bool log_write(LOG_LEVEL level, const char *format, ...) GNU_PRINTF(2, 3); |
62 | 64 | ||
63 | 65 | ||
64 | #endif // LOG_H | 66 | #endif // LOG_H |
diff --git a/other/bootstrap_daemon/src/log_backend_stdout.h b/other/bootstrap_daemon/src/log_backend_stdout.h index 5d8dd463..096af49c 100644 --- a/other/bootstrap_daemon/src/log_backend_stdout.h +++ b/other/bootstrap_daemon/src/log_backend_stdout.h | |||
@@ -29,6 +29,6 @@ | |||
29 | 29 | ||
30 | #include <stdarg.h> | 30 | #include <stdarg.h> |
31 | 31 | ||
32 | void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args); | 32 | void log_backend_stdout_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0); |
33 | 33 | ||
34 | #endif // LOG_BACKEND_STDOUT_H | 34 | #endif // LOG_BACKEND_STDOUT_H |
diff --git a/other/bootstrap_daemon/src/log_backend_syslog.c b/other/bootstrap_daemon/src/log_backend_syslog.c index 9fc6d18f..73ecc964 100644 --- a/other/bootstrap_daemon/src/log_backend_syslog.c +++ b/other/bootstrap_daemon/src/log_backend_syslog.c | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | #include <assert.h> | 31 | #include <assert.h> |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | ||
33 | #include <syslog.h> | 34 | #include <syslog.h> |
34 | 35 | ||
35 | void log_backend_syslog_open(void) | 36 | void log_backend_syslog_open(void) |
@@ -72,8 +73,9 @@ void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args) | |||
72 | return; | 73 | return; |
73 | } | 74 | } |
74 | 75 | ||
75 | VLA(char, buf, size + 1); | 76 | char *buf = (char *)malloc(size + 1); |
76 | vsnprintf(buf, size + 1, format, args); | 77 | vsnprintf(buf, size + 1, format, args); |
77 | 78 | ||
78 | syslog(log_backend_syslog_level(level), "%s", buf); | 79 | syslog(log_backend_syslog_level(level), "%s", buf); |
80 | free(buf); | ||
79 | } | 81 | } |
diff --git a/other/bootstrap_daemon/src/log_backend_syslog.h b/other/bootstrap_daemon/src/log_backend_syslog.h index f09b0431..5e9a3069 100644 --- a/other/bootstrap_daemon/src/log_backend_syslog.h +++ b/other/bootstrap_daemon/src/log_backend_syslog.h | |||
@@ -31,6 +31,6 @@ | |||
31 | 31 | ||
32 | void log_backend_syslog_open(void); | 32 | void log_backend_syslog_open(void); |
33 | void log_backend_syslog_close(void); | 33 | void log_backend_syslog_close(void); |
34 | void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args); | 34 | void log_backend_syslog_write(LOG_LEVEL level, const char *format, va_list args) GNU_PRINTF(2, 0); |
35 | 35 | ||
36 | #endif // LOG_BACKEND_SYSLOG_H | 36 | #endif // LOG_BACKEND_SYSLOG_H |