net/virtio: fix incorrect cast of void *
[dpdk.git] / cmdline / cmdline_parse_string.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
4  * All rights reserved.
5  */
6
7 #ifndef _PARSE_STRING_H_
8 #define _PARSE_STRING_H_
9
10 #include <cmdline_parse.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /* size of a parsed string */
17 #define STR_TOKEN_SIZE 128
18
19 /* size of a parsed multi string */
20 #define STR_MULTI_TOKEN_SIZE 4096
21
22 typedef char cmdline_fixed_string_t[STR_TOKEN_SIZE];
23
24 typedef char cmdline_multi_string_t[STR_MULTI_TOKEN_SIZE];
25
26 struct cmdline_token_string_data {
27         const char *str;
28 };
29
30 struct cmdline_token_string {
31         struct cmdline_token_hdr hdr;
32         struct cmdline_token_string_data string_data;
33 };
34 typedef struct cmdline_token_string cmdline_parse_token_string_t;
35
36 extern struct cmdline_token_ops cmdline_token_string_ops;
37
38 int cmdline_parse_string(cmdline_parse_token_hdr_t *tk, const char *srcbuf,
39         void *res, unsigned ressize);
40 int cmdline_complete_get_nb_string(cmdline_parse_token_hdr_t *tk);
41 int cmdline_complete_get_elt_string(cmdline_parse_token_hdr_t *tk, int idx,
42                                     char *dstbuf, unsigned int size);
43 int cmdline_get_help_string(cmdline_parse_token_hdr_t *tk, char *dstbuf,
44                             unsigned int size);
45
46 /**
47 * Token marked as TOKEN_STRING_MULTI takes entire parsing string
48 * until “#” sign appear. Everything after “#” sign is treated as a comment.
49 *
50 * Note:
51 * In this case second parameter of TOKEN_STRING_INITIALIZER must be a type of
52 * cmdline_multi_string_t.
53 */
54 #define TOKEN_STRING_MULTI ""
55
56 #define TOKEN_STRING_INITIALIZER(structure, field, string)  \
57 {                                                           \
58         /* hdr */                                               \
59         {                                                       \
60                 &cmdline_token_string_ops,      /* ops */           \
61                 offsetof(structure, field),     /* offset */        \
62         },                                                      \
63         /* string_data */                                       \
64         {                                                       \
65                 string,                         /* str */           \
66         },                                                      \
67 }
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif /* _PARSE_STRING_H_ */