Tchatator413
TripEnArvor instant messaging protocol - JSON-based
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions
cfg.h File Reference

Tchatator413 server configuration - Interface. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

Go to the source code of this file.

Macros

#define cfg_log(cfg, lvl, fmt, ...)   _cfg_log(__FILE_NAME__, __LINE__, cfg, lvl, fmt __VA_OPT__(,) __VA_ARGS__)
 

Typedefs

typedef struct cfg cfg_t
 An opaque handle to a configuration object.
 

Enumerations

enum  log_lvl_t { log_error , log_info , log_warning }
 Level of a log entry. More...
 

Functions

cfg_tcfg_defaults (void)
 Load the default configuration.
 
void cfg_destroy (cfg_t *cfg)
 Destroy a configuration.
 
cfg_tcfg_from_file (char const *filename)
 Load configuration from a file.
 
void cfg_dump (cfg_t const *cfg)
 Dump a configuration to standard output.
 
void cfg_set_verbosity (cfg_t *cfg, int verbosity)
 Set the logging verbosity.
 
bool _cfg_log (char const *file, int line, cfg_t *cfg, log_lvl_t lvl, char const *fmt,...)
 Log a formatted string.
 
void cfg_log_putc (cfg_t *cfg, char c)
 Log a single character.
 
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_page_outbox (cfg_t const *cfg)
 Get the configuration page_outbox.
 
int cfg_rate_limit_m (cfg_t const *cfg)
 Get the configuration rate_limit_m.
 
int cfg_rate_limit_h (cfg_t const *cfg)
 Get the configuration rate_limit_h.
 
int cfg_block_for (cfg_t const *cfg)
 Get the configuration block_for.
 
int cfg_backlog (cfg_t const *cfg)
 Get the configuration backlog.
 
uint16_t cfg_port (cfg_t const *cfg)
 Get the configuration port.
 

Detailed Description

Tchatator413 server configuration - Interface.

Author
Raphaƫl
Date
29/01/2025

Definition in file cfg.h.

Macro Definition Documentation

◆ cfg_log

#define cfg_log (   cfg,
  lvl,
  fmt,
  ... 
)    _cfg_log(__FILE_NAME__, __LINE__, cfg, lvl, fmt __VA_OPT__(,) __VA_ARGS__)

Definition at line 58 of file cfg.h.

Typedef Documentation

◆ cfg_t

typedef struct cfg cfg_t

An opaque handle to a configuration object.

Definition at line 14 of file cfg.h.

Enumeration Type Documentation

◆ log_lvl_t

enum log_lvl_t

Level of a log entry.

Enumerator
log_error 

Error. Always logged.

log_info 

Informational. Logged when verbosity is > 0.

log_warning 

Warning. Logged when verbosity is >= 0.

Definition at line 41 of file cfg.h.

41 {
42 log_error,
43 log_info,
45} log_lvl_t;
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

Function Documentation

◆ _cfg_log()

bool _cfg_log ( char const *  file,
int  line,
cfg_t cfg,
log_lvl_t  lvl,
char const *  fmt,
  ... 
)

Log a formatted string.

Parameters
fileThe file.
lineThe line.
cfgThe configuration.
lvlThe logging level. With the configured verbosity, this determines whether an entry will be logged or not.
fmtThe format string.
...Arguments to the format string.
Returns
true if an entry has been logged.
false if no entry has been logged.

◆ cfg_backlog()

int cfg_backlog ( cfg_t const *  cfg)

Get the configuration backlog.

Parameters
cfgConfiguration
Returns
the configuration backlog.

◆ cfg_block_for()

int cfg_block_for ( cfg_t const *  cfg)

Get the configuration block_for.

Parameters
cfgConfiguration
Returns
the configuration block_for.

◆ cfg_defaults()

cfg_t * cfg_defaults ( void  )

Load the default configuration.

Returns
A new configuration object.

The default verbosity is 0.

◆ cfg_destroy()

void cfg_destroy ( cfg_t cfg)

Destroy a configuration.

Parameters
cfgThe configuration to destroy. No-op if NULL.

◆ cfg_dump()

void cfg_dump ( cfg_t const *  cfg)

Dump a configuration to standard output.

Parameters
cfgThe configuration to dump.

◆ cfg_from_file()

cfg_t * cfg_from_file ( char const *  filename)

Load configuration from a file.

Parameters
filenameThe filename to read the config from.
Returns
A new configuration object.

◆ cfg_log_putc()

void cfg_log_putc ( cfg_t cfg,
char  c 
)

Log a single character.

Parameters
cfgThe configuration.
cA character.

◆ cfg_max_msg_length()

size_t cfg_max_msg_length ( cfg_t const *  cfg)

Get the configuration max_msg_length.

Parameters
cfgConfiguration
Returns
the configuration max_msg_length.

◆ cfg_page_inbox()

int cfg_page_inbox ( cfg_t const *  cfg)

Get the configuration page_inbox.

Parameters
cfgConfiguration
Returns
the configuration page_inbox.

◆ cfg_page_outbox()

int cfg_page_outbox ( cfg_t const *  cfg)

Get the configuration page_outbox.

Parameters
cfgConfiguration
Returns
the configuration page_outbox.

◆ cfg_port()

uint16_t cfg_port ( cfg_t const *  cfg)

Get the configuration port.

Parameters
cfgConfiguration
Returns
the configuration port.

◆ cfg_rate_limit_h()

int cfg_rate_limit_h ( cfg_t const *  cfg)

Get the configuration rate_limit_h.

Parameters
cfgConfiguration
Returns
the configuration rate_limit_h.

◆ cfg_rate_limit_m()

int cfg_rate_limit_m ( cfg_t const *  cfg)

Get the configuration rate_limit_m.

Parameters
cfgConfiguration
Returns
the configuration rate_limit_m.

◆ cfg_set_verbosity()

void cfg_set_verbosity ( cfg_t cfg,
int  verbosity 
)

Set the logging verbosity.

Parameters
cfgThe configuration.
verbosityThe logging verbosity.