Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tests / GIOP_Fragments / Big_String_Sequence / client.cpp
blob21ef8c8008b799c560c493f09e62e75e99838881
1 #include "EchoC.h"
2 #include "ace/Get_Opt.h"
3 #include <cstring>
5 const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
7 int parse_args (int argc, ACE_TCHAR *argv[])
9 ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("f:"));
10 int c;
12 while ((c = get_opts ()) != -1)
13 switch (c)
15 case 'f':
16 ior = get_opts.opt_arg ();
17 break;
19 case '?':
20 default:
21 ACE_ERROR_RETURN ((LM_ERROR,
22 "usage: %s "
23 "-f <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 CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
39 if (parse_args (argc, argv) != 0)
40 return -1;
42 CORBA::Object_var tmp = orb->string_to_object(ior);
44 Echo_var echo = Echo::_narrow(tmp.in ());
46 if (CORBA::is_nil (echo.in ()))
48 ACE_ERROR_RETURN ((LM_ERROR,
49 "Nil Echo reference <%s>\n",
50 ior),
51 -1);
54 Echo::List_var list = echo->return_list();
56 ACE_DEBUG ((LM_DEBUG,
57 "Received list of length %u\n",
58 list->length()));
59 if (list->length() != 2)
61 ACE_ERROR_RETURN ((LM_ERROR, "Expected length 2\n"), -1);
63 const char* value = (*list)[0].in();
64 size_t length = std::strlen(value);
65 ACE_DEBUG ((LM_DEBUG,
66 "First element has length %u\n",
67 length));
68 for (size_t n = 0; n < length; ++n)
70 if (value[n] != 'A')
72 ACE_ERROR_RETURN ((LM_ERROR,
73 "Character at position %u should be 'A',"
74 " but is '%c'\n", value[n]), -1);
77 value = (*list)[1].in();
78 length = std::strlen(value);
79 ACE_DEBUG ((LM_DEBUG,
80 "Second element has length %u, value: <%C>\n",
81 length, value));
82 if (strcmp(value, "Hello World") != 0)
84 ACE_ERROR_RETURN ((LM_ERROR, "Expected \"Hello World\""), -1);
87 Echo::WList_var wlist = echo->return_wlist();
89 ACE_DEBUG ((LM_DEBUG,
90 "Received wide list of length %u\n",
91 wlist->length()));
92 if (wlist->length() != 2)
94 ACE_ERROR_RETURN ((LM_ERROR, "Expected length 2\n"), -1);
97 echo->shutdown ();
98 orb->destroy ();
100 catch (const CORBA::Exception& ex)
102 ex._tao_print_exception ("Exception caught:");
103 return 1;
106 return 0;