2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: cmsdata.c /main/1 1996/04/21 19:22:08 drk $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Novell, Inc.
28 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
31 #include <EUSCompat.h>
40 /* standard calendar attr name and entry attr name table */
41 _DtCmNameTable *_DtCm_cal_name_tbl = NULL;
42 _DtCmNameTable *_DtCm_entry_name_tbl = NULL;
45 * allocate a cms_entry structure and initialized with
46 * all the library defined attribute names
49 _DtCm_make_cms_entry(_DtCmNameTable *tbl)
54 if ((ptr = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
57 /* initialize the entry with attribute names */
59 if ((ptr->attrs = (cms_attribute *)calloc(1,
60 sizeof(cms_attribute)*(tbl->size + 1))) == NULL) {
65 for (i = 1; i <= tbl->size; i++) {
66 if ((ptr->attrs[i].name.name = strdup(tbl->names[i])) == NULL) {
68 ptr->num_attrs = i - 1;
69 _DtCm_free_cms_entry(ptr);
73 ptr->attrs[i].name.num = i;
76 ptr->num_attrs = tbl->size;
81 extern CSA_return_code
82 _DtCm_copy_cms_entry(cms_entry *e, cms_entry **e_r)
87 if (e == NULL || e_r == NULL)
88 return (CSA_E_INVALID_PARAMETER);
90 if ((ptr = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
91 return (CSA_E_INSUFFICIENT_MEMORY);
93 if ((stat = _DtCm_copy_cms_attributes(e->num_attrs, e->attrs,
94 &ptr->num_attrs, &ptr->attrs)) != CSA_SUCCESS) {
100 return (CSA_SUCCESS);
105 _DtCm_free_cms_entry(cms_entry *entry)
110 if (entry->num_attrs > 0) {
111 _DtCm_free_cms_attributes(entry->num_attrs + 1, entry->attrs);
119 _DtCm_free_cms_entries(cms_entry *entry)
126 _DtCm_free_cms_entry(entry);
133 _DtCm_init_hash(void)
135 static boolean_t done = B_FALSE;
137 if (done == B_FALSE) {
139 /* need to check whether table is actually created */
140 _DtCm_cal_name_tbl = _DtCm_make_name_table(
141 _DtCM_DEFINED_CAL_ATTR_SIZE,
142 _CSA_calendar_attribute_names);
143 _DtCm_entry_name_tbl = _DtCm_make_name_table(
144 _DtCM_DEFINED_ENTRY_ATTR_SIZE,
145 _CSA_entry_attribute_names);
151 * attr->name.num contains the correct index for the attribute
153 extern CSA_return_code
154 _DtCmGrowAttrArray(uint *num_attrs, cms_attribute **attrs, cms_attribute *attr)
156 cms_attribute *newptr;
157 CSA_return_code stat;
160 index = attr->name.num;
162 if ((newptr = (cms_attribute *)realloc(*attrs,
163 sizeof(cms_attribute) * (index + 1))) == NULL)
164 return (CSA_E_INSUFFICIENT_MEMORY);
167 memset((void *)&(*attrs)[*num_attrs+1], 0,
168 sizeof(cms_attribute) * (index - *num_attrs));
171 if ((stat = _DtCm_copy_cms_attribute(&(*attrs)[index], attr, B_TRUE))