⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 catior.cpp

📁 TAO学习工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  return cat_octet_seq ("Object Key", stream);
}

ACE_TString
 _find_info (CORBA::ULong id)
{
    ACE_TString locale = ACE_TEXT("");
    ACE_Codeset_Registry::registry_to_locale(id, locale, NULL, NULL);
    return locale;
}

void displayHex( TAO_InputCDR &str )
{
  if (str.good_bit () == 0 )
    return;

  TAO_InputCDR clone_str( str );
  CORBA::ULong theSetId ;
  str.read_ulong(theSetId);
  ACE_DEBUG ((LM_DEBUG," Hex - %x", theSetId));
  ACE_DEBUG ((LM_DEBUG," Description - "));
  ACE_TString theDescr = _find_info ( theSetId );

  if( theDescr.length() == 0 )
  {
     ACE_DEBUG ((LM_DEBUG," Unknown CodeSet \n "));
     return;
  }

  ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" %s \n"), theDescr.c_str()));
}

static CORBA::Boolean
cat_codeset_info(TAO_InputCDR& stream)
{
     // Component Length
     CORBA::ULong compLen=0L;
     stream >> compLen;
     ACE_DEBUG ((LM_DEBUG, "\tComponent Length %u \n", compLen));

     // Byte Order
     CORBA::ULong byteOrder;
     stream >> byteOrder;

     if (byteOrder)
     {
        ACE_DEBUG ((LM_DEBUG,
            "\tThe Component Byte Order:\tLittle Endian\n"));
     }
     else
        ACE_DEBUG ((LM_DEBUG,
                "\tThe Component Byte Order:\tBig Endian\n"));

     // CodesetId for char
     // CORBA::ULong c_ncsId;
     ACE_DEBUG ((LM_DEBUG, "\tNative CodeSet for char: "));
     displayHex (stream);

     // number of Conversion Codesets for char
     CORBA::ULong c_ccslen=0;
     stream >> c_ccslen;
     ACE_DEBUG ((LM_DEBUG, "\tNumber of CCS for char %u \n", c_ccslen));

     if (c_ccslen)
        ACE_DEBUG ((LM_DEBUG, "\tConversion Codesets for char are: \n"));

     //  Loop through and display them
     CORBA::ULong index = 0;
     for ( ; index < c_ccslen; ++index)
     {
        // CodesetId for char
        ACE_DEBUG ((LM_DEBUG, "\t%u) ", index + 1L));
        displayHex (stream);
     }

     // CodesetId for wchar
     ACE_DEBUG ((LM_DEBUG, "\tNative CodeSet for wchar: "));
     displayHex (stream);

     // number of Conversion Codesets for char
     CORBA::ULong w_ccslen=0;
     stream >> w_ccslen;
     ACE_DEBUG ((LM_DEBUG, "\tNumber of CCS for wchar %u \n", w_ccslen));

     if (w_ccslen)
       ACE_DEBUG ((LM_DEBUG, "\tConversion Codesets for wchar are: \n"));

     //  Loop through and display them
     for (index = 0; index < w_ccslen; ++index)
     {
       ACE_DEBUG ((LM_DEBUG, "\t %u) ", index + 1L));
       displayHex (stream);
     }
     return 1;
}

