KTH framework for Nek5000 toolboxes; testing version  0.0.1
iniparser.h
Go to the documentation of this file.
1 
2 /*-------------------------------------------------------------------------*/
8 /*--------------------------------------------------------------------------*/
9 #ifndef _INIPARSER_H_
10 #define _INIPARSER_H_
11 
12 /*---------------------------------------------------------------------------
13  Includes
14  ---------------------------------------------------------------------------*/
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 
20 /*
21  * The following #include is necessary on many Unixes but not Linux.
22  * It is not needed for Windows platforms.
23  * Uncomment it if needed.
24  */
25 /* #include <unistd.h> */
26 
27 #include "dictionary.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 unsigned strstrip(char * s);
34 const char * strlwc(const char * in, char *out, unsigned len);
35 
36 
37 /*-------------------------------------------------------------------------*/
54 /*--------------------------------------------------------------------------*/
55 
56 int iniparser_getnsec(const dictionary * d);
57 
58 
59 /*-------------------------------------------------------------------------*/
72 /*--------------------------------------------------------------------------*/
73 
74 const char * iniparser_getsecname(const dictionary * d, int n);
75 
76 
77 /*-------------------------------------------------------------------------*/
87 /*--------------------------------------------------------------------------*/
88 
89 void iniparser_dump_ini(const dictionary * d, FILE * f);
90 
91 /*-------------------------------------------------------------------------*/
102 /*--------------------------------------------------------------------------*/
103 
104 void iniparser_dumpsection_ini(const dictionary * d, const char * s, FILE * f);
105 
106 /*-------------------------------------------------------------------------*/
118 /*--------------------------------------------------------------------------*/
119 void iniparser_dump(const dictionary * d, FILE * f);
120 
121 /*-------------------------------------------------------------------------*/
128 /*--------------------------------------------------------------------------*/
129 int iniparser_getsecnkeys(const dictionary * d, const char * s);
130 
131 /*-------------------------------------------------------------------------*/
146 /*--------------------------------------------------------------------------*/
147 const char ** iniparser_getseckeys(const dictionary * d, const char * s, const char ** keys);
148 
149 
150 /*-------------------------------------------------------------------------*/
164 /*--------------------------------------------------------------------------*/
165 const char * iniparser_getstring(const dictionary * d, const char * key, const char * def);
166 
167 /*-------------------------------------------------------------------------*/
193 /*--------------------------------------------------------------------------*/
194 int iniparser_getint(const dictionary * d, const char * key, int notfound);
195 
196 /*-------------------------------------------------------------------------*/
208 /*--------------------------------------------------------------------------*/
209 double iniparser_getdouble(const dictionary * d, const char * key, double notfound);
210 
211 /*-------------------------------------------------------------------------*/
242 /*--------------------------------------------------------------------------*/
243 int iniparser_getboolean(const dictionary * d, const char * key, int notfound);
244 
245 
246 /*-------------------------------------------------------------------------*/
258 /*--------------------------------------------------------------------------*/
259 int iniparser_set(dictionary * ini, const char * entry, const char * val);
260 
261 
262 /*-------------------------------------------------------------------------*/
271 /*--------------------------------------------------------------------------*/
272 void iniparser_unset(dictionary * ini, const char * entry);
273 
274 /*-------------------------------------------------------------------------*/
285 /*--------------------------------------------------------------------------*/
286 int iniparser_find_entry(const dictionary * ini, const char * entry) ;
287 
288 /*-------------------------------------------------------------------------*/
301 /*--------------------------------------------------------------------------*/
302 dictionary * iniparser_load(const char * ininame);
303 
304 /*-------------------------------------------------------------------------*/
314 /*--------------------------------------------------------------------------*/
316 
317 #ifdef __cplusplus
318 }
319 #endif
320 
321 #endif
Implements a dictionary for string variables.
double iniparser_getdouble(const dictionary *d, const char *key, double notfound)
Get the string associated to a key, convert to a double.
Definition: iniparser.c:435
void iniparser_unset(dictionary *ini, const char *entry)
Delete an entry in a dictionary.
Definition: iniparser.c:543
const char ** iniparser_getseckeys(const dictionary *d, const char *s, const char **keys)
Get the number of keys in a section of a dictionary.
Definition: iniparser.c:332
int iniparser_getsecnkeys(const dictionary *d, const char *s)
Get the number of keys in a section of a dictionary.
Definition: iniparser.c:291
const char * strlwc(const char *in, char *out, unsigned len)
Convert a string to lowercase.
Definition: iniparser.c:44
void iniparser_dumpsection_ini(const dictionary *d, const char *s, FILE *f)
Save a dictionary section to a loadable ini file.
Definition: iniparser.c:257
void iniparser_dump(const dictionary *d, FILE *f)
Dump a dictionary to an opened file pointer.
Definition: iniparser.c:194
unsigned strstrip(char *s)
Remove blanks at the beginning and the end of a string.
Definition: iniparser.c:90
void iniparser_freedict(dictionary *d)
Free all memory associated to an ini dictionary.
Definition: iniparser.c:759
int iniparser_getint(const dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to an int.
Definition: iniparser.c:413
dictionary * iniparser_load(const char *ininame)
Parse an ini file and return an allocated dictionary object.
Definition: iniparser.c:642
const char * iniparser_getsecname(const dictionary *d, int n)
Get name for section n in a dictionary.
Definition: iniparser.c:159
int iniparser_find_entry(const dictionary *ini, const char *entry)
Finds out if a given entry exists in a dictionary.
Definition: iniparser.c:505
int iniparser_getnsec(const dictionary *d)
Get number of sections in a dictionary.
Definition: iniparser.c:128
int iniparser_set(dictionary *ini, const char *entry, const char *val)
Set an entry in a dictionary.
Definition: iniparser.c:527
void iniparser_dump_ini(const dictionary *d, FILE *f)
Save a dictionary to a loadable ini file.
Definition: iniparser.c:219
const char * iniparser_getstring(const dictionary *d, const char *key, const char *def)
Get the string associated to a key.
Definition: iniparser.c:372
int iniparser_getboolean(const dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to a boolean.
Definition: iniparser.c:476
Dictionary object.
Definition: dictionary.h:45