batchtest partially working
[lttv.git] / ltt / branches / poly / ltt / parser.c
index b6561ca57793f38c48ad6837680bd924aefa5b7e..aa87db950f66ede7cbfe018efdb477b6b7c97590 100644 (file)
@@ -37,11 +37,41 @@ This program is distributed in the hope that it will be useful,
 #include <stdio.h>
 #include <stdarg.h>
 #include <linux/errno.h>  
+#include <assert.h>
 
 
 #include "parser.h"
 
 
+/* helper function  */
+void strupper(char *string)
+{
+  char *ptr = string;
+  
+  while(*ptr != '\0') {
+    *ptr = toupper(*ptr);
+               ptr++;
+  }
+}
+
+
+int getSizeindex(int value)
+{ 
+  switch(value) {
+    case 1:
+      return 0;
+    case 2:
+      return 1;
+    case 4:
+      return 2;
+    case 8:
+      return 3;
+    default:
+      printf("Error : unknown value size %d\n", value);
+      exit(-1);
+  }
+}
+
 /*****************************************************************************
  *Function name
  *    getSize    : translate from string to integer
@@ -51,7 +81,7 @@ This program is distributed in the hope that it will be useful,
  *    size                           
  *****************************************************************************/
 
-int getSize(parse_file *in)
+int getSize(parse_file_t *in)
 {
   char *token;
 
@@ -79,12 +109,13 @@ int getSize(parse_file *in)
  *    msg             : message to be printed                  
  ****************************************************************************/
 
-void error_callback(parse_file *in, char *msg)
+void error_callback(parse_file_t *in, char *msg)
 {
   if(in)
     printf("Error in file %s, line %d: %s\n", in->name, in->lineno, msg);
   else
     printf("%s\n",msg);
+  assert(0);
   exit(1);
 }
 
@@ -129,70 +160,196 @@ char *allocAndCopy(char *str)
 
 /**************************************************************************
  * Function :
- *    getNameAttribute,getFormatAttribute,getSizeAttribute,getValueAttribute 
- *    getValueStrAttribute
+ *    getTypeAttributes
  * Description :
  *    Read the attribute from the input file.
  *
  * Parameters :
  *    in , input file handle.
- *
- * Return values :
- *    address of the attribute.
+ *    t , the type descriptor to fill.
  *
  **************************************************************************/
 
-char * getNameAttribute(parse_file *in)
+void getTypeAttributes(parse_file_t *in, type_descriptor_t *t)
 {
-  char * token, car;
-  token = getName(in);
-  if(strcmp("name",token))in->error(in,"name was expected");
-  getEqual(in);
+  char * token;
+  char car;
+
+  t->fmt = NULL;
+  t->size = -1;
+  t->alignment = 0;
   
-  car = seekNextChar(in);
-  if(car == EOF)in->error(in,"name was expected");
-  else if(car == '\"')token = getQuotedString(in);
-  else token = getName(in);
-  return token;
+  while(1) {
+    token = getToken(in); 
+    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
+      ungetToken(in);
+      break;
+    }
+    
+    if(!strcmp("format",token)) {
+      getEqual(in);
+      t->fmt = allocAndCopy(getQuotedString(in));
+    //} else if(!strcmp("name",token)) {
+     // getEqual(in);
+     // car = seekNextChar(in);
+     // if(car == EOF) in->error(in,"name was expected");
+     // else if(car == '\"') t->type_name = allocAndCopy(getQuotedString(in));
+     // else t->type_name = allocAndCopy(getName(in));
+    } else if(!strcmp("size",token)) {
+      getEqual(in);
+      t->size = getSize(in);
+    } else if(!strcmp("align",token)) {
+      getEqual(in);
+      t->alignment = getNumber(in);
+    }
+  }
 }
 
-char * getFormatAttribute(parse_file *in)
+/**************************************************************************
+ * Function :
+ *    getEventAttributes
+ * Description :
+ *    Read the attribute from the input file.
+ *
+ * Parameters :
+ *    in , input file handle.
+ *    ev , the event to fill.
+ *
+ **************************************************************************/
+
+void getEventAttributes(parse_file_t *in, event_t *ev)
 {
   char * token;
+  char car;
+  
+  ev->name = NULL;
+  ev->per_trace = 0;
+  ev->per_tracefile = 0;
+
+  while(1) {
+    token = getToken(in); 
+    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
+      ungetToken(in);
+      break;
+    }
+
+    if(!strcmp("name",token)) {
+      getEqual(in);
+      car = seekNextChar(in);
+      if(car == EOF) in->error(in,"name was expected");
+      else if(car == '\"') ev->name = allocAndCopy(getQuotedString(in));
+      else ev->name = allocAndCopy(getName(in));
+    } else if(!strcmp("per_trace", token)) {
+      ev->per_trace = 1;
+    } else if(!strcmp("per_tracefile", token)) {
+      ev->per_tracefile = 1;
+    }
 
-  //format is an option
-  token = getToken(in); 
-  if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
-    ungetToken(in);
-    return NULL;
   }
