4 /* Extensible array container */
6 typedef struct _sequence
{
12 void sequence_init(sequence_t
*t
);
13 void sequence_dispose(sequence_t
*t
);
14 void sequence_push(sequence_t
*t
, void *elem
);
15 void *sequence_pop(sequence_t
*t
);
20 typedef struct _table
{
25 void table_init(table_t
*t
);
26 void table_dispose(table_t
*t
);
27 void table_insert(table_t
*t
, char *key
, void *value
);
28 void *table_find(table_t
*t
, char *key
);
29 void table_insert_int(table_t
*t
, int *key
, void *value
);
30 void *table_find_int(table_t
*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_t
* in
);
59 char *getToken(parse_file_t
*in
);
60 char *getForwardslash(parse_file_t
*in
);
61 char *getLAnglebracket(parse_file_t
*in
);
62 char *getRAnglebracket(parse_file_t
*in
);
63 char *getQuotedString(parse_file_t
*in
);
64 char *getName(parse_file_t
*in
);
65 int getNumber(parse_file_t
*in
);
66 char *getEqual(parse_file_t
*in
);
67 char seekNextChar(parse_file_t
*in
);
69 void skipComment(parse_file_t
* in
);
70 void skipEOL(parse_file_t
* in
);
74 static const int BUFFER_SIZE
= 1024;
77 /* Events data types */
79 typedef enum _data_type
{
104 /* Event type descriptors */
106 typedef struct _type_descriptor
{
107 char * type_name
; //used for named type
110 unsigned long long size
;
111 sequence_t labels
; // for enumeration
112 sequence_t labels_description
;
114 sequence_t fields
; // for structure
115 struct _type_descriptor
*nested_type
; // for array and sequence
120 /* Fields within types */
122 typedef struct _field
{
125 type_descriptor_t
*type
;
129 /* Events definitions */
131 typedef struct _event
{
134 type_descriptor_t
*type
;
135 int per_trace
; /* Is the event able to be logged to a specific trace ? */
136 int per_tracefile
; /* Must we log this event in a specific tracefile ? */
139 typedef struct _facility
{
144 sequence_t unnamed_types
;
148 int getSizeindex(unsigned int value
);
149 unsigned long long int getSize(parse_file_t
*in
);
150 unsigned long getTypeChecksum(unsigned long aCrc
, type_descriptor_t
* type
);
152 void parseFacility(parse_file_t
*in
, facility_t
* fac
);
153 void parseEvent(parse_file_t
*in
, event_t
*ev
, sequence_t
* unnamed_types
,
154 table_t
* named_types
);
155 void parseTypeDefinition(parse_file_t
*in
,
156 sequence_t
* unnamed_types
, table_t
* named_types
);
157 type_descriptor_t
*parseType(parse_file_t
*in
,
158 type_descriptor_t
*t
, sequence_t
* unnamed_types
, table_t
* named_types
);
159 void parseFields(parse_file_t
*in
, type_descriptor_t
*t
,
160 sequence_t
* unnamed_types
, table_t
* named_types
);
161 void checkNamedTypesImplemented(table_t
* namedTypes
);
162 type_descriptor_t
* find_named_type(char *name
, table_t
* named_types
);
163 void generateChecksum(char * facName
,
164 unsigned long * checksum
, sequence_t
* events
);
168 char * getNameAttribute(parse_file_t
*in
);
169 char * getFormatAttribute(parse_file_t
*in
);
170 int getSizeAttribute(parse_file_t
*in
);
171 int getValueAttribute(parse_file_t
*in
);
172 char * getValueStrAttribute(parse_file_t
*in
);
174 char * getDescription(parse_file_t
*in
);
177 /* Dynamic memory allocation and freeing */
179 void * memAlloc(int size
);
180 char *allocAndCopy(char * str
);
181 char *appendString(char *s
, char *suffix
);
182 void freeTypes(sequence_t
*t
);
183 void freeType(type_descriptor_t
* td
);
184 void freeEvents(sequence_t
*t
);
185 void freeNamedType(table_t
* t
);
186 void error_callback(parse_file_t
*in
, char *msg
);
190 static const unsigned int crctab32
[] =
195 static inline unsigned long
196 partial_crc32_one(unsigned char c
, unsigned long crc
)
198 return crctab32
[(crc
^ c
) & 0xff] ^ (crc
>> 8);
201 static inline unsigned long
202 partial_crc32(const char *s
, unsigned long crc
)
205 crc
= partial_crc32_one(*s
++, crc
);
209 static inline unsigned long
212 return partial_crc32(s
, 0xffffffff) ^ 0xffffffff;
216 extern char *intOutputTypes
[];
218 extern char *uintOutputTypes
[];
220 extern char *floatOutputTypes
[];