Crinit -- Configurable Rootfs Init
confparse.c File Reference

(2023-09-05, commit: 78cd7cc)

Implementation of the Config Parser. More...

#include "confparse.h"
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#include "confconv.h"
#include "confmap.h"
#include "elosio.h"
#include "envset.h"
#include "globopt.h"
#include "ini.h"
#include "ioredir.h"
#include "lexers.h"
#include "logio.h"
Include dependency graph for confparse.c:

Classes

struct  crinitIniParserCtx_t
 

Functions

static int crinitIniHandler (void *parserCtx, const char *section, const char *name, const char *value)
 
int crinitParseConf (crinitConfKvList_t **confList, const char *filename)
 
void crinitFreeConfList (crinitConfKvList_t *confList)
 
void crinitFreeArgvArray (char **inArgv)
 
static int crinitConfSanityCheck (void)
 
int crinitLoadSeriesConf (crinitFileSeries_t *series, const char *filename)
 

Detailed Description

Implementation of the Config Parser.

Function Documentation

◆ crinitConfSanityCheck()

static int crinitConfSanityCheck ( void  )
static

◆ crinitFreeArgvArray()

void crinitFreeArgvArray ( char **  inArgv)

Frees a string array with a backing string.

Parameters
inArgvThe string array to free, must be a double pointer with 2 allocations, one array of pointers and a single inner array of char.

◆ crinitFreeConfList()

void crinitFreeConfList ( crinitConfKvList_t confList)

Frees memory allocated for an crinitConfKvList_t by crinitParseConf().

Parameters
confListPointer to crinitConfKvList_t allocated by crinitParseConf() and not freed before. If confList is NULL, crinitFreeConfList() will return without freeing any memory.

◆ crinitIniHandler()

static int crinitIniHandler ( void *  parserCtx,
const char *  section,
const char *  name,
const char *  value 
)
static

Parser handler for libinih.

◆ crinitLoadSeriesConf()

int crinitLoadSeriesConf ( crinitFileSeries_t series,
const char *  filename 
)

Parse a series file.

Will return the task config and include files to be loaded in series. Will also set any global options specified in the series file.

Parameters
seriesReturns the paths to the task configs specified in the series file (or scanned from TASKDIR, if configured).
filenameThe path to the series file to load.
Returns
0 on success, -1 on failure

◆ crinitParseConf()

int crinitParseConf ( crinitConfKvList_t **  confList,
const char *  filename 
)

Parse a config file into a crinitConfKvList_t.

Parses a config file and fills confList. Items of confList are dynamically allocated (grown) and need to be freed using free_confList(). The format of the config file is expected to be KEY1=VALUE1<newline>KEY2=VALUE2<newline>... Lines beginning with '#' are considered comments.

Parameters
confListwill return a pointer to dynamically allocated memory of a ConfKvList filled with the key/value-pairs from the config file.
filenamePath to the configuration file.
Returns
0 on success, -1 on error