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: convert4-3.c /main/1 1996/04/21 19:22:43 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>
36 #include "convert4-3.h"
39 * forward declaration of static functions
41 static void free_excpt3(Except_3 *e);
42 static Abb_Appt_3 * abb4_to_abb3(Abb_Appt_4 *a4);
43 static void apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to);
44 static Reminder_3 * reminder4_to_reminder3(Reminder_4 *r4);
45 static Table_Res_Type_3 tablerestype4_to_tablerestype3(Table_Res_Type_4 t);
46 static void tablereslist4_to_tablereslist3(Table_Res_List_4 *from,
47 Table_Res_List_3 *to);
48 static void period4_to_period3(Period_4 *p4, Period_3 *p3);
49 static void assign_tag4to3(Tag_4 *t4, Tag_3 *t3);
50 static void assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3);
51 static void assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3);
52 static Buffer_3 buffer4_to_buffer3(Buffer_4 b);
53 static Tag_3 * tag4_to_tag3(Tag_4 *t4);
54 static Attribute_3 * attr4_to_attr3(Attribute_4 *a4);
55 static Except_3 * except4_to_except3(Except_4 *e4);
56 static Table_Args_Type_3 argstag4_to_argstag3(Table_Args_Type_4 t);
57 static void args4_to_args3(Args_4 *from, Args_3 *to);
58 static Table_Args_3 * tableargs4_to_tableargs3(Table_Args_4 *a4);
59 static Registration_3 * reg4_to_reg3(Registration_4 *r4);
60 static void free_tag3(Tag_3 *t);
62 /**************** DATA TYPE (4->3) CONVERSION ROUTINES **************/
65 _DtCm_id4_to_id3(Id_4 *from, Id_3 *to)
67 if ((from==NULL) || (to==NULL)) return;
68 to->tick = from->tick;
73 _DtCm_uid4_to_uid3(Uid_4 *ui4)
75 Uid_3 *ui3, *head, *prev;
79 ui3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
80 _DtCm_id4_to_id3(&(ui4->appt_id), &(ui3->appt_id));
95 _DtCm_appt4_to_appt3(Appt_4 *a4)
97 Appt_3 *a3, *head, *prev;
101 a3 = (Appt_3 *)calloc(1, sizeof(Appt_3));
102 _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
103 a3->tag = tag4_to_tag3(a4->tag);
104 a3->duration = a4->duration;
105 a3->ntimes = a4->ntimes;
106 a3->what = buffer4_to_buffer3(a4->what);
107 period4_to_period3(&(a4->period), &(a3->period));
108 a3->author = buffer4_to_buffer3(a4->author);
109 a3->client_data = buffer4_to_buffer3(a4->client_data);
110 a3->exception = except4_to_except3(a4->exception);
111 a3->attr = attr4_to_attr3(a4->attr);
112 assign_status4to3(&a4->appt_status, &a3->appt_status);
113 assign_privacy4to3(&a4->privacy, &a3->privacy);
128 _DtCm_free_appt3(Appt_3 *a)
141 if (a->author != NULL)
144 if (a->client_data != NULL)
145 free(a->client_data);
148 _DtCm_free_attr3(a->attr);
150 if (a->exception != NULL)
151 free_excpt3(a->exception);
160 _DtCm_free_attr3(Attribute_3 *a)
168 if (a->value != NULL)
170 if (a->clientdata != NULL)
179 free_excpt3(Except_3 *e)
191 abb4_to_abb3(Abb_Appt_4 *a4)
193 Abb_Appt_3 *a3, *head, *prev;
197 a3 = (Abb_Appt_3 *)calloc(1, sizeof(Abb_Appt_3));
198 _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
199 a3->tag = tag4_to_tag3(a4->tag);
200 a3->what = buffer4_to_buffer3(a4->what);
201 a3->duration = a4->duration;
202 period4_to_period3(&(a4->period), &(a3->period));
203 assign_status4to3(&a4->appt_status, &a3->appt_status);
204 assign_privacy4to3(&a4->privacy, &a3->privacy);
219 apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to)
221 if (from==NULL || to==NULL) return;
222 _DtCm_id4_to_id3(from->oid, to->oid);
223 to->new_appt = _DtCm_appt4_to_appt3(from->new_appt);
227 reminder4_to_reminder3(Reminder_4 *r4)
229 Reminder_3 *r3, *head, *prev;
234 r3 = (Reminder_3 *)calloc(1, sizeof(Reminder_3));
235 _DtCm_id4_to_id3(&(r4->appt_id), &(r3->appt_id));
237 attr3 = attr4_to_attr3(&(r4->attr));
253 static Table_Res_Type_3
254 tablerestype4_to_tablerestype3(Table_Res_Type_4 t)
271 tablereslist4_to_tablereslist3(Table_Res_List_4 *from, Table_Res_List_3 *to)
273 if (from==NULL || to==NULL) return;
274 to->tag = tablerestype4_to_tablerestype3(from->tag);
277 to->Table_Res_List_3_u.a = _DtCm_appt4_to_appt3(
278 from->Table_Res_List_4_u.a);
281 to->Table_Res_List_3_u.r = reminder4_to_reminder3(
282 from->Table_Res_List_4_u.r);
285 to->Table_Res_List_3_u.b = abb4_to_abb3(
286 from->Table_Res_List_4_u.b);
289 to->Table_Res_List_3_u.i = _DtCm_uid4_to_uid3(
290 from->Table_Res_List_4_u.i);
296 extern Access_Status_3
297 _DtCm_accstat4_to_accstat3(Access_Status_4 s)
303 return(access_added_3);
304 case access_removed_4:
305 return(access_removed_3);
306 case access_failed_4:
307 return(access_failed_3);
308 case access_exists_4:
309 return(access_exists_3);
310 case access_partial_4:
311 return(access_partial_3);
314 return(access_other_3);
319 _DtCm_tableres4_to_tableres3(Table_Res_4 *r4)
323 if (r4==NULL) return((Table_Res_3 *)NULL);
324 r3 = (Table_Res_3 *)calloc(1, sizeof(Table_Res_3));
325 r3->status = _DtCm_accstat4_to_accstat3(r4->status);
326 tablereslist4_to_tablereslist3(&(r4->res), &(r3->res));
330 extern Access_Entry_3 *
331 _DtCm_acclist4_to_acclist3(Access_Entry_4 *l4)
333 Access_Entry_3 *l3, *head, *prev;
337 l3 = (Access_Entry_3 *)calloc(1, sizeof(Access_Entry_3));
338 l3->who = buffer4_to_buffer3(l4->who);
339 l3->access_type = l4->access_type;
353 extern Access_Args_3 *
354 _DtCm_accargs4_to_accargs3(Access_Args_4 *a4)
358 if (a4==NULL) return((Access_Args_3 *)NULL);
359 a3 = (Access_Args_3 *)calloc(1, sizeof(Access_Args_3));
360 a3->target = buffer4_to_buffer3(a4->target);
361 a3->access_list = _DtCm_acclist4_to_acclist3(a4->access_list);
366 _DtCm_range4_to_range3(Range_4 *r4)
368 Range_3 *r3, *head, *prev;
372 r3 = (Range_3 *)calloc(1, sizeof(Range_3));
389 _DtCm_keyrange4_to_keyrange3(Keyrange_4 *r4)
391 Keyrange_3 *r3, *head, *prev;
395 r3 = (Keyrange_3 *)calloc(1, sizeof(Keyrange_3));
397 r3->tick1 = r4->tick1;
398 r3->tick2 = r4->tick2;
412 extern Registration_Status_3
413 _DtCm_regstat4_to_regstat3(Registration_Status_4 s)
417 return(registered_3);
421 return(deregistered_3);
430 extern Table_Status_3
431 _DtCm_tablestat4_to_tablestat3(Table_Status_4 s)
451 _DtCm_uidopt4_to_uid3(Uidopt_4 *uidopt)
453 Uid_3 *uid3, *head, *prev;
456 while (uidopt != NULL) {
457 uid3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
458 _DtCm_id4_to_id3(&(uidopt->appt_id), &(uid3->appt_id));
467 uidopt = uidopt->next;
473 * Repeating event types beyond "yearly" are mapped to "single"
474 * because the old front end does not recognize any other types
475 * Worse yet it uses Interval to index into an array which
476 * contains strings up to "yearly", any period types beyond that
477 * would index beyond the array and cause the front end to dump core.
480 period4_to_period3(Period_4 *p4, Period_3 *p3)
482 if (p3 == NULL || p4 == NULL) return;
484 switch (p4->period) {
486 case single_4: p3->period = single_3;
490 case daily_4: p3->period = daily_3;
494 case weekly_4: p3->period = weekly_3;
498 case biweekly_4: p3->period = biweekly_3;
502 case monthly_4: p3->period = monthly_3;
506 case yearly_4: p3->period = yearly_3;
510 default: p3->period = single_3;
518 assign_tag4to3(Tag_4 *t4, Tag_3 *t3)
522 case appointment_4: t3->tag = appointment_3;
525 case reminder_4: t3->tag = reminder_3;
528 case otherTag_4: t3->tag = otherTag_3;
531 case holiday_4: t3->tag = holiday_3;
534 case toDo_4: t3->tag = toDo_3;
541 assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3)
545 case active_4: *s3 = active_3;
548 case pendingAdd_4: *s3 = pendingAdd_3;
551 case pendingDelete_4: *s3 = pendingDelete_3;
554 case committed_4: *s3 = committed_3;
557 case cancelled_4: *s3 = cancelled_3;
560 case completed_4: *s3 = completed_3;
567 assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3)
571 case public_4: *p3 = public_3;
574 case private_4: *p3 = private_3;
577 case semiprivate_4: *p3 = semiprivate_3;
586 buffer4_to_buffer3(Buffer_4 b)
597 tag4_to_tag3(Tag_4 *t4)
599 Tag_3 *t3, *head, *prev;
603 t3 = (Tag_3 *)calloc(1, sizeof(Tag_3));
604 assign_tag4to3(t4, t3);
605 t3->showtime = t4->showtime;
620 attr4_to_attr3(Attribute_4 *a4)
622 Attribute_3 *a3, *head, *prev;
626 a3 = (Attribute_3 *)calloc(1, sizeof(Attribute_3));
628 a3->attr = buffer4_to_buffer3(a4->attr);
629 a3->value = buffer4_to_buffer3(a4->value);
630 a3->clientdata = buffer4_to_buffer3(a4->clientdata);
644 except4_to_except3(Except_4 *e4)
646 Except_3 *e3, *head, *prev;
650 e3 = (Except_3 *)calloc(1, sizeof(Except_3));
651 e3->ordinal = e4->ordinal;
665 static Table_Args_Type_3
666 argstag4_to_argstag3(Table_Args_Type_4 t)
687 args4_to_args3(Args_4 *from, Args_3 *to)
689 if (from==NULL || to==NULL) return;
690 to->tag = argstag4_to_argstag3(from->tag);
693 to->Args_3_u.tick = from->Args_4_u.tick;
696 to->Args_3_u.apptid.oid = (Id_3 *)calloc(1, sizeof(Id_3));
698 &(from->Args_4_u.apptid),
699 &(to->Args_3_u.apptid));
702 to->Args_3_u.key = _DtCm_uid4_to_uid3(from->Args_4_u.key);
705 to->Args_3_u.appt = _DtCm_appt4_to_appt3(from->Args_4_u.appt);
708 to->Args_3_u.range = _DtCm_range4_to_range3(from->Args_4_u.range);
711 to->Args_3_u.keyrange = _DtCm_keyrange4_to_keyrange3(
712 from->Args_4_u.keyrange);
718 static Table_Args_3 *
719 tableargs4_to_tableargs3(Table_Args_4 *a4)
723 if (a4==NULL) return((Table_Args_3 *)NULL);
724 a3 = (Table_Args_3 *)calloc(1, sizeof(Table_Args_3));
725 a3->target = buffer4_to_buffer3(a4->target);
726 args4_to_args3(&(a4->args), &(a3->args));
731 static Registration_3 *
732 reg4_to_reg3(Registration_4 *r4)
734 Registration_3 *r3, *head, *prev;
738 r3 = (Registration_3 *)calloc(1, sizeof(Registration_3));
739 r3->target = buffer4_to_buffer3(r4->target);
740 r3->prognum = r4->prognum;
741 r3->versnum = r4->versnum;
742 r3->procnum = r4->procnum;