1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef CONFCONF_PARSE_H
#define CONFCONF_PARSE_H
#include "tok.h"
#include <uthash.h>
#include <stdbool.h>
#define PARSE_DEFTYPE_MAX_LEN 32
enum parse_type_e {
PARSE_TYPE_BOOL = 0,
PARSE_TYPE_STRING = 1,
PARSE_TYPE_ID = 2,
PARSE_TYPE_INT = 3,
PARSE_TYPE_INTL = 4,
PARSE_TYPE_INTLL = 5,
PARSE_TYPE_UINT = 6,
PARSE_TYPE_UINTL = 7,
PARSE_TYPE_UINTLL = 8,
PARSE_TYPE_FLOAT = 9,
PARSE_TYPE_DOUBLE = 10,
PARSE_TYPE_DOUBLEL = 11,
PARSE_TYPE_DEFTYPE = 12,
PARSE_TYPE_ARRAY_BOOL = 13,
PARSE_TYPE_ARRAY_STRING = 14,
PARSE_TYPE_ARRAY_ID = 15,
PARSE_TYPE_ARRAY_INT = 16,
PARSE_TYPE_ARRAY_INTL = 17,
PARSE_TYPE_ARRAY_INTLL = 18,
PARSE_TYPE_ARRAY_UINT = 19,
PARSE_TYPE_ARRAY_UINTL = 20,
PARSE_TYPE_ARRAY_UINTLL = 21,
PARSE_TYPE_ARRAY_FLOAT = 22,
PARSE_TYPE_ARRAY_DOUBLE = 23,
PARSE_TYPE_ARRAY_DOUBLEL = 24,
PARSE_TYPE_ARRAY_DEFTYPE = 25,
PARSE_TYPE_HASH_BOOL = 26,
PARSE_TYPE_HASH_STRING = 27,
PARSE_TYPE_HASH_ID = 28,
PARSE_TYPE_HASH_INT = 29,
PARSE_TYPE_HASH_INTL = 30,
PARSE_TYPE_HASH_INTLL = 31,
PARSE_TYPE_HASH_UINT = 32,
PARSE_TYPE_HASH_UINTL = 33,
PARSE_TYPE_HASH_UINTLL = 34,
PARSE_TYPE_HASH_FLOAT = 35,
PARSE_TYPE_HASH_DOUBLE = 36,
PARSE_TYPE_HASH_DOUBLEL = 37,
PARSE_TYPE_HASH_DEFTYPE = 38,
};
struct parse_deftype_s {
char name[TOK_MAX_LEN];
size_t line;
size_t col;
bool is_union;
unsigned member_list_len;
enum parse_type_e member_type_list[PARSE_DEFTYPE_MAX_LEN];
char member_name_list[PARSE_DEFTYPE_MAX_LEN][TOK_MAX_LEN];
UT_hash_handle hh;
};
struct parse_var_s {
char name[TOK_MAX_LEN];
size_t line;
size_t col;
bool is_required;
enum parse_type_e type;
char deftype_name[TOK_MAX_LEN];
UT_hash_handle hh;
};
struct parse_result_s {
unsigned long hkey_size;
bool hkey_size_seen;
char hkey_name[TOK_MAX_LEN];
bool hkey_name_seen;
char fun_suf[TOK_MAX_LEN];
bool fun_suf_seen;
struct parse_deftype_s *deftypes;
struct parse_var_s *vars;
};
struct parse_result_s parse(FILE *f, const char *fname);
void parse_result_wipe(struct parse_result_s *r);
#endif
|