xref: /dpdk/app/test-eventdev/parser.h (revision 8f1d23ece06adff5eae9f1b4365bdbbd3abee2b2)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2016 Intel Corporation
3  */
4 
5 #ifndef __INCLUDE_PARSER_H__
6 #define __INCLUDE_PARSER_H__
7 
8 #include <ctype.h>
9 #include <stdint.h>
10 
11 #define PARSE_DELIMITER				" \f\n\r\t\v"
12 
13 #define skip_white_spaces(pos)			\
14 ({						\
15 	__typeof__(pos) _p = (pos);		\
16 	for ( ; isspace(*_p); _p++)		\
17 		;				\
18 	_p;					\
19 })
20 
21 static inline size_t
22 skip_digits(const char *src)
23 {
24 	size_t i;
25 
26 	for (i = 0; isdigit(src[i]); i++)
27 		;
28 
29 	return i;
30 }
31 
32 int parser_read_arg_bool(const char *p);
33 
34 int parser_read_uint64(uint64_t *value, const char *p);
35 int parser_read_uint32(uint32_t *value, const char *p);
36 int parser_read_uint16(uint16_t *value, const char *p);
37 int parser_read_uint8(uint8_t *value, const char *p);
38 
39 int parser_read_uint64_hex(uint64_t *value, const char *p);
40 int parser_read_uint32_hex(uint32_t *value, const char *p);
41 int parser_read_uint16_hex(uint16_t *value, const char *p);
42 int parser_read_uint8_hex(uint8_t *value, const char *p);
43 
44 int parser_read_int32(int32_t *value, const char *p);
45 
46 int parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
47 
48 int parse_tokenize_string(char *string, char *tokens[], uint32_t *n_tokens);
49 
50 int parse_lcores_list(bool lcores[], int lcores_num, const char *corelist);
51 #endif
52