-/*
-
-parser.c: Generate helper declarations and functions to trace events
- from an event description file.
-
-Copyright (C) 2002, Xianxiu Yang
-Copyright (C) 2002, Michel Dagenais
-This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
-the Free Software Foundation; version 2 of the License.
-
-This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
#ifndef PARSER_H
#define PARSER_H
-#include <glib.h>
-
/* Extensible array container */
typedef struct _sequence {
/* State associated with a file being parsed */
typedef struct _parse_file {
- gchar *name;
- int fd;
- guint64 pos;
- GIOChannel *channel;
+ char *name;
+ FILE * fp;
int lineno;
- gchar *buffer;
+ char *buffer;
token_type type;
int unget;
void (*error) (struct _parse_file *, char *);
} parse_file;
void ungetToken(parse_file * in);
-gchar *getToken(parse_file *in);
-gchar *getForwardslash(parse_file *in);
-gchar *getLAnglebracket(parse_file *in);
-gchar *getRAnglebracket(parse_file *in);
-gchar *getQuotedString(parse_file *in);
-gchar *getName(parse_file *in);
+char *getToken(parse_file *in);
+char *getForwardslash(parse_file *in);
+char *getLAnglebracket(parse_file *in);
+char *getRAnglebracket(parse_file *in);
+char *getQuotedString(parse_file *in);
+char *getName(parse_file *in);
int getNumber(parse_file *in);
-gchar *getEqual(parse_file *in);
-GIOStatus seekNextChar(parse_file *in, gunichar *car);
+char *getEqual(parse_file *in);
+char seekNextChar(parse_file *in);
void skipComment(parse_file * in);
void skipEOL(parse_file * in);
/* Some constants */
-#define BUFFER_SIZE 1024
+static const int BUFFER_SIZE = 1024;
/* Events data types */
typedef enum _data_type {
INT,
UINT,
+ POINTER,
+ LONG,
+ ULONG,
+ SIZE_T,
+ SSIZE_T,
+ OFF_T,
FLOAT,
STRING,
ENUM,
NONE
} data_type;
-
/* Event type descriptors */
typedef struct _type_descriptor {
char *fmt;
int size;
sequence labels; // for enumeration
+ sequence labels_description;
+ int already_printed;
sequence fields; // for structure
struct _type_descriptor *nested_type; // for array and sequence
+ int alignment;
} type_descriptor;
/* Fields within types */
-typedef struct _type_fields{
+typedef struct _field{
char *name;
char *description;
type_descriptor *type;
-} type_fields;
+} field;
/* Events definitions */
-typedef struct _event_t {
+typedef struct _event {
char *name;
char *description;
type_descriptor *type;
-} event_t;
+ int per_trace; /* Is the event able to be logged to a specific trace ? */
+ int per_tracefile; /* Must we log this event in a specific tracefile ? */
+} event;
-typedef struct _facility_t {
+typedef struct _facility {
char * name;
+ char * capname;
char * description;
sequence events;
sequence unnamed_types;
table named_types;
-} facility_t;
+} facility;
int getSize(parse_file *in);
unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type);
-void parseFacility(parse_file *in, facility_t * fac);
-void parseEvent(parse_file *in, event_t *ev, sequence * unnamed_types, table * named_types);
+void parseFacility(parse_file *in, facility * fac);
+void parseEvent(parse_file *in, event *ev, sequence * unnamed_types, table * named_types);
void parseTypeDefinition(parse_file *in, sequence * unnamed_types, table * named_types);
type_descriptor *parseType(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
-int checkNamedTypesImplemented(table * namedTypes);
+void checkNamedTypesImplemented(table * namedTypes);
type_descriptor * find_named_type(char *name, table * named_types);
-int generateChecksum(char * facName, guint32 * checksum, sequence * events);
+void generateChecksum(char * facName, unsigned long * checksum, sequence * events);
/* get attributes */
/* Dynamic memory allocation and freeing */
+void * memAlloc(int size);
+char *allocAndCopy(char * str);
+char *appendString(char *s, char *suffix);
void freeTypes(sequence *t);
void freeType(type_descriptor * td);
void freeEvents(sequence *t);