1 /* $XConsortium: cmsdata.c /main/1 1996/04/21 19:22:08 drk $ */
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 /* standard calendar attr name and entry attr name table */
19 _DtCmNameTable *_DtCm_cal_name_tbl = NULL;
20 _DtCmNameTable *_DtCm_entry_name_tbl = NULL;
23 * allocate a cms_entry structure and initialized with
24 * all the library defined attribute names
27 _DtCm_make_cms_entry(_DtCmNameTable *tbl)
32 if ((ptr = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
35 /* initialize the entry with attribute names */
37 if ((ptr->attrs = (cms_attribute *)calloc(1,
38 sizeof(cms_attribute)*(tbl->size + 1))) == NULL) {
43 for (i = 1; i <= tbl->size; i++) {
44 if ((ptr->attrs[i].name.name = strdup(tbl->names[i])) == NULL) {
46 ptr->num_attrs = i - 1;
47 _DtCm_free_cms_entry(ptr);
51 ptr->attrs[i].name.num = i;
54 ptr->num_attrs = tbl->size;
59 extern CSA_return_code
60 _DtCm_copy_cms_entry(cms_entry *e, cms_entry **e_r)
65 if (e == NULL || e_r == NULL)
66 return (CSA_E_INVALID_PARAMETER);
68 if ((ptr = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
69 return (CSA_E_INSUFFICIENT_MEMORY);
71 if ((stat = _DtCm_copy_cms_attributes(e->num_attrs, e->attrs,
72 &ptr->num_attrs, &ptr->attrs)) != CSA_SUCCESS) {
83 _DtCm_free_cms_entry(cms_entry *entry)
88 if (entry->num_attrs > 0) {
89 _DtCm_free_cms_attributes(entry->num_attrs + 1, entry->attrs);
97 _DtCm_free_cms_entries(cms_entry *entry)
104 _DtCm_free_cms_entry(entry);
113 static boolean_t done = B_FALSE;
115 if (done == B_FALSE) {
117 /* need to check whether table is actually created */
118 _DtCm_cal_name_tbl = _DtCm_make_name_table(
119 _DtCM_DEFINED_CAL_ATTR_SIZE,
120 _CSA_calendar_attribute_names);
121 _DtCm_entry_name_tbl = _DtCm_make_name_table(
122 _DtCM_DEFINED_ENTRY_ATTR_SIZE,
123 _CSA_entry_attribute_names);
129 * attr->name.num contains the correct index for the attribute
131 extern CSA_return_code
132 _DtCmGrowAttrArray(uint *num_attrs, cms_attribute **attrs, cms_attribute *attr)
134 cms_attribute *newptr;
135 CSA_return_code stat;
138 index = attr->name.num;
140 if ((newptr = (cms_attribute *)realloc(*attrs,
141 sizeof(cms_attribute) * (index + 1))) == NULL)
142 return (CSA_E_INSUFFICIENT_MEMORY);
145 memset((void *)&(*attrs)[*num_attrs+1], NULL,
146 sizeof(cms_attribute) * (index - *num_attrs));
149 if ((stat = _DtCm_copy_cms_attribute(&(*attrs)[index], attr, B_TRUE))