.TH "rte_cfgfile.h" 3 "Version 25.11.0" "DPDK" \" -*- nroff -*-
.ad l
.nh
.SH NAME
rte_cfgfile.h
.SH SYNOPSIS
.br
.PP
\fR#include <stddef\&.h>\fP
.br

.SS "Data Structures"

.in +1c
.ti -1c
.RI "struct \fBrte_cfgfile_entry\fP"
.br
.ti -1c
.RI "struct \fBrte_cfgfile_parameters\fP"
.br
.in -1c
.SS "Macros"

.in +1c
.ti -1c
.RI "#define \fBCFG_DEFAULT_COMMENT_CHARACTER\fP   ';'"
.br
.in -1c
.SS "Enumerations"

.PP
.RI "\fB\fP"
.br

.in +1c
.in +1c
.ti -1c
.RI "enum { \fBCFG_FLAG_GLOBAL_SECTION\fP = 1, \fBCFG_FLAG_EMPTY_VALUES\fP = 2 }"
.br
.in -1c
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "struct rte_cfgfile * \fBrte_cfgfile_load\fP (const char *filename, int flags)"
.br
.ti -1c
.RI "struct rte_cfgfile * \fBrte_cfgfile_load_with_params\fP (const char *filename, int flags, const struct \fBrte_cfgfile_parameters\fP *params)"
.br
.ti -1c
.RI "struct rte_cfgfile * \fBrte_cfgfile_create\fP (int flags)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_add_section\fP (struct rte_cfgfile *cfg, const char *sectionname)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_add_entry\fP (struct rte_cfgfile *cfg, const char *sectionname, const char *entryname, const char *entryvalue)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_set_entry\fP (struct rte_cfgfile *cfg, const char *sectionname, const char *entryname, const char *entryvalue)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_save\fP (struct rte_cfgfile *cfg, const char *filename)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_num_sections\fP (struct rte_cfgfile *cfg, const char *sec_name, size_t length)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_sections\fP (struct rte_cfgfile *cfg, char *sections[], int max_sections)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_has_section\fP (struct rte_cfgfile *cfg, const char *sectionname)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_section_num_entries\fP (struct rte_cfgfile *cfg, const char *sectionname)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_section_num_entries_by_index\fP (struct rte_cfgfile *cfg, char *sectionname, int index)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_section_entries\fP (struct rte_cfgfile *cfg, const char *sectionname, struct \fBrte_cfgfile_entry\fP *entries, int max_entries)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_section_entries_by_index\fP (struct rte_cfgfile *cfg, int index, char *sectionname, struct \fBrte_cfgfile_entry\fP *entries, int max_entries)"
.br
.ti -1c
.RI "const char * \fBrte_cfgfile_get_entry\fP (struct rte_cfgfile *cfg, const char *sectionname, const char *entryname)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_has_entry\fP (struct rte_cfgfile *cfg, const char *sectionname, const char *entryname)"
.br
.ti -1c
.RI "int \fBrte_cfgfile_close\fP (struct rte_cfgfile *cfg)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Configuration File management\&.

