rte_cfgfile.h(3)

πŸ“¦ version 26.03, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

rte_cfgfile.h β€” okay bestie, this is the config-file header from the Library Functions Manual, and it is literally the main character of reading app-defined parameters from a standard-format config file. πŸ’…βœ¨

✨ SYNOPSIS ✨

#include <stddef.h>

πŸŽ€ Data Structures πŸŽ€

  • struct rte_cfgfile_entry
  • struct 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 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 πŸ’œ

πŸ’– rte_cfgfile_load

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.

πŸ’– rte_cfgfile_load_with_params

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

πŸ’– rte_cfgfile_create

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

πŸ’– rte_cfgfile_add_section

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

πŸ’– rte_cfgfile_add_entry

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, -ENAMETOOLONG β€” entry exceeds CFG_NAME_LEN or value exceeds CFG_VALUE_LEN

πŸ’– rte_cfgfile_set_entry

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

πŸ’– rte_cfgfile_save

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

πŸ’– rte_cfgfile_num_sections

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.

πŸ’– rte_cfgfile_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.

πŸ’– rte_cfgfile_has_section

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.

πŸ’– rte_cfgfile_section_num_entries

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.

πŸ’– rte_cfgfile_section_num_entries_by_index

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.

πŸ’– rte_cfgfile_section_entries

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.

πŸ’– rte_cfgfile_section_entries_by_index

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.

πŸ’– rte_cfgfile_get_entry

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.

πŸ’– rte_cfgfile_has_entry

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.

πŸ’– rte_cfgfile_close

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.

okay bestie, that is the whole rte_cfgfile.h(3) page β€” the footer's source/version/date stamp is DPDK, Version 26.03.0, and this icon of a manpage is from the Library Functions Manual. Go read some config files, periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from