/** * @file HelloWorldClient.c * * Calls a HelloWorld object. */ #include #include "VMCFCoreImpl.h" /* Include the IDL-generated interface header file. */ #include "HelloWorld.h" int main(int argc, char **argv) { CORBA_Environment lenv = { CORBA_NO_EXCEPTION }; HelloWorld_Greetings obj = CORBA_OBJECT_NIL; CORBA_string objName = NULL; if (argc < 3) { fprintf(stderr, "Syntax: %s \n" "Where:\n" "- is the 'IOR:'-prefixed string printed out by " "the server,\n including the 'IOR:' prefix.\n\n" "- is of one of the forms:\n" " 'corbaloc:iiop::/'\n" " 'corbaloc:viop::/'\n" " with as defined by the instantiating server\n" " (in this example, the object name is 'HelloWorld').\n\n" " Note that, in the latter case, the server must have been\n" " started with the '--bind' option.\n\n" "- is an arbitraty string, e.g., jane\n\n", *argv); return 1; } /* One-time runtime initialization. */ if (!VMCFCoreImpl_init(CORBA_FALSE, NULL)) { printf("VMCFCoreImpl_init failed\n"); return 2; } /* Remember to initialize IDL module before making invocations. */ HelloWorld__Initialize(); do { /* Obtain object from the IOR string. */ obj = CORBA_ORB_string_to_object(VMCFCoreImpl_getORB(), *(argv+1), &lenv); VMCF_BREAK_ON_EXCEPTION(&lenv); /* Test inheritance: call CFObject's attribute getter. */ objName = VMCFCore_CFObject__get_name(obj, &lenv); VMCF_BREAK_ON_EXCEPTION(&lenv); printf("Object's name is: %s\n", objName); CORBA_free(objName); /* Call the object's 'hello' method. */ HelloWorld_Greetings_hello(obj, *(argv+2), &lenv); VMCF_BREAK_ON_EXCEPTION(&lenv); } while (0); if (VMCF_EXCEPTION_RAISED(&lenv)) { printf("Exception raised: %s\n", CORBA_exception_id(&lenv)); CORBA_exception_free(&lenv); } if (obj) { /* Properly release the object. */ CORBA_Object_release(obj, &lenv); CORBA_exception_free(&lenv); } return 0; }