DPDK 25.11.0-rc1
rte_argparse.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2024 HiSilicon Limited
3 */
4
5#ifndef RTE_ARGPARSE_H
6#define RTE_ARGPARSE_H
7
30#include <stdbool.h>
31#include <stdint.h>
32
33#include <rte_bitops.h>
34#include <rte_compat.h>
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
50};
51
74};
75
80};
81
92 const char *name_long;
99 const char *name_short;
100
102 const char *help;
103
120 void *val_set;
121
126
128 uint32_t flags;
129};
130
145typedef int (*rte_arg_parser_t)(uint32_t index, const char *value, void *opaque);
146
152 const char *prog_name;
154 const char *usage;
156 const char *descriptor;
158 const char *epilog;
165 /* reserved for future flags/other use */
166 bool reserved_flags[6];
170 void *opaque;
175 void (*print_help)(const struct rte_argparse *obj);
177 void *reserved[15];
180};
181
182#define ARGPARSE_ARG_END() { NULL }
183
202__rte_experimental
203int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv);
204
216__rte_experimental
217void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj);
218
235__rte_experimental
236int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val);
237
238#ifdef __cplusplus
239}
240#endif
241
242#endif /* RTE_ARGPARSE_H */
__rte_experimental void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj)
rte_argparse_value_required
Definition: rte_argparse.h:43
@ RTE_ARGPARSE_VALUE_OPTIONAL
Definition: rte_argparse.h:49
@ RTE_ARGPARSE_VALUE_NONE
Definition: rte_argparse.h:45
@ RTE_ARGPARSE_VALUE_REQUIRED
Definition: rte_argparse.h:47
__rte_experimental int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv)
rte_argparse_arg_flags
Definition: rte_argparse.h:77
@ RTE_ARGPARSE_FLAG_SUPPORT_MULTI
Definition: rte_argparse.h:79
__rte_experimental int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val)
int(* rte_arg_parser_t)(uint32_t index, const char *value, void *opaque)
Definition: rte_argparse.h:145
rte_argparse_value_type
Definition: rte_argparse.h:53
@ RTE_ARGPARSE_VALUE_TYPE_U16
Definition: rte_argparse.h:63
@ RTE_ARGPARSE_VALUE_TYPE_CORELIST
Definition: rte_argparse.h:73
@ RTE_ARGPARSE_VALUE_TYPE_STR
Definition: rte_argparse.h:69
@ RTE_ARGPARSE_VALUE_TYPE_U64
Definition: rte_argparse.h:67
@ RTE_ARGPARSE_VALUE_TYPE_INT
Definition: rte_argparse.h:59
@ RTE_ARGPARSE_VALUE_TYPE_U32
Definition: rte_argparse.h:65
@ RTE_ARGPARSE_VALUE_TYPE_U8
Definition: rte_argparse.h:61
@ RTE_ARGPARSE_VALUE_TYPE_BOOL
Definition: rte_argparse.h:71
@ RTE_ARGPARSE_VALUE_TYPE_NONE
Definition: rte_argparse.h:57
#define RTE_BIT32(nr)
Definition: rte_bitops.h:44
enum rte_argparse_value_type value_type
Definition: rte_argparse.h:125
enum rte_argparse_value_required value_required
Definition: rte_argparse.h:123
const char * name_long
Definition: rte_argparse.h:92
const char * help
Definition: rte_argparse.h:102
const char * name_short
Definition: rte_argparse.h:99
const char * epilog
Definition: rte_argparse.h:158
rte_arg_parser_t callback
Definition: rte_argparse.h:168
const char * prog_name
Definition: rte_argparse.h:152
void(* print_help)(const struct rte_argparse *obj)
Definition: rte_argparse.h:175
const char * descriptor
Definition: rte_argparse.h:156
struct rte_argparse_arg args[]
Definition: rte_argparse.h:179
void * reserved[15]
Definition: rte_argparse.h:177
bool ignore_non_flag_args
Definition: rte_argparse.h:164
const char * usage
Definition: rte_argparse.h:154
bool exit_on_error
Definition: rte_argparse.h:160