DPDK  17.11.10
rte_cfgfile.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef __INCLUDE_RTE_CFGFILE_H__
35 #define __INCLUDE_RTE_CFGFILE_H__
36 
37 #include <stddef.h>
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
52 #ifndef CFG_NAME_LEN
53 #define CFG_NAME_LEN 64
54 #endif
55 
56 #ifndef CFG_VALUE_LEN
57 #define CFG_VALUE_LEN 256
58 #endif
59 
61 struct rte_cfgfile;
62 
65  char name[CFG_NAME_LEN];
66  char value[CFG_VALUE_LEN];
67 };
68 
73 };
74 
76 enum {
83 
89 };
93 #define CFG_DEFAULT_COMMENT_CHARACTER ';'
94 
105 struct rte_cfgfile *rte_cfgfile_load(const char *filename, int flags);
106 
120 struct rte_cfgfile *rte_cfgfile_load_with_params(const char *filename,
121  int flags, const struct rte_cfgfile_parameters *params);
122 
137 struct rte_cfgfile *rte_cfgfile_create(int flags);
138 
149 int
150 rte_cfgfile_add_section(struct rte_cfgfile *cfg, const char *sectionname);
151 
166 int rte_cfgfile_add_entry(struct rte_cfgfile *cfg,
167  const char *sectionname, const char *entryname,
168  const char *entryvalue);
169 
184 int rte_cfgfile_set_entry(struct rte_cfgfile *cfg, const char *sectionname,
185  const char *entryname, const char *entryvalue);
186 
197 int rte_cfgfile_save(struct rte_cfgfile *cfg, const char *filename);
198 
211 int rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sec_name,
212  size_t length);
213 
231 int rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[],
232  int max_sections);
233 
244 int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname);
245 
259 int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg,
260  const char *sectionname);
261 
278 int rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg,
279  char *sectionname,
280  int index);
281 
300 int rte_cfgfile_section_entries(struct rte_cfgfile *cfg,
301  const char *sectionname,
302  struct rte_cfgfile_entry *entries,
303  int max_entries);
304 
327 int rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg,
328  int index,
329  char *sectionname,
330  struct rte_cfgfile_entry *entries,
331  int max_entries);
332 
348 const char *rte_cfgfile_get_entry(struct rte_cfgfile *cfg,
349  const char *sectionname,
350  const char *entryname);
351 
367 int rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname,
368  const char *entryname);
369 
378 int rte_cfgfile_close(struct rte_cfgfile *cfg);
379 
380 #ifdef __cplusplus
381 }
382 #endif
383 
384 #endif
int rte_cfgfile_add_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname, const char *entryvalue)
int rte_cfgfile_has_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname)
int rte_cfgfile_section_num_entries(struct rte_cfgfile *cfg, const char *sectionname)
int rte_cfgfile_section_entries(struct rte_cfgfile *cfg, const char *sectionname, struct rte_cfgfile_entry *entries, int max_entries)
struct rte_cfgfile * rte_cfgfile_create(int flags)
char name[CFG_NAME_LEN]
Definition: rte_cfgfile.h:65
char value[CFG_VALUE_LEN]
Definition: rte_cfgfile.h:66
int rte_cfgfile_add_section(struct rte_cfgfile *cfg, const char *sectionname)
int rte_cfgfile_num_sections(struct rte_cfgfile *cfg, const char *sec_name, size_t length)
int rte_cfgfile_save(struct rte_cfgfile *cfg, const char *filename)
int rte_cfgfile_has_section(struct rte_cfgfile *cfg, const char *sectionname)
Definition: rte_cfgfile.h:64
int rte_cfgfile_sections(struct rte_cfgfile *cfg, char *sections[], int max_sections)
int rte_cfgfile_section_num_entries_by_index(struct rte_cfgfile *cfg, char *sectionname, int index)
int rte_cfgfile_section_entries_by_index(struct rte_cfgfile *cfg, int index, char *sectionname, struct rte_cfgfile_entry *entries, int max_entries)
struct rte_cfgfile * rte_cfgfile_load(const char *filename, int flags)
int rte_cfgfile_set_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname, const char *entryvalue)
int rte_cfgfile_close(struct rte_cfgfile *cfg)
struct rte_cfgfile * rte_cfgfile_load_with_params(const char *filename, int flags, const struct rte_cfgfile_parameters *params)
const char * rte_cfgfile_get_entry(struct rte_cfgfile *cfg, const char *sectionname, const char *entryname)