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 /*******************************************************************************
27 ** $XConsortium: cmsattr.c /main/3 1995/11/03 11:08:50 rswiston $
29 ** RESTRICTED CONFIDENTIAL INFORMATION:
31 ** The information in this document is subject to special
32 ** restrictions in a confidential disclosure agreement between
33 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
34 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
35 ** Sun's specific written approval. This document and all copies
36 ** and derivative works thereof must be returned or destroyed at
39 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
41 *******************************************************************************/
43 static char sccsid[] = "@(#)cmsattr.c 1.2 94/10/05 Copyr 1991 Sun Microsystems, Inc.";
46 #include <EUSCompat.h>
54 extern CSA_return_code
55 _DtCmsUpdateSint32AttrVal(
56 cms_attribute_value *newval,
57 cms_attribute_value **attrval)
59 cms_attribute_value *val;
62 if (*attrval == NULL) {
63 if ((val = (cms_attribute_value *)malloc(
64 sizeof(cms_attribute_value))) == NULL) {
65 return (CSA_E_INSUFFICIENT_MEMORY);
68 val->type = newval->type;
72 (*attrval)->item.sint32_value = newval->item.sint32_value;
74 } else if (*attrval) {
83 extern CSA_return_code
84 _DtCmsUpdateUint32AttrVal(
85 cms_attribute_value *newval,
86 cms_attribute_value **attrval)
88 cms_attribute_value *val;
91 if (*attrval == NULL) {
92 if ((val = (cms_attribute_value *)malloc(
93 sizeof(cms_attribute_value))) == NULL) {
94 return (CSA_E_INSUFFICIENT_MEMORY);
97 val->type = newval->type;
101 (*attrval)->item.uint32_value = newval->item.uint32_value;
103 } else if (*attrval) {
109 return (CSA_SUCCESS);
112 extern CSA_return_code
113 _DtCmsUpdateStringAttrVal(
114 cms_attribute_value *newval,
115 cms_attribute_value **attrval)
117 cms_attribute_value *val;
118 char *newstring = NULL;
121 if (newval->item.string_value &&
122 (newstring = strdup(newval->item.string_value)) == NULL)
123 return (CSA_E_INSUFFICIENT_MEMORY);
125 if (*attrval == NULL) {
126 if ((val = (cms_attribute_value *)malloc(
127 sizeof(cms_attribute_value))) == NULL) {
130 return (CSA_E_INSUFFICIENT_MEMORY);
133 val->type = newval->type;
136 if (val->item.string_value)
137 free(val->item.string_value);
140 val->item.string_value = newstring;
144 } else if (*attrval) {
146 free((*attrval)->item.string_value);
151 return (CSA_SUCCESS);
154 extern CSA_return_code
155 _DtCmsUpdateAccessListAttrVal(
156 cms_attribute_value *newval,
157 cms_attribute_value **attrval)
159 cms_attribute_value *val;
160 cms_access_entry *newlist = NULL;
162 if (newval && newval->item.access_list_value &&
163 (newlist = _DtCm_copy_cms_access_list(
164 newval->item.access_list_value)) == NULL)
165 return (CSA_E_INSUFFICIENT_MEMORY);
167 if (*attrval == NULL) {
168 if ((val = (cms_attribute_value *)malloc(
169 sizeof(cms_attribute_value))) == NULL) {
171 _DtCm_free_cms_access_entry(newlist);
172 return (CSA_E_INSUFFICIENT_MEMORY);
175 val->type = CSA_VALUE_ACCESS_LIST;
178 _DtCm_free_cms_access_entry(
179 (cms_access_entry *)val->item.access_list_value);
182 val->item.access_list_value = newlist;
186 return (CSA_SUCCESS);
189 extern CSA_return_code
190 _DtCmsUpdateReminderAttrVal(
191 cms_attribute_value *newval,
192 cms_attribute_value **attrval)
194 CSA_return_code stat;
195 cms_attribute_value *val;
196 CSA_reminder *rem = NULL;
198 if (newval && newval->item.reminder_value) {
199 if ((stat = _DtCm_copy_reminder(newval->item.reminder_value,
200 &rem)) != CSA_SUCCESS)
201 return (CSA_E_INSUFFICIENT_MEMORY);
203 if (*attrval == NULL) {
204 if ((val = (cms_attribute_value *)malloc(
205 sizeof(cms_attribute_value))) == NULL) {
207 _DtCm_free_reminder(rem);
208 return (CSA_E_INSUFFICIENT_MEMORY);
211 val->type = newval->type;
214 if (val->item.reminder_value)
215 _DtCm_free_reminder(val->item.reminder_value);
218 val->item.reminder_value = rem;
222 } else if (*attrval) {
224 _DtCm_free_reminder((*attrval)->item.reminder_value);
229 return (CSA_SUCCESS);
232 extern CSA_return_code
233 _DtCmsUpdateDateTimeListAttrVal(
234 cms_attribute_value *newval,
235 cms_attribute_value **attrval)
237 cms_attribute_value *val;
238 CSA_date_time_list dtlist = NULL;
240 if (newval && newval->item.date_time_list_value) {
241 if ((dtlist = _DtCm_copy_date_time_list(
242 newval->item.date_time_list_value)) == NULL)
243 return (CSA_E_INSUFFICIENT_MEMORY);
245 if (*attrval == NULL) {
246 if ((val = (cms_attribute_value *)malloc(
247 sizeof(cms_attribute_value))) == NULL) {
249 _DtCm_free_date_time_list(dtlist);
250 return (CSA_E_INSUFFICIENT_MEMORY);
253 val->type = newval->type;
256 if (val->item.date_time_list_value)
257 _DtCm_free_date_time_list(
258 val->item.date_time_list_value);
261 val->item.date_time_list_value = dtlist;
265 } else if (*attrval) {
267 _DtCm_free_date_time_list((*attrval)->item.date_time_list_value);
272 return (CSA_SUCCESS);
275 extern CSA_return_code
276 _DtCmsUpdateOpaqueDataAttrVal(
277 cms_attribute_value *newval,
278 cms_attribute_value **attrval)
280 CSA_return_code stat;
281 cms_attribute_value *val;
282 CSA_opaque_data *opq = NULL;
284 if (newval && newval->item.opaque_data_value) {
285 if ((stat = _DtCm_copy_opaque_data(
286 newval->item.opaque_data_value, &opq)) != CSA_SUCCESS)
287 return (CSA_E_INSUFFICIENT_MEMORY);
289 if (*attrval == NULL) {
290 if ((val = (cms_attribute_value *)malloc(
291 sizeof(cms_attribute_value))) == NULL) {
292 if (opq) _DtCm_free_opaque_data(opq);
293 return (CSA_E_INSUFFICIENT_MEMORY);
296 val->type = newval->type;
299 if (val->item.opaque_data_value)
300 _DtCm_free_opaque_data(
301 val->item.opaque_data_value);
304 val->item.opaque_data_value = opq;
308 } else if (*attrval) {
310 _DtCm_free_opaque_data((*attrval)->item.opaque_data_value);
315 return (CSA_SUCCESS);