PreviousNext

Reading All of a Host Service's Data

Suppose you want to display host service data in an application that has a graphical user interface. The dcecp commands may not be adequate to display data for this application. The following example shows how to obtain the entire set of data for each host service:

dced_binding_handle_t dced_bh;

dced_string_t host_service;

void *data_list;

unsigned32 count;

dced_service_type_t service_type;

error_status_t status;

.

.

.

while(user_selects(&host_service, &service_type)){ /*application specific*/

dced_binding_create(host_service,

dced_c_binding_syntax_default,

&dced_bh,

&status);

if(status == error_status_ok) {

dced_object_read_all(dced_bh, &count, &data_list, &status);

if(status == error_status_ok) {

display(service_type, count, data_list); /*application specific*/

dced_objects_release(dced_bh, count, data_list, &status);

}

dced_binding_free( dced_bh, &status);

}

}

user_selects( )
This is an example of an application-specific routine that constructs the complete service name from host and service name information. Data is stored and retrievable for the hostdata, srvrconf, srvrexecD, and keytab services. No data is stored for the secval service.

dced_binding_create( )
Output from the dced_binding_create routine includes a dced binding handle whose data type is dced_binding_handle_t. If an application already has an RPC binding handle to a server on the host desired, it can use the dced_binding_from_rpc_binding( ) routine to bind to dced and one of its host services on that host. (Applications also use these routines to bind to the secval service to perform other functions.)

dced_object_read_all( )
Applications use the dced_object_read_all( ) routine to read data for all the objects in an entry list. The output includes the address of an allocated buffer of data and a count of the number of objects the buffer contains. The data type in the buffer depends on the service used.

display( )
This is an application-specific routine that displays the data. Before the data is displayed, it must be interpreted depending on the service. The hostdata data is an array of sec_attr_t data structures, the srvrconf and srvrexec data are arrays of server_t structures, and the keytab data is an array of dced_key_list_t structures. The following code fragments show the data type for each service:

void display(

dced_service_type_t service_type, /* dced service type */

int count, /* count of the number of data items */

void *data) /* obtained from dced_object_read{_all}( ) */

{

sec_attr_t *host_data;

server_t *servers;

dced_key_list_t *keytab_data;

.

.

.

switch(service_type) {

case dced_e_service_type_hostdata:

host_data = (sec_attr_t *)data;

. . .

case dced_e_service_type_srvrconf:

servers = (server_t *)data;

. . .

case dced_e_service_type_srvrexec:

servers = (server_t *)data;

. . .

case dced_e_service_type_keytab:

keytab_data = (dced_key_list_t *)data;

. . .

default:

/* No other dced service types have data to read. */

break;

}

return;

}

dced_objects_release( )
Each call to the dced_object_read_all( ) routine requires a corresponding call to dced_objects_release( ) to release the resources allocated.

dced_binding_free( )
Each call to the dced_binding_create( ) routine requires a corresponding call to dced_binding_free( ) to release the resources for the binding allocated.