22 #define POA_NAME_SEP '\xff' 23 #define TRANSIENT_SUFFIX_SEP '\xfe' 24 #define TRANSIENT_SUFFIX_SIZE 8 30 typedef _CORBA_Unbounded_Sequence_Octet OctetUSequence;
31 typedef _CORBA_Unbounded_Sequence_String StringUSequence;
36 static void print_key(std::stringstream& s, OctetUSequence& key);
38 static void print_omni_key(std::stringstream& sstr, OctetUSequence& key);
40 static int get_poa_info(OctetUSequence& key, StringUSequence& poas_out,
41 int& transient_out, OctetUSequence& id_out);
44 IOP::MultipleComponentProfile& comps);
45 #endif // ORB_IS_RTORB 58 if (iorstr == 0) {
return false; }
59 size_t size = strlen(iorstr);
64 throw CORBA::MARSHAL(0,CORBA::COMPLETED_NO);
67 const char* p = iorstr;
69 if (p[0] !=
'I' || p[1] !=
'O' || p[2] !=
'R' || p[3] !=
':')
72 throw CORBA::MARSHAL(0,CORBA::COMPLETED_NO);
78 size = (size - 4) / 2;
81 cdrMemoryStream buf((CORBA::ULong)size, 0);
82 for (
int i(0); i < (int)size; ++i)
87 if (p[j] >=
'0' && p[j] <=
'9') { v = ((p[
j] -
'0') << 4); }
88 else if (p[j] >=
'a' && p[j] <=
'f') { v = ((p[
j] -
'a' + 10) << 4); }
89 else if (p[j] >=
'A' && p[j] <=
'F') { v = ((p[
j] -
'A' + 10) << 4); }
90 else {
return false; }
93 if (p[k] >=
'0' && p[k] <=
'9') { v += (p[k] -
'0'); }
94 else if (p[k] >=
'a' && p[k] <=
'f') { v += (p[k] -
'a' + 10); }
95 else if (p[k] >=
'A' && p[k] <=
'F') { v += (p[k] -
'A' + 10); }
96 else {
return false; }
101 buf.rewindInputPtr();
102 CORBA::Boolean b = buf.unmarshalBoolean();
103 buf.setByteSwapFlag(b);
105 ior.type_id = IOP::IOR::unmarshaltype_id(buf);
106 ior.profiles <<= buf;
108 #else // ORB_IS_RTORB 111 #endif // ORB_IS_RTORB 124 cdrMemoryStream buf(CORBA::ULong(0),CORBA::Boolean(1));
125 buf.marshalBoolean(omni::myByteOrder);
126 buf.marshalRawString(ior.type_id);
127 ior.profiles >>= buf;
130 buf.rewindInputPtr();
131 size_t s = buf.bufSize();
132 CORBA::Char*
data = (CORBA::Char *)buf.bufPtr();
134 char *result =
new char[4 + s * 2 + 1];
135 result[4 + s * 2] =
'\0';
141 for (
int i(0); i < (int)s; ++i)
144 int v = (data[i] & 0xf0);
153 result[
j] =
'a' + (v - 10);
155 v = ((data[i] & 0xf));
158 result[j+1] =
'0' + v;
162 result[j+1] =
'a' + (v - 10);
168 #else // ORB_IS_RTORB 171 #endif // ORB_IS_RTORB 189 for (
unsigned long count(0); count < ior.profiles.length(); ++count)
192 if (ior.profiles[count].tag == IOP::TAG_INTERNET_IOP)
194 IIOP::ProfileBody pBody;
195 IIOP::unmarshalProfile(ior.profiles[count], pBody);
196 pBody.address.host = endpoint.c_str();
198 IOP::TaggedProfile profile;
200 IIOP::encodeProfile(pBody, profile);
201 CORBA::ULong max = profile.profile_data.maximum();
202 CORBA::ULong len = profile.profile_data.length();
203 CORBA::Octet* buf = profile.profile_data.get_buffer(1);
205 ior.profiles[count].profile_data.replace(max, len, buf, 1);
215 #endif // ORB_IS_RTORB 228 std::stringstream retstr;
233 if (ior.profiles.length() == 0 && strlen(ior.type_id) == 0)
235 retstr <<
"IOR is a nil object reference." << std::endl;
236 retstr << iorstr << std::endl;
240 retstr <<
"IOR information" << std::endl;
241 retstr <<
" Type ID: \"" << (
const char*) ior.type_id
242 <<
"\"" << std::endl;;
243 retstr <<
" Profiles:" << std::endl;;
244 for (
unsigned long count=0; count < ior.profiles.length(); ++count)
246 retstr <<
" " << count + 1 <<
". ";
247 if (ior.profiles[count].tag == IOP::TAG_INTERNET_IOP)
249 IIOP::ProfileBody pBody;
250 IIOP::unmarshalProfile(ior.profiles[count], pBody);
252 retstr <<
"IIOP " << (int) pBody.version.major <<
"." 253 << (
int) pBody.version.minor <<
" ";
254 retstr << (
const char*) pBody.address.host
255 <<
" " << pBody.address.port << std::endl;
257 print_omni_key(retstr, pBody.object_key);
263 else if (ior.profiles[count].tag == IOP::TAG_MULTIPLE_COMPONENTS)
266 retstr <<
"Multiple Component Profile ";
267 IIOP::ProfileBody pBody;
268 IIOP::unmarshalMultiComponentProfile(ior.profiles[count],
277 retstr <<
"Unrecognised profile tag: 0x" 279 << (unsigned)(ior.profiles[count].tag)
284 #else // ORB_IS_RTORB 285 retstr <<
"RtORB does't support formatIORinfo() function." << std::endl;
286 #endif // ORB_IS_RTORB 295 static void print_key(std::stringstream& sstr, OctetUSequence& key)
298 sstr <<
" Object Key: \"";
299 for(
unsigned int j = 0;
j < key.length(); ++
j)
301 if( (
char) key[
j] >=
' ' && (char) key[
j] <=
'~')
303 sstr << (char) key[
j];
314 for(
unsigned int j(0);
j < key.length(); ++
j)
316 int v = (key[
j] & 0xf0) >> 4;
317 if (v < 10) { sstr << (char)(
'0' + v); }
318 else { sstr << (char)(
'a' + (v - 10)); }
320 if (v < 10) { sstr << (char)(
'0' + v); }
321 else { sstr << (char)(
'a' + (v - 10)); }
323 sstr <<
" (" << key.length() <<
" bytes)" << std::endl;
328 StringUSequence poas;
334 sstr <<
" POA(" << (
char*)poas[0];
335 for(
unsigned i(1); i < poas.length(); ++i)
337 sstr <<
'/' << (
char*)poas[i];
343 if(key.length() !=
sizeof(omniOrbBoaKey))
352 static int get_poa_info(OctetUSequence& key, StringUSequence& poas_out,
353 int& transient_out, OctetUSequence& id_out)
355 const char* k = (
const char*) key.NP_data();
356 int len = key.length();
357 const char* kend = k + len;
360 poas_out[0] = CORBA::string_dup(
"root");
367 const char* name = k;
374 if(k == kend) {
return 0; }
376 char* nm =
new char[k - name + 1];
377 memcpy(nm, name, k - name);
379 poas_out.length(poas_out.length() + 1);
380 poas_out[poas_out.length() - 1] = nm;
382 if(k == kend) {
return 0; }
390 if(k >= kend || *k) {
return 0; }
393 id_out.length(kend - k);
394 memcpy(id_out.NP_data(), k, kend - k);
400 IOP::MultipleComponentProfile& components)
402 CORBA::ULong total(components.length());
408 CORBA::String_var content;
409 content = IOP::dumpComponent(components[
index]);
419 sstr <<
" " << (
const char*) p << std::endl;
423 catch (CORBA::MARSHAL& ex)
425 sstr <<
" Broken component" << std::endl;
429 #endif // ORB_IS_RTORB
bool toString(IOP::IOR &ior, std::string &iorstr)
Convert from IOR structure to IOR string.
#define TRANSIENT_SUFFIX_SEP
bool replaceEndpoint(std::string &iorstr, const std::string &endpoint)
Replace endpoint address in IOR entry.
static void print_key(std::stringstream &s, OctetUSequence &key)
std::string formatIORinfo(const char *iorstr)
Extracts information from IOR string and returns formatted string.
static void print_tagged_components(std::stringstream &sstr, IOP::MultipleComponentProfile &comps)
bool toIOR(const char *iorstr, IOP::IOR &ior)
Convert from IOR string to IOR structure.
def j(str, encoding="cp932")
#define TRANSIENT_SUFFIX_SIZE
CORBA IOR manipulation utility functions.
static int get_poa_info(OctetUSequence &key, StringUSequence &poas_out, int &transient_out, OctetUSequence &id_out)
static void print_omni_key(std::stringstream &sstr, OctetUSequence &key)