source: trunk/ORBit2-2.14.0/test/everything/basicServer.c

Last change on this file was 92, checked in by cinc, 19 years ago

Orbit2 modified for use with NOM

File size: 7.8 KB
Line 
1/*
2 * CORBA C language mapping tests
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2, or (at your option) any
7 * later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Author: Phil Dawes <philipd@users.sourceforge.net>
19 */
20
21#include "everything.h"
22#include "constants.h"
23#include <stdio.h>
24
25extern int _orbit_debug_flags;
26
27static CORBA_char *
28BasicServer__get_foo (PortableServer_Servant servant,
29 CORBA_Environment *ev)
30{
31 return CORBA_string_dup (constants_STRING_RETN);
32}
33
34static void
35BasicServer__set_foo (PortableServer_Servant servant,
36 const CORBA_char *val,
37 CORBA_Environment *ev)
38{
39 g_assert (!strcmp (val, constants_STRING_IN));
40}
41
42static CORBA_long
43BasicServer__get_bah (PortableServer_Servant servant,
44 CORBA_Environment *ev)
45{
46 return constants_LONG_RETN;
47}
48
49static CORBA_char *
50BasicServer_opString (PortableServer_Servant servant,
51 const CORBA_char *inArg,
52 CORBA_char **inoutArg,
53 CORBA_char **outArg,
54 CORBA_Environment *ev)
55{
56 g_assert (!strcmp (inArg, constants_STRING_IN));
57 g_assert (!strcmp (*inoutArg, constants_STRING_INOUT_IN));
58
59 CORBA_free (*inoutArg);
60 *inoutArg = CORBA_string_dup (constants_STRING_INOUT_OUT);
61 *outArg = CORBA_string_dup (constants_STRING_OUT);
62
63 return CORBA_string_dup (constants_STRING_RETN);
64}
65
66static CORBA_long
67BasicServer_opLong (PortableServer_Servant servant,
68 const CORBA_long inArg,
69 CORBA_long *inoutArg,
70 CORBA_long *outArg,
71 CORBA_Environment *ev)
72{
73 g_assert (inArg == constants_LONG_IN);
74 g_assert (*inoutArg == constants_LONG_INOUT_IN);
75
76 *inoutArg = constants_LONG_INOUT_OUT;
77 *outArg = constants_LONG_OUT;;
78
79 return constants_LONG_RETN;
80}
81
82static CORBA_long_long
83BasicServer_opLongLong (PortableServer_Servant servant,
84 const CORBA_long_long inArg,
85 CORBA_long_long *inoutArg,
86 CORBA_long_long *outArg,
87 CORBA_Environment *ev)
88{
89 g_assert (inArg == constants_LONG_LONG_IN);
90 g_assert (*inoutArg == constants_LONG_LONG_INOUT_IN);
91
92 *inoutArg = constants_LONG_LONG_INOUT_OUT;
93 *outArg = constants_LONG_LONG_OUT;;
94
95 return constants_LONG_LONG_RETN;
96}
97
98static CORBA_float
99BasicServer_opFloat (PortableServer_Servant servant,
100 const CORBA_float inArg,
101 CORBA_float *inoutArg,
102 CORBA_float *outArg,
103 CORBA_Environment *ev)
104{
105 g_assert (inArg == constants_FLOAT_IN);
106 g_assert (*inoutArg == constants_FLOAT_INOUT_IN);
107
108 *inoutArg = constants_FLOAT_INOUT_OUT;
109 *outArg = constants_FLOAT_OUT;;
110
111 return constants_FLOAT_RETN;
112}
113
114static CORBA_double
115BasicServer_opDouble (PortableServer_Servant servant,
116 const CORBA_double inArg,
117 CORBA_double *inoutArg,
118 CORBA_double *outArg,
119 CORBA_Environment *ev)
120{
121 g_assert (inArg == constants_DOUBLE_IN);
122 g_assert (*inoutArg == constants_DOUBLE_INOUT_IN);
123
124 *inoutArg = constants_DOUBLE_INOUT_OUT;
125 *outArg = constants_DOUBLE_OUT;;
126
127 return constants_DOUBLE_RETN;
128}
129
130static CORBA_long_double
131BasicServer_opLongDouble (PortableServer_Servant servant,
132 const CORBA_long_double inArg,
133 CORBA_long_double *inoutArg,
134 CORBA_long_double *outArg,
135 CORBA_Environment *ev)
136{
137 g_assert (inArg == constants_LONG_DOUBLE_IN);
138 g_assert (*inoutArg == constants_LONG_DOUBLE_INOUT_IN);
139
140 *inoutArg = constants_LONG_DOUBLE_INOUT_OUT;
141 *outArg = constants_LONG_DOUBLE_OUT;;
142
143 return constants_LONG_DOUBLE_RETN;
144}
145
146static test_AnEnum
147BasicServer_opEnum (PortableServer_Servant servant,
148 const test_AnEnum inArg,
149 test_AnEnum *inoutArg,
150 test_AnEnum *outArg,
151 CORBA_Environment *ev)
152{
153 g_assert (inArg == test_ENUM_IN);
154 g_assert (*inoutArg == test_ENUM_INOUT_IN);
155
156 *inoutArg = test_ENUM_INOUT_OUT;
157 *outArg = test_ENUM_OUT;
158
159 return test_ENUM_RETN;
160}
161
162static void
163BasicServer_opException (PortableServer_Servant servant,
164 CORBA_Environment *ev)
165{
166 test_TestException *ex = test_TestException__alloc ();
167
168 ex->reason = CORBA_string_dup (constants_STRING_IN);
169 ex->number = constants_LONG_IN;
170 ex->aseq._buffer = CORBA_sequence_CORBA_long_allocbuf (1);
171 ex->aseq._length = 1;
172 ex->aseq._buffer [0] = constants_LONG_IN;
173 ex->factory = getFactoryInstance(ev);
174
175 CORBA_sequence_set_release (&ex->aseq, CORBA_TRUE);
176
177 CORBA_exception_set (
178 ev, CORBA_USER_EXCEPTION, ex_test_TestException,ex);
179}
180
181static void
182BasicServer_opOneWay (PortableServer_Servant servant,
183 const CORBA_char *str,
184 CORBA_Environment *ev)
185{
186 g_assert (!strcmp (str, constants_STRING_IN));
187}
188
189static void
190BasicServer_testLargeStringSeq (PortableServer_Servant servant,
191 const test_StrSeq *seq,
192 CORBA_Environment *ev)
193{
194}
195
196/* Nasty IORs from JavaORB */
197static char* iorstrings[] = {
198 "IOR:010000001f00000049444c3a6f726269742f746573742f54657"
199 "374466163746f72793a312e300000030000000054424f6400000001"
200 "01020005000000554e495800000000160000006c6f63616c686f737"
201 "42e6c6f63616c646f6d61696e0000002d0000002f746d702f6f7262"
202 "69742d6d69636861656c2f6c696e632d363733322d302d373362323"
203 "966373333316662390000000000000000caaedfba58000000010102"
204 "002d0000002f746d702f6f726269742d6d69636861656c2f6c696e6"
205 "32d363733322d302d37336232396637333331666239000000001c00"
206 "000000000000331c40f8ba0fa828dc2928282828282808000000db7"
207 "e269601000000480000000100000002000000050000001c00000000"
208 "000000331c40f8ba0fa828dc2928282828282808000000db7e26960"
209 "1000000140000000100000001000105000000000901010000000000",
210 "IOR:000000000000002249444c3a4163636573736962696c6974792"
211 "f4170706c69636174696f6e3a312e30000000000000010000000000"
212 "000082000102000000000a3132372e302e302e3200837800000031a"
213 "fabcb00000000200d3e1d2600000001000000000000000100000008"
214 "526f6f74504f4100000000080000000100000000140000000000000"
215 "2000000010000002000000000000100010000000205010001000100"
216 "2000010109000000010001010000000026000000020002"
217};
218
219static CORBA_long
220BasicServer_getObjectCount (PortableServer_Servant servant,
221 CORBA_Environment *ev)
222{
223 return G_N_ELEMENTS (iorstrings) + 1;
224}
225
226static CORBA_Object
227BasicServer_getObject (PortableServer_Servant servant,
228 const CORBA_long which,
229 CORBA_Environment *ev)
230{
231 if (which < G_N_ELEMENTS (iorstrings))
232 return CORBA_ORB_string_to_object (global_orb, iorstrings[which], ev);
233 else
234 return CORBA_OBJECT_NIL;
235}
236
237static void
238BasicServer_testBoolString (PortableServer_Servant servant,
239 CORBA_boolean inBool,
240 const char *inArg,
241 char **inoutArg,
242 CORBA_Environment *ev)
243{
244}
245
246
247POA_test_BasicServer__epv BasicServer_epv = {
248 NULL,
249 BasicServer__get_foo,
250 BasicServer__set_foo,
251 BasicServer__get_bah,
252 BasicServer_opString,
253 BasicServer_opLong,
254 BasicServer_opLongLong,
255 BasicServer_opFloat,
256 BasicServer_opDouble,
257 BasicServer_opLongDouble,
258 BasicServer_opEnum,
259 BasicServer_opException,
260 BasicServer_opOneWay,
261 NULL, /* noImplement */
262 BasicServer_testLargeStringSeq,
263 BasicServer_getObjectCount,
264 BasicServer_getObject,
265 BasicServer_testBoolString,
266};
267
268PortableServer_ServantBase__epv BasicServer_base_epv = {NULL, simple_finalize, NULL};
269POA_test_BasicServer__vepv BasicServer_vepv = { &BasicServer_base_epv, &BasicServer_epv };
Note: See TracBrowser for help on using the repository browser.