00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include <string.h>
00036 #include <orbit/orbit.h>
00037
00038 #include "corba_util.h"
00039 #include "discovery_service.h"
00040
00041
00042 void register_object(unsigned char type, CORBA_Object servant,
00043 CORBA_ORB orb, CORBA_Environment *ev)
00044 {
00045 object_reference_t ref;
00046 CORBA_char *objref = NULL;
00047
00048 objref = CORBA_ORB_object_to_string(orb, servant, ev);
00049 if (raised_exception(ev))
00050 return;
00051
00052 ref.type = type;
00053 strncpy(ref.ior, objref, OBJ_REF_SIZE);
00054 CORBA_free(objref);
00055
00056 if (start_discovery(&ref) < 0)
00057 CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_CORBA_UNKNOWN, NULL);
00058 }
00059
00060
00061 CORBA_Object discover_object(unsigned char type, unsigned char level,
00062 CORBA_ORB orb, CORBA_Environment *ev)
00063 {
00064 CORBA_Object obj = CORBA_OBJECT_NIL;
00065 object_reference_t *objrefs = NULL;
00066 unsigned int num_objects = 0;
00067
00068 if (query_discovery_service(type, level,
00069 objrefs, &num_objects, NULL) < 0) {
00070 CORBA_exception_set(ev, CORBA_USER_EXCEPTION,
00071 ex_CORBA_OBJECT_NOT_EXIST, NULL);
00072 return CORBA_OBJECT_NIL;
00073 }
00074
00075 obj = (CORBA_Object)CORBA_ORB_string_to_object(orb, objrefs[0].ior, ev);
00076
00077 return obj;
00078 }