mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]

The inih ini-style, file parser modified for mxlib. More...

The inih ini-style, file parser modified for mxlib.

Author
Jared R. Males

Definition in file ini.hpp.

Go to the source code of this file.

Functions

int ini_parse_file (FILE *file, int(*handler)(void *, const char *, const char *, const char *), void *user)
 Parse ini file. More...
 
int ini_parse (const char *filename, int(*handler)(void *, const char *, const char *, const char *), void *user)
 Parse given INI-style file. More...
 

Function Documentation

◆ ini_parse()

int ini_parse ( const char *  filename,
int(*)(void *, const char *, const char *, const char *)  handler,
void *  user 
)

Parse given INI-style file.

May have [section]s, name=value pairs (whitespace stripped), and comments. By default comments start with ';' (semicolon) but this can be configured with the INI_COMMENT_CHAR macro. Section is "" if name=value pair parsed before any section heading. name:value pairs are also supported as a concession to Python's ConfigParser.

For each name=value pair parsed, call handler function with given user pointer as well as section, name, and value (data only valid for duration of handler call). Handler should return nonzero on success, zero on error.

Returns 0 on success, line number of first error on parse error (doesn't stop on first error), -1 on file open error, or -2 on memory allocation error (only when INI_USE_STACK is zero).

Definition at line 193 of file ini.cpp.

References ini_parse_file().

Referenced by mx::app::iniFile::parse().

◆ ini_parse_file()

int ini_parse_file ( FILE *  file,
int(*)(void *, const char *, const char *, const char *)  handler,
void *  user 
)

Parse ini file.

Same as ini_parse(), but takes a FILE* instead of filename. This doesn't close the file when it's finished – the caller must do that.

Definition at line 88 of file ini.cpp.

Referenced by ini_parse().