static CORBA::Boolean
cat_tagged_components (TAO_InputCDR& stream)
{
  // ... and object key.

  CORBA::ULong len;
  stream >> len;

  for (CORBA::ULong i = 0;
       i != len;
       ++i)
    {
      CORBA::ULong tag;
      stream >> tag;
      ACE_DEBUG ((LM_DEBUG,
                  "%I The component <%d> ID is ", i+1, tag));

      if (tag == IOP::TAG_ORB_TYPE) {
        ACE_DEBUG ((LM_DEBUG,"%d (TAG_ORB_TYPE)\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_tag_orb_type(stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));

      } else if (tag == IOP::TAG_CODE_SETS) {
        ACE_DEBUG ((LM_DEBUG,"%d (TAG_CODE_SETS)\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_codeset_info(stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));
      } else if (tag == IOP::TAG_ALTERNATE_IIOP_ADDRESS) {
        ACE_DEBUG ((LM_DEBUG,"%d (TAG_ALTERNATE_IIOP_ADDRESS)\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_tag_alternate_endpoints (stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));
      } else if (tag == TAO_TAG_ENDPOINTS) {
        ACE_DEBUG ((LM_DEBUG,"%d (TAO_TAG_ENDPOINTS)\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_tao_tag_endpoints(stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));

      } else if (tag == IOP::TAG_POLICIES) {
        ACE_DEBUG ((LM_DEBUG,"%d (TAG_POLICIES)\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_tag_policies(stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));
      } else {
        ACE_DEBUG ((LM_DEBUG,"%d\n", tag));
        ACE_DEBUG ((LM_DEBUG, "%{%{"));
        cat_octet_seq ("Component Value", stream);
        ACE_DEBUG ((LM_DEBUG, "%}%}"));
      }
    }

  return 1;
}

static CORBA::Boolean
cat_profile_helper (TAO_InputCDR& stream,
                    const char *protocol)
{
  // OK, we've got an IIOP profile.  It's going to be
  // encapsulated ProfileData.  Create a new decoding stream and
  // context for it, and tell the "parent" stream that this data
  // isn't part of it any more.

  CORBA::ULong encap_len;
  if (stream.read_ulong (encap_len) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "cannot read encap length\n"));
      return 0;
    }

  // Create the decoding stream from the encapsulation in the
  // buffer, and skip the encapsulation.
  TAO_InputCDR str (stream, encap_len);

  if (str.good_bit () == 0 || stream.skip_bytes (encap_len) == 0)
    return 0;

  // Read and verify major, minor versions, ignoring IIOP
  // profiles whose versions we don't understand.
  //
  // XXX this doesn't actually go back and skip the whole
  // encapsulation...
  CORBA::Octet iiop_version_major, iiop_version_minor;
  if (! (str.read_octet (iiop_version_major)
         && iiop_version_major == 1
         && str.read_octet (iiop_version_minor)
         && iiop_version_minor <= 2))
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I detected new v%d.%d %s profile that catior cannot decode",
                  iiop_version_major,
                  iiop_version_minor,
                  protocol));
      return 1;
    }

  ACE_DEBUG ((LM_DEBUG,
              "%s Version:\t%d.%d\n",
              protocol,
              iiop_version_major,
              iiop_version_minor));

  // Get host and port.
  CORBA::UShort port_number;
  char* hostname;
  if ((str >> hostname) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I problem decoding hostname\n"));
      return 1;
    }

  str >> port_number;

  ACE_DEBUG ((LM_DEBUG,
              "%I Host Name:\t%s\n",
              hostname));
  ACE_DEBUG ((LM_DEBUG,
              "%I Port Number:\t%d\n",
              port_number));
  CORBA::string_free (hostname);

  if (cat_object_key (str) == 0)
    return 0;

  //IIOP 1.0 does not have tagged_components.
  if (!(iiop_version_major == 1 && iiop_version_minor == 0))
    {
      if (cat_tagged_components (str) == 0)
        return 0;

      return 1;
    }
  else
    return 0;
}

static CORBA::Boolean
cat_iiop_profile (TAO_InputCDR& stream)
{
  return cat_profile_helper (stream, "IIOP");
}

static CORBA::Boolean
cat_shmiop_profile (TAO_InputCDR& stream)
{
  return cat_profile_helper (stream, "SHMIOP");
}

static CORBA::Boolean
cat_uiop_profile (TAO_InputCDR& stream)
{
  // OK, we've got a UIOP profile.  It's going to be encapsulated
  // ProfileData.  Create a new decoding stream and context for it,
  // and tell the "parent" stream that this data isn't part of it any
  // more.

  CORBA::ULong encap_len;
  if (stream.read_ulong (encap_len) == 0)
    return 0;

  // Create the decoding stream from the encapsulation in the
  // buffer, and skip the encapsulation.
  TAO_InputCDR str (stream, encap_len);

  if (str.good_bit () == 0 || stream.skip_bytes (encap_len) == 0)
    return 0;

  // Read and verify major, minor versions, ignoring UIOP
  // profiles whose versions we don't understand.
  //
  // XXX this doesn't actually go back and skip the whole
  // encapsulation...
  CORBA::Octet uiop_version_major, uiop_version_minor;
  // It appears that as of April 2002 UIOP version is 1.2
  if (! (str.read_octet (uiop_version_major)
         && uiop_version_major == 1
         && str.read_octet (uiop_version_minor)
         && uiop_version_minor <= 2))
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I detected new v%d.%d UIOP profile",
                  uiop_version_major,
                  uiop_version_minor));
      return 1;
    }

  ACE_DEBUG ((LM_DEBUG,
              "%I UIOP Version:\t%d.%d\n",
              uiop_version_major,
              uiop_version_minor));

  // Get host and port.
  CORBA::String_var rendezvous;
  if ((str >> rendezvous.out ()) == 0)
    return 0;

  ACE_DEBUG ((LM_DEBUG,
              "%I Rendezvous point:\t%s\n",
              rendezvous.in ()));

  if (cat_object_key (str) == 0)
    return 0;

  if (cat_tagged_components (str) == 0)
    return 0;

  return 1;
}

static CORBA::Boolean
cat_sciop_profile (TAO_InputCDR& stream)
{
  // OK, we've got an SCIOP profile.

  CORBA::ULong encap_len;
  if (stream.read_ulong (encap_len) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "cannot read encap length\n"));
      return 0;
    }

  // Create the decoding stream from the encapsulation in the
  // buffer, and skip the encapsulation.
  TAO_InputCDR str (stream, encap_len);

  if (str.good_bit () == 0 || stream.skip_bytes (encap_len) == 0)
    return 0;

  // Read and verify major, minor versions, ignoring IIOP
  // profiles whose versions we don't understand.
  //
  // XXX this doesn't actually go back and skip the whole
  // encapsulation...
  CORBA::Octet iiop_version_major, iiop_version_minor;
  if (! (str.read_octet (iiop_version_major)
         && iiop_version_major == 1
         && str.read_octet (iiop_version_minor)
         && iiop_version_minor <= 0))
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I detected new v%d.%d SCIOP profile that catior cannot decode",
                  iiop_version_major,
                  iiop_version_minor));
      return 1;
    }

  ACE_DEBUG ((LM_DEBUG,
              "SCIOP Version:\t%d.%d\n",
              iiop_version_major,
              iiop_version_minor));

  // Get host and port.
  CORBA::UShort port_number;
  CORBA::UShort max_streams;
  char* hostname;
  CORBA::ULong addresses;

  str >> addresses;

  ACE_DEBUG ((LM_DEBUG,
              "%I Addresses:\t%d\n",
              addresses));

  for (unsigned int i=0; i< addresses; i++) {
    if ((str >> hostname) == 0)
      {
        ACE_DEBUG ((LM_DEBUG,
                    "%I problem decoding hostname\n"));
        return 1;
      }
    ACE_DEBUG ((LM_DEBUG,
                "%I Host Name:\t%s\n",
                hostname));
    CORBA::string_free (hostname);
  }


  str >> port_number;

  ACE_DEBUG ((LM_DEBUG,
              "%I Port Number:\t%d\n",
              port_number));

  str >> max_streams;

  ACE_DEBUG ((LM_DEBUG,
              "%I Max Streams:\t%d\n",
              max_streams));

  if (cat_object_key (str) == 0)
    return 0;

  // Unlike IIOP (1.0), SCIOP always has tagged_components.
  if (cat_tagged_components (str) == 0)
    return 0;

  return 1;
}

