bool AdbInterfaceObject::GetInterfaceName(void* buffer,
                                          unsigned long* buffer_char_size,
                                          bool ansi) {
  if (NULL == buffer_char_size) {
    SetLastError(ERROR_INVALID_PARAMETER);
    return false;
  }

  // Lets see if buffer is big enough
  ULONG name_len = static_cast<ULONG>(interface_name_.length() + 1);
  if ((NULL == buffer) || (*buffer_char_size < name_len)) {
    *buffer_char_size = name_len;
    SetLastError(ERROR_INSUFFICIENT_BUFFER);
    return false;
  }

  if (!ansi) {
    // If user asked for wide char name just return it
    wcscpy(reinterpret_cast<wchar_t*>(buffer), interface_name().c_str());
    return true;
  }

  // We need to convert name from wide char to ansi string
  int res = WideCharToMultiByte(CP_ACP,
                                0,
                                interface_name().c_str(),
                                static_cast<int>(name_len),
                                reinterpret_cast<PSTR>(buffer),
                                static_cast<int>(*buffer_char_size),
                                NULL,
                                NULL);
  return (res != 0);
}
Exemplo n.º 2
0
Arquivo: genarr.c Projeto: spchamp/ilu
PRIVATE void
registerTheType(Type t, char * baseTypeName)
/* Registers the type of the array for variant support */
{
    TypeDescription d = type_description(t);
    Type elementType = d->structuredDes.array.type;
    list dimList = d->structuredDes.array.dimensions;
    int dimCnt = list_size(dimList);
    printf("    static{\n");
    printf("        int[] dims = new int[%d];\n", dimCnt);
    C_LOOP_BEGIN(dimList, Argument, a, idx, temp)
        printf("        dims[%d] = %lu;\n", 
            idx,
            list_ref(dimList, idx)
            );
    C_LOOP_END(idx)
    printf("        xerox.ilu.IluTypeRep.registerArrayType(\n");
    printf("            %s, //name\n", qoString(unresolvedIslTypeName(t)));
    printf("            %s, //islIfName\n", 
        qoString(interface_name(currentIfc)));
    printf("            %s, //islIfBrand\n", qoString(currentIfc->brand));
    printf("            %s, //uid\n", qoString(t->uid));
    printf("            %s, //baseUID\n", qoString(elementType->uid));
    printf("            %d, //dimcnt\n", dimCnt);
    printf("            dims); //dims\n");
    printf("    }//static\n");
}
Exemplo n.º 3
0
static void
  add_interfacedesc (Interface i, struct buffer_s *data)
{
  printmToBuffer (data, "(interface %s ", interface_name(i));
  add_quoted_string (i->brand, data);
  print0ToBuffer (data, ")");
}
SDBAPIHANDLE SdbLegacyInterfaceObject::OpenEndpoint(
    const wchar_t* endpoint_name,
    UCHAR endpoint_id,
    UCHAR endpoint_index,
    SdbOpenAccessType access_type,
    SdbOpenSharingMode sharing_mode) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  SdbLegacyEndpointObject* sdb_endpoint = NULL;

  try {
    sdb_endpoint =
        new SdbLegacyEndpointObject(this, endpoint_id, endpoint_index);
  } catch (...) {
    // We don't expect exceptions other than OOM thrown here.
    SetLastError(ERROR_OUTOFMEMORY);
    return NULL;
  }

  // Build full path to the object
  std::wstring endpoint_path = interface_name();
  endpoint_path += L"\\";
  endpoint_path += endpoint_name;

  SDBAPIHANDLE ret = sdb_endpoint->CreateHandle(endpoint_path.c_str(),
                                                access_type,
                                                sharing_mode);

  sdb_endpoint->Release();

  return ret;
}
ADBAPIHANDLE AdbInterfaceObject::OpenEndpoint(
    const wchar_t* endpoint_name,
    AdbOpenAccessType access_type,
    AdbOpenSharingMode sharing_mode) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  AdbEndpointObject* adb_endpoint = NULL;
  
  try {
    adb_endpoint = new AdbEndpointObject(this);
  } catch (...) {
    SetLastError(ERROR_OUTOFMEMORY);
    return NULL;
  }

  // Build full path to the object
  std::wstring endpoint_path = interface_name();
  endpoint_path += L"\\";
  endpoint_path += endpoint_name;

  ADBAPIHANDLE ret = adb_endpoint->CreateHandle(endpoint_path.c_str(),
                                                access_type,
                                                sharing_mode);

  adb_endpoint->Release();

  return ret;
}
ADBAPIHANDLE AdbInterfaceObject::CreateHandle() {
  // Open USB device for this intefface
  HANDLE usb_device_handle = CreateFile(interface_name().c_str(),
                                        GENERIC_READ | GENERIC_WRITE,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
                                        NULL,
                                        OPEN_EXISTING,
                                        0,
                                        NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle)
    return NULL;

  // Now, we ensured that our usb device / interface is up and running.
  // Lets collect device, interface and pipe information
  bool ok = true;
  if (!CacheUsbDeviceDescriptor(usb_device_handle) ||
      !CacheUsbConfigurationDescriptor(usb_device_handle) ||
      !CacheUsbInterfaceDescriptor(usb_device_handle)) {
    ok = false;
  }

  // Preserve error accross handle close
  ULONG error = ok ? NO_ERROR : GetLastError();

  ::CloseHandle(usb_device_handle);

  if (NO_ERROR != error)
    SetLastError(error);

  if (!ok)
    return false;

  return AdbObjectHandle::CreateHandle();
}
Exemplo n.º 7
0
/* Function to enumerate command and interface names */
const char *command_name(void *v, int i)
{
	int cmd_cnt = NELEM(commands);

	if (i >= cmd_cnt)
		return interface_name(v, i - cmd_cnt);
	else
		return commands[i].name;
}
Exemplo n.º 8
0
static void
  add_exceptiondesc (Exception e, struct buffer_s *data, /* OUT */ list referenced)
{
  printmToBuffer (data, "(exception %s %s \"\"",
		  interface_name(exception_interface(e)), exception_name(e));
  if ((e->type != NULL) && (type_ur_kind(e->type) != void_Type)) {
    print0ToBuffer (data, " ");
    add_typeref (e->type, data, referenced);
  } else {
    print0ToBuffer (data, " void");
  }
  print0ToBuffer (data, ")");
}
Exemplo n.º 9
0
static void add_exnref (Exception exn, struct buffer_s *data, list referenced)
{
  print0ToBuffer (data, "(exn ");
  if (exn->corba_rep_id != NULL) {
    print0ToBuffer(data, "(id ");
    add_quoted_string(exn->corba_rep_id, data);
    print0ToBuffer(data, ")");
  } else {
    printmToBuffer (data, "(ref %s %s)", interface_name(exception_interface(exn)), exception_name(exn));
    add_entity (ExceptionE, exn, referenced);
  }
  printmToBuffer (data, ")");
}
Exemplo n.º 10
0
static char *full_type_name(Type t)
{
  string n;

  if ((n = name_lang_name (t->name, "parser:full")) == NULL)
    {
      char buf[1024];
      sprintf (buf, "%s%s%s.%s",
	       t->builtIn ? "ilu" : interface_name(t->interface),
	       t->builtIn ? "" : (t->interface->brand != NULL) ? "|" : "",
	       t->builtIn ? "" : (t->interface->brand != NULL) ? t->interface->brand : "",
	       type_name(t));
      name_set_lang_name (t->name, "parser:full", buf);
      n = name_lang_name(t->name, "parser:full");
    }
  return (n);
}
Exemplo n.º 11
0
PUBLIC void enm_helpInnerCallback(Type t)
{
    list enum_field = type_description(t)->structuredDes.enumeration;
    printf("    static {\n");
    printf("        xerox.ilu.IluTypeRep __t = null;\n");
    printf("        __t = xerox.ilu.IluTypeRep.registerEnumerationType(\n");
    printf("            %s, //name\n", qoString(unresolvedIslTypeName(t)));
    printf("            %s, //islIfName\n",
        qoString(interface_name(currentIfc)));
    printf("            %s, //islIfBrand\n",qoString(currentIfc->brand));
    printf("            %s, //uid\n", qoString(t->uid));
    printf("            %d //elCnt\n", list_size(enum_field));
    printf("            );\n");
    registerEnumLiterals(t, "__t");
    printf("        __t.finish();\n");
    printf("        __t = null;\n");
    printf("    } //static\n");
} /* enm_helpInnerCallback */ 
Exemplo n.º 12
0
bool AdbInterfaceObject::GetEndpointInformation(UCHAR endpoint_index,
                                                AdbEndpointInformation* info) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  // Open USB device for this intefface
  HANDLE usb_device_handle = CreateFile(interface_name().c_str(),
                                        FILE_READ_ATTRIBUTES | FILE_READ_EA,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
                                        NULL,
                                        OPEN_EXISTING,
                                        0,
                                        NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle)
    return NULL;

  // Init ICTL param
  AdbQueryEndpointInformation param;
  param.endpoint_index = endpoint_index;

  // Send IOCTL
  DWORD ret_bytes = 0;
  BOOL ret = DeviceIoControl(usb_device_handle,
                             ADB_IOCTL_GET_ENDPOINT_INFORMATION,
                             &param, sizeof(param),
                             info, sizeof(AdbEndpointInformation),
                             &ret_bytes,
                             NULL);
  ATLASSERT(!ret || (sizeof(AdbEndpointInformation) == ret_bytes));

  // Preserve error accross CloseHandle
  ULONG error = ret ? NO_ERROR : GetLastError();

  ::CloseHandle(usb_device_handle);

  if (NO_ERROR != error)
    SetLastError(error);

  return ret ? true : false;
}
Exemplo n.º 13
0
SDBAPIHANDLE SdbLegacyInterfaceObject::CreateHandle() {
  // Open USB device for this intefface
  HANDLE usb_device_handle = CreateFile(interface_name().c_str(),
                                        GENERIC_READ | GENERIC_WRITE,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
                                        NULL,
                                        OPEN_EXISTING,
                                        0,
                                        NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle) {
    return NULL;
  }

  // Now, we ensured that our usb device / interface is up and running.
  // Lets collect device, interface and pipe information
  bool ok = true;
  if (!CacheUsbDeviceDescriptor(usb_device_handle) ||
      !CacheUsbConfigurationDescriptor(usb_device_handle) ||
      !CacheUsbInterfaceDescriptor(usb_device_handle)) {
    ok = false;
  }

  // Preserve error accross handle close
  ULONG error = ok ? NO_ERROR : GetLastError();

  ::CloseHandle(usb_device_handle);

  if (NO_ERROR != error) {
    SetLastError(error);
  }

  if (!ok) {
    return false;
  }

  // Save indexes and IDs for bulk read / write endpoints. We will use them to
  // convert SDB_QUERY_BULK_WRITE_ENDPOINT_INDEX and
  // SDB_QUERY_BULK_READ_ENDPOINT_INDEX into actual endpoint indexes and IDs.
  for (UCHAR endpoint = 0; endpoint < usb_interface_descriptor_.bNumEndpoints;
       endpoint++) {
    // Get endpoint information
    SdbEndpointInformation pipe_info;
    if (!GetEndpointInformation(endpoint, &pipe_info)) {
      return false;
    }

    if (SdbEndpointTypeBulk == pipe_info.endpoint_type) {
      // This is a bulk endpoint. Cache its index and ID.
      if (0 != (pipe_info.endpoint_address & USB_ENDPOINT_DIRECTION_MASK)) {
        // Use this endpoint as default bulk read endpoint
        ATLASSERT(0xFF == def_read_endpoint_);
        def_read_endpoint_ = endpoint;
        read_endpoint_id_ = pipe_info.endpoint_address;
      } else {
        // Use this endpoint as default bulk write endpoint
        ATLASSERT(0xFF == def_write_endpoint_);
        def_write_endpoint_ = endpoint;
        write_endpoint_id_ = pipe_info.endpoint_address;
      }
    }
  }

  return SdbObjectHandle::CreateHandle();
}
Exemplo n.º 14
0
bool SdbLegacyInterfaceObject::GetSerialNumber(void* buffer,
                                               unsigned long* buffer_char_size,
                                               bool ansi) {
  if (!IsOpened()) {
    SetLastError(ERROR_INVALID_HANDLE);
    return false;
  }

  // Open USB device for this intefface
  HANDLE usb_device_handle = CreateFile(interface_name().c_str(),
                                        GENERIC_READ,
                                        FILE_SHARE_READ | FILE_SHARE_WRITE,
                                        NULL,
                                        OPEN_EXISTING,
                                        0,
                                        NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle) {
    return NULL;
  }

  WCHAR serial_number[512];

  // Send IOCTL
  DWORD ret_bytes = 0;
  BOOL ret = DeviceIoControl(usb_device_handle,
                             SDB_IOCTL_GET_SERIAL_NUMBER,
                             NULL, 0,
                             serial_number, sizeof(serial_number),
                             &ret_bytes,
                             NULL);

  // Preserve error accross CloseHandle
  ULONG error = ret ? NO_ERROR : GetLastError();

  ::CloseHandle(usb_device_handle);

  if (NO_ERROR != error) {
    SetLastError(error);
    return false;
  }

  unsigned long str_len =
    static_cast<unsigned long>(wcslen(serial_number) + 1);

  if ((NULL == buffer) || (*buffer_char_size < str_len)) {
    *buffer_char_size = str_len;
    SetLastError(ERROR_INSUFFICIENT_BUFFER);
    return false;
  }

  if (!ansi) {
    // If user asked for wide char name just return it
    wcscpy(reinterpret_cast<wchar_t*>(buffer), serial_number);
    return true;
  }

  // We need to convert name from wide char to ansi string
  int res = WideCharToMultiByte(CP_ACP,
                                0,
                                serial_number,
                                static_cast<int>(str_len),
                                reinterpret_cast<PSTR>(buffer),
                                static_cast<int>(*buffer_char_size),
                                NULL,
                                NULL);
  return (res != 0);
}
Exemplo n.º 15
0
static void
  add_typedesc (Type t, struct buffer_s *data, /* OUT */ list referenced)
{
  unsigned int i, j;
  Argument arg;
  EnumField ef;
  Exception exn;
  Class obj;
  Procedure meth;
  struct ilu_integerLiteral_s lit;

  printmToBuffer (data, "(type %s %s ",
		  t->builtIn ? "ilu" : interface_name(type_interface(t)),
		  type_name(t));

  add_quoted_string(t->brand, data);
  switch (type_basic_type(t))
    {
    case array_Type:
      print0ToBuffer (data, " (array ");
      add_typeref (type_description(t)->structuredDes.array.type, data, referenced);
      for (i = 0;  i < list_size(type_description(t)->structuredDes.array.dimensions);  i++) {
	printmToBuffer (data, " (fixed %lu)",
			(unsigned) list_ref(type_description(t)->structuredDes.array.dimensions, i));
      }
      print0ToBuffer (data, ")");
      break;

    case sequence_Type:
      print0ToBuffer (data, " (sequence ");
      add_typeref (type_description(t)->structuredDes.sequence.type, data, referenced);
      printmToBuffer (data, " (variable %lu))",
		      (type_description(t)->structuredDes.sequence.limit == 0) ? 0xFFFFFFFF : ((unsigned long) type_description(t)->structuredDes.sequence.limit));
      break;

    case record_Type:
      print0ToBuffer (data, " (record");
      for (i = 0;  i < list_size(type_description(t)->structuredDes.record.fields); i++) {
	printmToBuffer (data, " (field %s ", argument_name((Argument) list_ref(type_description(t)->structuredDes.record.fields, i)));
	add_typeref (argument_type((Argument) list_ref(type_description(t)->structuredDes.record.fields, i)), data, referenced);
	print0ToBuffer (data, ")");
      };
      print0ToBuffer (data, ")");
      break;
      
    case optional_Type:
      print0ToBuffer (data, " (optional ");
      add_typeref (type_description(t)->structuredDes.optional, data, referenced);
      print0ToBuffer (data, ")");
      break;

    case reference_Type:
      print0ToBuffer (data, " (reference ");
      add_typeref (type_description(t)->structuredDes.reference.base_type, data, referenced);
      printmToBuffer (data, " (optional %s)",
		      type_description(t)->structuredDes.reference.optional ? "true" : "false");
      printmToBuffer (data, " (aliased %s)",
		      type_description(t)->structuredDes.reference.aliased ? "true" : "false");
      print0ToBuffer (data, ")");
      break;

    case union_Type:
      print0ToBuffer (data, " (union ");
      add_typeref (type_description(t)->structuredDes.uniond.discriminator_type, data, referenced);
      for (i = 0;  i < list_size(type_description(t)->structuredDes.uniond.types); i++) {
	arg = (Argument) list_ref(type_description(t)->structuredDes.uniond.types, i);
	print0ToBuffer (data, " (arm ");
	add_typeref (argument_type(arg), data, referenced);
	if (argument_name(arg) != NULL)
	  printmToBuffer (data, "(name %s) ", argument_name(arg));
	printmToBuffer (data, "(%s)",
			(arg == type_description(t)->structuredDes.uniond.default_arm) ? "default" : "");
	for (j = 0;  j < list_size(arg->values);  j++) {
	  print0ToBuffer(data, "(val");
	  add_constant (list_ref(arg->values, j), data);
	  print0ToBuffer(data, ")");
	}
	print0ToBuffer (data, ")");
      }
      if (type_description(t)->structuredDes.uniond.others_allowed)
	print0ToBuffer (data, " ((default) void)");
      print0ToBuffer (data, ")");
      break;

    case enumeration_Type:
      print0ToBuffer (data, " (enumeration");
      for (i = 0;  i < list_size(type_description(t)->structuredDes.enumeration);  i++) {
	ef = (EnumField) list_ref(type_description(t)->structuredDes.enumeration, i);
	printmToBuffer (data, " (element %s %d)", ef->name, ef->id);
      }
      print0ToBuffer (data, ")");
      break;

    case fixedpoint_Type:
      print0ToBuffer (data, " (fixedpoint ");
      add_integer_literal (type_description(t)->structuredDes.fixed.min_numerator, data);
      print0ToBuffer (data, " ");
      add_integer_literal (type_description(t)->structuredDes.fixed.max_numerator, data);
      print0ToBuffer (data, " ");
      lit = *type_description(t)->structuredDes.fixed.denominator;
      if (lit.negative) {
	lit.negative = FALSE;
	print0ToBuffer (data, "1/");
      }
      add_integer_literal (&lit, data);
      print0ToBuffer (data, ")");
      break;

    case string_Type:
      printmToBuffer (data, " (string %lu \"%s\" %u)",
		      type_description(t)->structuredDes.string.max_length,
		      ((type_description(t)->structuredDes.string.language != 0)
		       ? type_description(t)->structuredDes.string.language : ""),
		      type_description(t)->structuredDes.string.charset);
      break;

    case object_Type:
      obj = class_object(t);
      print0ToBuffer (data, " (object");
      if (obj->singleton != NULL)
	printmToBuffer (data, " (singleton \"%s\")", obj->singleton);
      if (obj->optional)
	print0ToBuffer (data, " optional");
      if (obj->collectible)
	print0ToBuffer (data, " collectible");
      for (i = 0;  i < list_size(obj->superclasses);  i++) {
	print0ToBuffer (data, " (supertype ");
	add_typeref ((Type) list_ref(obj->superclasses, i), data, referenced);
	print0ToBuffer (data, ")");
      }
      for (i = 0;  i < list_size(obj->methods); i++) {
	meth = (Procedure) list_ref(obj->methods, i);
	printmToBuffer (data, " (method %s %s%s(returns",
			name_base_name(meth->name),
			meth->asynch ? "asynchronous " : "",
			meth->functional ? "functional " : "");
	if (meth->returnType != NULL && (type_ur_kind(meth->returnType) != void_Type)) {
	  print0ToBuffer (data, " ");
	  add_typeref (meth->returnType, data, referenced);
	} else {
	  print0ToBuffer (data, " void");
	}
	for (j = 0;  j < list_size(meth->exceptions);  j++) {
	  print0ToBuffer (data, " ");
	  exn = (Exception) list_ref(meth->exceptions, j);
	  add_exnref (exn, data, referenced);
	}
	print0ToBuffer (data, ")");
	for (j = 0;  j < list_size(meth->arguments);  j++) {
	  arg = (Argument) list_ref(meth->arguments, j);
	  printmToBuffer (data, " (parameter %s %s ", argument_name(arg), argument_direction(arg));
	  add_typeref (argument_type(arg), data, referenced);
	  if (arg->sibling)
	    print0ToBuffer (data, " sibling");
	  print0ToBuffer(data, ")");
	}
	print0ToBuffer (data, ")");
      }
      print0ToBuffer (data, ")");
      break;

    case alias_Type:
      print0ToBuffer (data, " (redef ");
      add_typeref(under_type(t), data, referenced);
      printmToBuffer (data, " \"%s\")", type_uid(t));
      break;

    default:
      break;
    }
  print0ToBuffer (data, ")");
}  
ADBAPIHANDLE AdbWinUsbInterfaceObject::CreateHandle() {
  // Open USB device for this inteface Note that WinUsb API
  // requires the handle to be opened for overlapped I/O.
  usb_device_handle_ = CreateFile(interface_name().c_str(),
                                  GENERIC_READ | GENERIC_WRITE,
                                  FILE_SHARE_READ | FILE_SHARE_WRITE,
                                  NULL, OPEN_EXISTING,
                                  FILE_FLAG_OVERLAPPED, NULL);
  if (INVALID_HANDLE_VALUE == usb_device_handle_)
    return NULL;

  // Initialize WinUSB API for this interface
  if (!WinUsb_Initialize(usb_device_handle_, &winusb_handle_))
    return NULL;

  // Cache current interface number that will be used in
  // WinUsb_Xxx calls performed on this interface.
  if (!WinUsb_GetCurrentAlternateSetting(winusb_handle(), &interface_number_))
    return false;

  // Cache interface properties
  unsigned long bytes_written;

  // Cache USB device descriptor
  if (!WinUsb_GetDescriptor(winusb_handle(), USB_DEVICE_DESCRIPTOR_TYPE, 0, 0,
                            reinterpret_cast<PUCHAR>(&usb_device_descriptor_),
                            sizeof(usb_device_descriptor_), &bytes_written)) {
    return false;
  }

  // Cache USB configuration descriptor
  if (!WinUsb_GetDescriptor(winusb_handle(), USB_CONFIGURATION_DESCRIPTOR_TYPE,
                            0, 0,
                            reinterpret_cast<PUCHAR>(&usb_config_descriptor_),
                            sizeof(usb_config_descriptor_), &bytes_written)) {
    return false;
  }

  // Cache USB interface descriptor
  if (!WinUsb_QueryInterfaceSettings(winusb_handle(), interface_number(),
                                     &usb_interface_descriptor_)) {
    return false;
  }

  // Save indexes and IDs for bulk read / write endpoints. We will use them to
  // convert ADB_QUERY_BULK_WRITE_ENDPOINT_INDEX and
  // ADB_QUERY_BULK_READ_ENDPOINT_INDEX into actual endpoint indexes and IDs.
  for (UCHAR endpoint = 0; endpoint < usb_interface_descriptor_.bNumEndpoints;
       endpoint++) {
    // Get endpoint information
    WINUSB_PIPE_INFORMATION pipe_info;
    if (!WinUsb_QueryPipe(winusb_handle(), interface_number(), endpoint,
                          &pipe_info)) {
      return false;
    }

    if (UsbdPipeTypeBulk == pipe_info.PipeType) {
      // This is a bulk endpoint. Cache its index and ID.
      if (0 != (pipe_info.PipeId & USB_ENDPOINT_DIRECTION_MASK)) {
        // Use this endpoint as default bulk read endpoint
        ATLASSERT(0xFF == def_read_endpoint_);
        def_read_endpoint_ = endpoint;
        read_endpoint_id_ = pipe_info.PipeId;
      } else {
        // Use this endpoint as default bulk write endpoint
        ATLASSERT(0xFF == def_write_endpoint_);
        def_write_endpoint_ = endpoint;
        write_endpoint_id_ = pipe_info.PipeId;
      }
    }
  }

  return AdbInterfaceObject::CreateHandle();
}
Exemplo n.º 17
0
char *FigureTypeUID (Type t)
{
  struct buffer_s buffer;
  unsigned char hash[20];
  SHS_CTX ctx;
  static boolean initialized = FALSE;
  Type t2;

  if (! initialized)
    {
      verbose = (getenv ("ILU_TYPE_UID_VERBOSE") != NULL);
      initialized = TRUE;
    }


  if (type_uid(t) != NULL)
    return (type_uid(t));

  assert((t->importInterfaceName == NULL) || (type_kind(t) == alias_Type));

  if (type_kind(t) == alias_Type || t->importInterfaceName != NULL)
    return (type_uid(t) = ilu_strdup(FigureTypeUID(under_type(t))));

  if (type_kind(t) == object_Type &&
      class_object(t) != NULL &&
      class_object(t)->corba_rep_id != NULL)
    return (type_uid(t) = class_object(t)->corba_rep_id);

  if (verbose && !t->builtIn)
    fprintf(stderr,
	  "figuring 'ilut:' uid for <%s> (addr %p, ifc addr %p) from %s\n",
	    full_type_name(t), t, t->interface,
	    ((t->importInterfaceName != NULL)
	     ? t->importInterfaceName
	     : "(current ifc)"));
  buffer.data = (unsigned char *) iluparser_Malloc(buffer.size = 1024);
  buffer.used = 0;
  form_typedesc (t, &buffer);
  buffer.data[buffer.used] = '\0';

  if (verbose && ! t->builtIn)
    fprintf (stderr, "  buffer is <%*.*s>\n", buffer.used, buffer.used, buffer.data);

  SHSInit(&ctx);
  SHSUpdate (&ctx, buffer.data, buffer.used);
  SHSFinal (hash, &ctx);

/*
  {
    int i;

    fprintf (stderr, "  hash is ");
    for (i = 0;  i < 20;  i += 1)
      fprintf (stderr, "%u ", hash[i]);
    fprintf (stderr, "\n");
  }
*/

  type_uid(t) = (char *) iluparser_Malloc(40);
  strcpy (type_uid(t), "ilut:");
  /* convert to base 64 */
  convbase(hash,20,type_uid(t) + strlen(type_uid(t)));
  iluparser_Free(buffer.data);

  if (verbose && !t->builtIn)
    fprintf (stderr, "  uid for %s is %s\n", type_name(t), type_uid(t));

  if (iluparser_CString_Type == NULL &&
      t->importInterfaceName == NULL &&
      type_interface(t) != NULL &&
      strcmp(interface_name(type_interface(t)), "ilu") == 0 &&
      strcmp(type_name(t), "CString") == 0)
    iluparser_CString_Type = t;

  return (type_uid(t));
}
Exemplo n.º 18
0
static void add_typeref (Type t, struct buffer_s *data, list referenced)
{
  if ((t->uid != NIL) && t->explicit_uid) {
  } else if (type_kind(t) == alias_Type) {
    add_typeref (t->supertype, data, referenced);
  } else {
    switch (type_kind(t))
      {
      case byte_Type:
	print0ToBuffer (data, "byte");
	break;

      case shortcardinal_Type:
	print0ToBuffer (data, "shortcardinal");
	break;

      case cardinal_Type:
	print0ToBuffer (data, "cardinal");
	break;

      case longcardinal_Type:
	print0ToBuffer (data, "longcardinal");
	break;

      case shortinteger_Type:
	print0ToBuffer (data, "shortinteger");
	break;

      case integer_Type:
	print0ToBuffer (data, "integer");
	break;

      case longinteger_Type:
	print0ToBuffer (data, "longinteger");
	break;

      case shortreal_Type:
	print0ToBuffer (data, "shortreal");
	break;

      case real_Type:
	print0ToBuffer (data, "real");
	break;

      case longreal_Type:
	print0ToBuffer (data, "longreal");
	break;

      case shortcharacter_Type:
	print0ToBuffer (data, "shortcharacter");
	break;

      case character_Type:
	print0ToBuffer (data, "character");
	break;

#if 0
      case longcharacter_Type:
#endif

      case boolean_Type:
	print0ToBuffer (data, "boolean");
	break;

      case pickle_Type:
	print0ToBuffer (data, "pickle");
	break;

      case void_Type:
	print0ToBuffer (data, "void");
	break;

      case object_Type:
      case fixedpoint_Type:
      case string_Type:
      case union_Type:
      case sequence_Type:
      case record_Type:
      case array_Type:
      case enumeration_Type:
      case optional_Type:
      case reference_Type:
	printmToBuffer (data, "(ref %s %s)", interface_name(type_interface(t)), type_name(t));
	add_entity (InterfaceE, type_interface(t), referenced);
	add_entity (TypeE, t, referenced);
	break;

      default:
	fprintf (stderr, "Invalid type kind %d for built-in type %s\n",
		 type_basic_type(t), full_type_name(t));
	exit(1);
      }
  }
}