aboutsummaryrefslogtreecommitdiff
path: root/src/ezini.h
blob: e563c7ca661a329d46275e3c2d48451d7a32b6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
 * \brief INI File handling library header
 * \file ezini.h
 * \author Michael Dipperstein (mdipperstein@gmail.com)
 * \date November 22, 2015
 *
 * This file implements a set of library functions that maybe be used
 * to create, update, and/or parse INI files.
 *
 * \copyright Copyright (C) 2015, 2019 by Michael Dipperstein
 * (mdipperstein@gmail.com)
 *
 * \par
 * This file is part of the ezini library.
 *
 * \license The ezini library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * \par
 * The ezini library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
 * General Public License for more details.
 *
 * \par
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef __EZINI_H
#define __EZINI_H

/**
 * \mainpage EZIni - INI File handling library
 *
 * These pages provide documentation for EZIni, an INI File handling library.
 *
 * \copyright Copyright (C) 2015, 2019 by Michael Dipperstein
 * (mdipperstein@gmail.com)
 *
 * \license
 * The ezini library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version.
 *
 * \par
 * The ezini library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
 * General Public License for more details.
 *
 * \par
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifdef __cplusplus
extern "C" {
#endif

/***************************************************************************
*                            TYPE DEFINITIONS
***************************************************************************/

/**
 * \struct ini_entry_t
 * \brief A structure containing the section, key, and value of INI.
 * file entry
 */
typedef struct
{
    char *section;      /*!< pointer to a NULL terminated string containing the
                            section name */
    char *key;          /*!< pointer to a a NULL terminated string containing
                            the key name */
    char *value;        /*!< pointer to a NULL terminated string with entry
                            value.  Use ASCII strings to represent numbers */
} ini_entry_t;

/**
 * \typedef ini_entry_list_t
 * \brief A shortcut for forward referenced struct ini_section_list_t*
 */
typedef struct ini_section_list_t* ini_entry_list_t;

/***************************************************************************
*                               PROTOTYPES
***************************************************************************/

/* add (section, key, value) to a list of INI entries */
int AddEntryToList(ini_entry_list_t *list, const char *section,
    const char *key, const char *value);

/* free all of the entries in an entry list */
void FreeList(ini_entry_list_t list);

/* create/add entries to an INI file from a sorted entry list */
int MakeINIFile(const char *iniFile, const ini_entry_list_t list);
int AddEntryToFile(const char *iniFile, const ini_entry_list_t list);

/* remove a single entry from an INI file */
int DeleteEntryFromFile(const char *iniFile, const char *section,
    const char *key);

/***************************************************************************
* get the next entry in INI file.
* returns:  1 if an entry is found
*           0 if there are no more entries
*           -1 on error
***************************************************************************/
int GetEntryFromFile(FILE *iniFile, ini_entry_t *entry);

#ifdef __cplusplus
}
#endif

#endif  /* ndef __EZINI_H */