mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
Loading...
Searching...
No Matches
ini.hpp
Go to the documentation of this file.
1/** \file ini.hpp
2 * \author Jared R. Males
3 * \brief The inih ini-style, file parser modified for mxlib.
4 *
5 * \ingroup mxApp_files
6 *
7 */
8
9//***********************************************************************//
10// Copyright 2015, 2016, 2017, 2018 Jared R. Males (jaredmales@gmail.com)
11//
12// This file is part of mxlib.
13//
14// mxlib is free software: you can redistribute it and/or modify
15// it under the terms of the GNU General Public License as published by
16// the Free Software Foundation, either version 3 of the License, or
17// (at your option) any later version.
18//
19// mxlib is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22// GNU General Public License for more details.
23//
24// You should have received a copy of the GNU General Public License
25// along with mxlib. If not, see <http://www.gnu.org/licenses/>.
26//***********************************************************************//
27
28// This file was originally ini.c
29// Modifications made by jaredmales@gmail.com to support inclusion
30// in a c++ library and other features:
31// #ifdef protection
32// made comment character configurable at compile time by adding INI_COMMENT_CHAR
33// copied defines from ini.h
34// copied documentation from ini.h, and updated for doxygen
35// commented out ini.h
36// NOTE: original ini.h and ini.c are in the inih directory
37
38#ifndef ini_hpp
39#define ini_hpp
40
41/* inih -- simple .INI file parser
42
43inih is released under the New BSD license (see LICENSE.txt). Go to the project
44home page for more info:
45
46http://code.google.com/p/inih/
47
48*/
49
50#include <stdio.h>
51#include <ctype.h>
52#include <string.h>
53
54// #include "ini.h"
55
56/// Parse ini file
57/** Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
58 close the file when it's finished -- the caller must do that. */
59int ini_parse_file( FILE *file, int ( *handler )( void *, const char *, const char *, const char * ), void *user );
60
61/// Parse given INI-style file.
62/** May have [section]s, name=value pairs
63 (whitespace stripped), and comments. By default comments start with ';' (semicolon)
64 but this can be configured with the INI_COMMENT_CHAR macro. Section
65 is "" if name=value pair parsed before any section heading. name:value
66 pairs are also supported as a concession to Python's ConfigParser.
67
68 For each name=value pair parsed, call handler function with given user
69 pointer as well as section, name, and value (data only valid for duration
70 of handler call). Handler should return nonzero on success, zero on error.
71
72 Returns 0 on success, line number of first error on parse error (doesn't
73 stop on first error), -1 on file open error, or -2 on memory allocation
74 error (only when INI_USE_STACK is zero).
75*/
76int ini_parse( const char *filename, int ( *handler )( void *, const char *, const char *, const char * ), void *user );
77
78#endif // ini_hpp
int ini_parse_file(FILE *file, int(*handler)(void *, const char *, const char *, const char *), void *user)
Parse ini file.
Definition ini.cpp:89
int ini_parse(const char *filename, int(*handler)(void *, const char *, const char *, const char *), void *user)
Parse given INI-style file.
Definition ini.cpp:202