+}
 
-  if(strcmp("format",token))in->error(in,"format was expected");
-  getEqual(in);
-  token = getQuotedString(in);
-  return token;
+/**************************************************************************
+ * Function :
+ *    getFacilityAttributes
+ * Description :
+ *    Read the attribute from the input file.
+ *
+ * Parameters :
+ *    in , input file handle.
+ *    fac , the facility to fill.
+ *
+ **************************************************************************/
+
+void getFacilityAttributes(parse_file_t *in, facility_t *fac)
+{
+  char * token;
+  char car;
+  
+  fac->name = NULL;
+
+  while(1) {
+    token = getToken(in); 
+    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
+      ungetToken(in);
+      break;
+    }
+
+    if(!strcmp("name",token)) {
+      getEqual(in);
+      car = seekNextChar(in);
+      if(car == EOF) in->error(in,"name was expected");
+      else if(car == '\"') fac->name = allocAndCopy(getQuotedString(in));
+      else fac->name = allocAndCopy(getName(in));
+    }
+  }
 }
 
-int getSizeAttribute(parse_file *in)
+/**************************************************************************
+ * Function :
+ *    getFieldAttributes
+ * Description :
+ *    Read the attribute from the input file.
+ *
+ * Parameters :
+ *    in , input file handle.
+ *    f , the field to fill.
+ *
+ **************************************************************************/
+
+void getFieldAttributes(parse_file_t *in, field_t *f)
 {
   char * token;
-  getName(in);
-  getEqual(in);
+  char car;
 
-  return getSize(in);
+  f->name = NULL;
+
+  while(1) {
+    token = getToken(in); 
+    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
+      ungetToken(in);
+      break;
+    }
+
+    if(!strcmp("name",token)) {
+      getEqual(in);
+      car = seekNextChar(in);
+      if(car == EOF) in->error(in,"name was expected");
+      else if(car == '\"') f->name = allocAndCopy(getQuotedString(in));
+      else f->name = allocAndCopy(getName(in));
+    }
+  }
 }
 
-int getValueAttribute(parse_file *in)
+char *getNameAttribute(parse_file_t *in)
 {
   char * token;
-  getName(in);
-  getEqual(in);
+  char *name = NULL;
+  char car;
+  
+  while(1) {
+    token = getToken(in); 
+    if(strcmp("/",token) == 0 || strcmp(">",token) == 0){
+      ungetToken(in);
+      break;
+    }
+
+    if(!strcmp("name",token)) {
+      getEqual(in);
+      car = seekNextChar(in);
+      if(car == EOF) in->error(in,"name was expected");
+      else if(car == '\"') name = allocAndCopy(getQuotedString(in));
+      else name = allocAndCopy(getName(in));
+    }
+  }
+  if(name == NULL) in->error(in, "Name was expected");
+  return name;
   
-  return getNumber(in);
 }
 
-//for <label name=label_name value=n/>, value is an option
-char * getValueStrAttribute(parse_file *in)
+
+
+//for <label name=label_name value=n format="..."/>, value is an option
+char * getValueStrAttribute(parse_file_t *in)
 {
   char * token;
 
@@ -209,7 +366,7 @@ char * getValueStrAttribute(parse_file *in)
   return token;  
 }
 
