PatchworkOS
Loading...
Searching...
No Matches
config.c File Reference
#include <libpatchwork/patchwork.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/io.h>
#include <sys/list.h>

Go to the source code of this file.

Data Structures

struct  config_pair_t
 
struct  config_section_t
 
struct  config_t
 Opaque configuration structure. More...
 

Functions

static char * config_trim_whitespace (char *str)
 
static config_section_tconfig_find_section (config_t *cfg, const char *section)
 
static config_pair_tconfig_find_pair (config_section_t *sec, const char *key)
 
config_tconfig_open (const char *prefix, const char *name)
 Open a configuration file.
 
void config_close (config_t *config)
 Close a configuration file.
 
const char * config_get_string (config_t *config, const char *section, const char *key, const char *fallback)
 Get a string value from a configuration file.
 
int64_t config_get_int (config_t *config, const char *section, const char *key, int64_t fallback)
 Get an integer value from a configuration file.
 
bool config_get_bool (config_t *config, const char *section, const char *key, bool fallback)
 Get a boolean value from a configuration file.
 
config_array_tconfig_get_array (config_t *config, const char *section, const char *key)
 Get an array of strings from a configuration file.
 
void config_array_free (config_array_t *array)
 Free a configuration array.
 

Function Documentation

◆ config_find_pair()

static config_pair_t * config_find_pair ( config_section_t sec,
const char *  key 
)
static

Definition at line 74 of file config.c.

References config_pair_t::key, LIST_FOR_EACH, NULL, config_section_t::pairs, and strcasecmp().

Referenced by config_get_string().

◆ config_find_section()

static config_section_t * config_find_section ( config_t cfg,
const char *  section 
)
static

Definition at line 55 of file config.c.

References LIST_FOR_EACH, config_section_t::name, NULL, config_t::sections, and strcasecmp().

Referenced by config_get_string().

◆ config_trim_whitespace()

static char * config_trim_whitespace ( char *  str)
static

Definition at line 32 of file config.c.

References isspace(), and strlen().

Referenced by config_open().