rte_kvargs.h(3)
π rte_kvargs.h β the Library Functions Manual page, bestie edition β¨
okay so this is the <italic>Library Functions Manual</italic> entry for rte_kvargs.h, and honestly? she's a whole vibe. this is RTE's argument-parsing girlie and she's about to make key1=value1,key2=value2 make sense. no cap. π
πΈ NAME πΈ
rte_kvargs.h
β¨ SYNOPSIS β¨
π¦ Data Structures
struct rte_kvargs_pairstruct rte_kvargs
π¦ Macros
#define RTE_KVARGS_MAX 32
#define RTE_KVARGS_PAIRS_DELIM ','
#define RTE_KVARGS_KV_DELIM '='
π¦ Typedefs
typedef int(*arg_handler_t) (const char *key, const char *value, void *opaque)
π¦ Functions
struct rte_kvargs * rte_kvargs_parse (const char *args, const char *const valid_keys[])
struct rte_kvargs * rte_kvargs_parse_delim (const char *args, const char *const valid_keys[], const char *valid_ends)
void rte_kvargs_free (struct rte_kvargs *kvlist)
const char * rte_kvargs_get (const struct rte_kvargs *kvlist, const char *key)
const char * rte_kvargs_get_with_value (const struct rte_kvargs *kvlist, const char *key, const char *value)
int rte_kvargs_process (const struct rte_kvargs *kvlist, const char *key_match, arg_handler_t handler, void *opaque_arg)
int rte_kvargs_process_opt (const struct rte_kvargs *kvlist, const char *key_match, arg_handler_t handler, void *opaque_arg)
unsigned rte_kvargs_count (const struct rte_kvargs *kvlist, const char *key_match)
π Detailed Description π
RTE Argument parsing β that's the whole assignment, and she ate. π
this module parses arguments whose format is literally:
key1=value1,key2=value2,key3=value3,...
and here's the part that's actually iconic: the same key can show up several times, with the same value or a different one. bestie, the arguments are stored as a list of key/value associations, not as a dictionary. so no "last one wins" sneaky business β every single pair is kept. π
this file gives you some helpers that are especially used by virtual ethernet devices at initialization, for arguments parsing. iykyk.
Definition in file rte_kvargs.h.
π Macro Definition Documentation π
#define RTE_KVARGS_MAX 32
the maximum number of key/value associations. that's the ceiling, periodt.
Definition at line 29 of file rte_kvargs.h.
#define RTE_KVARGS_PAIRS_DELIM ','
the separator character used between each pair β it's a comma, she's lowkey famous. π
Definition at line 32 of file rte_kvargs.h.
#define RTE_KVARGS_KV_DELIM '='
the separator character used between key and value β yeah, the equals sign, the main character of the whole format. β¨
Definition at line 35 of file rte_kvargs.h.
π§ Typedef Documentation π§
typedef int(* arg_handler_t) (const char *key, const char *value, void *opaque)
the callback prototype used by rte_kvargs_process(). this is the little function you hand over and she calls it for you. π«Ά
Parameters
keyβ the key to consider, it will not beNULL.valueβ the value corresponding to the key, it may beNULL(e.g. only with key)opaqueβ an opaque pointer coming from the caller.
Returns
>=0handle key success.<0on error.
Definition at line 50 of file rte_kvargs.h.
π Function Documentation π
struct rte_kvargs * rte_kvargs_parse (const char * args, const char *const valid_keys[])
Allocate a rte_kvargs and store key/value associations from a string.
this function allocates and fills a rte_kvargs structure from a given string whose format is key1=value1,key2=value2,... β yes, the exact same format, she's consistent. π
the structure can be freed with rte_kvargs_free() β don't forget, bestie, we do not leak in this house. π
Parameters
argsβ the input string containing the key/value associationsvalid_keysβ a list of valid keys (table ofconst char *, the last must beNULL). this argument is ignored ifNULL
Returns
- a pointer to an allocated
rte_kvargsstructure on success NULLon error
struct rte_kvargs * rte_kvargs_parse_delim (const char * args, const char *const valid_keys[], const char * valid_ends)
Allocate a rte_kvargs and store key/value associations from a string. but make it deluxe β¨ β this version considers any byte from valid_ends as a possible terminating character, and it will not parse beyond any of their occurrence. like, stop at the first one you see, no further. π
the function allocates and fills an rte_kvargs structure from a given string whose format is key1=value1,key2=value2,...
the structure can be freed with rte_kvargs_free().
Parameters
argsβ the input string containing the key/value associationsvalid_keysβ a list of valid keys (table ofconst char *, the last must beNULL). this argument is ignored ifNULLvalid_endsβ acceptable terminating characters. ifNULL, the behavior is the same asrte_kvargs_parse
Returns
- a pointer to an allocated
rte_kvargsstructure on success NULLon error
void rte_kvargs_free (struct rte_kvargs * kvlist)
Free a rte_kvargs structure. the cleanup queen we all need. π§Ή
frees a rte_kvargs structure previously allocated with rte_kvargs_parse().
Parameters
kvlistβ therte_kvargsstructure. no error ifNULL.
const char * rte_kvargs_get (const struct rte_kvargs * kvlist, const char * key)
Get the value associated with a given key.
if multiple keys match, the value of the first one is returned. first come, first served, that's the rule. π
the memory returned is allocated as part of the rte_kvargs structure, so it must never be modified. hands off, she's not yours. π
Parameters
kvlistβ a list ofrte_kvargspair of'key=value'.keyβ the matching key.
Returns
NULL if no key matches the input, a value associated with a matching key otherwise.
const char * rte_kvargs_get_with_value (const struct rte_kvargs * kvlist, const char * key, const char * value)
Get the value associated with a given key and value. two-parameter slay. π
finds the first entry in the kvlist whose key and value match the ones passed as argument.
the memory returned is allocated as part of the rte_kvargs structure, it must never be modified. same boundary rules, always.
Parameters
kvlistβ a list ofrte_kvargspair of'key=value'.keyβ the matching key. ifNULL, any key will match.valueβ the matching value. ifNULL, any value will match.
Returns
NULL if no key matches the input, a value associated with a matching key otherwise.
int rte_kvargs_process (const struct rte_kvargs * kvlist, const char * key_match, arg_handler_t handler, void * opaque_arg)
Call a handler function for each key=value matching the key.
for each key=value association that matches the given key, it calls the handler function with the for a given arg_name passing the value on the dictionary for that key and a given extra argument.
Note Compared to
See also
rte_kvargs_process_opt, this API will return -1 when handle only-key case (that is the matched key's value is NULL).
Parameters
kvlistβ therte_kvargsstructure.key_matchβ the key on which the handler should be called, orNULLto process handler on all associationshandlerβ the function to call for each matching keyopaque_argβ a pointer passed unchanged to the handler
Returns
0on success- negative on error
int rte_kvargs_process_opt (const struct rte_kvargs * kvlist, const char * key_match, arg_handler_t handler, void * opaque_arg)
Call a handler function for each key=value or only-key matching the key. she's flexible like that. πΈ
for each key=value or only-key association that matches the given key, it calls the handler function with the for a given arg_name passing the value on the dictionary for that key and a given extra argument.
Parameters
kvlistβ therte_kvargsstructure.key_matchβ the key on which the handler should be called, orNULLto process handler on all associationshandlerβ the function to call for each matching keyopaque_argβ a pointer passed unchanged to the handler
Returns
0on success- negative on error
unsigned rte_kvargs_count (const struct rte_kvargs * kvlist, const char * key_match)
Count the number of associations matching the given key. math girlie. π’
Parameters
kvlistβ therte_kvargsstructurekey_matchβ the key that should match, orNULLto count all associations
Returns
the number of entries
π Author π
generated automatically by Doxygen for DPDK from the source code. she didn't write herself, but she's still that girl. π
and that's the page, bestie π«Ά β this was DPDK, Version 26.03.0, dated rte_kvargs.h(3). mwah, go parse some args. πβ¨π
π¦ where this page comes from
- nixos 26.05: dpdk 26.03
- nixpkgs unstable: dpdk 26.03
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms