OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
int num_attr, str_size;
sec_attr_enc_str_array_t *attr_array;
.
.
.
dced_binding_create(dced_c_service_hostdata,
dced_c_binding_syntax_default,
&dced_bh,
&status);
/*Create Entry Data */
uuid_create(&(entry.id), &status);
entry.name = (dced_string_t)("NEWERprinter");
entry.description = (dced_string_t)("Configuration for a new printer.");
entry.storage_tag = (dced_string_t)("/etc/NEWprinter");
/* Create the Attributes, one for this example */
data.count = 1;
num_attr = 1;
data.list = (sec_attr_t *)malloc( data.count * sizeof(sec_attr_t) );
(data.list)->attr_id = dced_g_uuid_fileattr;
(data.list)->attr_value.attr_encoding = sec_attr_enc_printstring_array;
str_size = sizeof(sec_attr_enc_str_array_t) +
num_attr * sizeof(sec_attr_enc_printstring_p_t);
attr_array = (sec_attr_enc_str_array_t *)malloc(str_size);
(data.list)->attr_value.tagged_union.string_array = attr_array;
attr_array->num_strings = num_attr;
attr_array->strings[0] = (dced_string_t)("New printer configuration data");
dced_hostdata_create(dced_bh, &entry, &data, &status);
dced_binding_free( dced_bh, &status);
The description of this example is as follows:
dced_binding_create()
This routine creates a dced binding to a dced service. The binding
handle created is used in all subsequent calls to appropriate dced API
routines. By using the dced_c_server_hostdata value for the first
parameter, we are using the hostdata service on the local host.
Create Entry Data
Prior to creating a hostdata entry, we have to set its values. These
include the name and UUID that dced will use to identify the new data, a
description of the entry, and a filename with the full pathname of where
the actual data will reside.
Create the Attributes
The data stored is of type sec_attr_t. This data type is a very flexible
one that can store many different kinds of data. In this example, we set
the file to have one attribute, printable string information. This example
has only one string of data. You can also establish binary data for the
file.
dced_hostdata_create()
This routine takes the binding handle, entry, and new data as input; it
creates the file with the new data and returns a status code.
If the printer configuration file already exists on the host, but you want to
now make it accessible to dced, use the dce_entry_add() routine
2 14 Tandem Computers Incorporated 124245