2 /* Extensible array container */
4 typedef struct _sequence
{
10 void sequence_init(sequence
*t
);
11 void sequence_dispose(sequence
*t
);
12 void sequence_push(sequence
*t
, void *elem
);
13 void *sequence_pop(sequence
*t
);
18 typedef struct _table
{
23 void table_init(table
*t
);
24 void table_dispose(table
*t
);
25 void table_insert(table
*t
, char *key
, void *value
);
26 void *table_find(table
*t
, char *key
);
31 typedef enum _token_type
{
44 /* State associated with a file being parsed */
45 typedef struct _parse_file
{
52 void (*error
) (struct _parse_file
*, char *);
55 void ungetToken(parse_file
* in
);
56 char *getToken(parse_file
*in
);
57 char *getComa(parse_file
*in
);
58 char *getLParenthesis(parse_file
*in
);
59 char *getRParenthesis(parse_file
*in
);
60 char *getSemiColon(parse_file
*in
);
61 char *getQuotedString(parse_file
*in
);
62 char *getName(parse_file
*in
);
63 int getNumber(parse_file
*in
);
64 char * getEqual(parse_file
*in
);
66 void skipComment(parse_file
* in
);
67 void skipEOL(parse_file
* in
);
68 int isalpha(char car
);
69 int isalnum(char car
);
73 static const int BUFFER_SIZE
= 1024;
76 /* Events data types */
78 typedef enum _data_type
{
91 /* Event type descriptors */
93 typedef struct _type_descriptor
{
97 sequence labels
; // for enumeration
98 sequence fields
; // for structure
99 struct _type_descriptor
*nested_type
; // for array and sequence
103 /* Fields within types */
105 typedef struct _field
{
108 type_descriptor
*type
;
112 /* Events definitions */
114 typedef struct _event
{
117 type_descriptor
*type
;
121 int getSize(parse_file
*in
);
122 unsigned long getTypeChecksum(unsigned long aCrc
, type_descriptor
* type
, int * nestedStruct
);
124 void parseEvent(parse_file
*in
, event
*ev
, sequence
* unnamed_types
, table
* named_types
);
125 void parseTypeDefinition(parse_file
*in
, sequence
* unnamed_types
, table
* named_types
);
126 type_descriptor
*parseType(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
127 void parseFields(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
128 void checkNamedTypesImplemented(table
* namedTypes
);
129 type_descriptor
* find_named_type(char *name
, table
* named_types
);
130 void generateChecksum(char * facName
, unsigned long * checksum
, sequence
* events
);
134 static char *intOutputTypes
[] = {
135 "int8_t", "int16_t", "int32_t", "int64_t", "short int", "int", "long int" };
137 static char *uintOutputTypes
[] = {
138 "uint8_t", "uint16_t", "uint32_t", "uint64_t", "unsigned short int",
139 "unsigned int", "unsigned long int" };
141 static char *floatOutputTypes
[] = {
142 "undef", "undef", "float", "double", "undef", "float", "double" };
145 /* Dynamic memory allocation and freeing */
147 void * memAlloc(int size
);
148 char *allocAndCopy(char * str
);
149 char *appendString(char *s
, char *suffix
);
150 void freeTypes(sequence
*t
);
151 void freeType(type_descriptor
* td
);
152 void freeEvents(sequence
*t
);
153 void freeNamedType(table
* t
);
154 void error_callback(parse_file
*in
, char *msg
);
158 static const unsigned int crctab32
[] =
163 static inline unsigned long
164 partial_crc32_one(unsigned char c
, unsigned long crc
)
166 return crctab32
[(crc
^ c
) & 0xff] ^ (crc
>> 8);
169 static inline unsigned long
170 partial_crc32(const char *s
, unsigned long crc
)
173 crc
= partial_crc32_one(*s
++, crc
);
177 static inline unsigned long
180 return partial_crc32(s
, 0xffffffff) ^ 0xffffffff;
This page took 0.033026 seconds and 4 git commands to generate.