2 #include "ace/Get_Opt.h"
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:"));
12 while ((c
= get_opts ()) != -1)
16 ior
= get_opts
.opt_arg ();
21 ACE_ERROR_RETURN ((LM_ERROR
,
28 // Indicates successful parsing of the command line
33 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
39 if (parse_args (argc
, argv
) != 0)
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",
54 Echo::List_var list
= echo
->return_list();
57 "Received list of length %u\n",
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
);
66 "First element has length %u\n",
68 for (size_t n
= 0; n
< length
; ++n
)
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
);
80 "Second element has length %u, value: <%C>\n",
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();
90 "Received wide list of length %u\n",
92 if (wlist
->length() != 2)
94 ACE_ERROR_RETURN ((LM_ERROR
, "Expected length 2\n"), -1);
100 catch (const CORBA::Exception
& ex
)
102 ex
._tao_print_exception ("Exception caught:");