source: trunk/ORBit2-2.14.0/test/empty-server.c@ 255

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

Orbit2 modified for use with NOM

File size: 2.6 KB
Line 
1/*
2 * CORBA empty test
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: Elliot Lee <sopwith@redhat.com>
19 */
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23#include <signal.h>
24#include "empty.h"
25
26static Empty empty_client = CORBA_OBJECT_NIL;
27
28static void do_Nothing(PortableServer_Servant servant, CORBA_Environment *ev);
29
30static PortableServer_ServantBase__epv base_epv = {
31 NULL,
32 NULL,
33 NULL
34};
35static POA_Empty__epv empty_epv = { NULL, do_Nothing };
36static POA_Empty__vepv poa_empty_vepv = { &base_epv, &empty_epv };
37static POA_Empty poa_empty_servant = { NULL, &poa_empty_vepv };
38
39static void do_exit(int arg)
40{
41 exit(2);
42}
43
44int
45main (int argc, char *argv[])
46{
47 FILE *iorfile;
48 PortableServer_ObjectId objid = {0, sizeof("myFoo"), "myFoo"};
49 PortableServer_POA poa;
50
51 CORBA_Environment ev;
52 char *retval;
53 CORBA_ORB orb;
54 PortableServer_ObjectId *oid;
55
56 signal(SIGINT, do_exit);
57 signal(SIGTERM, do_exit);
58
59 CORBA_exception_init(&ev);
60 orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
61
62 POA_Empty__init(&poa_empty_servant, &ev);
63
64 poa = (PortableServer_POA)
65 CORBA_ORB_resolve_initial_references(orb,
66 "RootPOA", &ev);
67 PortableServer_POAManager_activate(
68 PortableServer_POA__get_the_POAManager(poa, &ev),
69 &ev);
70
71 oid = PortableServer_POA_activate_object(poa, &poa_empty_servant, &ev);
72 if(ev._major == CORBA_NO_EXCEPTION)
73 CORBA_free(oid);
74
75 empty_client =
76 PortableServer_POA_servant_to_reference(poa,
77 &poa_empty_servant,
78 &ev);
79 if (ev._major != CORBA_NO_EXCEPTION)
80 {
81 printf("Cannot get objref\n");
82 return 1;
83 }
84
85 retval = CORBA_ORB_object_to_string(orb, empty_client, &ev);
86
87 iorfile = fopen ("empty-server.iorfile", "w");
88 fprintf(iorfile, "%s\n", retval);
89 fclose(iorfile);
90
91 g_print("%s\n", retval); fflush(stdout);
92
93 CORBA_free(retval);
94
95 CORBA_ORB_run(orb, &ev);
96
97 PortableServer_POA_deactivate_object(poa, &objid, &ev);
98
99 return 0;
100}
101
102static void
103do_Nothing(PortableServer_Servant servant,
104 CORBA_Environment *ev)
105{
106}
Note: See TracBrowser for help on using the repository browser.