xtc_cfg(3)
---xtc_cfg(3)
typed runtime configuration registry
| XTC_CFG(3) | Library Functions Manual | XTC_CFG(3) |
NAME
xtc_cfg_register,
xtc_cfg_unregister,
xtc_cfg_register_bool,
xtc_cfg_register_int,
xtc_cfg_register_int64,
xtc_cfg_register_double,
xtc_cfg_register_string,
xtc_cfg_register_enum,
xtc_cfg_get,
xtc_cfg_get_bool,
xtc_cfg_get_int,
xtc_cfg_get_int64,
xtc_cfg_get_double,
xtc_cfg_get_string,
xtc_cfg_get_enum,
xtc_cfg_set,
xtc_cfg_set_bool,
xtc_cfg_set_int,
xtc_cfg_set_int64,
xtc_cfg_set_double,
xtc_cfg_set_string,
xtc_cfg_set_enum,
xtc_cfg_count, xtc_cfg_kind,
xtc_cfg_load_file,
xtc_cfg_reload — typed
runtime configuration registry
SYNOPSIS
#include <xtc.h>
#include <xtc_cfg.h>
int
xtc_cfg_register(const
xtc_cfg_spec_t *spec);
int
xtc_cfg_unregister(const
char *name);
int
xtc_cfg_register_bool(const
char *name, int
*out_var, int
default_v, const char
*help);
int
xtc_cfg_register_int(const
char *name, int
*out_var, int
default_v, int min,
int max,
const char *help);
int
xtc_cfg_register_int64(const
char *name, int64_t
*out_var, int64_t
default_v, int64_t
min, int64_t max,
const char *help);
int
xtc_cfg_register_double(const
char *name, double
*out_var, double
default_v, double
min, double max,
const char *help);
int
xtc_cfg_register_string(const
char *name, char
*buf, size_t
buflen, const char
*default_v, const char
*help);
int
xtc_cfg_set(const
char *name, const char
*value);
int
xtc_cfg_get_bool(const
char *name, int
*out);
int
xtc_cfg_get_int(const
char *name, int
*out);
int
xtc_cfg_get_int64(const
char *name, int64_t
*out);
int
xtc_cfg_get_double(const
char *name, double
*out);
int
xtc_cfg_get_string(const
char *name, const char
**out);
int
xtc_cfg_get_enum(const
char *name, int
*out);
int
xtc_cfg_set_bool(const
char *name, int
v);
int
xtc_cfg_set_int(const
char *name, int
v);
int
xtc_cfg_set_int64(const
char *name, int64_t
v);
int
xtc_cfg_set_double(const
char *name, double
v);
int
xtc_cfg_set_string(const
char *name, const char
*v);
int
xtc_cfg_set_enum(const
char *name, int
v);
int
xtc_cfg_count(void);
int
xtc_cfg_kind(const
char *name,
xtc_cfg_kind_t *out);
int
xtc_cfg_load_file(const
char *path);
int
xtc_cfg_reload(void);
DESCRIPTION
xtc_cfg is a typed runtime configuration
registry, modeled on PostgreSQL's GUC system. Modules register named knobs
at startup; operators set them by name; values get bound to live variables
and validated against type and bounds.
Supported types:
bool, int,
int64, double,
string, enum. Each
xtc_cfg_register_*()
takes:
- A canonical name (dot-separated, e.g. ‘rexis.max_clients’).
- A backing storage pointer. When the cfg value changes, the storage is updated atomically.
- A default and bounds (for numeric types).
- A help string used in ‘cfg dump’ output.
xtc_cfg_set()
parses the string value to the registered type, validates against bounds,
and updates the backing variable. An optional on-change callback fires.
Modules register a knob with
xtc_cfg_register(),
passing an xtc_cfg_spec_t that carries name, type,
backing storage, default and bounds; the type-specific
xtc_cfg_register_bool(),
xtc_cfg_register_int(),
xtc_cfg_register_int64(),
xtc_cfg_register_double(),
xtc_cfg_register_string(),
and
xtc_cfg_register_enum()
wrappers fill that spec for one type.
xtc_cfg_unregister()
removes a knob by name.
xtc_cfg_set()
parses the string value to the registered type, validates against bounds,
and updates the backing variable. An optional on-change callback fires. The
typed setters
xtc_cfg_set_bool(),
xtc_cfg_set_int(),
xtc_cfg_set_int64(),
xtc_cfg_set_double(),
xtc_cfg_set_string(),
and
xtc_cfg_set_enum()
assign a value of the matching C type without going through the string
parser.
xtc_cfg_get()
(via the typed accessors) reads the current value. Use
xtc_cfg_get_bool(),
xtc_cfg_get_int(),
xtc_cfg_get_int64(),
xtc_cfg_get_double(),
xtc_cfg_get_string(),
or
xtc_cfg_get_enum()
for the corresponding registered kind.
xtc_cfg_count()
returns the number of registered knobs;
xtc_cfg_kind()
reports the xtc_cfg_kind_t type of a named knob.
EXAMPLES
static int g_max_clients = 1000;
xtc_cfg_register_int("rexis.max_clients", &g_max_clients,
1000, 1, 100000,
"Maximum concurrent client connections");
/* Operator runtime change: */
xtc_cfg_set("rexis.max_clients", "5000");
SEE ALSO
HISTORY
Appeared in xtc 0.1.
| May 28, 2026 | Debian |