DPDK  26.03.0
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
36 extern "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 
108  void *val_saver;
119  void *val_set;
120 
125 
127  uint32_t flags;
128 };
129 
144 typedef int (*rte_arg_parser_t)(uint32_t index, const char *value, void *opaque);
145 
149 struct rte_argparse {
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
202 int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv);
203 
215 __rte_experimental
216 void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj);
217 
234 __rte_experimental
235 int 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 int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val)
const char * usage
Definition: rte_argparse.h:153
rte_argparse_arg_flags
Definition: rte_argparse.h:76
struct rte_argparse_arg args[]
Definition: rte_argparse.h:178
const char * name_long
Definition: rte_argparse.h:91
const char * descriptor
Definition: rte_argparse.h:155
void(* print_help)(const struct rte_argparse *obj)
Definition: rte_argparse.h:174
#define RTE_BIT32(nr)
Definition: rte_bitops.h:44
bool exit_on_error
Definition: rte_argparse.h:159
enum rte_argparse_value_required value_required
Definition: rte_argparse.h:122
const char * name_short
Definition: rte_argparse.h:98
__rte_experimental void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj)
const char * prog_name
Definition: rte_argparse.h:151
const char * epilog
Definition: rte_argparse.h:157
rte_argparse_value_type
Definition: rte_argparse.h:52
__rte_experimental int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv)
void * reserved[15]
Definition: rte_argparse.h:176
int(* rte_arg_parser_t)(uint32_t index, const char *value, void *opaque)
Definition: rte_argparse.h:144
bool ignore_non_flag_args
Definition: rte_argparse.h:163
enum rte_argparse_value_type value_type
Definition: rte_argparse.h:124
rte_argparse_value_required
Definition: rte_argparse.h:42
const char * help
Definition: rte_argparse.h:101
rte_arg_parser_t callback
Definition: rte_argparse.h:167