Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / orbsvcs / tests / InterfaceRepo / Bug_3495_Regression / server.cpp
blobc2ad5bff2bd52132df7e3845c88c9932ecb05175
1 #include "ace/Get_Opt.h"
2 #include "ace/OS_NS_stdio.h"
3 #include "tao/IFR_Client/IFR_BasicC.h"
4 // Must include this header file and link to TAO_IFR_Client.lib
5 // to dynamically load this necessary library.
6 #include "tao/IFR_Client/IFR_Client_Adapter_Impl.h"
7 #include "TestImpl.h"
9 #include "ace/streams.h"
11 const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior");
13 int
14 parse_args (int argc, ACE_TCHAR *argv[])
16 ACE_Get_Opt get_opts (argc, argv, "o:");
17 int c;
19 while ((c = get_opts ()) != -1)
20 switch (c)
22 case 'o':
23 ior_output_file = get_opts.opt_arg ();
24 break;
26 case '?':
27 default:
28 ACE_ERROR_RETURN ((LM_ERROR,
29 "usage: %s "
30 "-o <iorfile>"
31 "\n",
32 argv [0]),
33 -1);
35 // Indicates successful parsing of the command line
36 return 0;
39 int
40 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
42 try
44 CORBA::ORB_var orb =
45 CORBA::ORB_init (argc, argv);
47 CORBA::Object_var poa_object =
48 orb->resolve_initial_references("RootPOA");
50 PortableServer::POA_var root_poa =
51 PortableServer::POA::_narrow (poa_object.in ());
53 if (CORBA::is_nil (root_poa.in ()))
54 ACE_ERROR_RETURN ((LM_ERROR,
55 " (%P|%t) Panic: nil RootPOA\n"),
56 1);
58 PortableServer::POAManager_var poa_manager =
59 root_poa->the_POAManager ();
61 poa_manager->activate ();
63 if (parse_args (argc, argv) != 0)
64 return 1;
66 Test_interfaceOne_i *ifo_impl;
67 ACE_NEW_RETURN (ifo_impl,
68 Test_interfaceOne_i (),
69 1);
70 PortableServer::ServantBase_var owner_transfer(ifo_impl);
72 Test::interfaceOne_var ifo = ifo_impl->_this ();
74 CORBA::String_var ior =
75 orb->object_to_string (ifo.in ());
77 // Output the IOR to the <ior_output_file>
78 FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
79 if (output_file == 0)
80 ACE_ERROR_RETURN ((LM_ERROR,
81 "Cannot open output file for writing IOR: %s\n",
82 ior_output_file),
83 1);
84 ACE_OS::fprintf (output_file, "%s", ior.in ());
86 ACE_OS::fclose (output_file);
88 orb->run ();
90 ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
92 root_poa->destroy (true, true);
94 orb->destroy ();
96 catch (const CORBA::Exception& ex)
98 ex._tao_print_exception ("Exception caught:");
99 return 1;
102 return 0;