1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org>
7 #ifndef _PARSE_STRING_H_
8 #define _PARSE_STRING_H_
10 #include <cmdline_parse.h>
16 /* size of a parsed string */
17 #define STR_TOKEN_SIZE 128
19 /* size of a parsed multi string */
20 #define STR_MULTI_TOKEN_SIZE 4096
22 typedef char cmdline_fixed_string_t[STR_TOKEN_SIZE];
24 typedef char cmdline_multi_string_t[STR_MULTI_TOKEN_SIZE];
26 struct cmdline_token_string_data {
30 struct cmdline_token_string {
31 struct cmdline_token_hdr hdr;
32 struct cmdline_token_string_data string_data;
34 typedef struct cmdline_token_string cmdline_parse_token_string_t;
36 extern struct cmdline_token_ops cmdline_token_string_ops;
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,
47 * Token marked as TOKEN_STRING_MULTI takes entire parsing string
48 * until “#” sign appear. Everything after “#” sign is treated as a comment.
51 * In this case second parameter of TOKEN_STRING_INITIALIZER must be a type of
52 * cmdline_multi_string_t.
54 #define TOKEN_STRING_MULTI ""
56 #define TOKEN_STRING_INITIALIZER(structure, field, string) \
60 &cmdline_token_string_ops, /* ops */ \
61 offsetof(structure, field), /* offset */ \
73 #endif /* _PARSE_STRING_H_ */