Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / tests / Security / Bug_2908_Regression / MessengerClient.cpp
blob939ac5713d9bc80d6e5de68db6d9d2b0d47382e5
1 #include "MessengerC.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR *ior = ACE_TEXT("file://server.ior");
6 int
7 parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'k':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-k <ior> "
24 "\n",
25 argv [0]),
26 -1);
28 // Indicates successful parsing of the command line
29 return 0;
32 int
33 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
35 try
37 // Initialize orb
38 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
40 if (parse_args (argc, argv) != 0)
41 return 1;
43 CORBA::Object_var obj =
44 orb->string_to_object (ior);
46 // Narrow the Messenger object reference
47 Messenger_var messenger = Messenger::_narrow(obj.in());
48 if (CORBA::is_nil(messenger.in())) {
49 ACE_ERROR((LM_ERROR, " ERROR: Client cannot get a Messenger reference\n"));
50 return 1;
53 CORBA::String_var message = CORBA::string_dup("Hello!");
55 ACE_DEBUG((LM_DEBUG, "CLIENT: Start sending message\n"));
57 // Send a message
58 messenger->send_message("user", "TAO Test", message.inout());
60 ACE_DEBUG((LM_DEBUG, "CLIENT: Message was sent\n"));
62 messenger->shutdown ();
64 orb->destroy();
66 catch (const CORBA::Exception& ex)
68 ex._tao_print_exception ("Caught exception:");
69 return 1;
72 return 0;