OSF DCE Application Development Guide--Introduction and Style Guide
Using the DCE Name Service
One way of avoiding unnecessary regeneration of object UUIDs would be to have a
restarted server check the namespace for the presence of its previously exported object
UUIDs, as demonstrated in the following code fragment. Refer to the OSF DCE
Application Development Reference for further information on the function calls.
have_object = false;
/* Create an inquiry context for inspecting the object */
/* UUIDs exported to "my_entry_name"... */
rpc_ns_entry_object_inq_begin(my_entry_name_syntax,
my_entry_name,
&context, &st);
/* If we successfully created context, look at */
/* object UUIDs... */
if (st == rpc_s_ok)
{
/* Try to get one object UUID from the entry... */
rpc_ns_entry_object_inq_next(context, &obj, &st);
/* If an object UUID is there already, we don’t */
/* need to generate another one... */
have_object = (st == rpc_s_ok)
/* Delete the inquiry context... */
rpc_ns_entry_object_inq_done(&context, &st);
/* If there were no object UUIDs in the entry, */
/* generate one now... */
if (! have_object)
{
uuid_create(&obj, &st);
/* Put it in an object UUID vector... */
objvec.count = 1;
objvec.id[0] = &uuid;
}
/* Export bindings. If an object UUID was generated, */
/* export it too... */
rpc_ns_binding_export( my_entry_name_syntax,
my_entry_name,
my_interface_spec,
my_bindings,
have_object ? NULL : &objvec, &st);
124246 Tandem Computers Incorporated 5− 17