summaryrefslogtreecommitdiff
path: root/TAO/utils
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-08-30 21:26:28 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-08-30 21:26:28 +0000
commite3713b2667f0dbe2b67f0aac0bf973d54dba97c3 (patch)
tree8fd6a0206fa0b958ec80984dd8c5350bb5916009 /TAO/utils
parent124e7aca8236a527115e04eca7af5ee2bf4734e0 (diff)
downloadATCD-e3713b2667f0dbe2b67f0aac0bf973d54dba97c3.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/utils')
-rw-r--r--TAO/utils/IOR-parser/IOR_Parser.dsp101
-rw-r--r--TAO/utils/IOR-parser/IOR_Parser.dsw29
-rw-r--r--TAO/utils/IOR-parser/Makefile59
-rw-r--r--TAO/utils/IOR-parser/README16
-rw-r--r--TAO/utils/IOR-parser/TaoSimple.IOR1
-rw-r--r--TAO/utils/IOR-parser/ior-handler.cpp405
-rw-r--r--TAO/utils/IOR-parser/ior-handler.h127
-rw-r--r--TAO/utils/IOR-parser/ior-parser.cpp38
8 files changed, 776 insertions, 0 deletions
diff --git a/TAO/utils/IOR-parser/IOR_Parser.dsp b/TAO/utils/IOR-parser/IOR_Parser.dsp
new file mode 100644
index 00000000000..35a4bc8dfc7
--- /dev/null
+++ b/TAO/utils/IOR-parser/IOR_Parser.dsp
@@ -0,0 +1,101 @@
+# Microsoft Developer Studio Project File - Name="IOR Parser" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=IOR Parser - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "IOR_Parser.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "IOR_Parser.mak" CFG="IOR Parser - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "IOR Parser - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "IOR Parser - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "IOR Parser - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x407 /d "NDEBUG"
+# ADD RSC /l 0x407 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib /nologo /subsystem:console /machine:I386 /out:"Release/parseIor.exe" /libpath:"..\..\..\ace"
+
+!ELSEIF "$(CFG)" == "IOR Parser - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x407 /d "_DEBUG"
+# ADD RSC /l 0x407 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /out:"parseIor.exe" /pdbtype:sept /libpath:"..\..\..\ace"
+
+!ENDIF
+
+# Begin Target
+
+# Name "IOR Parser - Win32 Release"
+# Name "IOR Parser - Win32 Debug"
+# Begin Source File
+
+SOURCE="ior-handler.cpp"
+# End Source File
+# Begin Source File
+
+SOURCE="ior-handler.h"
+# End Source File
+# Begin Source File
+
+SOURCE="ior-parser.cpp"
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/utils/IOR-parser/IOR_Parser.dsw b/TAO/utils/IOR-parser/IOR_Parser.dsw
new file mode 100644
index 00000000000..14ece8c7c41
--- /dev/null
+++ b/TAO/utils/IOR-parser/IOR_Parser.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "IOR_Parser"="IOR_Parser.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/utils/IOR-parser/Makefile b/TAO/utils/IOR-parser/Makefile
new file mode 100644
index 00000000000..5e8b7bb755b
--- /dev/null
+++ b/TAO/utils/IOR-parser/Makefile
@@ -0,0 +1,59 @@
+#----------------------------------------------------------------------------
+# $Id$
+#
+# Makefile for the IOR Parser
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Local macros
+#----------------------------------------------------------------------------
+
+BIN = ior-parser
+
+FILES = ior-handler
+
+SRC = $(addsuffix .cpp,$(FILES))
+OBJ = $(addsuffix .o,$(FILES))
+
+BUILD = $(VBIN)
+
+#----------------------------------------------------------------------------
+# Include macros and targets
+#----------------------------------------------------------------------------
+
+include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
+include $(ACE_ROOT)/include/makeinclude/macros.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
+include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
+
+#----------------------------------------------------------------------------
+# Local targets
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+# Dependencies
+#----------------------------------------------------------------------------
+# DO NOT DELETE THIS LINE -- g++dep uses it.
+# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
+
+.obj/ior-handler.o .obj/ior-handler.so .shobj/ior-handler.o .shobj/ior-handler.so: ior-handler.cpp ior-handler.h \
+ $(ACE_ROOT)/ace/OS.h \
+ $(ACE_ROOT)/ace/inc_user_config.h \
+ $(ACE_ROOT)/ace/config.h \
+ $(ACE_ROOT)/ace/config-g++-common.h \
+ $(ACE_ROOT)/ace/streams.h \
+ $(ACE_ROOT)/ace/Basic_Types.h \
+ $(ACE_ROOT)/ace/Basic_Types.i \
+ $(ACE_ROOT)/ace/OS.i \
+ $(ACE_ROOT)/ace/Trace.h \
+ $(ACE_ROOT)/ace/Log_Msg.h \
+ $(ACE_ROOT)/ace/Log_Record.h \
+ $(ACE_ROOT)/ace/ACE.h \
+ $(ACE_ROOT)/ace/ACE.i \
+ $(ACE_ROOT)/ace/Log_Priority.h \
+ $(ACE_ROOT)/ace/Log_Record.i
+
+# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/TAO/utils/IOR-parser/README b/TAO/utils/IOR-parser/README
new file mode 100644
index 00000000000..f4fefcb2310
--- /dev/null
+++ b/TAO/utils/IOR-parser/README
@@ -0,0 +1,16 @@
+// FILENAME : README
+// AUTHOR : Priya Narasimhan
+// LAST MODIFIED : June 18, 1998
+// DESCRIPTION : Description of the Ior Parser
+
+The "parseIor" utility parses IORs generated by most ORBs. It has been
+tested with Orbix, VisiBroker and TAO so far.
+
+USAGE: parseIor <IOR filename>
+
+There is a sample file in this directory called TaoSimple.IOR that is
+an IOR generated using the example $TAO_ROOT/tests/Simple. You can
+run the "parseIor" utility against that to see what the output looks
+like.
+
+
diff --git a/TAO/utils/IOR-parser/TaoSimple.IOR b/TAO/utils/IOR-parser/TaoSimple.IOR
new file mode 100644
index 00000000000..830ed119a9c
--- /dev/null
+++ b/TAO/utils/IOR-parser/TaoSimple.IOR
@@ -0,0 +1 @@
+IOR:000000000000001649444c3a73696d706c655f6f626a6563743a312e3000000000000001000000000000003600010000000000036d750000aada00000000002250333564623666626130303062383766612f6368696c645f706f612f736572766572 \ No newline at end of file
diff --git a/TAO/utils/IOR-parser/ior-handler.cpp b/TAO/utils/IOR-parser/ior-handler.cpp
new file mode 100644
index 00000000000..929980ed9fc
--- /dev/null
+++ b/TAO/utils/IOR-parser/ior-handler.cpp
@@ -0,0 +1,405 @@
+// $Id$
+
+#include "ior-handler.h"
+
+IorHandler::IorHandler (void)
+{
+}
+
+u_long
+IorHandler::getOctet8Field (char *readPtr, int *hexCharsRead)
+{
+ char octet8Holder[8];
+
+ for (int i = 0; i < 8; i++)
+ octet8Holder[i] = readPtr[i];
+
+ hexCharsRead[0] = 8;
+
+ u_long value =
+ 16 * ACE::hex2byte (octet8Holder[6])
+ + ACE::hex2byte (octet8Holder[7]);
+
+ return value;
+}
+
+u_long
+IorHandler::getOctet4Field (char *readPtr, int *hexCharsRead)
+{
+ char octet4Holder[4];
+
+ for (int i = 0; i < 4; i++)
+ octet4Holder[i] = readPtr[i];
+
+ hexCharsRead[0] = 4;
+
+ u_long value =
+ 16 * 16 * 16 * ACE::hex2byte (octet4Holder[0])
+ + 16 * 16 * ACE::hex2byte (octet4Holder[1])
+ + 16 * ACE::hex2byte (octet4Holder[2])
+ + ACE::hex2byte (octet4Holder[3]);
+
+ return value;
+}
+
+u_long
+IorHandler::getOctet2Field (char *readPtr, int *hexCharsRead)
+{
+ char octet2Holder[2];
+
+ for (int i = 0; i < 2; i++)
+ octet2Holder[i] = readPtr[i];
+
+ hexCharsRead[0] = 2;
+
+ u_long value =
+ 16 * ACE::hex2byte (octet2Holder[0])
+ + ACE::hex2byte (octet2Holder[1]);
+
+ return value;
+}
+
+void
+IorHandler::skipNullOctets (char *readPtr, int *hexCharsRead)
+{
+ char nullOctet[2];
+ int offset;
+
+ hexCharsRead[0] = 0;
+ offset = 0;
+
+ // There sometimes occurs a null padding of 2 octets after strings
+ // such as the type_id in order to ensure even number of octets.
+
+ while (1)
+ {
+ nullOctet[0] = readPtr[offset];
+ nullOctet[1] = readPtr[offset + 1];
+ if (nullOctet[0] == '0' && nullOctet[1] == '0')
+ offset += 2;
+ else
+ break;
+ }
+
+ hexCharsRead[0] = offset;
+}
+
+char *
+IorHandler::getString (char *readPtr, int givenLen)
+{
+ int j = 0;
+
+ // i indexes hexChars while j indexes octet pairs
+
+ for (int i = 0;
+ i <= givenLen - 2;
+ i += 2)
+ {
+ char octetPair[2];
+ octetPair[0] = readPtr[i];
+ octetPair[1] = readPtr[i + 1];
+
+ int intEquiv =
+ 16 * ACE::hex2byte (octetPair[0])
+ + ACE::hex2byte (octetPair[1]);
+
+ char parsedOctetPair[2];
+ sprintf (parsedOctetPair,
+ "%c",
+ intEquiv);
+
+ parsedStr[j] = parsedOctetPair[0];
+ j++;
+ }
+
+ return parsedStr;
+}
+
+void
+IorHandler::prettyPrintIOR (IOR thisIor)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "TypeIdLen\t: %lu bytes\n",
+ thisIor.typeIdLen));
+ ACE_DEBUG ((LM_DEBUG,
+ "TypeId\t\t: %s\n",
+ thisIor.typeId));
+ ACE_DEBUG ((LM_DEBUG,
+ "IDL Interface\t: %s\n",
+ thisIor.idlInterface));
+ ACE_DEBUG ((LM_DEBUG,
+ "ProfileBodyLen\t: %lu bytes\n",
+ thisIor.profileBodyLen));
+ ACE_DEBUG ((LM_DEBUG,
+ "HostLen\t\t: %lu bytes\n",
+ thisIor.hostLen));
+ ACE_DEBUG ((LM_DEBUG,
+ "HostName\t: %s\n",
+ thisIor.HostName));
+ ACE_DEBUG ((LM_DEBUG,
+ "Port Number\t: %d\n",
+ thisIor.portNum));
+ ACE_DEBUG ((LM_DEBUG,
+ "ObjectKeyLen\t: %lu bytes\n",
+ thisIor.objectKeyLen));
+ ACE_DEBUG ((LM_DEBUG,
+ "ObjectKey\t: %s\n",
+ thisIor.objectKey));
+}
+
+void
+IorHandler::interpretIor (char *thisIor, IOR *thisIorInfo)
+{
+ int numCharsToSkip;
+
+ // Skip the prefix "IOR:"
+ int numHexCharsRead = 4;
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead), &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ int ulongValue = getOctet2Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the length of the type_id field
+ if (ulongValue == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: type_id len seems to be NULL \n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+
+ numHexCharsRead += numCharsToSkip;
+ thisIorInfo->typeIdLen = ulongValue;
+
+ // Read the type_id and store it
+ ACE_OS::strncpy (thisIorInfo->typeId,
+ getString ((char *) (thisIor + numHexCharsRead),
+ 2 * thisIorInfo->typeIdLen),
+ thisIorInfo->typeIdLen);
+ numHexCharsRead += 2 * thisIorInfo->typeIdLen;
+
+ // While we have the type_id, we may as well extract the IDL
+ // interface name from it.
+ ACE_OS::strcpy (thisIorInfo->idlInterface,
+ getIdlInterface (thisIorInfo->typeId));
+ ACE_DEBUG ((LM_DEBUG,
+ "\nTypeId\t\t: %s \n",
+ thisIorInfo->typeId));
+ ACE_DEBUG ((LM_DEBUG,
+ "IDL Interface\t: %s\n",
+ thisIorInfo->idlInterface));
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead), &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ ulongValue = getOctet2Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the 4 octets, which should equal 1 (numTaggedProfiles = 1)
+ if (ulongValue != 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: numTaggedProfiles != 1\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+
+ ulongValue = getOctet8Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the 4 octets, which should equal 0 (TAG_INTERNET_IOP = 0)
+
+ if (ulongValue != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: TAG_INTERNET_IOP != 0\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ // Since the object_key and the hostname are part of the ProfileBody
+ // field of the IOR, and this is the part that needs to be changed,
+ // the IOR should be cut here typically if we want to fake it.
+ cutAndPasteHere = numHexCharsRead;
+
+ ulongValue = getOctet2Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the 4 octets, which represent the length of the ProfileBody
+ if (ulongValue == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: ProfileBody len equals NULL\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+
+ numHexCharsRead += numCharsToSkip;
+ thisIorInfo->profileBodyLen = ulongValue;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\nTAG_INTERNET_IOP Profile:\n"));
+
+ ulongValue = getOctet4Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the 4 octets, which represent the IIOP version number = 1
+ if (ulongValue != 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: IIOP version != 1\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead), &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ ulongValue = getOctet2Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the 2 octets, which represent the length of the hostname
+ if (ulongValue == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: hostLen equals NULL\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+ thisIorInfo->hostLen = ulongValue;
+
+ // Read the hostname and store it
+ ACE_OS::strncpy (thisIorInfo->HostName,
+ getString ((char *) (thisIor + numHexCharsRead),
+ 2 * thisIorInfo->hostLen),
+ thisIorInfo->hostLen);
+ numHexCharsRead += 2 * thisIorInfo->hostLen;
+
+ ACE_DEBUG ((LM_DEBUG,
+ " HostName : %s\n",
+ thisIorInfo->HostName));
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ ulongValue = getOctet4Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the port number and store it
+ if (ulongValue == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: port number equals NULL\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+ thisIorInfo->portNum = ulongValue;
+ ACE_DEBUG ((LM_DEBUG,
+ " Port Number: %d\n",
+ thisIorInfo->portNum));
+
+ skipNullOctets ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+ numHexCharsRead += numCharsToSkip;
+
+ ulongValue = getOctet2Field ((char *) (thisIor + numHexCharsRead),
+ &numCharsToSkip);
+
+ // Read the object key length and store it
+ if (ulongValue == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "<%d hexChars read>: objectKeyLen equals NULL\n",
+ numHexCharsRead));
+ ACE_OS::exit (1);
+ }
+ numHexCharsRead += numCharsToSkip;
+ thisIorInfo->objectKeyLen = ulongValue;
+
+ // Read the object_key and store it
+ ACE_OS::strncpy (thisIorInfo->objectKey,
+ getString ((char *) (thisIor + numHexCharsRead),
+ 2 * thisIorInfo->objectKeyLen),
+ thisIorInfo->objectKeyLen);
+ numHexCharsRead += 2 * thisIorInfo->objectKeyLen;
+
+ ACE_DEBUG ((LM_DEBUG,
+ " ObjectKey : %s \n\n",
+ thisIorInfo->objectKey));
+
+ // Pretty print the IOR with more debugging information
+ // prettyPrintIOR (*thisIorInfo);
+}
+
+char *
+IorHandler::getIdlInterface (char *typeId)
+{
+ int lenInterface;
+
+ char *readStart = strchr (typeId, ':');
+
+ // A sample type_id for an IDL interface name "EchoTests" is
+ // IDL:EchoTests:1.0 => the trick is to isolate the parts between
+ // the two colons.
+
+ if (readStart == NULL)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "getIdlInterface: type_id contains no starting :\n"));
+ ACE_OS::exit (1);
+ }
+
+ char *readEnd = strrchr (typeId, ':');
+
+ if (readEnd == NULL)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "getIdlInterface: type_id contains no ending:\n"));
+ ACE_OS::exit (1);
+ }
+
+ // Now, count the number of bytes between the two colons.
+ lenInterface = readEnd - readStart - 1;
+
+ // Copy the IDL interface part of the type_id.
+ ACE_OS::strncpy ((char *) idlInterface,
+ readStart + 1,
+ lenInterface);
+ idlInterface[lenInterface] = '\0';
+
+ return (char *) idlInterface;
+}
+
+void
+IorHandler::readIorFromFile (char *filename)
+{
+ FILE *fp = ACE_OS::fopen (filename, "r");
+
+ // Read the real IOR from the file REAL_IOR_FILE.
+ if (fp == NULL)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "%p\n",
+ "Unable to open file"));
+ ACE_OS::exit (1);
+ }
+
+ fscanf (fp,
+ "%s",
+ stringRealIOR);
+ ACE_OS::fclose (fp);
+
+ interpretIor (stringRealIOR, &parsedRealIOR);
+}
diff --git a/TAO/utils/IOR-parser/ior-handler.h b/TAO/utils/IOR-parser/ior-handler.h
new file mode 100644
index 00000000000..beb7fcd203a
--- /dev/null
+++ b/TAO/utils/IOR-parser/ior-handler.h
@@ -0,0 +1,127 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/utils/IOR-parser
+//
+// = FILENAME
+// ior-handler.h
+//
+// = DESCRIPTION
+// Provides the definition of a class that parses real (valid) IORs.
+//
+// = AUTHORS
+// Priya Narasimhan <priya@lambda.ece.ucsb.edu>
+//
+// ============================================================================
+
+#if !defined (__IORPARSER_H__)
+#define __IORPARSER_H__
+
+#include "ace/OS.h"
+
+// @@ Priya, are these still required?
+// Maximum length of either the type_id, the ProfileBody or the
+// object_key fields. Tentatively assigned.
+#define MAX_IOR_FIELD_LEN 200
+#define MAX_TYPE_ID_LEN 100
+
+// These are CDR-encoded sequences of hexChars (note, not octets) that
+// are useful in creating IORs.
+#define NULL_HEXCHARS "00000000"
+#define NUM_TAG_PROFS "0001"
+#define IIOP_VERSION "0001"
+
+struct IOR
+{
+ // = TITLE
+ // This is the useful information obtained from parsing an IOR.
+ //
+ // = DESCRIPTION
+ // This structure assumes that the profile_id is
+ // TAG_INTERNET_IOP and that there is only one TaggedProfile in
+ // the IOR.
+ u_long typeIdLen;
+ // The length of the type_id field of the IOR.
+
+ char typeId[MAX_TYPE_ID_LEN];
+ // The string in the type_id field of the IOR.
+
+ char idlInterface[MAX_TYPE_ID_LEN];
+ // The IDL interface of the server that published the IOR (can be
+ // extracted from the type_id field).
+
+ u_long profileBodyLen;
+ // The lenght of the body of the profile field of the IOR.
+
+ u_long hostLen;
+ // The length of the hostname embedded in the IOR.
+
+ char HostName[MAXHOSTNAMELEN];
+ // The server's hostname embedded in the IOR.
+
+ u_long portNum;
+ // The server's port number embedded in the IOR.
+
+ u_long objectKeyLen;
+ // The length of the object_key field of the IOR.
+
+ // @@ Priya, can you please change this so that it's not a magic
+ // number?!
+ char objectKey[100];
+ // The object_key field of the IOR.
+};
+
+class IorHandler
+{
+ // = TITLE
+ // This is the class that takes in a real (valid) IOR and
+ // parses it.
+ //
+ // = DESCRIPTION
+ // This class prints out the useful information in the
+ // IORs generated by VisiBroker, Orbix and TAO
+public:
+ IorHandler (void);
+ // Constructor.
+
+ void prettyPrintIOR (IOR thisIor);
+ // Prints out additional detailed information in the IOR.
+
+ void interpretIor (char *thisIor, IOR *thisIorInfo);
+ // The main parsing routine.
+
+ char *getIdlInterface (char *typeId);
+ // Obtains the IDL interface part of the type_id field in the IOR.
+
+ void readIorFromFile (char *filename);
+ // Reads in the IOR from a specified file.
+
+ int cutAndPasteHere;
+
+ // @@ Priya, can you please change this so that it's not a magic
+ // number?!
+ char stringRealIOR[400];
+ IOR parsedRealIOR;
+ char parsedStr[MAX_IOR_FIELD_LEN];
+ char idlInterface[MAX_TYPE_ID_LEN];
+
+private:
+ u_long getOctet8Field (char *readPtr, int *hexCharsRead);
+ // Interpret the next 8 octets into an unsigned long
+
+ u_long getOctet4Field (char *readPtr, int *hexCharsRead);
+ // Interpret the next 4 octets into an unsigned long
+
+ u_long getOctet2Field (char *readPtr, int *hexCharsRead);
+ // Interpret the next 2 octets into an unsigned long
+
+ void skipNullOctets (char *readPtr, int *hexCharsRead);
+ // Skip the null octets encountered while parsing the IOR
+
+ char *getString (char *readPtr, int givenLen);
+ // Extract a character string of a given length from the IOR
+};
+
+#endif /* __IORPARSER_H__ */
diff --git a/TAO/utils/IOR-parser/ior-parser.cpp b/TAO/utils/IOR-parser/ior-parser.cpp
new file mode 100644
index 00000000000..6099966470c
--- /dev/null
+++ b/TAO/utils/IOR-parser/ior-parser.cpp
@@ -0,0 +1,38 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/utils/IOR-parser
+//
+// = FILENAME
+// ior-parser.cpp
+//
+// = DESCRIPTION
+// Main loop of the IOR Parser.
+//
+// = AUTHORS
+// Priya Narasimhan <priya@lambda.ece.ucsb.edu>
+//
+// ============================================================================
+
+#include "ior-handler.h"
+
+IorHandler parser;
+
+int
+main (int argc, char **argv)
+{
+ if (argc <= 1 || argc >= 3)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "USAGE: parseIor <IOR filename>\n"),
+ 1);
+
+ parser.readIorFromFile (argv[1]);
+ return 0;
+}
+
+
+
+
+