-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu Yang
- *
- * 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 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.
- */
-
-#include <stdio.h>
-#include <asm/types.h>
-#include <linux/byteorder/swab.h>
-
-#include "parser.h"
-#include <ltt/ltt.h>
-#include "ltt-private.h"
-#include <ltt/event.h>
-#include <ltt/trace.h>
-
-/*****************************************************************************
- *Function name
- * ltt_event_refresh_fields : refresh fields of an event
- *Input params
- * offsetRoot : offset from the root
- * offsetParent : offset from the parent
- * fld : field
- * evD : event data
- *Return value
- * int : size of the field
- ****************************************************************************/
-
-int ltt_event_refresh_fields(int offsetRoot,int offsetParent,
- LttField * fld, void *evD)
-{
- int size, size1, element_number, i, offset1, offset2;
- LttType * type = fld->field_type;
-
- if(type->type_class != LTT_STRUCT && type->type_class != LTT_ARRAY &&
- type->type_class != LTT_SEQUENCE && type->type_class != LTT_STRING){
- size = fld->field_size;
- }else if(type->type_class == LTT_ARRAY){
- element_number = (int) type->element_number;
- if(fld->field_fixed == 0){// has string or sequence
- size = 0;
- for(i=0;i<element_number;i++){
- size += ltt_event_refresh_fields(offsetRoot+size,size,
- fld->child[0], evD+size);
- }
- }else size = fld->field_size;
- }else if(type->type_class == LTT_SEQUENCE){
- size1 = fld->sequ_number_size;
- element_number = getIntNumber(size1,evD);
- type->element_number = element_number;
- if(fld->element_size > 0){
- size = element_number * fld->element_size;
- }else{//sequence has string or sequence
- size = 0;
- for(i=0;i<element_number;i++){
- size += ltt_event_refresh_fields(offsetRoot+size+size1,size+size1,
- fld->child[0], evD+size+size1);
- }
- size += size1;
- }
- }else if(type->type_class == LTT_STRING){
- size = strlen((char*)evD) + 1; //include end : '\0'
- }else if(type->type_class == LTT_STRUCT){
- element_number = (int) type->element_number;
- if(fld->field_fixed == 0){
- offset1 = offsetRoot;
- offset2 = 0;
- for(i=0;i<element_number;i++){
- size=ltt_event_refresh_fields(offset1,offset2,fld->child[i],evD+offset2);
- offset1 += size;
- offset2 += size;
- }
- size = offset2;
- }else size = fld->field_size;
- }
-
- fld->offset_root = offsetRoot;
- fld->offset_parent = offsetParent;
- fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
- fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
- fld->field_size = size;
-
- return size;
-}
-
-/*****************************************************************************
- *Function name
- * ltt_event_eventtype_id: get event type id
- * (base id + position of the event)
- *Input params
- * e : an instance of an event type
- *Return value
- * unsigned : event type id
- ****************************************************************************/