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 librararies 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: convert3-4.c /main/1 1996/04/21 19:22:31 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>
37 #include "convert3-4.h"
40 * forward declaration of static functions
42 static void assign_period3to4(Period_3 *p3, Period_4 *p4);
43 static void assign_tag3to4(Tag_3 *t3, Tag_4 *t4);
44 static void assign_privacy3to4(Privacy_Level_3 *p3, Privacy_Level_4 *p4);
45 static void assign_status3to4(Appt_Status_3 *s3, Appt_Status_4 *s4);
46 static Buffer_4 buffer3_to_buffer4(Buffer_3 b);
47 static void period3_to_period4(Period_3 *p3, Period_4 *p4);
48 static Tag_4 * tag3_to_tag4(Tag_3 *t3);
49 static Attribute_4 * attr3_to_attr4(Attribute_3 *a3);
50 static Except_4 * except3_to_except4(Except_3 *e3);
51 static void id3_to_id4(Id_3 *from, Id_4 *to);
52 static Uid_4 * uid3_to_uid4(Uid_3 *ui3);
53 static Appt_4 * appt3_to_appt4(Appt_3 *a3);
54 static Abb_Appt_4 * abb3_to_abb4(Abb_Appt_3 *a3);
55 static void apptid3_to_apptid4(Apptid_3 *from, Apptid_4 *to);
56 static Reminder_4 * reminder3_to_reminder4(Reminder_3 *r3);
57 static Table_Res_Type_4 tablerestype3_to_tablerestype4(Table_Res_Type_3 t);
58 static void tablereslist3_to_tablereslist4(Table_Res_List_3 *from,
59 Table_Res_List_4 *to);
60 static Access_Entry_4 * acclist3_to_acclist4(Access_Entry_3 *l3);
61 static Range_4 * range3_to_range4(Range_3 *r3);
62 static Keyrange_4 * keyrange3_to_keyrange4(Keyrange_3 *r3);
63 static Table_Args_Type_4 argstag3_to_argstag4(Table_Args_Type_3 t);
64 static void args3_to_args4(Args_3 *from, Args_4 *to);
65 static Uidopt_4 * uid3_to_uidopt(Uid_3 *uid3, Options_4 opt);
67 /**************** DATA TYPE (3->4) CONVERSION ROUTINES **************/
69 extern Access_Status_4
70 _DtCm_accstat3_to_accstat4(Access_Status_3 s)
76 return(access_added_4);
77 case access_removed_3:
78 return(access_removed_4);
80 return(access_failed_4);
82 return(access_exists_4);
83 case access_partial_3:
84 return(access_partial_4);
87 return(access_other_4);
92 _DtCm_tableres3_to_tableres4(Table_Res_3 *r3)
96 if (r3==NULL) return((Table_Res_4 *)NULL);
97 r4 = (Table_Res_4 *)calloc(1, sizeof(Table_Res_4));
98 r4->status = _DtCm_accstat3_to_accstat4(r3->status);
99 tablereslist3_to_tablereslist4(&(r3->res), &(r4->res));
103 extern Access_Args_4 *
104 _DtCm_accargs3_to_accargs4(Access_Args_3 *a3)
108 if (a3==NULL) return((Access_Args_4 *)NULL);
109 a4 = (Access_Args_4 *)calloc(1, sizeof(Access_Args_4));
110 a4->target = buffer3_to_buffer4(a3->target);
111 a4->access_list = acclist3_to_acclist4(a3->access_list);
115 extern Table_Args_4 *
116 _DtCm_tableargs3_to_tableargs4(Table_Args_3 *a3)
120 if (a3==NULL) return((Table_Args_4 *)NULL);
121 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
122 a4->target = buffer3_to_buffer4(a3->target);
123 args3_to_args4(&(a3->args), &(a4->args));
128 extern Table_Args_4 *
129 _DtCm_tabledelargs3_to_tabledelargs4(Table_Args_3 *a3, Options_4 opt)
134 return((Table_Args_4 *)NULL);
136 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
137 a4->target = buffer3_to_buffer4(a3->target);
139 a4->args.tag = UIDOPT_4;
140 a4->args.Args_4_u.uidopt = uid3_to_uidopt(a3->args.Args_3_u.key, opt);
144 extern Registration_Status_4
145 _DtCm_regstat3_to_regstat4(Registration_Status_3 s)
149 return(registered_4);
153 return(deregistered_4);
161 extern Registration_4 *
162 _DtCm_reg3_to_reg4(Registration_3 *r3)
164 Registration_4 *r4, *head, *prev;
168 r4 = (Registration_4 *)calloc(1, sizeof(Registration_4));
169 r4->target = buffer3_to_buffer4(r3->target);
170 r4->prognum = r3->prognum;
171 r4->versnum = r3->versnum;
172 r4->procnum = r3->procnum;
187 extern Table_Status_4
188 _DtCm_tablestat3_to_tablestat4(Table_Status_3 s)
208 assign_period3to4(Period_3 *p3, Period_4 *p4)
210 switch (p3->period) {
212 case single_3: p4->period = single_4;
215 case daily_3: p4->period = daily_4;
218 case weekly_3: p4->period = weekly_4;
221 case biweekly_3: p4->period = biweekly_4;
224 case monthly_3: p4->period = monthly_4;
227 case yearly_3: p4->period = yearly_4;
230 case nthWeekday_3: p4->period = nthWeekday_4;
233 case everyNthDay_3: p4->period = everyNthDay_4;
236 case everyNthWeek_3: p4->period = everyNthWeek_4;
239 case everyNthMonth_3: p4->period = everyNthMonth_4;
242 case otherPeriod_3: p4->period = otherPeriod_4;
248 assign_tag3to4(Tag_3 *t3, Tag_4 *t4)
252 case appointment_3: t4->tag = appointment_4;
255 case reminder_3: t4->tag = reminder_4;
258 case otherTag_3: t4->tag = otherTag_4;
261 case holiday_3: t4->tag = holiday_4;
264 case toDo_3: t4->tag = toDo_4;
270 assign_privacy3to4(Privacy_Level_3 *p3, Privacy_Level_4 *p4)
274 case public_3: *p4 = public_4;
277 case private_3: *p4 = private_4;
280 case semiprivate_3: *p4 = semiprivate_4;
286 assign_status3to4(Appt_Status_3 *s3, Appt_Status_4 *s4)
290 case active_3: *s4 = active_4;
293 case pendingAdd_3: *s4 = pendingAdd_4;
296 case pendingDelete_3: *s4 = pendingDelete_4;
299 case committed_3: *s4 = committed_4;
302 case cancelled_3: *s4 = cancelled_4;
305 case completed_3: *s4 = completed_4;
311 buffer3_to_buffer4(Buffer_3 b)
322 period3_to_period4(Period_3 *p3, Period_4 *p4)
324 if (p3 == NULL || p4==NULL) return;
325 assign_period3to4(p3, p4);
330 tag3_to_tag4(Tag_3 *t3)
332 Tag_4 *t4, *head, *prev;
336 t4 = (Tag_4 *)calloc(1, sizeof(Tag_4));
337 assign_tag3to4(t3, t4);
338 t4->showtime = t3->showtime;
353 attr3_to_attr4(Attribute_3 *a3)
355 Attribute_4 *a4, *head, *prev;
359 a4 = (Attribute_4 *)calloc(1, sizeof(Attribute_4));
361 a4->attr = buffer3_to_buffer4(a3->attr);
362 a4->value = buffer3_to_buffer4(a3->value);
363 a4->clientdata = buffer3_to_buffer4(a3->clientdata);
377 except3_to_except4(Except_3 *e3)
379 Except_4 *e4, *head, *prev;
383 e4 = (Except_4 *)calloc(1, sizeof(Except_4));
384 e4->ordinal = e3->ordinal;
399 id3_to_id4(Id_3 *from, Id_4 *to)
401 if ((from==NULL) || (to==NULL)) return;
402 to->tick = from->tick;
407 uid3_to_uid4(Uid_3 *ui3)
409 Uid_4 *ui4, *head, *prev;
412 while (ui3 != NULL) {
413 ui4 = (Uid_4 *)calloc(1, sizeof(Uid_4));
414 id3_to_id4(&(ui3->appt_id), &(ui4->appt_id));
429 appt3_to_appt4(Appt_3 *a3)
431 Appt_4 *a4, *head, *prev;
435 a4 = (Appt_4 *)calloc(1, sizeof(Appt_4));
436 id3_to_id4(&(a3->appt_id), &(a4->appt_id));
437 a4->tag = tag3_to_tag4(a3->tag);
438 a4->duration = a3->duration;
439 a4->ntimes = a3->ntimes;
440 a4->what = buffer3_to_buffer4(a3->what);
441 period3_to_period4(&(a3->period), &(a4->period));
442 a4->author = buffer3_to_buffer4(a3->author);
443 a4->client_data = buffer3_to_buffer4(a3->client_data);
444 a4->exception = except3_to_except4(a3->exception);
445 a4->attr = attr3_to_attr4(a3->attr);
446 assign_status3to4(&a3->appt_status, &a4->appt_status);
447 assign_privacy3to4(&a3->privacy, &a4->privacy);
462 abb3_to_abb4(Abb_Appt_3 *a3)
464 Abb_Appt_4 *a4, *head, *prev;
468 a4 = (Abb_Appt_4 *)calloc(1, sizeof(Abb_Appt_4));
469 id3_to_id4(&(a3->appt_id), &(a4->appt_id));
470 a4->tag = tag3_to_tag4(a3->tag);
471 a4->what = buffer3_to_buffer4(a3->what);
472 a4->duration = a3->duration;
473 period3_to_period4(&(a3->period), &(a4->period));
474 assign_status3to4(&a3->appt_status, &a4->appt_status);
475 assign_privacy3to4(&a3->privacy, &a4->privacy);
491 apptid3_to_apptid4(Apptid_3 *from, Apptid_4 *to)
493 if (from==NULL || to==NULL) return;
494 id3_to_id4(from->oid, to->oid);
495 to->new_appt = appt3_to_appt4(from->new_appt);
496 /* do_all is the default, the caller needs to
497 * modify it to the appropriate value
499 to->option = do_all_4;
503 reminder3_to_reminder4(Reminder_3 *r3)
505 Reminder_4 *r4, *head, *prev;
510 r4 = (Reminder_4 *)calloc(1, sizeof(Reminder_4));
511 id3_to_id4(&(r3->appt_id), &(r4->appt_id));
513 attr4 = attr3_to_attr4(&(r3->attr));
529 static Table_Res_Type_4
530 tablerestype3_to_tablerestype4(Table_Res_Type_3 t)
547 tablereslist3_to_tablereslist4(Table_Res_List_3 *from, Table_Res_List_4 *to)
549 if (from==NULL || to==NULL) return;
550 to->tag = tablerestype3_to_tablerestype4(from->tag);
553 to->Table_Res_List_4_u.a = appt3_to_appt4(
554 from->Table_Res_List_3_u.a);
557 to->Table_Res_List_4_u.r = reminder3_to_reminder4(
558 from->Table_Res_List_3_u.r);
561 to->Table_Res_List_4_u.b = abb3_to_abb4(
562 from->Table_Res_List_3_u.b);
565 to->Table_Res_List_4_u.i = uid3_to_uid4(
566 from->Table_Res_List_3_u.i);
573 static Access_Entry_4 *
574 acclist3_to_acclist4(Access_Entry_3 *l3)
576 Access_Entry_4 *l4, *head, *prev;
580 l4 = (Access_Entry_4 *)calloc(1, sizeof(Access_Entry_4));
581 l4->who = buffer3_to_buffer4(l3->who);
582 l4->access_type = l3->access_type;
597 range3_to_range4(Range_3 *r3)
599 Range_4 *r4, *head, *prev;
603 r4 = (Range_4 *)calloc(1, sizeof(Range_4));
620 keyrange3_to_keyrange4(Keyrange_3 *r3)
622 Keyrange_4 *r4, *head, *prev;
626 r4 = (Keyrange_4 *)calloc(1, sizeof(Keyrange_4));
628 r4->tick1 = r3->tick1;
629 r4->tick2 = r3->tick2;
643 static Table_Args_Type_4
644 argstag3_to_argstag4(Table_Args_Type_3 t)
665 args3_to_args4(Args_3 *from, Args_4 *to)
667 if (from==NULL || to==NULL) return;
668 to->tag = argstag3_to_argstag4(from->tag);
671 to->Args_4_u.tick = from->Args_3_u.tick;
674 to->Args_4_u.apptid.oid = (Id_4 *)calloc(1, sizeof(Id_4));
676 &(from->Args_3_u.apptid),
677 &(to->Args_4_u.apptid));
680 to->Args_4_u.key = uid3_to_uid4(from->Args_3_u.key);
683 to->Args_4_u.appt = appt3_to_appt4(from->Args_3_u.appt);
686 to->Args_4_u.range = range3_to_range4(from->Args_3_u.range);
689 to->Args_4_u.keyrange = keyrange3_to_keyrange4(
690 from->Args_3_u.keyrange);
697 uid3_to_uidopt(Uid_3 *uid3, Options_4 opt)
699 Uidopt_4 *uidopt, *head, *prev;
702 while (uid3 != NULL) {
703 uidopt = (Uidopt_4 *)calloc(1, sizeof(Uidopt_4));
704 id3_to_id4(&(uid3->appt_id), &(uidopt->appt_id));
705 uidopt->option = opt;