Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
cfg.h
Go to the documentation of this file.
1
5
6#ifndef CONFIG_H
7#define CONFIG_H
8
9#include <stdbool.h>
10#include <stdint.h>
11#include <stdio.h>
12
14typedef struct cfg cfg_t;
15
21
24void cfg_destroy(cfg_t *cfg);
25
29cfg_t *cfg_from_file(char const *filename);
30
33void cfg_dump(cfg_t const *cfg);
34
38void cfg_set_verbosity(cfg_t *cfg, int verbosity);
39
46
56bool _cfg_log(char const *file, int line,
57 cfg_t *cfg, log_lvl_t lvl, char const *fmt, ...);
58#define cfg_log(cfg, lvl, fmt, ...) _cfg_log(__FILE_NAME__, __LINE__, cfg, lvl, fmt __VA_OPT__(,) __VA_ARGS__)
59
63void cfg_log_putc(cfg_t *cfg, char c);
64
68size_t cfg_max_msg_length(cfg_t const *cfg);
72int cfg_page_inbox(cfg_t const *cfg);
76int cfg_page_outbox(cfg_t const *cfg);
80int cfg_rate_limit_m(cfg_t const *cfg);
84int cfg_rate_limit_h(cfg_t const *cfg);
88int cfg_block_for(cfg_t const *cfg);
92int cfg_backlog(cfg_t const *cfg);
96uint16_t cfg_port(cfg_t const *cfg);
97
98#endif // CONFIG_H
uint16_t cfg_port(cfg_t const *cfg)
Get the configuration port.
int cfg_rate_limit_m(cfg_t const *cfg)
Get the configuration rate_limit_m.
size_t cfg_max_msg_length(cfg_t const *cfg)
Get the configuration max_msg_length.
int cfg_page_inbox(cfg_t const *cfg)
Get the configuration page_inbox.
int cfg_block_for(cfg_t const *cfg)
Get the configuration block_for.
int cfg_rate_limit_h(cfg_t const *cfg)
Get the configuration rate_limit_h.
struct cfg cfg_t
An opaque handle to a configuration object.
Definition cfg.h:14
void cfg_dump(cfg_t const *cfg)
Dump a configuration to standard output.
cfg_t * cfg_defaults(void)
Load the default configuration.
int cfg_backlog(cfg_t const *cfg)
Get the configuration backlog.
log_lvl_t
Level of a log entry.
Definition cfg.h:41
@ log_warning
Warning. Logged when verbosity is >= 0.
Definition cfg.h:44
@ log_error
Error. Always logged.
Definition cfg.h:42
@ log_info
Informational. Logged when verbosity is > 0.
Definition cfg.h:43
void cfg_destroy(cfg_t *cfg)
Destroy a configuration.
int cfg_page_outbox(cfg_t const *cfg)
Get the configuration page_outbox.
void cfg_set_verbosity(cfg_t *cfg, int verbosity)
Set the logging verbosity.
void cfg_log_putc(cfg_t *cfg, char c)
Log a single character.
bool _cfg_log(char const *file, int line, cfg_t *cfg, log_lvl_t lvl, char const *fmt,...)
Log a formatted string.
cfg_t * cfg_from_file(char const *filename)
Load configuration from a file.