-char * getDescription(parse_file *in)
+char * getDescription(parse_file_t *in)
 {
   long int pos;
   char * token, car, *str;
@@ -255,12 +412,16 @@ char * getDescription(parse_file *in)
  *    fac           : facility filled with event list
  ****************************************************************************/
 
-void parseFacility(parse_file *in, facility * fac)
+void parseFacility(parse_file_t *in, facility_t * fac)
 {
   char * token;
-  event *ev;
+  event_t *ev;
   
-  fac->name = allocAndCopy(getNameAttribute(in));    
+  getFacilityAttributes(in, fac);
+  if(fac->name == NULL) in->error(in, "Attribute not named");
+
+  fac->capname = allocAndCopy(fac->name);
+       strupper(fac->capname);
   getRAnglebracket(in);    
   
   fac->description = getDescription(in);
@@ -273,7 +434,7 @@ void parseFacility(parse_file *in, facility * fac)
       in->error(in,"the definition of the facility is not finished");
 
     if(strcmp("event",token) == 0){
-      ev = (event*) memAlloc(sizeof(event));
+      ev = (event_t*) memAlloc(sizeof(event_t));
       sequence_push(&(fac->events),ev);
       parseEvent(in,ev, &(fac->unnamed_types), &(fac->named_types));    
     }else if(strcmp("type",token) == 0){
@@ -300,14 +461,15 @@ void parseFacility(parse_file *in, facility * fac)
  *    ev            : new event (parameters are passed to it)   
  ****************************************************************************/
 
-void parseEvent(parse_file *in, event * ev, sequence * unnamed_types, 
-               table * named_types) 
+void parseEvent(parse_file_t *in, event_t * ev, sequence_t * unnamed_types, 
+               table_t * named_types) 
 {
   char *token;
-  type_descriptor *t;
+  type_descriptor_t *t;
 
   //<event name=eventtype_name>
-  ev->name = allocAndCopy(getNameAttribute(in));
+  getEventAttributes(in, ev);
+  if(ev->name == NULL) in->error(in, "Event not named");
   getRAnglebracket(in);  
 
   //<description>...</descriptio>
@@ -346,17 +508,19 @@ void parseEvent(parse_file *in, event * ev, sequence * unnamed_types,
  *    named_types   : array of named types
  ****************************************************************************/
 
-void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types,
-                table * named_types) 
+void parseFields(parse_file_t *in, type_descriptor_t *t,
+    sequence_t * unnamed_types,
+               table_t * named_types) 
 {
   char * token;
-  field *f;
+  field_t *f;
 
-  f = (field *)memAlloc(sizeof(field));
+  f = (field_t *)memAlloc(sizeof(field_t));
   sequence_push(&(t->fields),f);
 
   //<field name=field_name> <description> <type> </field>
-  f->name = allocAndCopy(getNameAttribute(in)); 
+  getFieldAttributes(in, f);
+  if(f->name == NULL) in->error(in, "Field not named");
   getRAnglebracket(in);
 
   f->description = getDescription(in);
@@ -393,14 +557,14 @@ void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types,
  *    type_descriptor* : a type descriptor             
  ****************************************************************************/
 
-type_descriptor *parseType(parse_file *in, type_descriptor *inType, 
-                          sequence * unnamed_types, table * named_types) 
+type_descriptor_t *parseType(parse_file_t *in, type_descriptor_t *inType, 
+                          sequence_t * unnamed_types, table_t * named_types) 
 {
   char *token;
-  type_descriptor *t;
+  type_descriptor_t *t;
 
   if(inType == NULL) {
-    t = (type_descriptor *) memAlloc(sizeof(type_descriptor));
+    t = (type_descriptor_t *) memAlloc(sizeof(type_descriptor_t));
     t->type_name = NULL;
     t->type = NONE;
     t->fmt = NULL;
@@ -412,6 +576,7 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
 
   if(strcmp(token,"struct") == 0) {
     t->type = STRUCT;
+    getTypeAttributes(in, t);
     getRAnglebracket(in); //<struct>
     getLAnglebracket(in); //<field name=..>
     token = getToken(in);
@@ -431,7 +596,8 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
   }
   else if(strcmp(token,"union") == 0) {
     t->type = UNION;
-    t->size = getSizeAttribute(in);
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "Union has empty size");
     getRAnglebracket(in); //<union typecodesize=isize>
 
     getLAnglebracket(in); //<field name=..>
@@ -452,11 +618,12 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
   }
   else if(strcmp(token,"array") == 0) {
     t->type = ARRAY;
-    t->size = getValueAttribute(in);
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "Array has empty size");
     getRAnglebracket(in); //<array size=n>
 
     getLAnglebracket(in); //<type struct> 
-    t->nested_type = parseType(in,NULL, unnamed_types, named_types);
+    t->nested_type = parseType(in, NULL, unnamed_types, named_types);
 
     getLAnglebracket(in); //</array>
     getForwardslash(in);
@@ -466,7 +633,8 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
   }
   else if(strcmp(token,"sequence") == 0) {
     t->type = SEQUENCE;
-    t->size = getSizeAttribute(in);
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "Sequence has empty size");
     getRAnglebracket(in); //<array lengthsize=isize>
 
     getLAnglebracket(in); //<type struct> 
@@ -482,8 +650,10 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
     char * str, *str1;
     t->type = ENUM;
     sequence_init(&(t->labels));
-    t->size = getSizeAttribute(in);
-    t->fmt = allocAndCopy(getFormatAttribute(in));
+    sequence_init(&(t->labels_description));
+               t->already_printed = 0;
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "Sequence has empty size");
     getRAnglebracket(in);
 
     //<label name=label1 value=n/>
@@ -493,17 +663,22 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
       str   = allocAndCopy(getNameAttribute(in));      
       token = getValueStrAttribute(in);
       if(token){
-       str1 = appendString(str,"=");
-       free(str);
-       str = appendString(str1,token);
-       free(str1);
-       sequence_push(&(t->labels),str);
-      }else
-       sequence_push(&(t->labels),str);
+       str1 = appendString(str,"=");
+       free(str);
+       str = appendString(str1,token);
+       free(str1);
+       sequence_push(&(t->labels),str);
+      }
+      else
+       sequence_push(&(t->labels),str);
 
       getForwardslash(in);
       getRAnglebracket(in);
       
+      //read description if any. May be NULL.
+      str = allocAndCopy(getDescription(in));
+                       sequence_push(&(t->labels_description),str);
+                             
       //next label definition
       getLAnglebracket(in);
       token = getToken(in); //"label" or "/"      
@@ -511,32 +686,67 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
     if(strcmp("/",token))in->error(in, "not a valid enum definition");
     token = getName(in);
     if(strcmp("enum",token))in->error(in, "not a valid enum definition");
-    getRAnglebracket(in); //</label>
+      getRAnglebracket(in); //</label>
   }
   else if(strcmp(token,"int") == 0) {
     t->type = INT;
-    t->size = getSizeAttribute(in);
-    t->fmt  = allocAndCopy(getFormatAttribute(in));
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "int has empty size");
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"uint") == 0) {
     t->type = UINT;
-    t->size = getSizeAttribute(in);
-    t->fmt  = allocAndCopy(getFormatAttribute(in));
+    getTypeAttributes(in, t);
+    if(t->size == -1) in->error(in, "uint has empty size");
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"pointer") == 0) {
+    t->type = POINTER;
+    getTypeAttributes(in, t);
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"long") == 0) {
+    t->type = LONG;
+    getTypeAttributes(in, t);
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"ulong") == 0) {
+    t->type = ULONG;
+    getTypeAttributes(in, t);
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"size_t") == 0) {
+    t->type = SIZE_T;
+    getTypeAttributes(in, t);
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"ssize_t") == 0) {
+    t->type = SSIZE_T;
+    getTypeAttributes(in, t);
+    getForwardslash(in);
+    getRAnglebracket(in); 
+  }
+  else if(strcmp(token,"off_t") == 0) {
+    t->type = OFF_T;
+    getTypeAttributes(in, t);
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"float") == 0) {
     t->type = FLOAT;
-    t->size = getSizeAttribute(in);
-    t->fmt  = allocAndCopy(getFormatAttribute(in));
+    getTypeAttributes(in, t);
     getForwardslash(in);
     getRAnglebracket(in); 
   }
   else if(strcmp(token,"string") == 0) {
     t->type = STRING;
-    t->fmt  = allocAndCopy(getFormatAttribute(in));
+    getTypeAttributes(in, t);
     getForwardslash(in);
     getRAnglebracket(in); 
   }
