1 /* $XConsortium: cmsentry.c /main/4 1995/11/09 12:41:44 rswiston $ */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company
4 * (c) Copyright 1993, 1994 International Business Machines Corp.
5 * (c) Copyright 1993, 1994 Novell, Inc.
6 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
18 /******************************************************************************
19 * forward declaration of static functions used within the file
20 ******************************************************************************/
21 static CSA_return_code
22 _ExtractEntryAttrsFromEntry(uint srcsize, cms_attribute *srcattrs,
23 uint *dstsize, cms_attribute **dstattrs, boolean_t time_only);
25 /*****************************************************************************
27 *****************************************************************************/
30 * Given a hashed name table, initialize a new cms_entry with
31 * the given list of attribute values
33 extern CSA_return_code
34 _DtCmsMakeHashedEntry(
42 CSA_return_code stat = CSA_SUCCESS;
44 if (cal == NULL || entry == NULL)
45 return (CSA_E_INVALID_PARAMETER);
47 if ((eptr = _DtCm_make_cms_entry(cal->entry_tbl)) == NULL)
48 return (CSA_E_INSUFFICIENT_MEMORY);
50 for (i = 0; i < num && stat == CSA_SUCCESS; i++) {
51 index = _DtCm_get_index_from_table(cal->entry_tbl,
56 if (index > _DtCM_DEFINED_ENTRY_ATTR_SIZE &&
58 attrs[i].value->type != cal->types[index])
59 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
61 stat = _DtCm_copy_cms_attr_val(attrs[i].value,
62 &eptr->attrs[index].value);
63 } else if (attrs[i].value) {
64 if ((stat = _DtCmExtendNameTable(attrs[i].name.name, 0,
65 attrs[i].value->type, _DtCm_entry_name_tbl,
66 _DtCM_DEFINED_ENTRY_ATTR_SIZE,
67 _CSA_entry_attribute_names, &cal->entry_tbl,
68 &cal->types)) == CSA_SUCCESS) {
70 attrs[i].name.num = cal->entry_tbl->size;
72 stat = _DtCmGrowAttrArray(&eptr->num_attrs,
73 &eptr->attrs, &attrs[i]);
78 if (stat != CSA_SUCCESS) {
79 _DtCm_free_cms_entry(eptr);
88 _DtCmsFreeEntryAttrResItem(cms_get_entry_attr_res_item *elist)
90 cms_get_entry_attr_res_item *ptr;
95 _DtCm_free_cms_attributes(elist->num_attrs, elist->attrs);
102 extern CSA_return_code
103 _DtCmsGetCmsEntryForClient(cms_entry *e, cms_entry **e_r, boolean_t time_only)
106 CSA_return_code stat;
108 if (e == NULL || e_r == NULL)
109 return (CSA_E_INVALID_PARAMETER);
111 if ((ptr = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
112 return (CSA_E_INSUFFICIENT_MEMORY);
114 if ((stat = _ExtractEntryAttrsFromEntry(e->num_attrs, e->attrs,
115 &ptr->num_attrs, &ptr->attrs,time_only)) != CSA_SUCCESS) {
121 return (CSA_SUCCESS);
125 /*****************************************************************************
126 * static functions used within the file
127 *****************************************************************************/
129 static CSA_return_code
130 _ExtractEntryAttrsFromEntry(
132 cms_attribute *srcattrs,
134 cms_attribute **dstattrs,
137 CSA_return_code stat;
139 cms_attribute *attrs;
141 if (dstsize == NULL || dstattrs == NULL)
142 return (CSA_E_INVALID_PARAMETER);
148 return (CSA_SUCCESS);
150 if ((attrs = calloc(1, sizeof(cms_attribute) * srcsize)) == NULL)
151 return (CSA_E_INSUFFICIENT_MEMORY);
153 for (i = 0, j = 0; i <= srcsize; i++) {
154 if (srcattrs[i].value == NULL)
157 if ((stat = _DtCm_copy_cms_attribute(&attrs[j], &srcattrs[i],
158 B_TRUE)) != CSA_SUCCESS)
161 if ( (i == CSA_ENTRY_ATTR_SUMMARY_I) && (time_only == B_TRUE) ) {
162 if (attrs[j].value && attrs[j].value->item.string_value)
163 attrs[j].value->item.string_value[0] = '\0';
170 if (stat == CSA_SUCCESS && j > 0) {
174 _DtCm_free_cms_attributes(j, attrs);