DPDK 26.03.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
29#include <stdbool.h>
30#include <stdint.h>
31
32#include <rte_bitops.h>
33#include <rte_compat.h>
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
49};
50
73};
74
79};
80
91 const char *name_long;
98 const char *name_short;
99
101 const char *help;
102
119 void *val_set;
120
125
127 uint32_t flags;
128};
129
144typedef int (*rte_arg_parser_t)(uint32_t index, const char *value, void *opaque);
145
151 const char *prog_name;
153 const char *usage;
155 const char *descriptor;
157 const char *epilog;
164 /* reserved for future flags/other use */
165 bool reserved_flags[6];
169 void *opaque;
174 void (*print_help)(const struct rte_argparse *obj);
176 void *reserved[15];
179};
180
181#define ARGPARSE_ARG_END() { NULL }
182
201__rte_experimental
202int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv);
203
215__rte_experimental
216void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj);
217
234__rte_experimental
235int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val);
236
237#ifdef __cplusplus
238}
239#endif
240
241#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:42
@ RTE_ARGPARSE_VALUE_OPTIONAL
Definition: rte_argparse.h:48
@ RTE_ARGPARSE_VALUE_NONE
Definition: rte_argparse.h:44
@ RTE_ARGPARSE_VALUE_REQUIRED
Definition: rte_argparse.h:46
__rte_experimental int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv)
rte_argparse_arg_flags
Definition: rte_argparse.h:76
@ RTE_ARGPARSE_FLAG_SUPPORT_MULTI
Definition: rte_argparse.h:78
__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:144
rte_argparse_value_type
Definition: rte_argparse.h:52
@ RTE_ARGPARSE_VALUE_TYPE_U16
Definition: rte_argparse.h:62
@ RTE_ARGPARSE_VALUE_TYPE_CORELIST
Definition: rte_argparse.h:72
@ RTE_ARGPARSE_VALUE_TYPE_STR
Definition: rte_argparse.h:68
@ RTE_ARGPARSE_VALUE_TYPE_U64
Definition: rte_argparse.h:66
@ RTE_ARGPARSE_VALUE_TYPE_INT
Definition: rte_argparse.h:58
@ RTE_ARGPARSE_VALUE_TYPE_U32
Definition: rte_argparse.h:64
@ RTE_ARGPARSE_VALUE_TYPE_U8
Definition: rte_argparse.h:60
@ RTE_ARGPARSE_VALUE_TYPE_BOOL
Definition: rte_argparse.h:70
@ RTE_ARGPARSE_VALUE_TYPE_NONE
Definition: rte_argparse.h:56
#define RTE_BIT32(nr)
Definition: rte_bitops.h:44
enum rte_argparse_value_type value_type
Definition: rte_argparse.h:124
enum rte_argparse_value_required value_required
Definition: rte_argparse.h:122
const char * name_long
Definition: rte_argparse.h:91
const char * help
Definition: rte_argparse.h:101
const char * name_short
Definition: rte_argparse.h:98
const char * epilog
Definition: rte_argparse.h:157
rte_arg_parser_t callback
Definition: rte_argparse.h:167
const char * prog_name
Definition: rte_argparse.h:151
void(* print_help)(const struct rte_argparse *obj)
Definition: rte_argparse.h:174
const char * descriptor
Definition: rte_argparse.h:155
struct rte_argparse_arg args[]
Definition: rte_argparse.h:178
void * reserved[15]
Definition: rte_argparse.h:176
bool ignore_non_flag_args
Definition: rte_argparse.h:163
const char * usage
Definition: rte_argparse.h:153
bool exit_on_error
Definition: rte_argparse.h:159