source: trunk/ORBit2-2.14.0/test/test-any-server.c@ 249

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

Orbit2 modified for use with NOM

File size: 2.1 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include "test-any.h"
5
6static TestAny client;
7
8static CORBA_any *
9do_print(PortableServer_Servant servant,
10 const CORBA_any *any,
11 CORBA_Environment *ev);
12
13static PortableServer_ServantBase__epv base_epv = {
14 NULL,
15 NULL,
16 NULL
17};
18
19static POA_TestAny__epv TestAny_epv = { NULL, do_print };
20static POA_TestAny__vepv poa_TestAny_vepv = { &base_epv, &TestAny_epv };
21static POA_TestAny poa_TestAny_servant = { NULL, &poa_TestAny_vepv };
22
23int
24main (int argc, char *argv[])
25{
26 FILE *iorfile;
27 PortableServer_ObjectId *objid;
28 PortableServer_POA poa;
29
30 CORBA_Environment ev;
31 char *retval;
32 CORBA_ORB orb;
33
34 CORBA_exception_init(&ev);
35 orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
36
37 POA_TestAny__init(&poa_TestAny_servant, &ev);
38
39 poa = (PortableServer_POA)
40 CORBA_ORB_resolve_initial_references(orb, "RootPOA", &ev);
41
42 PortableServer_POAManager_activate(
43 PortableServer_POA__get_the_POAManager(poa, &ev), &ev);
44
45 objid = PortableServer_POA_activate_object(poa,
46 &poa_TestAny_servant,
47 &ev);
48
49 client = PortableServer_POA_servant_to_reference(poa,
50 &poa_TestAny_servant,
51 &ev);
52 if (!client) {
53 printf("Cannot get objref\n");
54 return 1;
55 }
56
57 retval = CORBA_ORB_object_to_string(orb, client, &ev);
58
59 iorfile = fopen ("test-any-server.iorfile", "w");
60 fprintf(iorfile, "%s\n", retval);
61 fclose(iorfile);
62
63 g_print("%s\n", retval); fflush(stdout);
64
65 CORBA_free(retval);
66
67 CORBA_ORB_run(orb, &ev);
68
69 return 0;
70}
71
72static CORBA_any*
73do_print(PortableServer_Servant servant,
74 const CORBA_any *any,
75 CORBA_Environment *ev)
76{
77 TestAnyStruct* any_struct = any->_value;
78 CORBA_any *retval;
79
80 g_message("[server] %d: %s", any_struct->long_value,
81 any_struct->string_value);
82
83 retval = CORBA_any_alloc();
84#if 1
85 retval->_type = (CORBA_TypeCode)TC_TestAnyStruct;
86 retval->_value = TestAnyStruct__alloc();
87 ((TestAnyStruct *)retval->_value)->long_value = 84;
88 ((TestAnyStruct *)retval->_value)->string_value
89 = CORBA_string_dup("Hi there");
90#else
91 retval->_type = (CORBA_TypeCode)TC_null;
92 retval->_value = NULL;
93#endif
94
95 CORBA_any_set_release(retval, CORBA_TRUE);
96
97 return retval;
98}
Note: See TracBrowser for help on using the repository browser.