---
name: "rte_cfgfile_section_entries"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_cfgfile.h"
---

# rte\_cfgfile\_section\_entries(3)

Part of [rte\_cfgfile.h(3)](/rte_cfgfile.h/3.md).

## NAME

rte\_cfgfile.h

## SYNOPSIS

`#include <stddef.h>`\

### Data Structures

struct **rte\_cfgfile\_entry**\
 struct **rte\_cfgfile\_parameters**\

### Macros

\#define **CFG\_DEFAULT\_COMMENT\_CHARACTER**   ';'\

### 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 allows reading application defined parameters from standard format configuration file.

Definition in file **rte\_cfgfile.h**.

## Macro Definition Documentation

### #define CFG\_DEFAULT\_COMMENT\_CHARACTER ';'

Defines the default comment character used for parsing config files.

Definition at line **63** of file **rte\_cfgfile.h**.

## Enumeration Type Documentation

### anonymous enum

cfgfile load operation flags

**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.*

**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.*

**Parameters**

*filename Config file name* \
 *flags Config file flags* \
 *params 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*

**Parameters**

*flags*

- •

  *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=').*

**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.*

**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.*

**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*

**Parameters**

*cfg Config file* \
 *sectionname Section name* \
 *entryname Entry name to look for the value change* \
 *entryvalue New entry value. Can be also an empty string if CFG\_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*

**Parameters**

*cfg Config file structure* \
 *filename 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.*

**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 least CFG\_NAME\_LEN characters.* \
 *max\_sections Maximum number of section names to be stored in sections array.*

**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.*

**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.*

**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.*

**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.*

*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 least max\_entries entries where the section entries are stored as key-value pair after successful invocation.* \
 *max\_entries Maximum number of section entries to be stored in entries array.*

**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 least CFG\_NAME\_LEN characters where the section name is stored after successful invocation.* \
 *entries Pre-allocated array of at least max\_entries entries where the section entries are stored as key-value pair after successful invocation.* \
 *max\_entries Maximum number of section entries to be stored in entries array.*

**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.*

**Parameters**

*cfg Config file.*

**Returns**

*0 on success, -1 otherwise.*

## Author

*Generated automatically by Doxygen for DPDK from the source code.*
