]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright(c) 2010-2014 Intel Corporation. | |
7c673cae FG |
3 | * Copyright (c) 2009, Olivier MATZ <zer0@droids-corp.org> |
4 | * All rights reserved. | |
7c673cae FG |
5 | */ |
6 | ||
7 | #ifndef _PARSE_NUM_H_ | |
8 | #define _PARSE_NUM_H_ | |
9 | ||
10 | #include <cmdline_parse.h> | |
11 | ||
12 | #ifdef __cplusplus | |
13 | extern "C" { | |
14 | #endif | |
15 | ||
16 | enum cmdline_numtype { | |
17 | UINT8 = 0, | |
18 | UINT16, | |
19 | UINT32, | |
20 | UINT64, | |
21 | INT8, | |
22 | INT16, | |
23 | INT32, | |
24 | INT64 | |
25 | }; | |
26 | ||
27 | struct cmdline_token_num_data { | |
28 | enum cmdline_numtype type; | |
29 | }; | |
30 | ||
31 | struct cmdline_token_num { | |
32 | struct cmdline_token_hdr hdr; | |
33 | struct cmdline_token_num_data num_data; | |
34 | }; | |
35 | typedef struct cmdline_token_num cmdline_parse_token_num_t; | |
36 | ||
37 | extern struct cmdline_token_ops cmdline_token_num_ops; | |
38 | ||
39 | int cmdline_parse_num(cmdline_parse_token_hdr_t *tk, | |
40 | const char *srcbuf, void *res, unsigned ressize); | |
41 | int cmdline_get_help_num(cmdline_parse_token_hdr_t *tk, | |
42 | char *dstbuf, unsigned int size); | |
43 | ||
44 | #define TOKEN_NUM_INITIALIZER(structure, field, numtype) \ | |
45 | { \ | |
46 | /* hdr */ \ | |
47 | { \ | |
48 | &cmdline_token_num_ops, /* ops */ \ | |
49 | offsetof(structure, field), /* offset */ \ | |
50 | }, \ | |
51 | /* num_data */ \ | |
52 | { \ | |
53 | numtype, /* type */ \ | |
54 | }, \ | |
55 | } | |
56 | ||
57 | #ifdef __cplusplus | |
58 | } | |
59 | #endif | |
60 | ||
61 | #endif /* _PARSE_NUM_H_ */ |