Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / Multiple_Inheritance / server.cpp
blob1a0d87596da2e03da49b023bb2ca55f7deab444e
1 #include "ace/Get_Opt.h"
2 #include "Multiple_Inheritance_i.h"
3 #include "tao/Utils/ORB_Manager.h"
4 #include "ace/OS_NS_stdio.h"
5 #include "ace/OS_NS_string.h"
7 static ACE_TCHAR *ior_output_file = 0;
9 Multiple_Inheritance_i::Multiple_Inheritance_i ()
11 // Sun/CC 5.0 crashes if there is no explicit default
12 // constructor
13 // Default constructor, do nothin..
16 int
17 parse_args (int argc, ACE_TCHAR **argv)
19 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("f:"));
20 int c;
22 while ((c = get_opts ()) != -1)
23 switch (c)
25 case 'f':
26 ior_output_file = ACE_OS::strdup (get_opts.opt_arg ());
27 break;
28 case '?':
29 default:
30 ACE_ERROR_RETURN ((LM_ERROR,
31 "usage: %s "
32 "-f <iorfile>"
33 "\n",
34 argv [0]),
35 -1);
37 // Indicates successful parsing of the command line
38 return 0;
42 int
43 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
45 Multiple_Inheritance_i servant;
46 TAO_ORB_Manager orb_manager;
48 ACE_DEBUG ((LM_DEBUG, "\n\tMultiple Inheritance Server\n\n"));
49 try
51 orb_manager.init_child_poa (argc,
52 argv,
53 "child_poa");
55 if (parse_args (argc, argv) != 0)
56 return -1;
58 CORBA::String_var ior =
59 orb_manager.activate_under_child_poa ("my_object",
60 &servant);
62 ACE_DEBUG ((LM_DEBUG, "%C\n",
63 ior.in ()));
65 // If the ior_output_file exists, output the ior to it
66 if (ior_output_file != 0)
68 FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
69 if (output_file == 0)
70 ACE_ERROR_RETURN ((LM_ERROR,
71 "Cannot open output file for writing IOR: %s",
72 ior_output_file),
73 -1);
74 ACE_OS::fprintf (output_file, "%s", ior.in ());
75 ACE_OS::fclose (output_file);
78 orb_manager.run ();
80 catch (const CORBA::SystemException& sysex)
82 sysex._tao_print_exception ("System Exception");
83 return -1;
86 return 0;