2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_string.h"
5 class Test_i
: public virtual POA_Test
8 Test_i (CORBA::ORB_ptr orb
);
10 void hello (CORBA::Long howmany
);
12 //FUZZ: disable check_for_lack_ACE_OS
14 //FUZZ: enable check_for_lack_ACE_OS
20 Test_i::Test_i (CORBA::ORB_ptr orb
)
21 : orb_ (CORBA::ORB::_duplicate (orb
))
26 Test_i::hello (CORBA::Long howmany
)
28 ACE_DEBUG ((LM_DEBUG
, "hello called with : %i\n", howmany
));
34 this->orb_
->shutdown (false);
37 static const ACE_TCHAR
*ior_output_file
= 0;
40 parse_args (int argc
, ACE_TCHAR
*argv
[])
42 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
45 while ((c
= get_opts ()) != -1)
49 ior_output_file
= get_opts
.opt_arg ();
53 ACE_ERROR_RETURN ((LM_ERROR
,
60 // Indicates successful parsing of the command line
64 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
68 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
70 if (parse_args (argc
, argv
) != 0)
74 CORBA::Object_var obj
= orb
->resolve_initial_references ("RootPOA");
76 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow (obj
.in());
78 // Get the POAManager of the RootPOA
79 PortableServer::POAManager_var poa_mgr
=
80 root_poa
->the_POAManager ();
85 Test_i
servant (orb
.in ());
87 PortableServer::ObjectId_var oid
=
88 root_poa
->activate_object (&servant
);
90 obj
= root_poa
->id_to_reference (oid
.in());
92 CORBA::String_var ior
=
93 orb
->object_to_string (obj
.in());
95 // If the ior_output_file exists, output the ior to it
96 if (ior_output_file
!= 0)
99 ACE_OS::fopen (ior_output_file
, "w");
101 if (output_file
== 0)
102 ACE_ERROR_RETURN ((LM_ERROR
,
103 "Cannot open output file %s for writing IOR: %C",
108 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
109 ACE_OS::fclose (output_file
);
112 ACE_ERROR_RETURN ((LM_ERROR
,"ior file name is null\n"),1);
116 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
118 root_poa
->destroy (true, true);
122 catch (const CORBA::Exception
& ex
)
124 ex
._tao_print_exception ("Exception in setting up server");