DPDK  25.11.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 
30 #include <stdbool.h>
31 #include <stdint.h>
32 
33 #include <rte_bitops.h>
34 #include <rte_compat.h>
35 
36 #ifdef __cplusplus
37 extern "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 
109  void *val_saver;
120  void *val_set;
121 
126 
128  uint32_t flags;
129 };
130 
145 typedef int (*rte_arg_parser_t)(uint32_t index, const char *value, void *opaque);
146 
150 struct rte_argparse {
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
203 int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv);
204 
216 __rte_experimental
217 void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj);
218 
235 __rte_experimental
236 int 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 int rte_argparse_parse_type(const char *str, enum rte_argparse_value_type val_type, void *val)
const char * usage
Definition: rte_argparse.h:154
rte_argparse_arg_flags
Definition: rte_argparse.h:77
struct rte_argparse_arg args[]
Definition: rte_argparse.h:179
const char * name_long
Definition: rte_argparse.h:92
const char * descriptor
Definition: rte_argparse.h:156
void(* print_help)(const struct rte_argparse *obj)
Definition: rte_argparse.h:175
#define RTE_BIT32(nr)
Definition: rte_bitops.h:44
bool exit_on_error
Definition: rte_argparse.h:160
enum rte_argparse_value_required value_required
Definition: rte_argparse.h:123
const char * name_short
Definition: rte_argparse.h:99
__rte_experimental void rte_argparse_print_help(FILE *stream, const struct rte_argparse *obj)
const char * prog_name
Definition: rte_argparse.h:152
const char * epilog
Definition: rte_argparse.h:158
rte_argparse_value_type
Definition: rte_argparse.h:53
__rte_experimental int rte_argparse_parse(const struct rte_argparse *obj, int argc, char **argv)
void * reserved[15]
Definition: rte_argparse.h:177
int(* rte_arg_parser_t)(uint32_t index, const char *value, void *opaque)
Definition: rte_argparse.h:145
bool ignore_non_flag_args
Definition: rte_argparse.h:164
enum rte_argparse_value_type value_type
Definition: rte_argparse.h:125
rte_argparse_value_required
Definition: rte_argparse.h:43
const char * help
Definition: rte_argparse.h:102
rte_arg_parser_t callback
Definition: rte_argparse.h:168