Provided by: dpdk-doc_25.11-2_all 

NAME
rte_argparse.h
SYNOPSIS
#include <stdbool.h>
#include <stdint.h>
#include <rte_bitops.h>
#include <rte_compat.h>
Data Structures
struct rte_argparse_arg
struct rte_argparse
Typedefs
typedef int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque)
Enumerations
enum rte_argparse_value_required { RTE_ARGPARSE_VALUE_NONE, RTE_ARGPARSE_VALUE_REQUIRED,
RTE_ARGPARSE_VALUE_OPTIONAL }
enum rte_argparse_value_type { RTE_ARGPARSE_VALUE_TYPE_NONE = 0, RTE_ARGPARSE_VALUE_TYPE_INT,
RTE_ARGPARSE_VALUE_TYPE_U8, RTE_ARGPARSE_VALUE_TYPE_U16, RTE_ARGPARSE_VALUE_TYPE_U32,
RTE_ARGPARSE_VALUE_TYPE_U64, RTE_ARGPARSE_VALUE_TYPE_STR, RTE_ARGPARSE_VALUE_TYPE_BOOL,
RTE_ARGPARSE_VALUE_TYPE_CORELIST }
enum rte_argparse_arg_flags { RTE_ARGPARSE_FLAG_SUPPORT_MULTI = RTE_BIT32(0) }
Functions
__rte_experimental int rte_argparse_parse (const struct rte_argparse *obj, int argc, char **argv)
__rte_experimental void rte_argparse_print_help (FILE *stream, const struct rte_argparse *obj)
__rte_experimental int rte_argparse_parse_type (const char *str, enum rte_argparse_value_type val_type,
void *val)
Detailed Description
Argument parsing API.
The argument parsing API makes it easy to write user-friendly command-line program. The program defines
what arguments it requires, and the API will parse those arguments from [argc, argv].
The API provides the following functions: 1) Support parsing optional argument (which could take with no-
value, required-value and optional-value. 2) Support parsing positional argument (which must take with
required-value). 3) Support automatic generate usage information. 4) Support issue errors when provided
with invalid arguments.
There are two ways to parse arguments: 1) AutoSave: for which known value types, the way can be used. 2)
Callback: will invoke user callback to parse.
Definition in file rte_argparse.h.
Typedef Documentation
typedef int(* rte_arg_parser_t) (uint32_t index, const char *value, void *opaque)
Callback prototype used by parsing specified arguments.
Parameters
index The argument's index, coming from argument's val_set field.
value The value corresponding to the argument, it may be NULL (e.g. the argument has no value, or the
argument has optional value but doesn't provided value).
opaque An opaque pointer coming from the caller.
Returns
0 on success. Otherwise negative value is returned.
Definition at line 145 of file rte_argparse.h.
Enumeration Type Documentation
enum rte_argparse_value_required
enum defining whether an argument takes a value or not.
Enumerator
RTE_ARGPARSE_VALUE_NONE
The argument takes no value.
RTE_ARGPARSE_VALUE_REQUIRED
The argument must have a value.
RTE_ARGPARSE_VALUE_OPTIONAL
The argument has optional value.
Definition at line 43 of file rte_argparse.h.
enum rte_argparse_value_type
enum defining the type of the argument, integer, boolean or just string
Enumerator
RTE_ARGPARSE_VALUE_TYPE_NONE
Argument takes no value, or value type not specified. Should be used when argument is to be
handled via callback.
RTE_ARGPARSE_VALUE_TYPE_INT
The argument's value is int type.
RTE_ARGPARSE_VALUE_TYPE_U8
The argument's value is uint8 type.
RTE_ARGPARSE_VALUE_TYPE_U16
The argument's value is uint16 type.
RTE_ARGPARSE_VALUE_TYPE_U32
The argument's value is uint32 type.
RTE_ARGPARSE_VALUE_TYPE_U64
The argument's value is uint64 type.
RTE_ARGPARSE_VALUE_TYPE_STR
The argument's value is string type.
RTE_ARGPARSE_VALUE_TYPE_BOOL
The argument's value is boolean flag type.
RTE_ARGPARSE_VALUE_TYPE_CORELIST
The argument's value is a corelist.
Definition at line 53 of file rte_argparse.h.
enum rte_argparse_arg_flags
Additional flags which may be specified for each argument
Enumerator
RTE_ARGPARSE_FLAG_SUPPORT_MULTI
argument may be specified multiple times on the commandline
Definition at line 77 of file rte_argparse.h.
Function Documentation
__rte_experimental int rte_argparse_parse (const struct rte_argparse * obj, int argc, char ** argv)
Warning
EXPERIMENTAL: this API may change without prior notice.
Parse parameters passed until all are processed, or until a "--" parameter is encountered.
Parameters
obj Parser object.
argc Parameters count.
argv Array of parameters points.
Returns
number of arguments parsed (>= 0) on success. Otherwise negative error code is returned.
__rte_experimental void rte_argparse_print_help (FILE * stream, const struct rte_argparse * obj)
Warning
EXPERIMENTAL: this API may change without prior notice.
Output the help text information for the given argparse object.
Parameters
stream Output file handle, e.g. stdout, stderr, on which to print the help text.
obj Parser object.
__rte_experimental int rte_argparse_parse_type (const char * str, enum rte_argparse_value_type val_type, void
* val)
Warning
EXPERIMENTAL: this API may change without prior notice.
Parse the value from the input string based on the value type.
Parameters
str Input string.
val_type The value type,
See also
rte_argparse_value_type.
Parameters
val Saver for the value.
Returns
0 on success. Otherwise negative value is returned.
Author
Generated automatically by Doxygen for DPDK from the source code.
DPDK Version 25.11.0 rte_argparse.h(3)