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
[])
26 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:v"));
29 while ((c
= get_opts ()) != -1)
33 ior_output_file
= get_opts
.opt_arg ();
40 ACE_ERROR_RETURN ((LM_ERROR
,
48 // Indicates successful parsing of the command line
53 ACE_TMAIN( int argc
, ACE_TCHAR
*argv
[] )
55 ACE_Argv_Type_Converter
command_line(argc
, argv
);
57 #if (!defined ACE_HAS_WCHAR) && (!defined ACE_HAS_XPG4_MULTIBYTE_CHAR)
58 // the run_test script looks for the ior file. By touching it here, the
59 // script can run at full speed, rather than timing out waiting for a
60 // file that will never come.
61 FILE *output_file
= ACE_OS::fopen (ior_output_file
, ACE_TEXT("w"));
63 ACE_ERROR_RETURN ((LM_ERROR
,
64 ACE_TEXT("Cannot open output file ")
65 ACE_TEXT("for writing IOR: %s"),
68 ACE_OS::fprintf (output_file
, "no ior\n");
69 ACE_OS::fclose (output_file
);
70 ACE_ERROR_RETURN ((LM_ERROR
,"This test requires wchar support\n"),0);
76 CORBA::ORB_init(argc
, argv
);
77 if (parse_args(argc
, argv
))
79 ACE_ERROR_RETURN ((LM_ERROR
,
80 ACE_TEXT ("failed to parse args")),
84 //Get reference to Root POA
85 CORBA::Object_var obj
=
86 orb
->resolve_initial_references( "RootPOA");
88 PortableServer::POA_var poa
=
89 PortableServer::POA::_narrow( obj
.in());
91 PortableServer::POAManager_var mgr
=
92 poa
->the_POAManager( );
94 // Activate POA Manager
98 interop_WChar_Passer_i
servant(orb
.in(), verbose
);
100 // Register the servant with the RootPOA, obtain its object
101 // reference, stringify it, and write it to a file.
102 obj
= poa
->servant_to_reference(&servant
);
104 CORBA::String_var str
=
105 orb
->object_to_string( obj
.in());
107 FILE *output_file
= ACE_OS::fopen (ior_output_file
, ACE_TEXT("w"));
108 if (output_file
== 0)
109 ACE_ERROR_RETURN ((LM_ERROR
,
110 ACE_TEXT("Cannot open output file ")
111 ACE_TEXT("for writing IOR: %s"),
114 ACE_OS::fprintf (output_file
, "%s", str
.in ());
115 ACE_OS::fclose (output_file
);
121 catch (const CORBA::Exception
& ex
)
123 ex
._tao_print_exception ("uncaught exception");
128 #endif /* ACE_HAS_WCHAR */