.PP
This library allows reading application defined parameters from standard format configuration file\&. 
.PP
Definition in file \fBrte_cfgfile\&.h\fP\&.
.SH "Macro Definition Documentation"
.PP 
.SS "#define CFG_DEFAULT_COMMENT_CHARACTER   ';'"
Defines the default comment character used for parsing config files\&. 
.PP
Definition at line \fB63\fP of file \fBrte_cfgfile\&.h\fP\&.
.SH "Enumeration Type Documentation"
.PP 
.SS "anonymous enum"
cfgfile load operation flags 
.PP
\fBEnumerator\fP
.in +1c
.TP
\f(BICFG_FLAG_GLOBAL_SECTION \fP
Indicates that the file supports key value entries before the first defined section\&. These entries can be accessed in the "GLOBAL" section\&. 
.TP
\f(BICFG_FLAG_EMPTY_VALUES \fP
Indicates that file supports key value entries where the value can be zero length (e\&.g\&., "key=")\&. 
.PP
Definition at line \fB46\fP of file \fBrte_cfgfile\&.h\fP\&.
.SH "Function Documentation"
.PP 
.SS "struct rte_cfgfile * rte_cfgfile_load (const char * filename, int flags)"
Open config file\&.

.PP
\fBParameters\fP
.RS 4
\fIfilename\fP Config file name\&. 
.br
\fIflags\fP Config file flags\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Handle to configuration file on success, NULL otherwise\&. 
.RE
.PP

.SS "struct rte_cfgfile * rte_cfgfile_load_with_params (const char * filename, int flags, const struct \fBrte_cfgfile_parameters\fP * params)"
Open config file with specified optional parameters\&.

.PP
\fBParameters\fP
.RS 4
\fIfilename\fP Config file name 
.br
\fIflags\fP Config file flags 
.br
\fIparams\fP Additional configuration attributes\&. Must be configured with desired values prior to invoking this API\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Handle to configuration file on success, NULL otherwise 
.RE
.PP

.SS "struct rte_cfgfile * rte_cfgfile_create (int flags)"
Create new cfgfile instance with empty sections and entries

.PP
\fBParameters\fP
.RS 4
\fIflags\fP 
.IP "\(bu" 2
CFG_FLAG_GLOBAL_SECTION Indicates that the file supports key value entries before the first defined section\&. These entries can be accessed in the "GLOBAL" section\&.
.IP "\(bu" 2
CFG_FLAG_EMPTY_VALUES Indicates that file supports key value entries where the value can be zero length (e\&.g\&., "key=")\&. 
.PP
.RE
.PP
\fBReturns\fP
.RS 4
Handle to cfgfile instance on success, NULL otherwise 
.RE
.PP

.SS "int rte_cfgfile_add_section (struct rte_cfgfile * cfg, const char * sectionname)"
Add section in cfgfile instance\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Pointer to the cfgfile structure\&. 
.br
\fIsectionname\fP Section name which will be add to cfgfile\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -ENOMEM if can't add section 
.RE
.PP

.SS "int rte_cfgfile_add_entry (struct rte_cfgfile * cfg, const char * sectionname, const char * entryname, const char * entryvalue)"
Add entry to specified section in cfgfile instance\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Pointer to the cfgfile structure\&. 
.br
\fIsectionname\fP Given section name to add an entry\&. 
.br
\fIentryname\fP Entry name to add\&. 
.br
\fIentryvalue\fP Entry value to add\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -EEXIST if entry already exist, -EINVAL if bad argument 
.RE
.PP

.SS "int rte_cfgfile_set_entry (struct rte_cfgfile * cfg, const char * sectionname, const char * entryname, const char * entryvalue)"
Update value of specified entry name in given section in config file

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file 
.br
\fIsectionname\fP Section name 
.br
\fIentryname\fP Entry name to look for the value change 
.br
\fIentryvalue\fP New entry value\&. Can be also an empty string if CFG_FLAG_EMPTY_VALUES = 1 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -EINVAL if bad argument 
.RE
.PP

.SS "int rte_cfgfile_save (struct rte_cfgfile * cfg, const char * filename)"
Save object cfgfile to file on disc

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file structure 
.br
\fIfilename\fP File name to save data 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, errno otherwise 
.RE
.PP

.SS "int rte_cfgfile_num_sections (struct rte_cfgfile * cfg, const char * sec_name, size_t length)"
Get number of sections in config file\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsec_name\fP Section name\&. 
.br
\fIlength\fP Maximum section name length\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of sections\&. 
.RE
.PP

.SS "int rte_cfgfile_sections (struct rte_cfgfile * cfg, char * sections[], int max_sections)"
Get name of all config file sections\&.

.PP
Fills in the array sections with the name of all the sections in the file (up to the number of max_sections sections)\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsections\fP Array containing section names after successful invocation\&. Each element of this array should be preallocated by the user with at least CFG_NAME_LEN characters\&. 
.br
\fImax_sections\fP Maximum number of section names to be stored in sections array\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of populated sections names\&. 
.RE
.PP

.SS "int rte_cfgfile_has_section (struct rte_cfgfile * cfg, const char * sectionname)"
Check if given section exists in config file\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.RE
.PP
\fBReturns\fP
.RS 4
TRUE (value different than 0) if section exists, FALSE (value 0) otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_section_num_entries (struct rte_cfgfile * cfg, const char * sectionname)"
Get number of entries in given config file section\&.

.PP
If multiple sections have the given name, this function operates on the first one\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of entries in section on success, -1 otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_section_num_entries_by_index (struct rte_cfgfile * cfg, char * sectionname, int index)"
Get number of entries in given config file section\&.

.PP
The index of a section is the same as the index of its name in the result of rte_cfgfile_sections\&. This API can be used when there are multiple sections with the same name\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.br
\fIindex\fP Section index\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of entries in section on success, -1 otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_section_entries (struct rte_cfgfile * cfg, const char * sectionname, struct \fBrte_cfgfile_entry\fP * entries, int max_entries)"
Get section entries as key-value pairs\&.

.PP
If multiple sections have the given name, this function operates on the first one\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.br
\fIentries\fP Pre-allocated array of at least max_entries entries where the section entries are stored as key-value pair after successful invocation\&. 
.br
\fImax_entries\fP Maximum number of section entries to be stored in entries array\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of entries populated on success, -1 otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_section_entries_by_index (struct rte_cfgfile * cfg, int index, char * sectionname, struct \fBrte_cfgfile_entry\fP * entries, int max_entries)"
Get section entries as key-value pairs\&.

.PP
The index of a section is the same as the index of its name in the result of rte_cfgfile_sections\&. This API can be used when there are multiple sections with the same name\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIindex\fP Section index\&. 
.br
\fIsectionname\fP Pre-allocated string of at least CFG_NAME_LEN characters where the section name is stored after successful invocation\&. 
.br
\fIentries\fP Pre-allocated array of at least max_entries entries where the section entries are stored as key-value pair after successful invocation\&. 
.br
\fImax_entries\fP Maximum number of section entries to be stored in entries array\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Number of entries populated on success, -1 otherwise\&. 
.RE
.PP

.SS "const char * rte_cfgfile_get_entry (struct rte_cfgfile * cfg, const char * sectionname, const char * entryname)"
Get value of the named entry in named config file section\&.

.PP
If multiple sections have the given name, this function operates on the first one\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.br
\fIentryname\fP Entry name\&. 
.RE
.PP
\fBReturns\fP
.RS 4
Entry value on success, NULL otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_has_entry (struct rte_cfgfile * cfg, const char * sectionname, const char * entryname)"
Check if given entry exists in named config file section\&.

.PP
If multiple sections have the given name, this function operates on the first one\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.br
\fIsectionname\fP Section name\&. 
.br
\fIentryname\fP Entry name\&. 
.RE
.PP
\fBReturns\fP
.RS 4
TRUE (value different than 0) if entry exists, FALSE (value 0) otherwise\&. 
.RE
.PP

.SS "int rte_cfgfile_close (struct rte_cfgfile * cfg)"
Close config file\&.

.PP
\fBParameters\fP
.RS 4
\fIcfg\fP Config file\&. 
.RE
.PP
\fBReturns\fP
.RS 4
0 on success, -1 otherwise\&. 
.RE
.PP

.SH "Author"
.PP 
Generated automatically by Doxygen for DPDK from the source code\&.
