3 //=============================================================================
7 * C++ server side for testing interoperability with wchar data.
9 * @author Phil Mesnier <mesnier_p@ociweb.com>
11 //=============================================================================
13 #include "interop_wchar_i.h"
14 #include "ace/Get_Opt.h"
15 #include "ace/Argv_Type_Converter.h"
16 #if defined (TAO_EXPLICIT_NEGOTIATE_CODESETS)
17 #include "tao/Codeset/Codeset.h"
18 #endif /* TAO_EXPLICIT_NEGOTIATE_CODESETS */
20 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("IOR");
24 parse_args (int argc
, ACE_TCHAR
* argv
[])
27 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:v"));
30 while ((c
= get_opts ()) != -1)
34 ior_output_file
= get_opts
.opt_arg ();
41 ACE_ERROR_RETURN ((LM_ERROR
,
49 // Indicates successful parsing of the command line
54 ACE_TMAIN( int argc
, ACE_TCHAR
*argv
[] )
56 ACE_Argv_Type_Converter
command_line(argc
, argv
);
58 #if (!defined ACE_HAS_WCHAR) && (!defined ACE_HAS_XPG4_MULTIBYTE_CHAR)
59 // the run_test script looks for the ior file. By touching it here, the
60 // script can run at full speed, rather than timing out waiting for a
61 // file that will never come.
62 FILE *output_file
= ACE_OS::fopen (ior_output_file
, ACE_TEXT("w"));
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 ACE_TEXT("Cannot open output file ")
66 ACE_TEXT("for writing IOR: %s"),
69 ACE_OS::fprintf (output_file
, "no ior\n");
70 ACE_OS::fclose (output_file
);
71 ACE_ERROR_RETURN ((LM_ERROR
,"This test requires wchar support\n"),0);
77 CORBA::ORB_init(argc
, argv
);
78 if (parse_args(argc
, argv
))
80 ACE_ERROR_RETURN ((LM_ERROR
,
81 ACE_TEXT ("failed to parse args")),
85 //Get reference to Root POA
86 CORBA::Object_var obj
=
87 orb
->resolve_initial_references( "RootPOA");
89 PortableServer::POA_var poa
=
90 PortableServer::POA::_narrow( obj
.in());
92 PortableServer::POAManager_var mgr
=
93 poa
->the_POAManager( );
95 // Activate POA Manager
99 interop_WChar_Passer_i
servant(orb
.in(), verbose
);
101 // Register the servant with the RootPOA, obtain its object
102 // reference, stringify it, and write it to a file.
103 obj
= poa
->servant_to_reference(&servant
);
105 CORBA::String_var str
=
106 orb
->object_to_string( obj
.in());
108 FILE *output_file
= ACE_OS::fopen (ior_output_file
, ACE_TEXT("w"));
109 if (output_file
== 0)
110 ACE_ERROR_RETURN ((LM_ERROR
,
111 ACE_TEXT("Cannot open output file ")
112 ACE_TEXT("for writing IOR: %s"),
115 ACE_OS::fprintf (output_file
, "%s", str
.in ());
116 ACE_OS::fclose (output_file
);
122 catch (const CORBA::Exception
& ex
)
124 ex
._tao_print_exception ("uncaught exception");
129 #endif /* ACE_HAS_WCHAR */