ArvernOS
Loading...
Searching...
No Matches
inish.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
Include dependency graph for inish.h:

Data Structures

struct  inish_kv_pair_t
 
struct  inish_array_t
 
struct  inish_section_t
 
struct  inish_config_t
 

Functions

inish_config_tinish_load (const char *filename)
 
void inish_free (inish_config_t *conf)
 
inish_section_tinish_get_section (inish_config_t *conf, const char *name)
 
inish_kv_pair_tinish_get_kv_pair (inish_section_t *section, const char *key)
 
inish_array_tinish_get_array (inish_section_t *section, const char *key)
 
char * inish_get_string (inish_section_t *section, const char *key)
 
opt_uint64_t inish_get_int (inish_section_t *section, const char *key)
 
opt_bool_t inish_get_bool (inish_section_t *section, const char *key)
 
uint8_t inish_get_ipv4 (inish_section_t *section, const char *key, uint8_t ip[4])
 

Detailed Description

inish configuration parser. inish supports more features than the INI format and less than TOML... This module implements a recursive descent parser, see http://www.rioki.org/2016/04/18/recusive-descent-parser.html for some more information.

Function Documentation

◆ inish_free()

void inish_free ( inish_config_t * conf)

Releases the memory allocated after inish_read() has run. This function should be call once the inish configuration isn't used anymore.

Parameters
confthe inish configuration to free

◆ inish_get_array()

inish_array_t * inish_get_array ( inish_section_t * section,
const char * key )

Returns a inish array structure. This is the "raw" array.

Parameters
sectiona inish section
keythe key of the array to return
Returns
the array if found, NULL otherwise

◆ inish_get_bool()

opt_bool_t inish_get_bool ( inish_section_t * section,
const char * key )

Returns the boolean value for the given key.

Parameters
sectiona inish section
keythe key of the value to return
Returns
an optional type, indicating whether there is a value for the key and the value itself if that's the case

◆ inish_get_int()

opt_uint64_t inish_get_int ( inish_section_t * section,
const char * key )

Returns the integer value for the given key.

Parameters
sectiona inish section
keythe key of the value to return
Returns
an optional type, indicating whether there is a value for the key and the value itself if that's the case

◆ inish_get_ipv4()

uint8_t inish_get_ipv4 ( inish_section_t * section,
const char * key,
uint8_t ip[4] )

Loads an IPv4 address based on a value for the given key.

Parameters
sectiona inish section
keythe key of the value to return
ipthe array that should hold the IPv4 address
Returns
the number of bytes loaded in the ip array

◆ inish_get_kv_pair()

inish_kv_pair_t * inish_get_kv_pair ( inish_section_t * section,
const char * key )

Returns a inish key/value structure. This is the "raw" key/value but inish also offers specialized functions to directly get the value for a given key.

Parameters
sectiona inish section
keythe key of pair to return
Returns
the section if found, NULL otherwise

◆ inish_get_section()

inish_section_t * inish_get_section ( inish_config_t * conf,
const char * name )

Returns a inish section.

Parameters
confa inish configuration
namethe name of the section to return
Returns
the section if found, NULL otherwise

◆ inish_get_string()

char * inish_get_string ( inish_section_t * section,
const char * key )

Returns the string value for the given key.

Parameters
sectiona inish section
keythe key of the value to return
Returns
the value if found, NULL otherwise

◆ inish_load()

inish_config_t * inish_load ( const char * filename)

Parses and loads a inish configuration file in memory.

Parameters
filenamethe configuration filename to load
Returns
a inish configuration or NULL in case of an error