Beispiel #1
0
void ansi_c_convertt::convert_expr(exprt &expr)
{
  if(expr.id()==ID_sideeffect)
  {
    const irep_idt &statement=expr.get(ID_statement);

    if(statement==ID_statement_expression)
    {
      assert(expr.operands().size()==1);
      convert_code(to_code(expr.op0()));
      return;
      // done
    }
  }

  Forall_operands(it, expr)
    convert_expr(*it);

  if(expr.id()==ID_symbol)
  {
    expr.remove(ID_C_id_class);
    expr.remove(ID_C_base_name);
  }
  else if(expr.id()==ID_sizeof)
  {
    if(expr.operands().size()==0)
    {
      typet &type=static_cast<typet &>(expr.add(ID_type_arg));
      convert_type(type);
    }
  }
  else if(expr.id()==ID_designated_initializer)
  {
    exprt &designator=static_cast<exprt &>(expr.add(ID_designator));
    convert_expr(designator);
  }
  else if(expr.id()==ID_alignof)
  {
    if(expr.operands().size()==0)
    {
      typet &type=static_cast<typet &>(expr.add(ID_type_arg));
      convert_type(type);
    }
  }
  else if(expr.id()==ID_gcc_builtin_va_arg)
  {
    convert_type(expr.type());
  }
  else if(expr.id()==ID_generic_selection)
  {
    assert(expr.operands().size()==1);

    irept::subt &generic_associations=
      expr.add(ID_generic_associations).get_sub();

    Forall_irep(it, generic_associations)
    {
      convert_expr(static_cast<exprt &>(it->add(ID_value)));
      convert_type(static_cast<typet &>(it->add(ID_type_arg)));
    }
Beispiel #2
0
bool ProguardMap::parse_class(const std::string& line) {
  char classname[kBufSize];
  char newname[kBufSize];
  int n;
  n = sscanf(line.c_str(), "%s -> %[^:]:", classname, newname);
  if (n != 2) {
    return false;
  }
  m_currClass = convert_type(classname);
  m_currNewClass = convert_type(newname);
  m_classMap[m_currClass] = m_currNewClass;
  return true;
}
Beispiel #3
0
void sync_data(data_type *data, int source_machine)
{
    int num_elements = sizeof(data) / sizeof(data_type);
    MPI_Bcast(&num_elements, 1, MPI_INT, source_machine, MPI_COMM_WORLD);
    MPI_Bcast(data, num_elements, convert_type(get_abstraction_data_type<data_type>()), source_machine,
              MPI_COMM_WORLD);
};
Beispiel #4
0
static int buf_ioctl(int fd, unsigned long int cmd, struct v4l2_buffer *arg)
{
	struct v4l2_buffer buf = *arg;
	struct v4l2_plane plane = { 0 };
	int ret;

	buf.type = convert_type(arg->type);

	if (buf.type == arg->type)
		return SYS_IOCTL(fd, cmd, &buf);

	memcpy(&plane.m, &arg->m, sizeof(plane.m));
	plane.length = arg->length;
	plane.bytesused = arg->bytesused;
	
	buf.m.planes = &plane;
	buf.length = 1;

	ret = SYS_IOCTL(fd, cmd, &buf);

	arg->index = buf.index;
	arg->flags = buf.flags;
	arg->field = buf.field;
	arg->timestamp = buf.timestamp;
	arg->timecode = buf.timecode;
	arg->sequence = buf.sequence;

	arg->length = plane.length;
	arg->bytesused = plane.bytesused;

	return ret;
}
Beispiel #5
0
void ansi_c_convertt::convert_declaration(ansi_c_declarationt &declaration)
{
  c_storage_spect c_storage_spec;

  convert_type(declaration.type(), c_storage_spec);

  declaration.set_is_inline(c_storage_spec.is_inline);
  declaration.set_is_static(c_storage_spec.is_static);
  declaration.set_is_extern(c_storage_spec.is_extern);
  declaration.set_is_thread_local(c_storage_spec.is_thread_local);
  declaration.set_is_register(c_storage_spec.is_register);

  // do not overwrite is_typedef -- it's done by the parser
  // typedefs are macros
  if(declaration.get_is_typedef())
    declaration.set_is_macro(true);

  if(declaration.value().is_not_nil())
  {
    if(declaration.value().type().id()==ID_code)
      convert_code(to_code(declaration.value()));
    else
      convert_expr(declaration.value());
  }
}
static void
convert_symbol_bmsym (struct compile_c_instance *context,
		      struct bound_minimal_symbol bmsym)
{
  struct minimal_symbol *msym = bmsym.minsym;
  struct objfile *objfile = bmsym.objfile;
  struct type *type;
  enum gcc_c_symbol_kind kind;
  gcc_type sym_type;
  gcc_decl decl;
  CORE_ADDR addr;

  addr = MSYMBOL_VALUE_ADDRESS (objfile, msym);

  /* Conversion copied from write_exp_msymbol.  */
  switch (MSYMBOL_TYPE (msym))
    {
    case mst_text:
    case mst_file_text:
    case mst_solib_trampoline:
      type = objfile_type (objfile)->nodebug_text_symbol;
      kind = GCC_C_SYMBOL_FUNCTION;
      break;

    case mst_text_gnu_ifunc:
      /* nodebug_text_gnu_ifunc_symbol would cause:
	 function return type cannot be function  */
      type = objfile_type (objfile)->nodebug_text_symbol;
      kind = GCC_C_SYMBOL_FUNCTION;
      addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
      break;

    case mst_data:
    case mst_file_data:
    case mst_bss:
    case mst_file_bss:
      type = objfile_type (objfile)->nodebug_data_symbol;
      kind = GCC_C_SYMBOL_VARIABLE;
      break;

    case mst_slot_got_plt:
      type = objfile_type (objfile)->nodebug_got_plt_symbol;
      kind = GCC_C_SYMBOL_FUNCTION;
      break;

    default:
      type = objfile_type (objfile)->nodebug_unknown_symbol;
      kind = GCC_C_SYMBOL_VARIABLE;
      break;
    }

  sym_type = convert_type (context, type);
  decl = C_CTX (context)->c_ops->build_decl (C_CTX (context),
					     MSYMBOL_NATURAL_NAME (msym),
					     kind, sym_type, NULL, addr,
					     NULL, 0);
  C_CTX (context)->c_ops->bind (C_CTX (context), decl, 1 /* is_global */);
}
Beispiel #7
0
const float *
pvt::convert_to_float (const void *src, float *dst, int nvals,
                       TypeDesc format)
{
    switch (format.basetype) {
    case TypeDesc::FLOAT :
        return (float *)src;
    case TypeDesc::UINT8 :
        convert_type ((const unsigned char *)src, dst, nvals);
        break;
    case TypeDesc::HALF :
        convert_type ((const half *)src, dst, nvals);
        break;
    case TypeDesc::UINT16 :
        convert_type ((const unsigned short *)src, dst, nvals);
        break;
    case TypeDesc::INT8:
        convert_type ((const char *)src, dst, nvals);
        break;
    case TypeDesc::INT16 :
        convert_type ((const short *)src, dst, nvals);
        break;
    case TypeDesc::INT :
        convert_type ((const int *)src, dst, nvals);
        break;
    case TypeDesc::UINT :
        convert_type ((const unsigned int *)src, dst, nvals);
        break;
    case TypeDesc::INT64 :
        convert_type ((const long long *)src, dst, nvals);
        break;
    case TypeDesc::UINT64 :
        convert_type ((const unsigned long long *)src, dst, nvals);
        break;
    case TypeDesc::DOUBLE :
        convert_type ((const double *)src, dst, nvals);
        break;
    default:
        ASSERT (0 && "ERROR to_float: bad format");
        return NULL;
    }
    return dst;
}
Beispiel #8
0
mrb_value
mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method)
{
  mrb_value v;

  if (mrb_type(val) == type && type != MRB_TT_DATA) return val;
  v = convert_type(mrb, val, tname, method, 0/*Qfalse*/);
  if (mrb_nil_p(v) || mrb_type(v) != type) return mrb_nil_value();
  return v;
}
Beispiel #9
0
mrb_value
mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
  mrb_value v;

  if (mrb_type(val) == MRB_TT_FIXNUM) return val;
  v = convert_type(mrb, val, "Integer", method, FALSE);
  if (mrb_nil_p(v) || mrb_type(v) != MRB_TT_FIXNUM) {
    return mrb_nil_value();
  }
  return v;
}
Beispiel #10
0
mrb_value
mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
  mrb_value v;

  if (mrb_fixnum_p(val)) return val;
  v = convert_type(mrb, val, "Integer", method, FALSE);
  if (mrb_nil_p(v) || !mrb_fixnum_p(v)) {
    return mrb_nil_value();
  }
  return v;
}
Beispiel #11
0
mrb_value
mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char *tname, const char *method)
{
  mrb_value v;

  if (mrb_type(val) == type) return val;
  v = convert_type(mrb, val, tname, method, 1/*Qtrue*/);
  if (mrb_type(v) != type) {
    mrb_raisef(mrb, E_TYPE_ERROR, "%S cannot be converted to %S by #%S", val,
               mrb_str_new_cstr(mrb, tname), mrb_str_new_cstr(mrb, method));
  }
  return v;
}
Beispiel #12
0
mrb_value
mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
    mrb_value v;

    if (mrb_type(val) == MRB_TT_FIXNUM) return val;
    v = convert_type(mrb, val, "Integer", method, FALSE);
    if (mrb_nil_p(v)) return (v);
    if (!mrb_obj_is_kind_of(mrb, v, mrb_obj_class(mrb, v))) {
      return mrb_nil_value();
    }
    return v;
}
Beispiel #13
0
mrb_value
mrb_convert_type(mrb_state *mrb, mrb_value val, mrb_int type, const char *tname, const char *method)
{
  mrb_value v;

  if (mrb_type(val) == type) return val;
  v = convert_type(mrb, val, tname, method, 1/*Qtrue*/);
  if (mrb_type(v) != type) {
    mrb_raise(mrb, E_TYPE_ERROR, "%s#%s should return %s",
     mrb_obj_classname(mrb, val), method, tname);
  }
  return v;
}
Beispiel #14
0
static mrb_value
mrb_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
  mrb_value v;

  if (mrb_fixnum_p(val)) return val;
  v = convert_type(mrb, val, "Integer", method, TRUE);
  if (!mrb_obj_is_kind_of(mrb, v, mrb->fixnum_class)) {
    mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S to Integer (%S#%S gives %S)",
               val, val, mrb_str_new_cstr(mrb, method), v);
  }
  return v;
}
Beispiel #15
0
static mrb_value
mrb_to_integer(mrb_state *mrb, mrb_value val, const char *method)
{
    mrb_value v;

    if (mrb_fixnum_p(val)) return val;
    v = convert_type(mrb, val, "Integer", method, TRUE);
    if (!mrb_obj_is_kind_of(mrb, v, mrb->fixnum_class)) {
      const char *cname = mrb_obj_classname(mrb, val);
      mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %s to Integer (%s#%s gives %s)",
               cname, cname, method, mrb_obj_classname(mrb, v));
    }
    return v;
}
Beispiel #16
0
mrb_value
mrb_check_convert_type(mrb_state *mrb, mrb_value val, mrb_int type, const char *tname, const char *method)
{
  mrb_value v;

  /* always convert T_DATA */
  if (mrb_type(val) == type && type != MRB_TT_DATA) return val;
  v = convert_type(mrb, val, tname, method, 0/*Qfalse*/);
  if (mrb_nil_p(v)) return mrb_nil_value();
  if (mrb_type(v) != type) {
    mrb_raise(mrb, E_TYPE_ERROR, "%s#%s should return %s",
     mrb_obj_classname(mrb, val), method, tname);
  }
  return v;
}
Beispiel #17
0
static GIOStatus rfkill_process(GIOChannel *chan)
{
	unsigned char buf[32];
	struct rfkill_event *event = (void *) buf;
	enum connman_service_type type;
	gsize len;
	GIOStatus status;

	DBG("");

	memset(buf, 0, sizeof(buf));

	status = g_io_channel_read_chars(chan, (gchar *) buf,
			sizeof(struct rfkill_event), &len, NULL);

	if (status != G_IO_STATUS_NORMAL)
		return status;

	if (len != sizeof(struct rfkill_event))
		return status;

	DBG("idx %u type %u op %u soft %u hard %u", event->idx,
						event->type, event->op,
						event->soft, event->hard);

	type = convert_type(event->type);

	switch (event->op) {
	case RFKILL_OP_ADD:
		__connman_technology_add_rfkill(event->idx, type,
						event->soft, event->hard);
		break;
	case RFKILL_OP_DEL:
		__connman_technology_remove_rfkill(event->idx, type);
		break;
	case RFKILL_OP_CHANGE:
		__connman_technology_update_rfkill(event->idx, type,
						event->soft, event->hard);
		break;
	default:
		break;
	}

	return status;
}
Beispiel #18
0
MRB_API mrb_value
mrb_convert_to_integer(mrb_state *mrb, mrb_value val, int base)
{
  mrb_value tmp;

  if (mrb_nil_p(val)) {
    if (base != 0) goto arg_error;
      mrb_raise(mrb, E_TYPE_ERROR, "can't convert nil into Integer");
  }
  switch (mrb_type(val)) {
    case MRB_TT_FLOAT:
      if (base != 0) goto arg_error;
      if (FIXABLE(mrb_float(val))) {
        break;
      }
      return mrb_flo_to_fixnum(mrb, val);

    case MRB_TT_FIXNUM:
      if (base != 0) goto arg_error;
      return val;

    case MRB_TT_STRING:
    string_conv:
      return mrb_str_to_inum(mrb, val, base, TRUE);

    default:
      break;
  }
  if (base != 0) {
    tmp = mrb_check_string_type(mrb, val);
    if (!mrb_nil_p(tmp)) {
      goto string_conv;
    }
arg_error:
    mrb_raise(mrb, E_ARGUMENT_ERROR, "base specified for non string value");
  }
  tmp = convert_type(mrb, val, "Integer", "to_int", FALSE);
  if (mrb_nil_p(tmp)) {
    return mrb_to_integer(mrb, val, "to_i");
  }
  return tmp;
}
Beispiel #19
0
static value alloc_result( connection *c, MYSQL_RES *r ) {
	result *res = (result*)alloc(sizeof(result));
	value o = alloc_abstract(k_result,res);
	int num_fields = mysql_num_fields(r);
	int i,j;
	MYSQL_FIELD *fields = mysql_fetch_fields(r);
	res->r = r;
	res->conv_date = c->conv_date;
	res->conv_bytes = c->conv_bytes;
	res->conv_string = c->conv_string;
	res->current = NULL;
	res->nfields = num_fields;
	res->fields_ids = (field*)alloc_private(sizeof(field)*num_fields);
	res->fields_convs = (CONV*)alloc_private(sizeof(CONV)*num_fields);	
	for(i=0;i<num_fields;i++) {
		field id;
		if( strchr(fields[i].name,'(') )
			id = val_id("???"); // looks like an inner request : prevent hashing + cashing it
		else {
			id = val_id(fields[i].name);
			for(j=0;j<i;j++)
				if( res->fields_ids[j] == id ) {
					buffer b = alloc_buffer("Error, same field ids for : ");
					buffer_append(b,fields[i].name);
					buffer_append(b,":");
					val_buffer(b,alloc_int(i));
					buffer_append(b," and ");
					buffer_append(b,fields[j].name);
					buffer_append(b,":");
					val_buffer(b,alloc_int(j));
					buffer_append(b,".");
					bfailure(b);
				}
		}
		res->fields_ids[i] = id;
		res->fields_convs[i] = convert_type(fields[i].type,fields[i].flags,fields[i].length);
	}
	val_gc(o,free_result);
	return o;
}
static int
convert_file(struct nettle_buffer *buffer,
	     FILE *f,
	     enum object_type type,
	     int base64)
{
  if (type)
    {
      read_file(buffer, f);
      if (base64 && !decode_base64(buffer, 0, &buffer->size))
	return 0;
      
      if (convert_type(buffer, type,
		       buffer->size, buffer->contents) != 1)
	return 0;

      return 1;
    }
  else
    {
      /* PEM processing */
      for (;;)
	{
	  struct pem_info info;
	  const uint8_t *marker;
	  
	  nettle_buffer_reset(buffer);
	  switch (read_pem(buffer, f, &info))
	    {
	    default:
	      return 0;
	    case 1:
	      break;
	    case -1:
	      /* EOF */
	      return 1;
	    }

	  if (!decode_base64(buffer, info.data_start, &info.data_length))
	    return 0;

	  marker = buffer->contents + info.marker_start;

	  type = 0;
	  switch (info.marker_length)
	    {
	    case 10:
	      if (memcmp(marker, "PUBLIC KEY", 10) == 0)
		{
		  type = GENERAL_PUBLIC_KEY;
		  break;
		}
	    case 14:
	      if (memcmp(marker, "RSA PUBLIC KEY", 14) == 0)
		{
		  type = RSA_PUBLIC_KEY;
		  break;
		}

	    case 15:
	      if (memcmp(marker, "RSA PRIVATE KEY", 15) == 0)
		{
		  type = RSA_PRIVATE_KEY;
		  break;
		}
	      if (memcmp(marker, "DSA PRIVATE KEY", 15) == 0)
		{
		  type = DSA_PRIVATE_KEY;
		  break;
		}
	    }
	  
	  if (!type)
	    werror("Ignoring unsupported object type `%s'.\n", marker);

	  else if (convert_type(buffer, type,
				info.data_length,
				buffer->contents + info.data_start) != 1)
	    return 0;
	}
    }
}
static void
convert_one_symbol (struct compile_c_instance *context,
		    struct symbol *sym,
		    int is_global,
		    int is_local)
{
  gcc_type sym_type;
  const char *filename = symbol_symtab (sym)->filename;
  unsigned short line = SYMBOL_LINE (sym);

  error_symbol_once (context, sym);

  if (SYMBOL_CLASS (sym) == LOC_LABEL)
    sym_type = 0;
  else
    sym_type = convert_type (context, SYMBOL_TYPE (sym));

  if (SYMBOL_DOMAIN (sym) == STRUCT_DOMAIN)
    {
      /* Binding a tag, so we don't need to build a decl.  */
      C_CTX (context)->c_ops->tagbind (C_CTX (context),
				       SYMBOL_NATURAL_NAME (sym),
				       sym_type, filename, line);
    }
  else
    {
      gcc_decl decl;
      enum gcc_c_symbol_kind kind;
      CORE_ADDR addr = 0;
      char *symbol_name = NULL;

      switch (SYMBOL_CLASS (sym))
	{
	case LOC_TYPEDEF:
	  kind = GCC_C_SYMBOL_TYPEDEF;
	  break;

	case LOC_LABEL:
	  kind = GCC_C_SYMBOL_LABEL;
	  addr = SYMBOL_VALUE_ADDRESS (sym);
	  break;

	case LOC_BLOCK:
	  kind = GCC_C_SYMBOL_FUNCTION;
	  addr = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
	  if (is_global && TYPE_GNU_IFUNC (SYMBOL_TYPE (sym)))
	    addr = gnu_ifunc_resolve_addr (target_gdbarch (), addr);
	  break;

	case LOC_CONST:
	  if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_ENUM)
	    {
	      /* Already handled by convert_enum.  */
	      return;
	    }
	  C_CTX (context)->c_ops->build_constant (C_CTX (context), sym_type,
						  SYMBOL_NATURAL_NAME (sym),
						  SYMBOL_VALUE (sym),
						  filename, line);
	  return;

	case LOC_CONST_BYTES:
	  error (_("Unsupported LOC_CONST_BYTES for symbol \"%s\"."),
		 SYMBOL_PRINT_NAME (sym));

	case LOC_UNDEF:
	  internal_error (__FILE__, __LINE__, _("LOC_UNDEF found for \"%s\"."),
			  SYMBOL_PRINT_NAME (sym));

	case LOC_COMMON_BLOCK:
	  error (_("Fortran common block is unsupported for compilation "
		   "evaluaton of symbol \"%s\"."),
		 SYMBOL_PRINT_NAME (sym));

	case LOC_OPTIMIZED_OUT:
	  error (_("Symbol \"%s\" cannot be used for compilation evaluation "
		   "as it is optimized out."),
		 SYMBOL_PRINT_NAME (sym));

	case LOC_COMPUTED:
	  if (is_local)
	    goto substitution;
	  /* Probably TLS here.  */
	  warning (_("Symbol \"%s\" is thread-local and currently can only "
		     "be referenced from the current thread in "
		     "compiled code."),
		   SYMBOL_PRINT_NAME (sym));
	  /* FALLTHROUGH */
	case LOC_UNRESOLVED:
	  /* 'symbol_name' cannot be used here as that one is used only for
	     local variables from compile_dwarf_expr_to_c.
	     Global variables can be accessed by GCC only by their address, not
	     by their name.  */
	  {
	    struct value *val;
	    struct frame_info *frame = NULL;

	    if (symbol_read_needs_frame (sym))
	      {
		frame = get_selected_frame (NULL);
		if (frame == NULL)
		  error (_("Symbol \"%s\" cannot be used because "
			   "there is no selected frame"),
			 SYMBOL_PRINT_NAME (sym));
	      }

	    val = read_var_value (sym, frame);
	    if (VALUE_LVAL (val) != lval_memory)
	      error (_("Symbol \"%s\" cannot be used for compilation "
		       "evaluation as its address has not been found."),
		     SYMBOL_PRINT_NAME (sym));

	    kind = GCC_C_SYMBOL_VARIABLE;
	    addr = value_address (val);
	  }
	  break;


	case LOC_REGISTER:
	case LOC_ARG:
	case LOC_REF_ARG:
	case LOC_REGPARM_ADDR:
	case LOC_LOCAL:
	substitution:
	  kind = GCC_C_SYMBOL_VARIABLE;
	  symbol_name = symbol_substitution_name (sym);
	  break;

	case LOC_STATIC:
	  kind = GCC_C_SYMBOL_VARIABLE;
	  addr = SYMBOL_VALUE_ADDRESS (sym);
	  break;

	case LOC_FINAL_VALUE:
	default:
	  gdb_assert_not_reached ("Unreachable case in convert_one_symbol.");

	}

      /* Don't emit local variable decls for a raw expression.  */
      if (context->base.scope != COMPILE_I_RAW_SCOPE
	  || symbol_name == NULL)
	{
	  decl = C_CTX (context)->c_ops->build_decl (C_CTX (context),
						     SYMBOL_NATURAL_NAME (sym),
						     kind,
						     sym_type,
						     symbol_name, addr,
						     filename, line);

	  C_CTX (context)->c_ops->bind (C_CTX (context), decl, is_global);
	}

      xfree (symbol_name);
    }
}
Beispiel #22
0
static int
create_type9(RECORD **anrecord, struct finger_view_minutiae_record *fvmr, 
	     unsigned int idc)
{
	FIELD *field = NULL;
	SUBFIELD *subfield = NULL;
	ITEM *item = NULL;
	RECORD *lrecord;	// For local convenience
	struct finger_minutiae_data **fmds = NULL;
	struct ridge_count_data **rcds = NULL;
	struct core_data **cds;
	struct delta_data **dds;
	char buf[16];
	int mincnt, minidx, rdgcnt;
	int cnt, i;
	unsigned int x, y; 

	if (new_ANSI_NIST_record(anrecord, TYPE_9_ID) != 0) 
		ALLOC_ERR_EXIT("Type-9 Record");

	lrecord = *anrecord;

	/*** 9.001 - Length                                    ***/ 
	// Set to 0 now, will recalculate later
	APPEND_TYPE9_FIELD(lrecord, LEN_ID, "0");

	/*** 9.002 - IDC value                                 ***/ 
	snprintf(buf, sizeof(buf), IDC_FMT, idc);
	APPEND_TYPE9_FIELD(lrecord, IDC_ID, buf);

	/*** 9.003 - Impression type                           ***/ 
	CRW(fvmr->impression_type, MIN_TABLE_5_CODE, MAX_TABLE_5_CODE,
		"Impression type");
	snprintf(buf, sizeof(buf), "%d", fvmr->impression_type);
	APPEND_TYPE9_FIELD(lrecord, IMP_ID, buf);

	/*** 9.004 - Minutiae format                           ***/
	APPEND_TYPE9_FIELD(lrecord, FMT_ID, STD_STR);

	/*** 9.005 - Originating fingerprint reading system    ***/
	if (value2subfield(&subfield, "EXISTING IMAGE") != 0)
		ERR_OUT("creating Type-9 subfield");
	if (value2item(&item, AUTO_STR) != 0)
		ERR_OUT("creating Type-9 item");
	if (append_ANSI_NIST_subfield(subfield, item) != 0)
		ERR_OUT("appending Type-9 item");
	if (new_ANSI_NIST_field(&field, TYPE_9_ID, OFR_ID) != 0)
		ERR_OUT("creating Type-9 field");
	if (append_ANSI_NIST_field(field, subfield) != 0)
		ERR_OUT("appending Type-9 subfield");
	if (append_ANSI_NIST_record(lrecord, field) != 0)
		ERR_OUT("appending Type-9 field");

	/*** 9.006 - Finger position                           ***/ 
	snprintf(buf, sizeof(buf), "%02d", fvmr->finger_number);
	APPEND_TYPE9_FIELD(lrecord, FGP2_ID, buf);

	/*** 9.007 - Fingerprint pattern classification        ***/ 
	if (value2subfield(&subfield, TBL_STR) != 0)
		ERR_OUT("creating Type-9 subfield");
	if (value2item(&item, "UN") != 0)
		ERR_OUT("creating Type-9 item");
	if (append_ANSI_NIST_subfield(subfield, item) != 0)
		ERR_OUT("appending Type-9 item");
	if (new_ANSI_NIST_field(&field, TYPE_9_ID, FPC_ID) != 0)
		ERR_OUT("creating Type-9 field");
	if (append_ANSI_NIST_field(field, subfield) != 0)
		ERR_OUT("appending Type-9 subfield");
	if (append_ANSI_NIST_record(lrecord, field) != 0)
		ERR_OUT("appending Type-9 field");

	/*** 9.008 - Core position                             ***/ 
	cnt = get_core_count(fvmr);
	if (cnt > 0) {
		if (new_ANSI_NIST_field(&field, TYPE_9_ID, CRP_ID) != 0)
			ERR_OUT("allocating field");

		cds = (struct core_data **) malloc(
			cnt * sizeof(struct core_data **));
		if (cds == NULL)
			ALLOC_ERR_EXIT("Core data");

		if (get_cores(fvmr, cds) != cnt)
			ERR_OUT("retrieving core data");

		for (i = 0; i < cnt; i++) {
			convert_xy(fvmr->fmr->x_image_size, 
				   fvmr->fmr->y_image_size,
				   fvmr->fmr->x_resolution,
				   fvmr->fmr->y_resolution,
				   cds[i]->x_coord, 
				   cds[i]->y_coord, 
				   &x, &y);
			snprintf(buf, sizeof(buf), "%04u%04u", x, y);
			if (value2subfield(&subfield, buf) != 0)
				ERR_OUT("creating subfield");
			if (append_ANSI_NIST_field(field, subfield) != 0)
				ERR_OUT("appending subfield");
		}
		if (append_ANSI_NIST_record(lrecord, field) != 0)
			ERR_OUT("adding field to record");

	} else if (cnt < 0)
		ERR_OUT("getting core record count");

	/*** 9.009 - Delta(s) position                         ***/ 
	cnt = get_delta_count(fvmr);
	if (cnt > 0) {
		if (new_ANSI_NIST_field(&field, TYPE_9_ID, DLT_ID) != 0)
			ERR_OUT("creating Type-9 field");

		dds = (struct delta_data **) malloc(
			cnt * sizeof(struct delta_data **));
		if (dds == NULL)
			ALLOC_ERR_EXIT("Delta data");

		if (get_deltas(fvmr, dds) != cnt)
			ERR_OUT("retrieving delta data");

		for (i = 0; i < cnt; i++) {
			convert_xy(fvmr->fmr->x_image_size, 
				   fvmr->fmr->y_image_size,
				   fvmr->fmr->x_resolution,
				   fvmr->fmr->y_resolution,
				   dds[i]->x_coord, 
				   dds[i]->y_coord, 
				   &x, &y);
			snprintf(buf, sizeof(buf), "%04u%04u", x, y);
			if (value2subfield(&subfield, buf) != 0)
				ERR_OUT("creating subfield");
			if (append_ANSI_NIST_field(field, subfield) != 0)
				ERR_OUT("appending subfield");
		}
		if (append_ANSI_NIST_record(lrecord, field) != 0)
			ERR_OUT("adding field to record");

	} else if (cnt < 0)
		ERR_OUT("getting delta record count");

	/*** 9.010 - Number of minutiae                        ***/ 
	mincnt = get_fmd_count(fvmr);
	if (mincnt < 0)
		ERR_OUT("getting minutiae count");

	snprintf(buf, sizeof(buf), "%d", mincnt);
	APPEND_TYPE9_FIELD(lrecord, MIN_ID, buf);

	/*** 9.011 - Minutiae ridge count indicator            ***/ 
	rdgcnt = get_rcd_count(fvmr);
	if (rdgcnt > 0) {
		rcds = (struct ridge_count_data **) malloc(
			rdgcnt * sizeof(struct ridge_count_data **));
		if (rcds == NULL)
			ALLOC_ERR_EXIT("Ridge Count data");

		if (get_rcds(fvmr, rcds) != rdgcnt)
			ERR_OUT("retrieving ridge count data");

		APPEND_TYPE9_FIELD(lrecord, RDG_ID, "1");
	} else if (rdgcnt < 0)
		ERR_OUT("getting ridge record count");
	else
		APPEND_TYPE9_FIELD(lrecord, RDG_ID, "0");

	/*** 9.012 - Minutiae and ridge count data             ***/ 
	fmds = (struct finger_minutiae_data **) malloc(
		mincnt * sizeof(struct finger_minutiae_data **));
	if (fmds == NULL)
		ALLOC_ERR_EXIT("Finger Minutiae data");

	if (get_fmds(fvmr, fmds) != mincnt)
		ERR_OUT("retrieving minutiae data");

	if (new_ANSI_NIST_field(&field, TYPE_9_ID, MRC_ID) != 0)
		ERR_OUT("creating Type-9 field");

	for (minidx = 0; minidx < mincnt; minidx++) {
		unsigned int theta, rdgidx, minqual;
		char mintype;
		int idxnum = minidx + 1;

		// Index number
		snprintf(buf, sizeof(buf), "%03d", idxnum);
		if (value2subfield(&subfield, buf) != 0)
			ERR_OUT("creating Type-9 subfield");

		// X, Y, and theta values
		convert_xy(fvmr->fmr->x_image_size, fvmr->fmr->y_image_size,
			   fvmr->fmr->x_resolution, fvmr->fmr->y_resolution,
			   fmds[minidx]->x_coord, fmds[minidx]->y_coord, 
			   &x, &y);
		convert_theta(fmds[minidx]->angle, &theta);
		snprintf(buf, sizeof(buf), "%04u%04u%03u", x, y, theta);
		if (value2item(&item, buf) != 0)
			ERR_OUT("creating Type-9 item");
		if (append_ANSI_NIST_subfield(subfield, item) != 0)
			ERR_OUT("appending Type-9 item");

		// Quality measure
		convert_quality(fmds[minidx]->quality, &minqual);
		snprintf(buf, sizeof(buf), "%u", minqual);
		if (value2item(&item, buf) != 0)
			ERR_OUT("creating Type-9 item");
		if (append_ANSI_NIST_subfield(subfield, item) != 0)
			ERR_OUT("appending Type-9 item");

		// Minutia type designation
		convert_type(fmds[minidx]->type, &mintype);
		snprintf(buf, sizeof(buf), "%c", mintype);
		if (value2item(&item, buf) != 0)
			ERR_OUT("creating Type-9 item");
		if (append_ANSI_NIST_subfield(subfield, item) != 0)
			ERR_OUT("appending Type-9 item");

		// Ridge count data: If the one of the index numbers
		// in the record matches the minutia index, then add that
		// ridge count data to the Type-9 record, using the index
		// number that is the 'other'.
		for (rdgidx = 0; rdgidx < rdgcnt; rdgidx++) {
		    if ((rcds[rdgidx]->index_one == idxnum) ||
			(rcds[rdgidx]->index_two == idxnum)) {
			    snprintf(buf, sizeof(buf), "%u,%u", 
				(rcds[rdgidx]->index_one == idxnum) ?
			 	rcds[rdgidx]->index_two :
				rcds[rdgidx]->index_one,
				rcds[rdgidx]->count);

			    if (value2item(&item, buf) != 0)
					ERR_OUT("creating Type-9 item");
			    if (append_ANSI_NIST_subfield(subfield, item) != 0)
					ERR_OUT("appending Type-9 item");
		    }
		}

		if (append_ANSI_NIST_field(field, subfield) != 0)
			ERR_OUT("appending Type-9 subfield");
	}
	free(fmds);
	if (append_ANSI_NIST_record(lrecord, field) != 0)
		ERR_OUT("appending Type-9 field");
	/*** End of minutiae and ridge count                 */

	// Calculate and update the record length field
	if (update_ANSI_NIST_tagged_record_LEN(lrecord) != 0)
		ERR_OUT("updating Type-9 record length");

	return 0;

err_out:
	fprintf(stderr, "Error creating Type-9 record\n");
	if (item != NULL)
		free_ANSI_NIST_item(item);
	if (subfield != NULL)
		free_ANSI_NIST_subfield(subfield);
	if (field != NULL)
		free_ANSI_NIST_field(field);
	if (lrecord != NULL)
		free_ANSI_NIST_record(lrecord);
	if (fmds != NULL)
		free(fmds);

	return -1;
}
compile_scope
compile_cplus_instance::new_scope (const char *type_name, struct type *type)
{
  /* Break the type name into components.  If TYPE was defined in some
     superclass, we do not process TYPE but process the enclosing type
     instead.  */
  compile_scope scope = type_name_to_scope (type_name, block ());

  if (!scope.empty ())
    {
      /* Get the name of the last component, which should be the
	 unqualified name of the type to process.  */
      scope_component &comp = scope.back ();

      if (!types_equal (type, SYMBOL_TYPE (comp.bsymbol.symbol))
	  && (m_scopes.empty ()
	      || (m_scopes.back ().back ().bsymbol.symbol
		  != comp.bsymbol.symbol)))
	{
	  /* The type is defined inside another class(es).  Convert that
	     type instead of defining this type.  */
	  convert_type (SYMBOL_TYPE (comp.bsymbol.symbol));

	  /* If the original type (passed in to us) is defined in a nested
	     class, the previous call will give us that type's gcc_type.
	     Upper layers are expecting to get the original type's
	     gcc_type!  */
	  get_cached_type (type, &scope.m_nested_type);
	  return scope;
	}
    }
  else
    {
      if (TYPE_NAME (type) == nullptr)
	{
	  /* Anonymous type  */

	  /* We don't have a qualified name for this to look up, but
	     we need a scope.  We have to assume, then, that it is the same
	     as the current scope, if any.  */
	  if (!m_scopes.empty ())
	    {
	      scope = m_scopes.back ();
	      scope.m_pushed = false;
	    }
	  else
	    scope.push_back (scope_component ());
	}
      else
	{
	  scope_component comp
	    = {
	        decl_name (TYPE_NAME (type)).get (),
		lookup_symbol (TYPE_NAME (type), block (), VAR_DOMAIN, nullptr)
	      };
	  scope.push_back (comp);
	}
    }

  /* There must be at least one component in the compile_scope.  */
  gdb_assert (scope.size () > 0);
  return scope;
}
Beispiel #24
0
void
print_icmp ()
{
    struct in_addr d_addr, s_addr;
    extern struct iphdr *ip;
    extern struct icmphdr *icmp;
    extern char *payload;
    extern struct ether_header *eptr;

    char *daddr, *saddr;
    time_t current;

    int i, type;
    int payload_len;

    struct ether_addr smac_addr;
    struct ether_addr dmac_addr;
    struct timeval tv;
    struct tm *t;

    int op_host = get_host ();

    d_addr.s_addr = ip->daddr;
    s_addr.s_addr = ip->saddr;


    for (i = 0; i <= ETH_ALEN; i++) {
        smac_addr.ether_addr_octet[i] = eptr->ether_shost[i];
        dmac_addr.ether_addr_octet[i] = eptr->ether_dhost[i];
    }

    current = time (NULL);
    gettimeofday (&tv, NULL);

    t = gmtime (&current);
    type = ntohs (eptr->ether_type);

    nk_printf ("%d:%d:%d-%ld  ", t->tm_hour, t->tm_min, t->tm_sec, tv.tv_usec);


    daddr = ether_ntoa (&dmac_addr);
    print_mac (daddr);
    nk_printf ("-> ");
    saddr = ether_ntoa (&smac_addr);
    print_mac (saddr);

    nk_printf (" Type:0x%X [%s]  Len:%d  ", type, convert_type (type), ntohs (ip->tot_len));

    saddr = inet_ntoa (s_addr);

    if (op_host) {
        nk_printf ("%s -> ", nk_resolve (saddr));
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s", nk_resolve (daddr));
    } else {
        nk_printf ("%s -> ", saddr);
        daddr = inet_ntoa (d_addr);
        nk_printf ("%s ", daddr);
    }

    nk_printf (" ICMP  %s  Type:%d  Code:%d  ",
               convert_icmp (icmp->code, icmp->type), icmp->type, icmp->code);

    if (icmp->type == 0 || icmp->type == 8) {
        nk_printf ("[ EchoID:%d  Seq:%d  ", ntohs ((icmp->un).echo.id),
                   ntohs ((icmp->un).echo.sequence));

        nk_printf ("TOS:0x%x  ID:%d  TTL:%d ]  ", ip->tos, ntohs (ip->id), ip->ttl);
    }


    /* ip */
    nk_printf ("TOS:0x%x  ID:%d  TTL:%d", ip->tos, ntohs (ip->id), ip->ttl);
    nk_printf ("\n\n");

    payload_len = (ntohs (ip->tot_len) - ICMP_LEN - IP_LEN);
    print_payload (payload, payload_len, ip, 0);
    return;
}
Beispiel #25
0
void do_convert_type (const std::vector<S> &svec, std::vector<D> &dvec)
{
    convert_type (&svec[0], &dvec[0], svec.size());
    DoNotOptimize (dvec[0]);  // Be sure nothing is optimized away
}
Beispiel #26
0
static void createDescription( const QValueList<Widget> &l, QTextStream &ts )
{
    int indent = 0;
    ts << "<!DOCTYPE CW><CW>" << endl;
    ts << makeIndent( indent ) << "<customwidgets>" << endl;
    indent++;

    for ( QValueList<Widget>::ConstIterator it = l.begin(); it != l.end(); ++it ) {
	Widget w = *it;
	ts << makeIndent( indent ) << "<customwidget>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<class>" << w.w->className() << "</class>" << endl;
	ts << makeIndent( indent ) << "<header location=\"" << w.location << "\">" << w.include << "</header>" << endl;
	ts << makeIndent( indent ) << "<sizehint>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<width>" << w.w->sizeHint().width() << "</width>" << endl;
	ts << makeIndent( indent ) << "<height>" << w.w->sizeHint().height() << "</height>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizehint>" << endl;
	ts << makeIndent( indent ) << "<container>" << ( w.w->inherits( "QGroupBox" ) || w.w->inherits( "QWidgetStack" ) ) << "</container>" << endl;
	ts << makeIndent( indent ) << "<sizepolicy>" << endl;
	indent++;
	ts << makeIndent( indent ) << "<hordata>" << (int)w.w->sizePolicy().horData() << "</hordata>" << endl;
	ts << makeIndent( indent ) << "<verdata>" << (int)w.w->sizePolicy().verData() << "</verdata>" << endl;
	indent--;
	ts << makeIndent( indent ) << "</sizepolicy>" << endl;
	
	QStrList sigs = w.w->metaObject()->signalNames( TRUE );
	if ( !sigs.isEmpty() ) {
	    for ( int i = 0; i < (int)sigs.count(); ++i )
		ts << makeIndent( indent ) << "<signal>" << entitize( sigs.at( i ) ) << "</signal>" << endl;
	}
	QStrList slts = w.w->metaObject()->slotNames( TRUE );
	if ( !slts.isEmpty() ) {
	    for ( int i = 0; i < (int)slts.count(); ++i ) {
		QMetaData::Access data = w.w->metaObject()->slot( i, TRUE )->access;
		if ( data == QMetaData::Private )
		    continue;
		ts << makeIndent( indent ) << "<slot access=\""
		   << ( data == QMetaData::Protected ? "protected" : "public" )
		   << "\">" << entitize( slts.at( i ) ) << "</slot>" << endl;
	    }
	}	
	QStrList props = w.w->metaObject()->propertyNames( TRUE );
	if ( !props.isEmpty() ) {
	    for ( int i = 0; i < (int)props.count(); ++i ) {
		const QMetaProperty *p = w.w->metaObject()->
					 property( w.w->metaObject()->
						   findProperty( props.at( i ), TRUE ), TRUE );
		if ( !p )
		    continue;
		if ( !p->writable() || !p->designable( w.w ) )
		    continue;
		ts << makeIndent( indent ) << "<property type=\"" << convert_type( p->type() ) << "\">" << entitize( p->name() ) << "</property>" << endl;
	    }
	}
	indent--;
	ts << makeIndent( indent ) << "</customwidget>" << endl;
    }

    indent--;
    ts << makeIndent( indent ) << "</customwidgets>" << endl;
    ts << "</CW>" << endl;
}