LIRC libraries
LinuxInfraredRemoteControl
 All Classes Files Functions Variables Typedefs Enumerations Macros Modules Pages
ciniparser.h
Go to the documentation of this file.
1 #ifndef _INIPARSER_H_
2 #define _INIPARSER_H_
3 
4 /* Copyright (c) 2000-2007 by Nicolas Devillard.
5  * Copyright (x) 2009 by Tim Post <tinkertim@gmail.com>
6  * MIT License
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  */
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <unistd.h>
49 
50 #include "dictionary.h"
51 
52 #define ciniparser_getstr(d, k) ciniparser_getstring(d, k, NULL)
53 #define ciniparser_setstr ciniparser_setstring
54 
70 
81 const char* ciniparser_getsecname(dictionary* d, int n);
82 
92 void ciniparser_dump_ini(dictionary* d, FILE* f);
93 
105 void ciniparser_dump(dictionary* d, FILE* f);
106 
120 const char* ciniparser_getstring(dictionary* d, const char* key, char* def);
121 
147 int ciniparser_getint(dictionary* d, const char* key, int notfound);
148 
160 double ciniparser_getdouble(dictionary* d, const char* key, double notfound);
161 
192 int ciniparser_getboolean(dictionary* d, const char* key, int notfound);
193 
205 int ciniparser_setstring(dictionary* ini, char const* entry, const char* val);
206 
215 void ciniparser_unset(dictionary* ini, char* entry);
216 
227 int ciniparser_find_entry(dictionary* ini, const char* entry);
228 
241 dictionary* ciniparser_load(const char* ininame);
242 
253 
264 int ciniparser_set(dictionary* d, const char* entry, const char* val);
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 
271 #endif
272 
const char * ciniparser_getstring(dictionary *d, const char *key, char *def)
Get the string associated to a key.
Definition: ciniparser.c:286
dictionary * ciniparser_load(const char *ininame)
Parse an ini file and return an allocated dictionary object.
Definition: ciniparser.c:368
void ciniparser_dump_ini(dictionary *d, FILE *f)
Save a dictionary to a loadable ini file.
Definition: ciniparser.c:244
int ciniparser_getint(dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to an int.
Definition: ciniparser.c:300
void ciniparser_freedict(dictionary *d)
Free all memory associated to an ini dictionary.
Definition: ciniparser.c:468
int ciniparser_set(dictionary *d, const char *entry, const char *val)
Set an item in the dictionary.
Definition: ciniparser.c:358
int ciniparser_find_entry(dictionary *ini, const char *entry)
Finds out if a given entry exists in a dictionary.
Definition: ciniparser.c:348
int ciniparser_setstring(dictionary *ini, char const *entry, const char *val)
Set an entry in a dictionary.
void ciniparser_unset(dictionary *ini, char *entry)
Delete an entry in a dictionary.
Definition: ciniparser.c:363
double ciniparser_getdouble(dictionary *d, const char *key, double notfound)
Get the string associated to a key, convert to a double.
Definition: ciniparser.c:312
const char * ciniparser_getsecname(dictionary *d, int n)
Get name for section n in a dictionary.
Definition: ciniparser.c:198
void ciniparser_dump(dictionary *d, FILE *f)
Dump a dictionary to an opened file pointer.
Definition: ciniparser.c:227
Dictionary object.
Definition: dictionary.h:67
int ciniparser_getnsec(dictionary *d)
Get number of sections in a dictionary.
Definition: ciniparser.c:179
int ciniparser_getboolean(dictionary *d, const char *key, int notfound)
Get the string associated to a key, convert to a boolean.
Definition: ciniparser.c:324
Implements a dictionary for string variables.This module implements a simple dictionary object...