summaryrefslogtreecommitdiff
path: root/utils.h
blob: a568bd94279b8466b13afba0a1bc5887d634cfe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef UTILS_H
#define UTILS_H 1

#include <stdarg.h>

#define CMDARG(_default_value)                                                                                         \
    {                                                                                                                  \
        .value = NULL, .default_value = (_default_value)                                                               \
    }

struct cmdarg
{
    char * value;
    char const * const default_value;
};

void set_cmdarg(struct cmdarg * const ca, char const * const val);

char const * get_cmdarg(struct cmdarg const * const ca);

int is_cmdarg_set(struct cmdarg const * const ca);

int is_path_absolute(char const * const prefix, char const * const path);

void daemonize_enable(void);

int is_daemonize_enabled(void);

int daemonize_with_pidfile(char const * const pidfile);

int daemonize_shutdown(char const * const pidfile);

int change_user_group(char const * const user,
                      char const * const group,
                      char const * const pidfile,
                      char const * const uds_collector_path,
                      char const * const uds_distributor_path);

void init_logging(char const * const daemon_name);

void log_app_info(void);

void shutdown_logging(void);

int enable_file_logger(char const * const log_file);

int get_log_file_fd(void);

void enable_console_logger(void);

int is_console_logger_enabled(void);

void vlogger(int is_error, char const * const format, va_list ap);

__attribute__((format(printf, 2, 3))) void logger(int is_error, char const * const format, ...);

__attribute__((format(printf, 2, 3))) void logger_early(int is_error, char const * const format, ...);

int set_fd_cloexec(int fd);

char const * get_nDPId_version(void);

#endif