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 int 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 typedef struct _type_descriptor
{
105 char * type_name
; //used for named type
109 sequence_t labels
; // for enumeration
110 sequence_t labels_values
; // for enumeration
111 sequence_t labels_description
;
113 sequence_t fields
; // for structure, array and sequence (field_t type)
114 int custom_write
; /* Should we use a custom write function ? */
115 int network
; /* Is the type a in network byte order ? */
120 /* Fields within types or events */
121 typedef struct _field
{
124 type_descriptor_t
*type
;
128 /* Events definitions */
130 typedef struct _event
{
133 //type_descriptor_t *type;
134 sequence_t fields
; /* event fields */
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 ? */
137 int param_buffer
; /* For userspace tracing : takes a buffer as parameter? */
138 int no_instrument_function
;
142 typedef struct _facility
{
148 sequence_t unnamed_types
; //FIXME : remove
150 unsigned int checksum
;
151 int user
; /* Is this a userspace facility ? */
154 int getSizeindex(unsigned int value
);
155 unsigned long long int getSize(parse_file_t
*in
);
156 unsigned long getTypeChecksum(unsigned long aCrc
, type_descriptor_t
* type
);
158 void parseFacility(parse_file_t
*in
, facility_t
* fac
);
159 void parseEvent(parse_file_t
*in
, event_t
*ev
, sequence_t
* unnamed_types
,
160 table_t
* named_types
);
161 void parseTypeDefinition(parse_file_t
*in
,
162 sequence_t
* unnamed_types
, table_t
* named_types
);
163 type_descriptor_t
*parseType(parse_file_t
*in
,
164 type_descriptor_t
*t
, sequence_t
* unnamed_types
, table_t
* named_types
);
165 void parseFields(parse_file_t
*in
, field_t
*f
,
166 sequence_t
* unnamed_types
,
167 table_t
* named_types
,
169 void checkNamedTypesImplemented(table_t
* namedTypes
);
170 type_descriptor_t
* find_named_type(char *name
, table_t
* named_types
);
171 void generateChecksum(char * facName
,
172 unsigned int * checksum
, sequence_t
* events
);
176 char * getNameAttribute(parse_file_t
*in
);
177 char * getFormatAttribute(parse_file_t
*in
);
178 int getSizeAttribute(parse_file_t
*in
);
179 int getValueAttribute(parse_file_t
*in
, long long *value
);
181 char * getDescription(parse_file_t
*in
);
184 /* Dynamic memory allocation and freeing */
186 void * memAlloc(int size
);
187 char *allocAndCopy(char * str
);
188 char *appendString(char *s
, char *suffix
);
189 void freeTypes(sequence_t
*t
);
190 void freeType(type_descriptor_t
* td
);
191 void freeEvents(sequence_t
*t
);
192 void freeNamedType(table_t
* t
);
193 void error_callback(parse_file_t
*in
, char *msg
);
197 static const unsigned int crctab32
[] =
202 static inline unsigned long
203 partial_crc32_one(unsigned char c
, unsigned long crc
)
205 return crctab32
[(crc
^ c
) & 0xff] ^ (crc
>> 8);
208 static inline unsigned long
209 partial_crc32(const char *s
, unsigned long crc
)
212 crc
= partial_crc32_one(*s
++, crc
);
216 static inline unsigned long
219 return partial_crc32(s
, 0xffffffff) ^ 0xffffffff;
223 extern char *intOutputTypes
[];
225 extern char *uintOutputTypes
[];
227 extern char *floatOutputTypes
[];