| 1 | #include <stdio.h>
|
|---|
| 2 | #include "test-any.h"
|
|---|
| 3 |
|
|---|
| 4 | int
|
|---|
| 5 | main (int argc, char *argv[])
|
|---|
| 6 | {
|
|---|
| 7 | CORBA_Environment ev;
|
|---|
| 8 | CORBA_ORB orb;
|
|---|
| 9 |
|
|---|
| 10 | TestAny obj;
|
|---|
| 11 | TestAnyStruct any_value, *retany_value;
|
|---|
| 12 |
|
|---|
| 13 | CORBA_any *retany, any;
|
|---|
| 14 |
|
|---|
| 15 | CORBA_exception_init(&ev);
|
|---|
| 16 | orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
|
|---|
| 17 |
|
|---|
| 18 | if(argc < 2)
|
|---|
| 19 | {
|
|---|
| 20 | printf("Need a binding ID thing as argv[1]\n");
|
|---|
| 21 | return 1;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
|
|---|
| 25 |
|
|---|
| 26 | if (!obj)
|
|---|
| 27 | {
|
|---|
| 28 | printf("Cannot bind to %s\n", argv[1]);
|
|---|
| 29 | return 1;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | any_value.long_value = 42;
|
|---|
| 33 | any_value.string_value = "fourty two.";
|
|---|
| 34 |
|
|---|
| 35 | any._type = (CORBA_TypeCode)TC_TestAnyStruct;
|
|---|
| 36 | any._value = &any_value;
|
|---|
| 37 | CORBA_any_set_release(&any, CORBA_FALSE );
|
|---|
| 38 | retany = TestAny_print (obj, &any, &ev);
|
|---|
| 39 | if(ev._major == CORBA_NO_EXCEPTION)
|
|---|
| 40 | {
|
|---|
| 41 |
|
|---|
| 42 | retany_value = retany->_value;
|
|---|
| 43 | if(retany_value)
|
|---|
| 44 | g_message("long %d string %s",
|
|---|
| 45 | retany_value->long_value,
|
|---|
| 46 | retany_value->string_value);
|
|---|
| 47 |
|
|---|
| 48 | CORBA_free(retany);
|
|---|
| 49 | }
|
|---|
| 50 | else
|
|---|
| 51 | {
|
|---|
| 52 | printf("we got exception %d from TestAny_print!\n", ev._major);
|
|---|
| 53 | return 1;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | CORBA_Object_release(obj, &ev);
|
|---|
| 57 | CORBA_Object_release((CORBA_Object)orb, &ev);
|
|---|
| 58 |
|
|---|
| 59 | return 0;
|
|---|
| 60 | }
|
|---|