ior.cc
来自「编译工具」· CC 代码 · 共 1,411 行 · 第 1/3 页
CC
1,411 行
// -*- Mode: C++; -*-// Package : omniORB// ior.cc Created on: 5/7/96// Author : Sai Lai Lo (sll)//// Copyright (C) 1996-1999 AT&T Laboratories Cambridge//// This file is part of the omniORB library//// The omniORB library is free software; you can redistribute it and/or// modify it under the terms of the GNU Library General Public// License as published by the Free Software Foundation; either// version 2 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Library General Public License for more details.//// You should have received a copy of the GNU Library General Public// License along with this library; if not, write to the Free// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA// 02111-1307, USA////// Description:// *** PROPRIETORY INTERFACE ***///* $Log: ior.cc,v $ Revision 1.10.2.26 2004/03/02 15:31:22 dgrisby Support for persistent server identifier. Revision 1.10.2.25 2003/11/20 13:39:59 dgrisby corbaloc handler for Unix sockets. Uses omniunix scheme name. Revision 1.10.2.24 2003/07/26 22:52:22 dgrisby Avoid spurious gcc warnings when sizeof pointer > sizeof int. Revision 1.10.2.23 2003/02/03 16:53:14 dgrisby Force type in constructor argument to help confused compilers. Revision 1.10.2.22 2003/01/14 14:18:12 dgrisby Don't overwrite component data when decoding multi component profile. Revision 1.10.2.21 2002/08/16 16:00:50 dgrisby Bugs accessing uninitialised String_vars with []. Revision 1.10.2.20 2002/03/18 12:38:26 dpg1 Lower trace(0) to trace(1), propagate fatalException. Revision 1.10.2.19 2002/03/14 14:39:44 dpg1 Obscure bug in objref creation with unaligned buffers. Revision 1.10.2.18 2002/01/02 18:17:00 dpg1 Relax IOR strictness when strictIIOP not set. Revision 1.10.2.17 2001/08/21 10:50:46 dpg1 Incorrect length calculation if no components. Revision 1.10.2.16 2001/08/17 17:12:39 sll Modularise ORB configuration parameters. Revision 1.10.2.15 2001/08/06 15:49:17 sll Added IOP component TAG_OMNIORB_UNIX_TRANS for omniORB specific local transport using the unix domain socket. Revision 1.10.2.14 2001/08/03 17:41:22 sll System exception minor code overhaul. When a system exeception is raised, a meaning minor code is provided. Revision 1.10.2.13 2001/07/31 16:27:59 sll Added GIOP BiDir support. Revision 1.10.2.12 2001/06/13 20:13:15 sll Minor updates to make the ORB compiles with MSVC++. Revision 1.10.2.11 2001/06/11 17:53:22 sll The omniIOR ctor used by genior and corbaloc now has the option to select whether to call interceptors and what set of interceptors to call. Revision 1.10.2.10 2001/05/31 16:18:13 dpg1 inline string matching functions, re-ordered string matching in _ptrToInterface/_ptrToObjRef Revision 1.10.2.9 2001/05/09 16:59:08 sll Added unmarshalObjectKey() to allow quick extraction of the object key. Revision 1.10.2.8 2001/04/18 18:18:07 sll Big checkin with the brand new internal APIs. Revision 1.10.2.7 2000/12/05 17:39:31 dpg1 New cdrStream functions to marshal and unmarshal raw strings. Revision 1.10.2.6 2000/11/20 14:42:23 sll Do not insert codeset component if the IOR is GIOP 1.0. Revision 1.10.2.5 2000/11/15 17:24:45 sll Added service context marshalling operators. Added hooks to add TAG_CODE_SETS componment to an IOR. Revision 1.10.2.4 2000/11/03 19:12:07 sll Use new marshalling functions for byte, octet and char. Use get_octet_array instead of get_char_array and put_octet_array instead of put_char_array. Revision 1.10.2.3 2000/10/04 16:53:16 sll Added default interceptor to encode and decode supported tag components. Revision 1.10.2.2 2000/09/27 18:20:32 sll Removed obsoluted IOP::iorToEncapStr and IOP::EncapStrToIor. Added new function IOP::IOR::unmarshaltype_id(), IIOP::encodeProfile(), IIOP::decodeProfile(), IIOP::addAlternativeIIOPAddress(). Use the new cdrStream abstraction. Revision 1.10.2.1 2000/07/17 10:35:54 sll Merged from omni3_develop the diff between omni3_0_0_pre3 and omni3_0_0. Revision 1.11 2000/07/13 15:25:57 dpg1 Merge from omni3_develop for 3.0 release. Revision 1.9.6.5 2000/06/22 10:40:15 dpg1 exception.h renamed to exceptiondefs.h to avoid name clash on some platforms. Revision 1.9.6.4 2000/04/27 10:50:30 dpg1 Interoperable Naming Service IOR: prefix is not case sensitive. Revision 1.9.6.3 1999/10/14 16:22:11 djr Implemented logging when system exceptions are thrown. Revision 1.9.6.2 1999/09/27 08:48:32 djr Minor corrections to get rid of warnings. Revision 1.9.6.1 1999/09/22 14:26:51 djr Major rewrite of orbcore to support POA. Revision 1.9 1999/05/25 17:06:14 sll Make sure all padding bytes are converted to 0s in the stringified IOR. Revision 1.8 1999/03/11 16:25:53 djr Updated copyright notice Revision 1.7 1998/08/14 13:48:04 sll Added pragma hdrstop to control pre-compile header if the compiler feature is available. Revision 1.6 1997/12/09 17:32:39 sll Removed obsoluted functions IIOP::profileToEncapStream and IIOP::EncapStreamToProfile. IOP::EncapStrToIor now accepts dodgy nil object reference. Revision 1.5 1997/08/21 22:04:23 sll minor cleanup to get rid of purify's warnings.// Revision 1.4 1997/05/06 15:21:58 sll// Public release.// */#include <omniORB4/CORBA.h>#include <omniORB4/omniInterceptors.h>#include <exceptiondefs.h>#include <initialiser.h>#include <giopBiDir.h>#include <SocketCollection.h>#include <orbParameters.h>#include <stdio.h>OMNI_USING_NAMESPACE(omni)voidIOP::TaggedProfile::operator>>= (cdrStream &s) const { tag >>= s; profile_data >>= s;}voidIOP::TaggedProfile::operator<<= (cdrStream &s) { tag <<= s; profile_data <<= s;}voidIOP::TaggedComponent::operator>>= (cdrStream& s) const { tag >>= s; component_data >>= s;}voidIOP::TaggedComponent::operator<<= (cdrStream& s) { tag <<= s; component_data <<= s;}voidIOP::ServiceContext::operator>>= (cdrStream& s) const { context_id >>= s; context_data >>= s;}voidIOP::ServiceContext::operator<<= (cdrStream& s) { context_id <<= s; context_data <<= s;}voidIOP::IOR::operator<<= (cdrStream& s) { type_id = unmarshaltype_id(s); profiles <<= s;}voidIOP::IOR::operator>>= (cdrStream& s) { type_id >>= s; profiles >>= s;}char*IOP::IOR::unmarshaltype_id(cdrStream& s) { CORBA::ULong idlen; CORBA::String_var id; idlen <<= s; if (!s.checkInputOverrun(1,idlen)) OMNIORB_THROW(MARSHAL,MARSHAL_SequenceIsTooLong, (CORBA::CompletionStatus)s.completion()); switch (idlen) { case 0:#ifdef NO_SLOPPY_NIL_REFERENCE OMNIORB_THROW(MARSHAL,MARSHAL_StringNotEndWithNull, (CORBA::CompletionStatus)s.completion());#else // According to the CORBA specification 2.0 section 10.6.2: // Null object references are indicated by an empty set of // profiles, and by a NULL type ID (a string which contain // only *** a single terminating character ***). // // Therefore the idlen should be 1. // Visibroker for C++ (Orbeline) 2.0 Release 1.51 gets it wrong // and sends out a 0 len string. // We quietly accept it here. Turn this off by defining // NO_SLOPPY_NIL_REFERENCE id = CORBA::string_alloc(1); ((char*)id)[0] = '\0';#endif break; case 1: id = CORBA::string_alloc(1); ((char*)id)[0] = s.unmarshalOctet(); if (((char*)id)[0] != '\0') OMNIORB_THROW(MARSHAL,MARSHAL_StringNotEndWithNull, (CORBA::CompletionStatus)s.completion()); idlen = 0; break; default: id = CORBA::string_alloc(idlen); s.get_octet_array((CORBA::Octet*)((const char*)id), idlen); if( ((char*)id)[idlen - 1] != '\0' ) OMNIORB_THROW(MARSHAL,MARSHAL_StringNotEndWithNull, (CORBA::CompletionStatus)s.completion()); break; } return id._retn();}voidIIOP::Address::operator>>= (cdrStream& s) const { s.marshalRawString(host); port >>= s;}voidIIOP::Address::operator<<= (cdrStream& s) { host = s.unmarshalRawString(); port <<= s;}voidIIOP::encodeProfile(const IIOP::ProfileBody& body,IOP::TaggedProfile& profile){ profile.tag = IOP::TAG_INTERNET_IOP; CORBA::ULong bufsize; { cdrCountingStream s(orbParameters::anyCharCodeSet, orbParameters::anyWCharCodeSet); s.marshalOctet(omni::myByteOrder); s.marshalOctet(body.version.major); s.marshalOctet(body.version.minor); s.marshalRawString(body.address.host); body.address.port >>= s; body.object_key >>= s; if (body.version.minor > 0) { CORBA::ULong total = body.components.length(); total >>= s; for (CORBA::ULong index=0; index < total; index++) { body.components[index] >>= s; } } bufsize = s.total(); } { cdrEncapsulationStream s(bufsize,1); s.marshalOctet(body.version.major); s.marshalOctet(body.version.minor); s.marshalRawString(body.address.host); body.address.port >>= s; body.object_key >>= s; if (body.version.minor > 0) { CORBA::ULong total = body.components.length(); total >>= s; for (CORBA::ULong index=0; index < total; index++) { body.components[index] >>= s; } } _CORBA_Octet* p; CORBA::ULong max; CORBA::ULong len; s.getOctetStream(p,max,len); profile.profile_data.replace(max,len,p,1); }}voidIIOP::encodeMultiComponentProfile(const IOP::MultipleComponentProfile& body, IOP::TaggedProfile& profile){ profile.tag = IOP::TAG_MULTIPLE_COMPONENTS; CORBA::ULong bufsize; { cdrCountingStream s(orbParameters::anyCharCodeSet, orbParameters::anyWCharCodeSet); s.marshalOctet(omni::myByteOrder); CORBA::ULong total = body.length(); if (total) { total >>= s; for (CORBA::ULong index=0; index < total; index++) { body[index] >>= s; } } bufsize = s.total(); } { cdrEncapsulationStream s(bufsize,1); CORBA::ULong total = body.length(); if (total) { total >>= s; for (CORBA::ULong index=0; index < total; index++) { body[index] >>= s; } } _CORBA_Octet* p; CORBA::ULong max; CORBA::ULong len; s.getOctetStream(p,max,len); profile.profile_data.replace(max,len,p,1); }}voidIIOP::unmarshalProfile(const IOP::TaggedProfile& profile, IIOP::ProfileBody& body){ OMNIORB_ASSERT(profile.tag == IOP::TAG_INTERNET_IOP); cdrEncapsulationStream s(profile.profile_data.get_buffer(), profile.profile_data.length(), 1); body.version.major = s.unmarshalOctet(); body.version.minor = s.unmarshalOctet(); if (body.version.major != 1) OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO); body.address.host = s.unmarshalRawString(); body.address.port <<= s; body.object_key <<= s; if (body.version.minor > 0) { CORBA::ULong total; total <<= s; if (total) { if (!s.checkInputOverrun(1,total)) OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO); body.components.length(total); for (CORBA::ULong index=0; index<total; index++) { body.components[index] <<= s; } } } // Check that the profile body ends here. if (s.checkInputOverrun(1,1)) { if (orbParameters::strictIIOP) { omniORB::logs(10, "IIOP Profile has garbage at end"); OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO); } else omniORB::logs(1, "Warning: IIOP Profile has garbage at end. Ignoring."); }}voidIIOP::unmarshalMultiComponentProfile(const IOP::TaggedProfile& profile, IOP::MultipleComponentProfile& body){ OMNIORB_ASSERT(profile.tag == IOP::TAG_MULTIPLE_COMPONENTS); cdrEncapsulationStream s(profile.profile_data.get_buffer(), profile.profile_data.length(), 1); CORBA::ULong newitems; newitems <<= s; if (newitems) { if (!s.checkInputOverrun(1,newitems)) OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO); CORBA::ULong oldlen = body.length(); body.length(oldlen + newitems); for (CORBA::ULong index = oldlen; index < oldlen+newitems; index++) { body[index] <<= s; } } // Check that the profile body ends here. if (s.checkInputOverrun(1,1)) { if (orbParameters::strictIIOP) { omniORB::logs(10, "Multi-component profile has garbage at end"); OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO); } else omniORB::logs(1, "Warning: Multi-component profile has " "garbage at end. Ignoring."); }}voidIIOP::unmarshalObjectKey(const IOP::TaggedProfile& profile, _CORBA_Unbounded_Sequence_Octet& key){ OMNIORB_ASSERT(profile.tag == IOP::TAG_INTERNET_IOP); cdrEncapsulationStream s(profile.profile_data.get_buffer(), profile.profile_data.length(), 1); CORBA::ULong len; CORBA::UShort port;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?