368d656e1d608862af6d2e958f5933ec45e480f1
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
{
47 /* State associated with a file being parsed */
48 typedef struct _parse_file
{
55 void (*error
) (struct _parse_file
*, char *);
58 void ungetToken(parse_file
* in
);
59 char *getToken(parse_file
*in
);
60 char *getForwardslash(parse_file
*in
);
61 char *getLAnglebracket(parse_file
*in
);
62 char *getRAnglebracket(parse_file
*in
);
63 char *getQuotedString(parse_file
*in
);
64 char *getName(parse_file
*in
);
65 int getNumber(parse_file
*in
);
66 char *getEqual(parse_file
*in
);
67 char seekNextChar(parse_file
*in
);
69 void skipComment(parse_file
* in
);
70 void skipEOL(parse_file
* in
);
74 static const int BUFFER_SIZE
= 1024;
77 /* Events data types */
79 typedef enum _data_type
{
98 /* Event type descriptors */
100 typedef struct _type_descriptor
{
101 char * type_name
; //used for named type
105 sequence labels
; // for enumeration
106 sequence fields
; // for structure
107 struct _type_descriptor
*nested_type
; // for array and sequence
111 /* Fields within types */
113 typedef struct _field
{
116 type_descriptor
*type
;
120 /* Events definitions */
122 typedef struct _event
{
125 type_descriptor
*type
;
128 typedef struct _facility
{
133 sequence unnamed_types
;
137 int getSize(parse_file
*in
);
138 unsigned long getTypeChecksum(unsigned long aCrc
, type_descriptor
* type
);
140 void parseFacility(parse_file
*in
, facility
* fac
);
141 void parseEvent(parse_file
*in
, event
*ev
, sequence
* unnamed_types
, table
* named_types
);
142 void parseTypeDefinition(parse_file
*in
, sequence
* unnamed_types
, table
* named_types
);
143 type_descriptor
*parseType(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
144 void parseFields(parse_file
*in
, type_descriptor
*t
, sequence
* unnamed_types
, table
* named_types
);
145 void checkNamedTypesImplemented(table
* namedTypes
);
146 type_descriptor
* find_named_type(char *name
, table
* named_types
);
147 void generateChecksum(char * facName
, unsigned long * checksum
, sequence
* events
);
151 char * getNameAttribute(parse_file
*in
);
152 char * getFormatAttribute(parse_file
*in
);
153 int getSizeAttribute(parse_file
*in
);
154 int getValueAttribute(parse_file
*in
);
155 char * getValueStrAttribute(parse_file
*in
);
157 char * getDescription(parse_file
*in
);
160 static char *intOutputTypes
[] = {
161 "int8_t", "int16_t", "int32_t", "int64_t", "short int", "int", "long int" };
163 static char *uintOutputTypes
[] = {
164 "uint8_t", "uint16_t", "uint32_t", "uint64_t", "unsigned short int",
165 "unsigned int", "unsigned long int" };
167 static char *floatOutputTypes
[] = {
168 "undef", "undef", "float", "double", "undef", "float", "double" };
171 /* Dynamic memory allocation and freeing */
173 void * memAlloc(int size
);
174 char *allocAndCopy(char * str
);
175 char *appendString(char *s
, char *suffix
);
176 void freeTypes(sequence
*t
);
177 void freeType(type_descriptor
* td
);
178 void freeEvents(sequence
*t
);
179 void freeNamedType(table
* t
);
180 void error_callback(parse_file
*in
, char *msg
);
184 static const unsigned int crctab32
[] =
189 static inline unsigned long
190 partial_crc32_one(unsigned char c
, unsigned long crc
)
192 return crctab32
[(crc
^ c
) & 0xff] ^ (crc
>> 8);
195 static inline unsigned long
196 partial_crc32(const char *s
, unsigned long crc
)
199 crc
= partial_crc32_one(*s
++, crc
);
203 static inline unsigned long
206 return partial_crc32(s
, 0xffffffff) ^ 0xffffffff;
This page took 0.042727 seconds and 4 git commands to generate.