1 /*******************************************************************************
5 ** $XConsortium: cmsattr.c /main/3 1995/11/03 11:08:50 rswiston $
7 ** RESTRICTED CONFIDENTIAL INFORMATION:
9 ** The information in this document is subject to special
10 ** restrictions in a confidential disclosure agreement between
11 ** HP, IBM, Sun, USL, SCO and Univel. Do not distribute this
12 ** document outside HP, IBM, Sun, USL, SCO, or Univel without
13 ** Sun's specific written approval. This document and all copies
14 ** and derivative works thereof must be returned or destroyed at
17 ** Copyright 1993 Sun Microsystems, Inc. All rights reserved.
19 *******************************************************************************/
21 static char sccsid[] = "@(#)cmsattr.c 1.2 94/10/05 Copyr 1991 Sun Microsystems, Inc.";
24 #include <EUSCompat.h>
32 extern CSA_return_code
33 _DtCmsUpdateSint32AttrVal(
34 cms_attribute_value *newval,
35 cms_attribute_value **attrval)
37 cms_attribute_value *val;
40 if (*attrval == NULL) {
41 if ((val = (cms_attribute_value *)malloc(
42 sizeof(cms_attribute_value))) == NULL) {
43 return (CSA_E_INSUFFICIENT_MEMORY);
46 val->type = newval->type;
50 (*attrval)->item.sint32_value = newval->item.sint32_value;
52 } else if (*attrval) {
61 extern CSA_return_code
62 _DtCmsUpdateUint32AttrVal(
63 cms_attribute_value *newval,
64 cms_attribute_value **attrval)
66 cms_attribute_value *val;
69 if (*attrval == NULL) {
70 if ((val = (cms_attribute_value *)malloc(
71 sizeof(cms_attribute_value))) == NULL) {
72 return (CSA_E_INSUFFICIENT_MEMORY);
75 val->type = newval->type;
79 (*attrval)->item.uint32_value = newval->item.uint32_value;
81 } else if (*attrval) {
90 extern CSA_return_code
91 _DtCmsUpdateStringAttrVal(
92 cms_attribute_value *newval,
93 cms_attribute_value **attrval)
95 cms_attribute_value *val;
96 char *newstring = NULL;
99 if (newval->item.string_value &&
100 (newstring = strdup(newval->item.string_value)) == NULL)
101 return (CSA_E_INSUFFICIENT_MEMORY);
103 if (*attrval == NULL) {
104 if ((val = (cms_attribute_value *)malloc(
105 sizeof(cms_attribute_value))) == NULL) {
108 return (CSA_E_INSUFFICIENT_MEMORY);
111 val->type = newval->type;
114 if (val->item.string_value)
115 free(val->item.string_value);
118 val->item.string_value = newstring;
122 } else if (*attrval) {
124 free((*attrval)->item.string_value);
129 return (CSA_SUCCESS);
132 extern CSA_return_code
133 _DtCmsUpdateAccessListAttrVal(
134 cms_attribute_value *newval,
135 cms_attribute_value **attrval)
137 cms_attribute_value *val;
138 cms_access_entry *newlist = NULL;
140 if (newval && newval->item.access_list_value &&
141 (newlist = _DtCm_copy_cms_access_list(
142 newval->item.access_list_value)) == NULL)
143 return (CSA_E_INSUFFICIENT_MEMORY);
145 if (*attrval == NULL) {
146 if ((val = (cms_attribute_value *)malloc(
147 sizeof(cms_attribute_value))) == NULL) {
149 _DtCm_free_cms_access_entry(newlist);
150 return (CSA_E_INSUFFICIENT_MEMORY);
153 val->type = CSA_VALUE_ACCESS_LIST;
156 _DtCm_free_cms_access_entry(
157 (cms_access_entry *)val->item.access_list_value);
160 val->item.access_list_value = newlist;
164 return (CSA_SUCCESS);
167 extern CSA_return_code
168 _DtCmsUpdateReminderAttrVal(
169 cms_attribute_value *newval,
170 cms_attribute_value **attrval)
172 CSA_return_code stat;
173 cms_attribute_value *val;
174 CSA_reminder *rem = NULL;
176 if (newval && newval->item.reminder_value) {
177 if ((stat = _DtCm_copy_reminder(newval->item.reminder_value,
178 &rem)) != CSA_SUCCESS)
179 return (CSA_E_INSUFFICIENT_MEMORY);
181 if (*attrval == NULL) {
182 if ((val = (cms_attribute_value *)malloc(
183 sizeof(cms_attribute_value))) == NULL) {
185 _DtCm_free_reminder(rem);
186 return (CSA_E_INSUFFICIENT_MEMORY);
189 val->type = newval->type;
192 if (val->item.reminder_value)
193 _DtCm_free_reminder(val->item.reminder_value);
196 val->item.reminder_value = rem;
200 } else if (*attrval) {
202 _DtCm_free_reminder((*attrval)->item.reminder_value);
207 return (CSA_SUCCESS);
210 extern CSA_return_code
211 _DtCmsUpdateDateTimeListAttrVal(
212 cms_attribute_value *newval,
213 cms_attribute_value **attrval)
215 cms_attribute_value *val;
216 CSA_date_time_list dtlist = NULL;
218 if (newval && newval->item.date_time_list_value) {
219 if ((dtlist = _DtCm_copy_date_time_list(
220 newval->item.date_time_list_value)) == NULL)
221 return (CSA_E_INSUFFICIENT_MEMORY);
223 if (*attrval == NULL) {
224 if ((val = (cms_attribute_value *)malloc(
225 sizeof(cms_attribute_value))) == NULL) {
227 _DtCm_free_date_time_list(dtlist);
228 return (CSA_E_INSUFFICIENT_MEMORY);
231 val->type = newval->type;
234 if (val->item.date_time_list_value)
235 _DtCm_free_date_time_list(
236 val->item.date_time_list_value);
239 val->item.date_time_list_value = dtlist;
243 } else if (*attrval) {
245 _DtCm_free_date_time_list((*attrval)->item.date_time_list_value);
250 return (CSA_SUCCESS);
253 extern CSA_return_code
254 _DtCmsUpdateOpaqueDataAttrVal(
255 cms_attribute_value *newval,
256 cms_attribute_value **attrval)
258 CSA_return_code stat;
259 cms_attribute_value *val;
260 CSA_opaque_data *opq = NULL;
262 if (newval && newval->item.opaque_data_value) {
263 if ((stat = _DtCm_copy_opaque_data(
264 newval->item.opaque_data_value, &opq)) != CSA_SUCCESS)
265 return (CSA_E_INSUFFICIENT_MEMORY);
267 if (*attrval == NULL) {
268 if ((val = (cms_attribute_value *)malloc(
269 sizeof(cms_attribute_value))) == NULL) {
270 if (opq) _DtCm_free_opaque_data(opq);
271 return (CSA_E_INSUFFICIENT_MEMORY);
274 val->type = newval->type;
277 if (val->item.opaque_data_value)
278 _DtCm_free_opaque_data(
279 val->item.opaque_data_value);
282 val->item.opaque_data_value = opq;
286 } else if (*attrval) {
288 _DtCm_free_opaque_data((*attrval)->item.opaque_data_value);
293 return (CSA_SUCCESS);