static CORBA::Boolean
cat_nsk_profile_helper (TAO_InputCDR& stream,
                        const char *protocol)
{
  // OK, we've got an NSK profile.  It's going to be
  // encapsulated ProfileData.  Create a new decoding stream and
  // context for it, and tell the "parent" stream that this data
  // isn't part of it any more.

  CORBA::ULong encap_len;
  if (stream.read_ulong (encap_len) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "cannot read encap length\n"));
      return 0;
    }

  // Create the decoding stream from the encapsulation in the
  // buffer, and skip the encapsulation.
  TAO_InputCDR str (stream, encap_len);

  if (str.good_bit () == 0 || stream.skip_bytes (encap_len) == 0)
    return 0;

  // Read and verify major, minor versions, ignoring NSK
  // profiles whose versions we don't understand.
  //
  // XXX this doesn't actually go back and skip the whole
  // encapsulation...
  CORBA::Octet iiop_version_major, iiop_version_minor;
  if (! (str.read_octet (iiop_version_major)
         && iiop_version_major == 1
         && str.read_octet (iiop_version_minor)
         && iiop_version_minor <= 2))
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I detected new v%d.%d %s profile that catior cannot decode",
                  iiop_version_major,
                  iiop_version_minor,
                  protocol));
      return 1;
    }

  ACE_DEBUG ((LM_DEBUG,
              "%s Version:\t%d.%d\n",
              protocol,
              iiop_version_major,
              iiop_version_minor));

  // Get address
  char* fsaddress;
  if ((str >> fsaddress) == 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "%I problem decoding file system address\n"));
      return 1;
    }


  ACE_DEBUG ((LM_DEBUG,
              "%I FS Address:\t%s\n",
              fsaddress));
  CORBA::string_free (fsaddress);

  if (cat_object_key (str) == 0)
    return 0;

  // Version 1.0 does not have tagged_components.
  if (!(iiop_version_major == 1 && iiop_version_minor == 0))
    {
      if (cat_tagged_components (str) == 0)
        return 0;

      return 1;
    }
  else
    return 0;
}

static CORBA::Boolean
cat_nskpw_profile (TAO_InputCDR& stream)
{
  return cat_nsk_profile_helper (stream, "NSKPW");
}

static CORBA::Boolean
cat_nskfs_profile (TAO_InputCDR& stream)
{
  return cat_nsk_profile_helper (stream, "NSKFS");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -