2 * \file gammu-inifile.h
5 * INI files manipulation.
7 #ifndef __gammu_inifile_h
8 #define __gammu_inifile_h
10 #include <gammu-types.h>
11 #include <gammu-error.h>
13 * \defgroup INI INI files
14 * These functions parse ini file and make them available in easily
17 * File format is standard ini file, comments are both # and ;.
21 * Private structure holding information INI entry.
24 typedef struct _INI_Entry INI_Entry
;
27 * Private structure holding information INI section.
30 typedef struct _INI_Section INI_Section
;
33 * Structure used to save value for single key in INI style file
35 * \todo This should be probably private.
38 INI_Entry
*Next
, *Prev
;
39 unsigned char *EntryName
;
40 unsigned char *EntryValue
;
44 * Structure used to save section in INI style file
46 * \todo This should be probably private.
49 INI_Section
*Next
, *Prev
;
50 INI_Entry
*SubEntries
;
51 unsigned char *SectionName
;
59 * \param head INI section data.
61 void INI_Free(INI_Section
* head
);
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.
74 GSM_Error
INI_ReadFile(const char *FileName
, gboolean Unicode
,
75 INI_Section
** result
);
78 * Returns pointer to last INI entry of given section.
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
);
95 * Returns value of INI file entry.
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
,
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
,
146 * Converts value to boolean.
148 * It just takes the string and checks whether there is true/yes/t/y/1
153 * \param value String to parse.
155 * \return Boolean value, -1 on failure.
157 gboolean
GSM_StringToBool(const char *value
);
161 /* Editor configuration
162 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: