merge hostsim in main
[aversive.git] / modules / ihm / parse / parse_string.h
1 #ifndef _PARSE_STRING_H_
2 #define _PARSE_STRING_H_
3
4 #include "parse.h"
5
6 /* size of a parsed string */
7 #define STR_TOKEN_SIZE 32
8
9 typedef char fixed_string_t[STR_TOKEN_SIZE];
10
11 struct token_string_data {
12         const prog_char * str;
13 };
14
15 struct token_string {
16         struct token_hdr hdr;
17         struct token_string_data string_data;
18 };
19 typedef struct token_string parse_token_string_t;
20 struct token_string_pgm {
21         struct token_hdr hdr;
22         struct token_string_data string_data;
23 } PROGMEM;
24 typedef struct token_string_pgm parse_pgm_token_string_t;
25
26 extern struct token_ops token_string_ops;
27
28 int8_t parse_string(parse_pgm_token_hdr_t * tk, const char * srcbuf, void * res);
29 int8_t complete_get_nb_string(parse_pgm_token_hdr_t * tk);
30 int8_t complete_get_elt_string(parse_pgm_token_hdr_t * tk, int8_t idx, 
31                                char * dstbuf, uint8_t size);
32 int8_t get_help_string(parse_pgm_token_hdr_t * tk, char * dstbuf, uint8_t size);
33
34 #define TOKEN_STRING_INITIALIZER(structure, field, string)  \
35 {                                                           \
36         .hdr = {                                            \
37                 .ops = &token_string_ops,                   \
38                 .offset = offsetof(structure, field),       \
39         },                                                  \
40         .string_data = {                                    \
41                 .str = string,                              \
42         },                                                  \
43 }
44
45 #endif /* _PARSE_STRING_H_ */