X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ffacility.c;h=619a4bab3b9f1e45d6b34d901ab9e90b154c96d6;hb=72013e4093fbaf26456b22101550d58253e858dd;hp=252c6759c49ac65bd9f9eda3718a1a23b828fa9a;hpb=2312de30ce2be53f81c4eaaa772ffff21511b509;p=lttv.git diff --git a/ltt/branches/poly/ltt/facility.c b/ltt/branches/poly/ltt/facility.c index 252c6759..619a4bab 100644 --- a/ltt/branches/poly/ltt/facility.c +++ b/ltt/branches/poly/ltt/facility.c @@ -2,19 +2,19 @@ * Copyright (C) 2003-2004 Xiangxiu Yang * 2005 Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License Version 2 as - * published by the Free Software Foundation; + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License Version 2.1 as published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, + * This library 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. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ #ifdef HAVE_CONFIG_H @@ -102,7 +102,25 @@ int ltt_facility_open(LttFacility *f, LttTrace * t, gchar * pathname) while(1){ token = getToken(&in); if(in.type == ENDFILE) break; - + + if(g_ascii_strcasecmp(token, "<")) in.error(&in,"not a facility file"); + token = getName(&in); + if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file"); + token = getName(&in); + if(g_ascii_strcasecmp(token, "xml")) in.error(&in,"not a facility file"); + token = getName(&in); + if(g_ascii_strcasecmp(token, "version")) in.error(&in,"not a facility file"); + token = getName(&in); + if(g_ascii_strcasecmp(token, "=")) in.error(&in,"not a facility file"); + token = getQuotedString(&in); + if(g_ascii_strcasecmp(token, "1.0")) in.error(&in,"not a facility file"); + token = getName(&in); + if(g_ascii_strcasecmp(token, "?")) in.error(&in,"not a facility file"); + token = getToken(&in); + if(g_ascii_strcasecmp(token, ">")) in.error(&in,"not a facility file"); + + token = getToken(&in); + if(g_ascii_strcasecmp(token, "<")) in.error(&in,"not a facility file"); token = getName(&in); @@ -281,7 +299,11 @@ void construct_fields(LttFacility *fac, type_descriptor_t *td; LttType *type; - field->name = g_quark_from_string(fld->name); + if(fld->name) + field->name = g_quark_from_string(fld->name); + else + fld->name = 0; + if(fld->description) { len = strlen(fld->description); field->description = g_new(gchar, len+1); @@ -294,7 +316,8 @@ void construct_fields(LttFacility *fac, type->enum_map = NULL; type->fields = NULL; type->fields_by_name = NULL; - + type->network = td->network; + switch(td->type) { case INT_FIXED: type->type_class = LTT_INT_FIXED; @@ -315,6 +338,7 @@ void construct_fields(LttFacility *fac, case UCHAR: type->type_class = LTT_UCHAR; type->size = td->size; + g_assert(type->size != 0); break; case SHORT: type->type_class = LTT_SHORT; @@ -331,6 +355,7 @@ void construct_fields(LttFacility *fac, case UINT: type->type_class = LTT_UINT; type->size = fac->int_size; + g_assert(type->size != 0); break; case LONG: type->type_class = LTT_LONG; @@ -365,13 +390,14 @@ void construct_fields(LttFacility *fac, type->size = fac->int_size; { guint i; - type->enum_map = g_hash_table_new(g_int_hash, g_int_equal); + type->enum_map = g_hash_table_new(g_direct_hash, g_direct_equal); for(i=0; ilabels.position; i++) { GQuark value = g_quark_from_string((char*)td->labels.array[i]); gint key = *(int*)td->labels_values.array[i]; g_hash_table_insert(type->enum_map, (gpointer)key, (gpointer)value); } } + g_assert(type->size != 0); break; case ARRAY: type->type_class = LTT_ARRAY;