| 1 | /* | 
|---|
| 2 | * CORBA emopty 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 |  | 
|---|
| 23 | #include "empty.h" | 
|---|
| 24 |  | 
|---|
| 25 | static Empty empty_client; | 
|---|
| 26 |  | 
|---|
| 27 | #define ABORT_IF_EXCEPTION(_ev, _message)                    \ | 
|---|
| 28 | if ((_ev)->_major != CORBA_NO_EXCEPTION) {                   \ | 
|---|
| 29 | g_error("%s: %s", _message, CORBA_exception_id (_ev));     \ | 
|---|
| 30 | CORBA_exception_free (_ev);                                \ | 
|---|
| 31 | abort();                                                   \ | 
|---|
| 32 | } | 
|---|
| 33 |  | 
|---|
| 34 | int | 
|---|
| 35 | main (int argc, char *argv[]) | 
|---|
| 36 | { | 
|---|
| 37 | CORBA_Environment ev; | 
|---|
| 38 | CORBA_ORB orb; | 
|---|
| 39 | int i; | 
|---|
| 40 |  | 
|---|
| 41 | int niters = 100; | 
|---|
| 42 |  | 
|---|
| 43 | CORBA_exception_init(&ev); | 
|---|
| 44 | orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev); | 
|---|
| 45 | ABORT_IF_EXCEPTION(&ev, "ORB init ..."); | 
|---|
| 46 |  | 
|---|
| 47 | #if 0 | 
|---|
| 48 | for(i = 0; i < (sizeof(theblah) - 1); i++) | 
|---|
| 49 | theblah[i] = 'a'; | 
|---|
| 50 | theblah[sizeof(theblah) - 1] = '\0'; | 
|---|
| 51 | #endif | 
|---|
| 52 |  | 
|---|
| 53 | if(argc < 2) { | 
|---|
| 54 | printf("Need a binding ID thing as argv[1]\n"); | 
|---|
| 55 | return 1; | 
|---|
| 56 | } | 
|---|
| 57 |  | 
|---|
| 58 | if(argc == 3) | 
|---|
| 59 | niters = atoi(argv[2]); | 
|---|
| 60 |  | 
|---|
| 61 | /* bind to object */ | 
|---|
| 62 | empty_client = CORBA_ORB_string_to_object(orb, argv[1], &ev); | 
|---|
| 63 | ABORT_IF_EXCEPTION(&ev, "Cannot bind to object ..."); | 
|---|
| 64 |  | 
|---|
| 65 | printf("corba = %d, empty = %d, foobar = %d\n", | 
|---|
| 66 | CORBA_Object_is_a(empty_client, "IDL:CORBA/Object:1.0", &ev), | 
|---|
| 67 | CORBA_Object_is_a(empty_client, "IDL:Empty:1.0", &ev), | 
|---|
| 68 | CORBA_Object_is_a(empty_client, "IDL:Foo/Bar:1.0", &ev)); | 
|---|
| 69 |  | 
|---|
| 70 | for(i = 0; i < niters; i++) { | 
|---|
| 71 | Empty_doNothing(empty_client, &ev); | 
|---|
| 72 | ABORT_IF_EXCEPTION(&ev, "doNothing() ..."); | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | /* release initial object reference */ | 
|---|
| 76 | CORBA_Object_release(empty_client, &ev); | 
|---|
| 77 | ABORT_IF_EXCEPTION(&ev, "release empty_client ..."); | 
|---|
| 78 |  | 
|---|
| 79 | /* shutdown ORB, shutdown IO channels */ | 
|---|
| 80 | CORBA_ORB_shutdown (orb, FALSE, &ev); | 
|---|
| 81 | ABORT_IF_EXCEPTION(&ev, "ORB shutdown ..."); | 
|---|
| 82 |  | 
|---|
| 83 | /* destroy local ORB */ | 
|---|
| 84 | CORBA_ORB_destroy (orb, &ev); | 
|---|
| 85 | ABORT_IF_EXCEPTION(&ev, "ORB destroy ..."); | 
|---|
| 86 |  | 
|---|
| 87 | return 0; | 
|---|
| 88 | } | 
|---|