CUBRID Engine  latest
ini_parser.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2007 by Nicolas Devillard.
3  * MIT License
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef _INI_PARSER_H_
25 #define _INI_PARSER_H_
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #if !defined(WINDOWS)
31 #include <unistd.h>
32 #endif
33 
34 typedef struct ini_table INI_TABLE;
35 struct ini_table
36 {
37  int size; /* storage size */
38  int n; /* number of entries in INI_TABLE */
39  int nsec; /* number of sector in INI_TABLE */
40  char **key; /* list of string keys */
41  char **val; /* list of string values */
42  int *lineno; /* list of lineno values for keys */
43  unsigned int *hash; /* list of hash values for keys */
44 };
45 
46 extern INI_TABLE *ini_parser_load (const char *ininame);
47 extern void ini_parser_free (INI_TABLE * ini);
48 
49 extern int ini_findsec (INI_TABLE * ini, const char *sec);
50 extern char *ini_getsecname (INI_TABLE * ini, int n, int *lineno);
51 extern int ini_hassec (const char *key);
52 extern int ini_seccmp (const char *key1, const char *key2);
53 
54 extern const char *ini_getstr (INI_TABLE * ini, const char *sec, const char *key, const char *def, int *lineno);
55 extern int ini_getint (INI_TABLE * ini, const char *sec, const char *key, int def, int *lineno);
56 extern int ini_getuint (INI_TABLE * ini, const char *sec, const char *key, int def, int *lineno);
57 #if defined(ENABLE_UNUSED_FUNCTION)
58 extern int ini_getuint_min (INI_TABLE * ini, const char *sec, const char *key, int def, int min, int *lineno);
59 #endif
60 extern int ini_getuint_max (INI_TABLE * ini, const char *sec, const char *key, int def, int max, int *lineno);
61 extern int ini_gethex (INI_TABLE * ini, const char *sec, const char *key, int def, int *lineno);
62 extern float ini_getfloat (INI_TABLE * ini, const char *sec, const char *key, float def, int *lineno);
63 #endif /* _INI_PARSER_H_ */
char * ini_getsecname(INI_TABLE *ini, int n, int *lineno)
Definition: ini_parser.c:729
unsigned int * hash
Definition: ini_parser.h:43
char ** key
Definition: ini_parser.h:40
float ini_getfloat(INI_TABLE *ini, const char *sec, const char *key, float def, int *lineno)
Definition: ini_parser.c:1020
int ini_getuint(INI_TABLE *ini, const char *sec, const char *key, int def, int *lineno)
Definition: ini_parser.c:912
INI_TABLE * ini_parser_load(const char *ininame)
Definition: ini_parser.c:569
int nsec
Definition: ini_parser.h:39
int ini_seccmp(const char *key1, const char *key2)
Definition: ini_parser.c:786
int size
Definition: ini_parser.h:37
#define min(a, b)
int ini_hassec(const char *key)
Definition: ini_parser.c:772
int ini_getint(INI_TABLE *ini, const char *sec, const char *key, int def, int *lineno)
Definition: ini_parser.c:885
#define max(a, b)
void ini_parser_free(INI_TABLE *ini)
Definition: ini_parser.c:683
int ini_getuint_max(INI_TABLE *ini, const char *sec, const char *key, int def, int max, int *lineno)
Definition: ini_parser.c:968
const char * ini_getstr(INI_TABLE *ini, const char *sec, const char *key, const char *def, int *lineno)
Definition: ini_parser.c:865
int * lineno
Definition: ini_parser.h:42
char ** val
Definition: ini_parser.h:41
int ini_gethex(INI_TABLE *ini, const char *sec, const char *key, int def, int *lineno)
Definition: ini_parser.c:993
int ini_findsec(INI_TABLE *ini, const char *sec)
Definition: ini_parser.c:697