Logo Search packages:      
Sourcecode: eresi version File versions  Download package

int revm_convert2raw ( revmobj_t obj  ) 

Convert to a raw data object

Definition at line 259 of file convert.c.

References ASPECT_TYPE_BYTE, ASPECT_TYPE_CADDR, ASPECT_TYPE_DADDR, aspect_type_get_by_id(), ASPECT_TYPE_INT, ASPECT_TYPE_LONG, ASPECT_TYPE_RAW, ASPECT_TYPE_SHORT, ASPECT_TYPE_STR, s_revm_object::get_name, s_revm_object::get_obj, s_revm_object::immed, s_revm_object::immed_val, s_revm_object::otype, s_revm_object::parent, revm_convert2raw(), s_revm_object::root, s_revm_object::size, s_revm_object::sizelem, and s_type::type.

Referenced by revm_convert2raw(), revm_convert_object(), and revm_setvar_raw().

{
  u_char    val8;
  u_short   val16;
  u_int           val32;
  eresi_Addr      val64;
  char            *str;

  PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);
  
  switch (obj->otype->type)
    {
    case ASPECT_TYPE_BYTE:
      val8 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent));
      XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, 2, -1);
      *obj->immed_val.str = val8;
      obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW);
      obj->immed = 1;
      obj->size = 1;
      obj->sizelem = 1;
      break;
    case ASPECT_TYPE_STR:
      str = (obj->immed ? obj->immed_val.str : 
           obj->get_name(obj->root, obj->parent));
      XREALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, obj->immed_val.str, obj->size, -1);
      memcpy(obj->immed_val.str, str, obj->size);
      obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW);
      obj->immed = 1;
      //obj->size; No size change
      obj->sizelem = 0;
      break;
    case ASPECT_TYPE_SHORT:
      val16 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent));
      XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val16) + 1, -1);
      memcpy(obj->immed_val.str, &val16, sizeof(val16));    // FIXME: Take care of endianess !
      obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW);
      obj->immed = 1;
      obj->size = 2;
      obj->sizelem = 0;
      break;
    case ASPECT_TYPE_INT:
      val32 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent));
      XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val32) + 1, -1);
      memcpy(obj->immed_val.str, &val32, sizeof(val32));    // FIXME: Take care of endianess !
      obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW);
      obj->immed = 1;
      obj->size = 4;
      obj->sizelem = 0;
      break;
    case ASPECT_TYPE_LONG:
    case ASPECT_TYPE_CADDR:
    case ASPECT_TYPE_DADDR:
      val64 = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent));
      XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val64) + 1, -1);
      memcpy(obj->immed_val.str, &val64, sizeof(val64)); // FIXME: Take care of endianess !
      obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW);
      obj->immed = 1;
      obj->size = sizeof(eresi_Addr);
      obj->sizelem = 0;
      break;
    default:
      PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, 
                  "Source type unknown", -1);
    }
  PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0);
}


Generated by  Doxygen 1.6.0   Back to index