@@ -568,13 +778,13 @@ type_descriptor *parseType(parse_file *in, type_descriptor *inType,
  *    type_descriptor *   : a type descriptor                       
  *****************************************************************************/
 
-type_descriptor * find_named_type(char *name, table * named_types)
+type_descriptor_t * find_named_type(char *name, table_t * named_types)
 { 
-  type_descriptor *t;
+  type_descriptor_t *t;
 
   t = table_find(named_types,name);
   if(t == NULL) {
-    t = (type_descriptor *)memAlloc(sizeof(type_descriptor));
+    t = (type_descriptor_t *)memAlloc(sizeof(type_descriptor_t));
     t->type_name = allocAndCopy(name);
     t->type = NONE;
     t->fmt = NULL;
@@ -593,20 +803,21 @@ type_descriptor * find_named_type(char *name, table * named_types)
  *    named_types         : array of named types
  *****************************************************************************/
 
-void parseTypeDefinition(parse_file * in, sequence * unnamed_types,
-                        table * named_types)
+void parseTypeDefinition(parse_file_t * in, sequence_t * unnamed_types,
+                        table_t * named_types)
 {
   char *token;
-  type_descriptor *t;
+  type_descriptor_t *t;
 
   token = getNameAttribute(in);
+  if(token == NULL) in->error(in, "Type has empty name");
   t = find_named_type(token, named_types);
 
   if(t->type != NONE) in->error(in,"redefinition of named type");
   getRAnglebracket(in); //<type name=type_name>
-  getLAnglebracket(in); //<struct>
+  getLAnglebracket(in); //<
   token = getName(in);
-  if(strcmp("struct",token))in->error(in,"not a valid type definition");
+  //MD ??if(strcmp("struct",token))in->error(in,"not a valid type definition");
   ungetToken(in);
   parseType(in,t, unnamed_types, named_types);
   
@@ -632,7 +843,7 @@ void parseTypeDefinition(parse_file * in, sequence * unnamed_types,
  *
  **************************************************************************/
 
-char *getName(parse_file * in) 
+char *getName(parse_file_t * in) 
 {
   char *token;
 
@@ -641,7 +852,7 @@ char *getName(parse_file * in)
   return token;
 }
 
-int getNumber(parse_file * in) 
+int getNumber(parse_file_t * in) 
 {
   char *token;
 
@@ -650,7 +861,7 @@ int getNumber(parse_file * in)
   return atoi(token);
 }
 
-char *getForwardslash(parse_file * in) 
+char *getForwardslash(parse_file_t * in) 
 {
   char *token;
 
@@ -659,7 +870,7 @@ char *getForwardslash(parse_file * in)
   return token;
 }
 
-char *getLAnglebracket(parse_file * in) 
+char *getLAnglebracket(parse_file_t * in) 
 {
   char *token;
 
@@ -668,7 +879,7 @@ char *getLAnglebracket(parse_file * in)
   return token;
 }
 
-char *getRAnglebracket(parse_file * in) 
+char *getRAnglebracket(parse_file_t * in) 
 {
   char *token;
 
@@ -677,7 +888,7 @@ char *getRAnglebracket(parse_file * in)
   return token;
 }
 
-char *getQuotedString(parse_file * in) 
+char *getQuotedString(parse_file_t * in) 
 {
   char *token;
 
@@ -686,7 +897,7 @@ char *getQuotedString(parse_file * in)
   return token;
 }
 
-char * getEqual(parse_file *in)
+char * getEqual(parse_file_t *in)
 {
   char *token;
 
@@ -695,7 +906,7 @@ char * getEqual(parse_file *in)
   return token;
 }
 
-char seekNextChar(parse_file *in)
+char seekNextChar(parse_file_t *in)
 {
   char car;
   while((car = getc(in->fp)) != EOF) {
@@ -722,12 +933,12 @@ char seekNextChar(parse_file *in)
  *
  ******************************************************************/
 
-void ungetToken(parse_file * in)
+void ungetToken(parse_file_t * in)
 {
   in->unget = 1;
 }
 
-char *getToken(parse_file * in)
+char *getToken(parse_file_t * in)
 {
   FILE *fp = in->fp;
   char car, car1;
@@ -820,7 +1031,7 @@ char *getToken(parse_file * in)
         in->buffer[0] = car;
         pos = 1;
         while((car = getc(fp)) != EOF && pos < BUFFER_SIZE) {
-          if(!isalnum(car)) {
+          if(!(isalnum(car) || car == '_')) {
             ungetc(car,fp);
             break;
           }
@@ -837,7 +1048,7 @@ char *getToken(parse_file * in)
   return in->buffer;
 }
 
-void skipComment(parse_file * in)
+void skipComment(parse_file_t * in)
 {
   char car;
   while((car = getc(in->fp)) != EOF) {
@@ -852,7 +1063,7 @@ void skipComment(parse_file * in)
   if(car == EOF) in->error(in,"comment begining with '/*' has no ending '*/'");
 }
 
-void skipEOL(parse_file * in)
+void skipEOL(parse_file_t * in)
 {
   char car;
   while((car = getc(in->fp)) != EOF) {
@@ -864,36 +1075,22 @@ void skipEOL(parse_file * in)
   if(car == EOF)ungetc(car, in->fp);
 }
 
-int isalpha(char c)
-{
-  int i,j;
-  if(c == '_')return 1;
-  i = c - 'a';
-  j = c - 'A';
-  if((i>=0 && i<26) || (j>=0 && j<26)) return 1;
-  return 0;
-}
-
-int isalnum(char c)
-{
-  return (isalpha(c) || isdigit(c));
-}
-
 /*****************************************************************************
  *Function name
  *    checkNamedTypesImplemented : check if all named types have definition
  ****************************************************************************/
 
-void checkNamedTypesImplemented(table * named_types)
+void checkNamedTypesImplemented(table_t * named_types)
 {
-  type_descriptor *t;
+  type_descriptor_t *t;
   int pos;
   char str[256];
 
   for(pos = 0 ; pos < named_types->values.position; pos++) {
-    t = (type_descriptor *) named_types->values.array[pos];
+    t = (type_descriptor_t *) named_types->values.array[pos];
     if(t->type == NONE){
-      sprintf(str,"named type '%s' has no definition",(char*)named_types->keys.array[pos]);
+      sprintf(str,"named type '%s' has no definition",
+          (char*)named_types->keys.array[pos]);
       error_callback(NULL,str);   
     }
   }
@@ -909,16 +1106,17 @@ void checkNamedTypesImplemented(table * named_types)
  *    checksum          : checksum for the facility
  ****************************************************************************/
 
-void generateChecksum( char* facName, unsigned long * checksum, sequence * events)
+void generateChecksum(char* facName,
+    unsigned long * checksum, sequence_t * events)
 {
   unsigned long crc ;
   int pos;
-  event * ev;
+  event_t * ev;
   char str[256];
 
   crc = crc32(facName);
   for(pos = 0; pos < events->position; pos++){
-    ev = (event *)(events->array[pos]);
+    ev = (event_t *)(events->array[pos]);
     crc = partial_crc32(ev->name,crc);    
     if(!ev->type) continue; //event without type
     if(ev->type->type != STRUCT){
@@ -940,12 +1138,12 @@ void generateChecksum( char* facName, unsigned long * checksum, sequence * event
  *    unsigned long     : checksum 
  *****************************************************************************/
 
-unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type)
+unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type)
 {
   unsigned long crc = aCrc;
   char * str = NULL, buf[16];
   int flag = 0, pos;
-  field * fld;
+  field_t * fld;
 
   switch(type->type){
     case INT:
@@ -954,6 +1152,30 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type)
     case UINT:
       str = uintOutputTypes[type->size];
       break;
+    case POINTER:
+      str = allocAndCopy("void *");
+                       flag = 1;
+      break;
+    case LONG:
+      str = allocAndCopy("long");
+                       flag = 1;
+      break;
+    case ULONG:
+      str = allocAndCopy("unsigned long");
+                       flag = 1;
+      break;
+    case SIZE_T:
+      str = allocAndCopy("size_t");
+                       flag = 1;
+      break;
+    case SSIZE_T:
+      str = allocAndCopy("ssize_t");
+                       flag = 1;
+      break;
+    case OFF_T:
+      str = allocAndCopy("off_t");
+                       flag = 1;
+      break;
     case FLOAT:
       str = floatOutputTypes[type->size];
       break;
@@ -966,12 +1188,12 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type)
       flag = 1;
       break;
     case ARRAY:
-      sprintf(buf,"%d\0",type->size);
+      sprintf(buf,"%d",type->size);
       str = appendString("array ",buf);
       flag = 1;
       break;
     case SEQUENCE:
-      sprintf(buf,"%d\0",type->size);
+      sprintf(buf,"%d",type->size);
       str = appendString("sequence ",buf);
       flag = 1;
       break;
@@ -997,7 +1219,7 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type)
     crc = getTypeChecksum(crc,type->nested_type);
   }else if(type->type == STRUCT || type->type == UNION){
     for(pos =0; pos < type->fields.position; pos++){
-      fld = (field *) type->fields.array[pos];
+      fld = (field_t *) type->fields.array[pos];
       crc = partial_crc32(fld->name,crc);
       crc = getTypeChecksum(crc, fld->type);
     }    
@@ -1011,10 +1233,10 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type)
 
 
 /* Event type descriptors */
-void freeType(type_descriptor * tp)
+void freeType(type_descriptor_t * tp)
 {
   int pos2;
-  field *f;
+  field_t *f;
 
   if(tp->fmt != NULL) free(tp->fmt);
   if(tp->type == ENUM) {
@@ -1025,7 +1247,7 @@ void freeType(type_descriptor * tp)
   }
   if(tp->type == STRUCT) {
     for(pos2 = 0; pos2 < tp->fields.position; pos2++) {
-      f = (field *) tp->fields.array[pos2];
+      f = (field_t *) tp->fields.array[pos2];
       free(f->name);
       free(f->description);
       free(f);
@@ -1034,39 +1256,39 @@ void freeType(type_descriptor * tp)
   }
 }
 
-void freeNamedType(table * t)
+void freeNamedType(table_t * t)
 {
   int pos;
-  type_descriptor * td;
+  type_descriptor_t * td;
 
   for(pos = 0 ; pos < t->keys.position; pos++) {
     free((char *)t->keys.array[pos]);
-    td = (type_descriptor*)t->values.array[pos];
+    td = (type_descriptor_t*)t->values.array[pos];
     freeType(td);
     free(td);
   }
 }
 
-void freeTypes(sequence *t) 
+void freeTypes(sequence_t *t) 
 {
   int pos, pos2;
-  type_descriptor *tp;
-  field *f;
+  type_descriptor_t *tp;
+  field_t *f;
 
   for(pos = 0 ; pos < t->position; pos++) {
-    tp = (type_descriptor *)t->array[pos];
+    tp = (type_descriptor_t *)t->array[pos];
     freeType(tp);
     free(tp);
   }
 }
 
-void freeEvents(sequence *t) 
+void freeEvents(sequence_t *t) 
 {
   int pos;
-  event *ev;
+  event_t *ev;
 
   for(pos = 0 ; pos < t->position; pos++) {
-    ev = (event *) t->array[pos];
+    ev = (event_t *) t->array[pos];
     free(ev->name);
     free(ev->description);
     free(ev);
@@ -1077,21 +1299,21 @@ void freeEvents(sequence *t)
 
 /* Extensible array */
 
-void sequence_init(sequence *t) 
+void sequence_init(sequence_t *t) 
 {
   t->size = 10;
   t->position = 0;
   t->array = (void **)memAlloc(t->size * sizeof(void *));
 }
 
-void sequence_dispose(sequence *t) 
+void sequence_dispose(sequence_t *t) 
 {
   t->size = 0;
   free(t->array);
   t->array = NULL;
 }
 
-void sequence_push(sequence *t, void *elem) 
+void sequence_push(sequence_t *t, void *elem) 
 {
   void **tmp;
 
@@ -1106,7 +1328,7 @@ void sequence_push(sequence *t, void *elem)
   t->position++;
 }
 
-void *sequence_pop(sequence *t) 
+void *sequence_pop(sequence_t *t) 
 {
   return t->array[t->position--];
 }
@@ -1114,25 +1336,25 @@ void *sequence_pop(sequence *t)
 
 /* Hash table API, implementation is just linear search for now */
 
-void table_init(table *t) 
+void table_init(table_t *t) 
 {
   sequence_init(&(t->keys));
   sequence_init(&(t->values));
 }
 
-void table_dispose(table *t) 
+void table_dispose(table_t *t) 
 {
   sequence_dispose(&(t->keys));
   sequence_dispose(&(t->values));
 }
 
-void table_insert(table *t, char *key, void *value) 
+void table_insert(table_t *t, char *key, void *value) 
 {
   sequence_push(&(t->keys),key);
   sequence_push(&(t->values),value);
 }
 
-void *table_find(table *t, char *key) 
+void *table_find(table_t *t, char *key) 
 {
   int pos;
   for(pos = 0 ; pos < t->keys.position; pos++) {
@@ -1142,13 +1364,13 @@ void *table_find(table *t, char *key)
   return NULL;
 }
 
-void table_insert_int(table *t, int *key, void *value)
+void table_insert_int(table_t *t, int *key, void *value)
 {
   sequence_push(&(t->keys),key);
   sequence_push(&(t->values),value);
 }
 
-void *table_find_int(table *t, int *key)
+void *table_find_int(table_t *t, int *key)
 {
   int pos;
   for(pos = 0 ; pos < t->keys.position; pos++) {
This page took 0.034878 seconds and 4 git commands to generate.