hl7parse
Classes | Macros | Functions
ini.h File Reference

ini file parser More...

Go to the source code of this file.

Classes

struct  last_pos_t
 parser positions This structure holds the last known position of element boundaries More...
 
struct  ini_item_t
 key value pair of an ini file, delimited by = This structure defines a key/value pair of an ini file More...
 
struct  ini_section_t
 a section, that contains N ini_item_t this structure holds a section with N items More...
 
struct  ini_section_list_t
 container holding ections Top level strcture, holds N sections. More...
 

Macros

#define ALLOC_NUM_ITEMS   10
 pre-allocate items More...
 

Functions

ini_section_list_tini_parse (FILE *fp)
 constructor More...
 
void ini_free (ini_section_list_t *ini)
 free memory More...
 
ini_section_tini_find_section (ini_section_list_t *ini, const char *section_name)
 find sections and keys in ini structure More...
 
ini_item_tini_find_key (ini_section_t *s, const char *key)
 search for key in section More...
 
char * ini_get_value (ini_section_list_t *ini, const char *section, const char *key)
 get value of key in section More...
 

Detailed Description

ini file parser

2020, Simon Wunderlin

Macro Definition Documentation

◆ ALLOC_NUM_ITEMS

#define ALLOC_NUM_ITEMS   10

pre-allocate items

we are dynamically pre-allocating child items so we don't have to call realloc() on every item added. If you have large structures with many items settin this to a higher value might benefit performance (less realloc calls).

default: 10

Function Documentation

◆ ini_find_key()

ini_item_t* ini_find_key ( ini_section_t s,
const char *  key 
)

search for key in section

Parameters
ssection to search in
keyname of the key to search for
Returns
reference to the key/value pair or NULL if not found

◆ ini_find_section()

ini_section_t* ini_find_section ( ini_section_list_t ini,
const char *  section_name 
)

find sections and keys in ini structure

Parameters
inistructure to search in
section_namesection to search for
Returns
pointer to section or NULL if was not found

◆ ini_free()

void ini_free ( ini_section_list_t ini)

free memory

Parameters
iniparsed structure

◆ ini_get_value()

char* ini_get_value ( ini_section_list_t ini,
const char *  section,
const char *  key 
)

get value of key in section

get a value for a specific item in a section. returns NULL if not found

Parameters
inisection list to search in
sectionname of the section to search in
keykey to search for in section
Returns
value if the key is found in section otherwise NULL

◆ ini_parse()

ini_section_list_t* ini_parse ( FILE *  fp)

constructor

PArses an ini file. make sure fp points to the beginning of the file before invoking.

Parameters
fpfile pointer
Returns
section list