OSF DCE Application Development Guide--Core Components

OSF DCE Application Development Guide—Core Components
sec_attr_enc_str_array_t *attr_array;
unsigned_char_t *string_uuid, temp_string[200];
dced_attr_list_t attr_list;
dced_binding_create(dced_c_service_hostdata,
dced_c_binding_syntax_default,
&dced_bh,
&status);
dced_hostdata_read(dced_bh,
&dced_g_uuid_hostdata_post_proc,
&dced_g_uuid_fileattr,
&data_ptr,
&status);
/* Create New Array and Copy Old Data into it */
num_strings = data_ptr->attr_value.tagged_union.string_array->num_strings + 1;
str_size = sizeof(sec_attr_enc_str_array_t) +
num_strings * sizeof(sec_attr_enc_printstring_p_t);
attr_array = (sec_attr_enc_str_array_t *)malloc(str_size);
attr_array->num_strings = num_strings;
for(i=0; i<(num_strings-1); i++) {
attr_array->strings[i] =
data_ptr->attr_value.tagged_union.string_array->strings[i];
}
dced_inq_id(dced_bh, "NEWERprinter", &entry_uuid, &status);
uuid_to_string(&entry_uuid, &string_uuid, &status);
sprintf(temp_string, "%s %s", string_uuid, "/path/and/program/to/run");
attr_array->strings[num_strings-1] = (dced_string_t)(temp_string);
data_ptr->attr_value.tagged_union.string_array = attr_array;
attr_list.count = 1;
attr_list.list = (sec_attr_t *)malloc(attr_list.count * sizeof(sec_attr_t));
attr_list.list = data_ptr;
dced_hostdata_write(dced_bh,
&dced_g_uuid_hostdata_post_proc,
&attr_list,
&status);
dced_objects_release(dced_bh, 1, (void*)(data_ptr), &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 the hostdata service on a
specified host. The binding handle created is used in all subsequent calls
to appropriate dced API routines. The dced_c_service_hostdata
argument is a constant string that is the well-known name of the
hostdata service. When this string is used by itself, it refers to the
service on the local host.
dced_hostdata_read( )
This routine reads the hostdata item referred to by the entry UUID. In
this example, the global variable dced_g_uuid_hostdata_post_proc
represents the UUID for the well-known post_processors file. The
second parameter specifies an attribute for the data. Attributes describe
2 16 Tandem Computers Incorporated 124245