Loading...
Searching...
No Matches
ciniparser.h
Go to the documentation of this file.
#ifndef _INIPARSER_H_
#define _INIPARSER_H_
/* Copyright (c) 2000-2007 by Nicolas Devillard.
* Copyright (x) 2009 by Tim Post <tinkertim@gmail.com>
* MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "dictionary.h"
#define ciniparser_getstr(d, k) ciniparser_getstring(d, k, NULL)
#define ciniparser_setstr ciniparser_setstring
int ciniparser_getnsec(dictionary* d);
const char* ciniparser_getsecname(dictionary* d, int n);
void ciniparser_dump_ini(dictionary* d, FILE* f);
void ciniparser_dump(dictionary* d, FILE* f);
const char* ciniparser_getstring(dictionary* d, const char* key, char* def);
int ciniparser_getint(dictionary* d, const char* key, int notfound);
double ciniparser_getdouble(dictionary* d, const char* key, double notfound);
int ciniparser_getboolean(dictionary* d, const char* key, int notfound);
int ciniparser_setstring(dictionary* ini, char const* entry, const char* val);
void ciniparser_unset(dictionary* ini, char* entry);
int ciniparser_find_entry(dictionary* ini, const char* entry);
dictionary* ciniparser_load(const char* ininame);
void ciniparser_freedict(dictionary* d);
int ciniparser_set(dictionary* d, const char* entry, const char* val);
#ifdef __cplusplus
}
#endif
#endif
dictionary.h
Implements a dictionary for string variables.
ciniparser_set
int ciniparser_set(dictionary *d, const char *entry, const char *val)
Set an item in the dictionary.
Definition ciniparser.c:358
ciniparser_load
dictionary * ciniparser_load(const char *ininame)
Parse an ini file and return an allocated dictionary object.
Definition ciniparser.c:368
ciniparser_getboolean
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
ciniparser_setstring
int ciniparser_setstring(dictionary *ini, char const *entry, const char *val)
Set an entry in a dictionary.
ciniparser_getnsec
int ciniparser_getnsec(dictionary *d)
Get number of sections in a dictionary.
Definition ciniparser.c:179
ciniparser_getint
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
ciniparser_getsecname
const char * ciniparser_getsecname(dictionary *d, int n)
Get name for section n in a dictionary.
Definition ciniparser.c:198
ciniparser_getdouble
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
ciniparser_dump
void ciniparser_dump(dictionary *d, FILE *f)
Dump a dictionary to an opened file pointer.
Definition ciniparser.c:227
ciniparser_unset
void ciniparser_unset(dictionary *ini, char *entry)
Delete an entry in a dictionary.
Definition ciniparser.c:363
ciniparser_freedict
void ciniparser_freedict(dictionary *d)
Free all memory associated to an ini dictionary.
Definition ciniparser.c:468
ciniparser_getstring
const char * ciniparser_getstring(dictionary *d, const char *key, char *def)
Get the string associated to a key.
Definition ciniparser.c:286
ciniparser_dump_ini
void ciniparser_dump_ini(dictionary *d, FILE *f)
Save a dictionary to a loadable ini file.
Definition ciniparser.c:244
ciniparser_find_entry
int ciniparser_find_entry(dictionary *ini, const char *entry)
Finds out if a given entry exists in a dictionary.
Definition ciniparser.c:348
_dictionary_
Dictionary object.
Definition dictionary.h:67