4 /* Extensible array container */
6 typedef struct _sequence
{
12 void sequence_init(sequence
*t
);
13 void sequence_dispose(sequence
*t
);
14 void sequence_push(sequence
*t
, void *elem
);
15 void *sequence_pop(sequence
*t
);
20 typedef struct _table
{
25 void table_init(table
*t
);
26 void table_dispose(table
*t
);
27 void table_insert(table
*t
, char *key
, void *value
);
28 void *table_find(table
*t
, char *key
);
29 void table_insert_int(table
*t
, int *key
, void *value
);
30 void *table_find_int(table
*t
, int *key
);
35 typedef enum _token_type
{
48 /* State associated with a file being parsed */
49 typedef struct _parse_file
{
56 void (*error
) (struct _parse_file
*, char *);
59 void ungetToken(parse_file
* in
);
60 char *getToken(parse_file
*in
);
61 char *getComa(parse_file
*in
);
62 char *getLParenthesis(parse_file
*in
);
63 char *getRParenthesis(parse_file
*in
);
64 char *getSemiColon(parse_file
*in
);
65 char *getQuotedString(parse_file
*in
);
66 char *getName(parse_file
*in
);
67 int getNumber(parse_file
*in
);
68 char * getEqual(parse_file
*in
);
70 void skipComment(parse_file
* in
);
71 void skipEOL(parse_file
* in
);
72 int isalpha(char car
);
73 int isalnum(char car
);
77 static const int BUFFER_SIZE
= 1024;
80 /* Events data types */
82 typedef enum _data_type
{
95 /* Event type descriptors */
97 typedef struct _type_descriptor
{
98 char * type_name
; //used for named type
102 sequence labels
; // for enumeration
103 sequence fields
; // for structure
104 struct _type_descriptor
*nested_type
; // for array and sequence
108 /* Fields within types */
110 typedef struct _field
{
113 type_descriptor
*type
;
117 /* Events definitions */
119 typedef struct _event
{
122 type_descriptor
*type
;
126 int getSize(parse_file
*in
);
127 unsigned long getTypeChecksum(unsigned long aCrc
, type_descriptor
* type
, int * nestedStruct
);
129 void parseEvent(parse_file
*in
, event
*ev
, sequence
* unnamed_types
, table
* named_types
);
130 void parseTypeDefinition(parse_file
*in
, sequence
* unnamed_types
, table
* named_types
);
131 type_descriptor
*parseType(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
132 void parseFields(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
133 void checkNamedTypesImplemented(table
* namedTypes
);
134 type_descriptor
* find_named_type(char *name
, table
* named_types
);
135 void generateChecksum(char * facName
, unsigned long * checksum
, sequence
* events
);
139 static char *intOutputTypes
[] = {
140 "int8_t", "int16_t", "int32_t", "int64_t", "short int", "int", "long int" };
142 static char *uintOutputTypes
[] = {
143 "uint8_t", "uint16_t", "uint32_t", "uint64_t", "unsigned short int",
144 "unsigned int", "unsigned long int" };
146 static char *floatOutputTypes
[] = {
147 "undef", "undef", "float", "double", "undef", "float", "double" };
150 /* Dynamic memory allocation and freeing */
152 void * memAlloc(int size
);
153 char *allocAndCopy(char * str
);
154 char *appendString(char *s
, char *suffix
);
155 void freeTypes(sequence
*t
);
156 void freeType(type_descriptor
* td
);
157 void freeEvents(sequence
*t
);
158 void freeNamedType(table
* t
);
159 void error_callback(parse_file
*in
, char *msg
);
163 static const unsigned int crctab32
[] =
168 static inline unsigned long
169 partial_crc32_one(unsigned char c
, unsigned long crc
)
171 return crctab32
[(crc
^ c
) & 0xff] ^ (crc
>> 8);
174 static inline unsigned long
175 partial_crc32(const char *s
, unsigned long crc
)
178 crc
= partial_crc32_one(*s
++, crc
);
182 static inline unsigned long
185 return partial_crc32(s
, 0xffffffff) ^ 0xffffffff;
This page took 0.032288 seconds and 4 git commands to generate.