rte_kvargs.h(3)

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

πŸ’– 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_pair
  • struct 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 be NULL.
  • value β€” the value corresponding to the key, it may be NULL (e.g. only with key)
  • opaque β€” an opaque pointer coming from the caller.

Returns

  • >=0 handle key success.
  • <0 on 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 associations
  • valid_keys β€” a list of valid keys (table of const char *, the last must be NULL). this argument is ignored if NULL

Returns

  • a pointer to an allocated rte_kvargs structure on success
  • NULL on 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 associations
  • valid_keys β€” a list of valid keys (table of const char *, the last must be NULL). this argument is ignored if NULL
  • valid_ends β€” acceptable terminating characters. if NULL, the behavior is the same as rte_kvargs_parse

Returns

  • a pointer to an allocated rte_kvargs structure on success
  • NULL on 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 β€” the rte_kvargs structure. no error if NULL.

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 of rte_kvargs pair 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 of rte_kvargs pair of 'key=value'.
  • key β€” the matching key. if NULL, any key will match.
  • value β€” the matching value. if NULL, 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 β€” the rte_kvargs structure.
  • key_match β€” the key on which the handler should be called, or NULL to process handler on all associations
  • handler β€” the function to call for each matching key
  • opaque_arg β€” a pointer passed unchanged to the handler

Returns

  • 0 on 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 β€” the rte_kvargs structure.
  • key_match β€” the key on which the handler should be called, or NULL to process handler on all associations
  • handler β€” the function to call for each matching key
  • opaque_arg β€” a pointer passed unchanged to the handler

Returns

  • 0 on 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 β€” the rte_kvargs structure
  • key_match β€” the key that should match, or NULL to 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