rte_cfgfile.h(3)
π rte_cfgfile.h β the Library Functions Manual glowup π
ok so bestie, welcome to rte_cfgfile.h(3) β this is the DPDK manpage for the config file library and honestly? she's a queen. Config file management, reading your app-defined params from a regular-format config file, all of it. Let's get into it π
β¨ NAME β¨
rte_cfgfile.h β no cap, that's the whole name. she's just her.
πΈ SYNOPSIS πΈ
#include <stddef.h>
π¦ Data Structures
struct rte_cfgfile_entrystruct rte_cfgfile_parameters
π Macros
#define CFG_DEFAULT_COMMENT_CHARACTER ';'
π Enumerations
enum { CFG_FLAG_GLOBAL_SECTION = 1, CFG_FLAG_EMPTY_VALUES = 2 }
π Functions
struct rte_cfgfile * rte_cfgfile_load (const char *filename, int flags)
struct rte_cfgfile * rte_cfgfile_load_with_params (const char *filename,
int flags, const struct rte_cfgfile_parameters *params)
struct rte_cfgfile * rte_cfgfile_create (int flags)
int rte_cfgfile_add_section (struct rte_cfgfile *cfg, const char
*sectionname)
int rte_cfgfile_add_entry (struct rte_cfgfile *cfg, const char
*sectionname, const char *entryname, const char *entryvalue)
int rte_cfgfile_set_entry (struct rte_cfgfile *cfg, const char
*sectionname, const char *entryname, const char *entryvalue)
int rte_cfgfile_save (struct rte_cfgfile *cfg, const char *filename)
int rte_cfgfile_num_sections (struct rte_cfgfile *cfg, const char
*sec_name, size_t length)
int rte_cfgfile_sections (struct rte_cfgfile *cfg, char *sections[], int
max_sections)
int rte_cfgfile_has_section (struct rte_cfgfile *cfg, const char
*sectionname)
int rte_cfgfile_section_num_entries (struct rte_cfgfile *cfg, const char
*sectionname)
int rte_cfgfile_section_num_entries_by_index (struct rte_cfgfile *cfg,
char *sectionname, int index)
int rte_cfgfile_section_entries (struct rte_cfgfile *cfg, const char
*sectionname, struct rte_cfgfile_entry *entries, int max_entries)
int rte_cfgfile_section_entries_by_index (struct rte_cfgfile *cfg, int
index, char *sectionname, struct rte_cfgfile_entry *entries, int
max_entries)
const char * rte_cfgfile_get_entry (struct rte_cfgfile *cfg, const char
*sectionname, const char *entryname)
int rte_cfgfile_has_entry (struct rte_cfgfile *cfg, const char
*sectionname, const char *entryname)
int rte_cfgfile_close (struct rte_cfgfile *cfg)
π«Ά Detailed Description π«Ά
Configuration File management.
This library lets you read application defined parameters out of a standard format configuration file. it's giving "your app has opinions and they live in a text file" energy and we love her for it π
Definition in file rte_cfgfile.h.
π Macro Definition Documentation π
#define CFG_DEFAULT_COMMENT_CHARACTER ';'
Literally defines the default comment character that gets used when parsing config files. it's the semicolon bestie. she's the vibe.
Definition at line 63 of file rte_cfgfile.h.
π Enumeration Type Documentation π
anonymous enum
cfgfile load operation flags. aka the little switches that change how your file gets read π
Enumerator
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.CFG_FLAG_EMPTY_VALUESβ Indicates that file supports key value entries where the value can be zero length (e.g.,"key=").
Definition at line 46 of file rte_cfgfile.h.
β¨ Function Documentation β¨
struct rte_cfgfile * rte_cfgfile_load (const char * filename, int flags)
Open config file. the main character entrance fr fr.
Parameters
filenameβ Config file name.flagsβ Config file flags.
Returns
Handle to configuration file on success, NULL otherwise.
struct rte_cfgfile * rte_cfgfile_load_with_params (const char * filename, int flags, const struct rte_cfgfile_parameters * params)
Open config file with specified optional parameters. same energy as rte_cfgfile_load but she lets you be picky π
Parameters
filenameβ Config file nameflagsβ Config file flagsparamsβ Additional configuration attributes. Must be configured with desired values prior to invoking this API.
Returns
Handle to configuration file on success, NULL otherwise
struct rte_cfgfile * rte_cfgfile_create (int flags)
Create new cfgfile instance with empty sections and entries. a blank canvas, an empty notes app, the start of something iconic π¦
Parameters
flagsCFG_FLAG_GLOBAL_SECTIONIndicates that the file supports key value entries before the first defined section. These entries can be accessed in the"GLOBAL"section.CFG_FLAG_EMPTY_VALUESIndicates that file supports key value entries where the value can be zero length (e.g.,"key=").
Returns
Handle to cfgfile instance on success, NULL otherwise
int rte_cfgfile_add_section (struct rte_cfgfile * cfg, const char * sectionname)
Add section in cfgfile instance. new section just dropped π₯
Parameters
cfgβ Pointer to the cfgfile structure.sectionnameβ Section name which will be add to cfgfile.
Returns
0 on success, -ENOMEM if can't add section
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. key + value, a matched set, a duo π«Ά
Parameters
cfgβ Pointer to the cfgfile structure.sectionnameβ Given section name to add an entry.entrynameβ Entry name to add.entryvalueβ Entry value to add.
Returns
0 on success, -EEXIST if entry already exist, -EINVAL if bad argument
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. glow-up applied β¨
Parameters
cfgβ Config filesectionnameβ Section nameentrynameβ Entry name to look for the value changeentryvalueβ New entry value. Can be also an empty string ifCFG_FLAG_EMPTY_VALUES = 1
Returns
0 on success, -EINVAL if bad argument
int rte_cfgfile_save (struct rte_cfgfile * cfg, const char * filename)
Save object cfgfile to file on disc. commit her to disk, she deserves it πΎ
Parameters
cfgβ Config file structurefilenameβ File name to save data
Returns
0 on success, errno otherwise
int rte_cfgfile_num_sections (struct rte_cfgfile * cfg, const char * sec_name, size_t length)
Get number of sections in config file. counting queen π’
Parameters
cfgβ Config file.sec_nameβ Section name.lengthβ Maximum section name length.
Returns
Number of sections.
int rte_cfgfile_sections (struct rte_cfgfile * cfg, char * sections[], int max_sections)
Get name of all config file sections.
Fills in the array sections with the name of all the sections in the file (up to the number of max_sections sections).
Parameters
cfgβ Config file.sectionsβ Array containing section names after successful invocation. Each element of this array should be preallocated by the user with at leastCFG_NAME_LENcharacters.max_sectionsβ Maximum number of section names to be stored insectionsarray.
Returns
Number of populated sections names.
int rte_cfgfile_has_section (struct rte_cfgfile * cfg, const char * sectionname)
Check if given section exists in config file. vibe check on a section, basically π΅οΈ
Parameters
cfgβ Config file.sectionnameβ Section name.
Returns
TRUE (value different than 0) if section exists, FALSE (value 0) otherwise.
int rte_cfgfile_section_num_entries (struct rte_cfgfile * cfg, const char * sectionname)
Get number of entries in given config file section.
If multiple sections have the given name, this function operates on the first one. β οΈ (yes this matters, don't @ me)
Parameters
cfgβ Config file.sectionnameβ Section name.
Returns
Number of entries in section on success, -1 otherwise.
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.
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. π the dupe-name situation is exactly her moment
Parameters
cfgβ Config file.sectionnameβ Section name.indexβ Section index.
Returns
Number of entries in section on success, -1 otherwise.
int rte_cfgfile_section_entries (struct rte_cfgfile * cfg, const char * sectionname, struct rte_cfgfile_entry * entries, int max_entries)
Get section entries as key-value pairs. the whole section, unpacked π
If multiple sections have the given name, this function operates on the first one.
Parameters
cfgβ Config file.sectionnameβ Section name.entriesβ Pre-allocated array of at leastmax_entriesentries where the section entries are stored as key-value pair after successful invocation.max_entriesβ Maximum number of section entries to be stored inentriesarray.
Returns
Number of entries populated on success, -1 otherwise.
int rte_cfgfile_section_entries_by_index (struct rte_cfgfile * cfg, int index, char * sectionname, struct rte_cfgfile_entry * entries, int max_entries)
Get section entries as key-value pairs.
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. π¦
Parameters
cfgβ Config file.indexβ Section index.sectionnameβ Pre-allocated string of at leastCFG_NAME_LENcharacters where the section name is stored after successful invocation.entriesβ Pre-allocated array of at leastmax_entriesentries where the section entries are stored as key-value pair after successful invocation.max_entriesβ Maximum number of section entries to be stored inentriesarray.
Returns
Number of entries populated on success, -1 otherwise.
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.
If multiple sections have the given name, this function operates on the first one.
Parameters
cfgβ Config file.sectionnameβ Section name.entrynameβ Entry name.
Returns
Entry value on success, NULL otherwise.
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.
If multiple sections have the given name, this function operates on the first one.
Parameters
cfgβ Config file.sectionnameβ Section name.entrynameβ Entry name.
Returns
TRUE (value different than 0) if entry exists, FALSE (value 0) otherwise.
int rte_cfgfile_close (struct rte_cfgfile * cfg)
Close config file. say bye bestie, she's done π₯Ή
Parameters
cfgβ Config file.
Returns
0 on success, -1 otherwise.
π Author π
Generated automatically by Doxygen for DPDK from the source code.
ok that's the whole page, mwah π and for the sign-off: this was shipped by DPDK, Version 25.11.3 β that's the source and version, periodt. take care of her, she's iconic ππ
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms