Translated using Weblate.
[gammu.git] / include / gammu-inifile.h
blobc1aa76adfe216393da924d9e440dc0333c14fab6
1 /**
2 * \file gammu-inifile.h
3 * \author Michal Čihař
5 * INI files manipulation.
6 */
7 #ifndef __gammu_inifile_h
8 #define __gammu_inifile_h
10 #include <gammu-types.h>
11 #include <gammu-error.h>
12 /**
13 * \defgroup INI INI files
14 * These functions parse ini file and make them available in easily
15 * accessable manner.
17 * File format is standard ini file, comments are both # and ;.
20 /**
21 * Private structure holding information INI entry.
22 * \ingroup INI
24 typedef struct _INI_Entry INI_Entry;
26 /**
27 * Private structure holding information INI section.
28 * \ingroup INI
30 typedef struct _INI_Section INI_Section;
32 /**
33 * Structure used to save value for single key in INI style file
34 * \ingroup INI
35 * \todo This should be probably private.
37 struct _INI_Entry {
38 INI_Entry *Next, *Prev;
39 unsigned char *EntryName;
40 unsigned char *EntryValue;
43 /**
44 * Structure used to save section in INI style file
45 * \ingroup INI
46 * \todo This should be probably private.
48 struct _INI_Section {
49 INI_Section *Next, *Prev;
50 INI_Entry *SubEntries;
51 unsigned char *SectionName;
54 /**
55 * Free INI data.
57 * \ingroup INI
59 * \param head INI section data.
61 void INI_Free(INI_Section * head);
63 /**
64 * Reads INI data.
66 * \ingroup INI
68 * \param FileName File to read.
69 * \param Unicode Whether file shoul be treated like unicode.
70 * \param result Pointer where file will be read.
72 * \return Error code
74 GSM_Error INI_ReadFile(const char *FileName, gboolean Unicode,
75 INI_Section ** result);
77 /**
78 * Returns pointer to last INI entry of given section.
80 * \ingroup INI
82 * \param file_info File data as returned by \ref INI_ReadFile.
83 * \param section Section to scan.
84 * \param Unicode Whether file is unicode.
86 * \return Last entry in section.
88 * \bug Unicode should be part of file_info.
90 INI_Entry *INI_FindLastSectionEntry(INI_Section * file_info,
91 const unsigned char *section,
92 const gboolean Unicode);
94 /**
95 * Returns value of INI file entry.
97 * \ingroup INI
99 * \param file_info File data as returned by \ref INI_ReadFile.
100 * \param section Section to scan.
101 * \param key Name of key to read.
102 * \param Unicode Whether file is unicode.
104 * \return Entry value.
106 * \bug Unicode should be part of file_info.
108 unsigned char *INI_GetValue(INI_Section * file_info,
109 const unsigned char *section,
110 const unsigned char *key, const gboolean Unicode);
113 * Returns integer value from configuration. The file is automatically
114 * handled as not unicode.
116 * \param cfg File data as returned by \ref INI_ReadFile.
117 * \param section Section to scan.
118 * \param key Name of key to read.
119 * \param fallback Fallback value.
121 * \return Key value or fallback in case of failure.
123 int INI_GetInt(INI_Section *cfg,
124 const unsigned char *section,
125 const unsigned char *key,
126 int fallback);
129 * Returns boolean value from configuration. The file is automatically
130 * handled as not unicode.
132 * \param cfg File data as returned by \ref INI_ReadFile.
133 * \param section Section to scan.
134 * \param key Name of key to read.
135 * \param fallback Fallback value.
137 * \return Key value or fallback in case of failure.
139 gboolean INI_GetBool(INI_Section *cfg,
140 const unsigned char *section,
141 const unsigned char *key,
142 gboolean fallback);
146 * Converts value to boolean.
148 * It just takes the string and checks whether there is true/yes/t/y/1
149 * or false/no/f/n/0.
151 * \ingroup INI
153 * \param value String to parse.
155 * \return Boolean value, -1 on failure.
157 gboolean GSM_StringToBool(const char *value);
159 #endif
161 /* Editor configuration
162 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: