3 //=============================================================================
7 * A simple client to demonstrate the use of codeset translation
9 * @author Phil Mesnier <mesnier_p@ociweb.com>
11 //=============================================================================
13 // IDL generated headers
15 #include "ace/ace_wchar.h"
17 // FUZZ: disable check_for_streams_include
18 #include "ace/streams.h"
20 #include "ace/OS_NS_string.h"
21 #include "ace/Log_Msg.h"
22 #include "ace/Get_Opt.h"
24 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
27 parse_args (int argc
, ACE_TCHAR
*argv
[])
29 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
32 while ((c
= get_opts ()) != -1)
36 ior
= get_opts
.opt_arg ();
41 ACE_ERROR_RETURN ((LM_ERROR
,
48 // Indicates successful parsing of the command line
53 make_wstring (const char *str
)
55 // Short circuit null pointer case
59 size_t len
= ACE_OS::strlen (str
) + 1;
60 wchar_t *wstr
= new wchar_t[len
];
62 "make_wstring: str = %C\n", str
));
63 for (size_t i
= 0; i
< len
; i
++)
65 char *t
= const_cast<char *> (str
);
66 wstr
[i
] = static_cast<wchar_t> (*(t
+ i
));
68 "wstr[%d] = %d\n", i
, (short)wstr
[i
]));
73 // ------------------------------------------------------------
75 // ------------------------------------------------------------
76 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
83 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
85 // Get IOR from command line (or file)
86 if (parse_args (argc
, argv
) != 0)
89 // The first arg should be the IOR
90 CORBA::Object_var object
=
91 orb
->string_to_object (ior
);
94 simple_var server
= simple::_narrow (object
.in ());
96 const char *bare_string
= "Hello World";
98 const char *any_string
= "Any World";
100 inarg
<<= any_string
;
101 CORBA::Any_var outarg
;
104 CORBA::String_var reply
=
105 server
->op1 (bare_string
,
109 const char *any_reply
;
110 outarg
>>= any_reply
;
112 ACE_DEBUG ((LM_DEBUG
,
113 "Client sent %C, got %C\n", bare_string
, reply
.in ()) );
115 if (ACE_OS::strcmp (bare_string
, reply
.in ()) != 0)
120 ACE_DEBUG ((LM_DEBUG
,
121 "Client sent %C, got %C\n", any_string
, any_reply
) );
123 if (ACE_OS::strcmp (any_string
, any_reply
) != 0)
127 #if defined (ACE_HAS_WCHAR)
128 wchar_t *wide_string
= ACE_OS::strdup(ACE_TEXT_ALWAYS_WCHAR(ACE_TEXT ("Wide String")));
129 wchar_t *wide_reply
= server
->op2 (wide_string
);
130 ACE_DEBUG ((LM_DEBUG
,
131 "sent %W, got %W\n", wide_string
, wide_reply
));
133 ACE_OS::free (wide_string
);
134 CORBA::wstring_free (wide_reply
);
135 #endif /* ACE_HAS_WCHAR */
141 catch (const CORBA::Exception
& ex
)
143 ex
._tao_print_exception ("Exception caught in client:");