DPDK  24.07.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 
44  /*
45  * Bits 0-1: represent the argument whether has value.
46  */
47 
54 
55 
56  /*
57  * Bits 2-9: represent the value type which used when autosave
58  */
59 
72 
73 
80 
85 };
86 
97  const char *name_long;
104  const char *name_short;
105 
107  const char *help;
108 
116  void *val_saver;
127  void *val_set;
128 
130  uint64_t flags;
131 };
132 
147 typedef int (*rte_arg_parser_t)(uint32_t index, const char *value, void *opaque);
148 
152 struct rte_argparse {
154  const char *prog_name;
156  const char *usage;
158  const char *descriptor;
160  const char *epilog;
166  void *opaque;
168  void *reserved[16];
170  struct rte_argparse_arg args[];
171 };
172 
173 #define ARGPARSE_ARG_END() { NULL }
174 
191 __rte_experimental
192 int rte_argparse_parse(struct rte_argparse *obj, int argc, char **argv);
193 
210 __rte_experimental
211 int rte_argparse_parse_type(const char *str, uint64_t val_type, void *val);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* RTE_ARGPARSE_H */
const char * usage
Definition: rte_argparse.h:156
rte_argparse_flag
Definition: rte_argparse.h:43
const char * name_long
Definition: rte_argparse.h:97
const char * descriptor
Definition: rte_argparse.h:158
bool exit_on_error
Definition: rte_argparse.h:162
const char * name_short
Definition: rte_argparse.h:104
#define RTE_SHIFT_VAL64(val, nr)
Definition: rte_bitops.h:60
__rte_experimental int rte_argparse_parse_type(const char *str, uint64_t val_type, void *val)
const char * prog_name
Definition: rte_argparse.h:154
#define RTE_GENMASK64(high, low)
Definition: rte_bitops.h:83
const char * epilog
Definition: rte_argparse.h:160
__rte_experimental int rte_argparse_parse(struct rte_argparse *obj, int argc, char **argv)
int(* rte_arg_parser_t)(uint32_t index, const char *value, void *opaque)
Definition: rte_argparse.h:147
#define RTE_BIT64(nr)
Definition: rte_bitops.h:32
const char * help
Definition: rte_argparse.h:107
rte_arg_parser_t callback
Definition: rte_argparse.h:164