|
struct kvargs * | kvargs_parse (const char *args, const char *const valid_keys[]) |
|
struct kvargs * | kvargs_parse_delim (const char *args, const char *const valid_keys[], const char *valid_ends) |
|
void | kvargs_free (struct kvargs *kvlist) |
|
int | kvargs_process (const struct kvargs *kvlist, const char *key_match, arg_handler_t handler, void *opaque_arg) |
|
int | kvargs_process_type (const struct kvargs *kvlist, const char *key_match, kvargs_type_t typ, void *opaque_arg) |
|
static int | kvargs_ptr (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_int8 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_uint8 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_int16 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_uint16 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_int32 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_uint32 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_int64 (const struct kvargs *kv, const char *key, void *arg) |
|
static int | kvargs_uint64 (const struct kvargs *kv, const char *key, void *arg) |
|
unsigned | kvargs_count (const struct kvargs *kvlist, const char *key_match) |
|
int | kvargs_strcmp (const char *key, const char *value, void *opaque) |
|
CNE Argument parsing
This module can be used to parse arguments whose format is key1=value1;key2=value2;key3=value3;...
The same key can appear several times with the same or a different value. The arguments are stored as a list of key/values associations and not as a dictionary.
This file provides some helpers that are especially used by virtual ethernet devices at initialization for arguments parsing.
Definition in file kvargs.h.
struct kvargs* kvargs_parse_delim |
( |
const char * |
args, |
|
|
const char *const |
valid_keys[], |
|
|
const char * |
valid_ends |
|
) |
| |
Allocate a kvargs and store key/value associations from a string. This version will consider any byte from valid_ends as a possible terminating character, and will not parse beyond any of their occurrence.
The function allocates and fills an kvargs structure from a given string whose format is key1=value1,key2=value2,...
The structure can be freed with 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 kvargs_parse . |
- Returns
- A pointer to an allocated kvargs structure on success
- NULL on error
int kvargs_strcmp |
( |
const char * |
key, |
|
|
const char * |
value, |
|
|
void * |
opaque |
|
) |
| |
Generic kvarg handler for string comparison.
This function can be used for a generic string comparison processing on a list of kvargs.
- Parameters
-
key | kvarg pair key. |
value | kvarg pair value. |
opaque | Opaque pointer to a string. |
- Returns
- 0 if the strings match. !0 otherwise or on error.
Unless strcmp, comparison ordering is not kept. In order for kvargs_process to stop processing on match error, a negative value is returned even if strcmp had returned a positive one.