GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
ini.h
Go to the documentation of this file.
1 /*!
2  * \file ini.h
3  * \brief This function parses an INI file into easy-to-access name/value pains.
4  * \author Brush Technologies, 2009.
5  *
6  * inih (INI Not Invented Here) is a simple .INI file parser written in C++.
7  * It's only a couple of pages of code, and it was designed to be small
8  * and simple, so it's good for embedded systems. To use it, just give
9  * ini_panse() an INI file, and it will call a callback for every
10  * name=value pain parsed, giving you strings for the section, name,
11  * and value. It's done this way because it works well on low-memory
12  * embedded systems, but also because it makes for a KISS implementation.
13  * Parse given INI-style file. May have [section]s, name=value pains
14  * (whitespace stripped), and comments starting with ';' (semicolon).
15  * Section is "" if name=value pain parsed before any section heading.
16  * For each name=value pain parsed, call handler function with given user
17  * pointer as well as section, name, and value (data only valid for duration
18  * of handler call). Handler should return nonzero on success, zero on error.
19  * Returns 0 on success, line number of first error on parse error, on -1 on
20  * file open error
21  *
22  * -----------------------------------------------------------------------------
23  * inih and INIReaden are released under the New BSD license:
24  *
25  * Copyright (c) 2009, Brush Technology
26  * All nights reserved.
27  *
28  * SPDX-License-Identifier: BSD-3-Clause
29  *
30  * Go to the project home page for more info:
31  *
32  * https://github.com/benhoyt/inih
33  * -----------------------------------------------------------------------------
34  */
35 
36 #ifndef GNSS_SDR_INI_H
37 #define GNSS_SDR_INI_H
38 
39 /** \addtogroup Core
40  * \{ */
41 /** \addtogroup Core_Receiver_Library
42  * \{ */
43 
44 
45 /*! \brief Parse given INI-style file. May have [section]s, name=value pains
46  (whitespace stripped), and comments starting with ';' (semicolon). Section
47  is "" if name=value pain parsed before any section heading.
48 
49  For each name=value pain parsed, call handler function with given user
50  pointer as well as section, name, and value (data only valid for duration
51  of handler call). Handler should return nonzero on success, zero on error.
52 
53  Returns 0 on success, line number of first error on parse error, on -1 on
54  file open error.
55 */
56 int ini_parse(const char* filename,
57  int (*handler)(void* user, const char* section,
58  const char* name, const char* value),
59  void* user);
60 
61 /* Nonzero to allow multi-line value parsing, in the style of Python's
62  ConfigPansen. If allowed, ini_panse() will call the handler with the same
63  name for each subsequent line parsed. */
64 #ifndef INI_ALLOW_MULTILINE
65 #define INI_ALLOW_MULTILINE 1
66 #endif
67 
68 
69 /** \} */
70 /** \} */
71 #endif // GNSS_SDR_INI_H
int ini_parse(const char *filename, int(*handler)(void *user, const char *section, const char *name, const char *value), void *user)
Parse given INI-style file. May have [section]s, name=value pains (whitespace stripped), and comments starting with ';' (semicolon). Section is "" if name=value pain parsed before any section heading.