1 /* $XConsortium: convert3-4.c /main/1 1996/04/21 19:22:31 drk $ */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company
4 * (c) Copyright 1993, 1994 International Business Machines Corp.
5 * (c) Copyright 1993, 1994 Novell, Inc.
6 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
15 #include "convert3-4.h"
18 * forward declaration of static functions
20 static void assign_period3to4(Period_3 *p3, Period_4 *p4);
21 static void assign_tag3to4(Tag_3 *t3, Tag_4 *t4);
22 static void assign_privacy3to4(Privacy_Level_3 *p3, Privacy_Level_4 *p4);
23 static void assign_status3to4(Appt_Status_3 *s3, Appt_Status_4 *s4);
24 static Buffer_4 buffer3_to_buffer4(Buffer_3 b);
25 static void period3_to_period4(Period_3 *p3, Period_4 *p4);
26 static Tag_4 * tag3_to_tag4(Tag_3 *t3);
27 static Attribute_4 * attr3_to_attr4(Attribute_3 *a3);
28 static Except_4 * except3_to_except4(Except_3 *e3);
29 static void id3_to_id4(Id_3 *from, Id_4 *to);
30 static Uid_4 * uid3_to_uid4(Uid_3 *ui3);
31 static Appt_4 * appt3_to_appt4(Appt_3 *a3);
32 static Abb_Appt_4 * abb3_to_abb4(Abb_Appt_3 *a3);
33 static void apptid3_to_apptid4(Apptid_3 *from, Apptid_4 *to);
34 static Reminder_4 * reminder3_to_reminder4(Reminder_3 *r3);
35 static Table_Res_Type_4 tablerestype3_to_tablerestype4(Table_Res_Type_3 t);
36 static void tablereslist3_to_tablereslist4(Table_Res_List_3 *from,
37 Table_Res_List_4 *to);
38 static Access_Entry_4 * acclist3_to_acclist4(Access_Entry_3 *l3);
39 static Range_4 * range3_to_range4(Range_3 *r3);
40 static Keyrange_4 * keyrange3_to_keyrange4(Keyrange_3 *r3);
41 static Table_Args_Type_4 argstag3_to_argstag4(Table_Args_Type_3 t);
42 static void args3_to_args4(Args_3 *from, Args_4 *to);
43 static Uidopt_4 * uid3_to_uidopt(Uid_3 *uid3, Options_4 opt);
45 /**************** DATA TYPE (3->4) CONVERSION ROUTINES **************/
47 extern Access_Status_4
48 _DtCm_accstat3_to_accstat4(Access_Status_3 s)
54 return(access_added_4);
55 case access_removed_3:
56 return(access_removed_4);
58 return(access_failed_4);
60 return(access_exists_4);
61 case access_partial_3:
62 return(access_partial_4);
65 return(access_other_4);
70 _DtCm_tableres3_to_tableres4(Table_Res_3 *r3)
74 if (r3==NULL) return((Table_Res_4 *)NULL);
75 r4 = (Table_Res_4 *)calloc(1, sizeof(Table_Res_4));
76 r4->status = _DtCm_accstat3_to_accstat4(r3->status);
77 tablereslist3_to_tablereslist4(&(r3->res), &(r4->res));
81 extern Access_Args_4 *
82 _DtCm_accargs3_to_accargs4(Access_Args_3 *a3)
86 if (a3==NULL) return((Access_Args_4 *)NULL);
87 a4 = (Access_Args_4 *)calloc(1, sizeof(Access_Args_4));
88 a4->target = buffer3_to_buffer4(a3->target);
89 a4->access_list = acclist3_to_acclist4(a3->access_list);
94 _DtCm_tableargs3_to_tableargs4(Table_Args_3 *a3)
98 if (a3==NULL) return((Table_Args_4 *)NULL);
99 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
100 a4->target = buffer3_to_buffer4(a3->target);
101 args3_to_args4(&(a3->args), &(a4->args));
106 extern Table_Args_4 *
107 _DtCm_tabledelargs3_to_tabledelargs4(Table_Args_3 *a3, Options_4 opt)
112 return((Table_Args_4 *)NULL);
114 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
115 a4->target = buffer3_to_buffer4(a3->target);
117 a4->args.tag = UIDOPT_4;
118 a4->args.Args_4_u.uidopt = uid3_to_uidopt(a3->args.Args_3_u.key, opt);
122 extern Registration_Status_4
123 _DtCm_regstat3_to_regstat4(Registration_Status_3 s)
127 return(registered_4);
131 return(deregistered_4);
139 extern Registration_4 *
140 _DtCm_reg3_to_reg4(Registration_3 *r3)
142 Registration_4 *r4, *head, *prev;
146 r4 = (Registration_4 *)calloc(1, sizeof(Registration_4));
147 r4->target = buffer3_to_buffer4(r3->target);
148 r4->prognum = r3->prognum;
149 r4->versnum = r3->versnum;
150 r4->procnum = r3->procnum;
165 extern Table_Status_4
166 _DtCm_tablestat3_to_tablestat4(Table_Status_3 s)
186 assign_period3to4(Period_3 *p3, Period_4 *p4)
188 switch (p3->period) {
190 case single_3: p4->period = single_4;
193 case daily_3: p4->period = daily_4;
196 case weekly_3: p4->period = weekly_4;
199 case biweekly_3: p4->period = biweekly_4;
202 case monthly_3: p4->period = monthly_4;
205 case yearly_3: p4->period = yearly_4;
208 case nthWeekday_3: p4->period = nthWeekday_4;
211 case everyNthDay_3: p4->period = everyNthDay_4;
214 case everyNthWeek_3: p4->period = everyNthWeek_4;
217 case everyNthMonth_3: p4->period = everyNthMonth_4;
220 case otherPeriod_3: p4->period = otherPeriod_4;
226 assign_tag3to4(Tag_3 *t3, Tag_4 *t4)
230 case appointment_3: t4->tag = appointment_4;
233 case reminder_3: t4->tag = reminder_4;
236 case otherTag_3: t4->tag = otherTag_4;
239 case holiday_3: t4->tag = holiday_4;
242 case toDo_3: t4->tag = toDo_4;
248 assign_privacy3to4(Privacy_Level_3 *p3, Privacy_Level_4 *p4)
252 case public_3: *p4 = public_4;
255 case private_3: *p4 = private_4;
258 case semiprivate_3: *p4 = semiprivate_4;
264 assign_status3to4(Appt_Status_3 *s3, Appt_Status_4 *s4)
268 case active_3: *s4 = active_4;
271 case pendingAdd_3: *s4 = pendingAdd_4;
274 case pendingDelete_3: *s4 = pendingDelete_4;
277 case committed_3: *s4 = committed_4;
280 case cancelled_3: *s4 = cancelled_4;
283 case completed_3: *s4 = completed_4;
289 buffer3_to_buffer4(Buffer_3 b)
300 period3_to_period4(Period_3 *p3, Period_4 *p4)
302 if (p3 == NULL || p4==NULL) return;
303 assign_period3to4(p3, p4);
308 tag3_to_tag4(Tag_3 *t3)
310 Tag_4 *t4, *head, *prev;
314 t4 = (Tag_4 *)calloc(1, sizeof(Tag_4));
315 assign_tag3to4(t3, t4);
316 t4->showtime = t3->showtime;
331 attr3_to_attr4(Attribute_3 *a3)
333 Attribute_4 *a4, *head, *prev;
337 a4 = (Attribute_4 *)calloc(1, sizeof(Attribute_4));
339 a4->attr = buffer3_to_buffer4(a3->attr);
340 a4->value = buffer3_to_buffer4(a3->value);
341 a4->clientdata = buffer3_to_buffer4(a3->clientdata);
355 except3_to_except4(Except_3 *e3)
357 Except_4 *e4, *head, *prev;
361 e4 = (Except_4 *)calloc(1, sizeof(Except_4));
362 e4->ordinal = e3->ordinal;
377 id3_to_id4(Id_3 *from, Id_4 *to)
379 if ((from==NULL) || (to==NULL)) return;
380 to->tick = from->tick;
385 uid3_to_uid4(Uid_3 *ui3)
387 Uid_4 *ui4, *head, *prev;
390 while (ui3 != NULL) {
391 ui4 = (Uid_4 *)calloc(1, sizeof(Uid_4));
392 id3_to_id4(&(ui3->appt_id), &(ui4->appt_id));
407 appt3_to_appt4(Appt_3 *a3)
409 Appt_4 *a4, *head, *prev;
413 a4 = (Appt_4 *)calloc(1, sizeof(Appt_4));
414 id3_to_id4(&(a3->appt_id), &(a4->appt_id));
415 a4->tag = tag3_to_tag4(a3->tag);
416 a4->duration = a3->duration;
417 a4->ntimes = a3->ntimes;
418 a4->what = buffer3_to_buffer4(a3->what);
419 period3_to_period4(&(a3->period), &(a4->period));
420 a4->author = buffer3_to_buffer4(a3->author);
421 a4->client_data = buffer3_to_buffer4(a3->client_data);
422 a4->exception = except3_to_except4(a3->exception);
423 a4->attr = attr3_to_attr4(a3->attr);
424 assign_status3to4(&a3->appt_status, &a4->appt_status);
425 assign_privacy3to4(&a3->privacy, &a4->privacy);
440 abb3_to_abb4(Abb_Appt_3 *a3)
442 Abb_Appt_4 *a4, *head, *prev;
446 a4 = (Abb_Appt_4 *)calloc(1, sizeof(Abb_Appt_4));
447 id3_to_id4(&(a3->appt_id), &(a4->appt_id));
448 a4->tag = tag3_to_tag4(a3->tag);
449 a4->what = buffer3_to_buffer4(a3->what);
450 a4->duration = a3->duration;
451 period3_to_period4(&(a3->period), &(a4->period));
452 assign_status3to4(&a3->appt_status, &a4->appt_status);
453 assign_privacy3to4(&a3->privacy, &a4->privacy);
469 apptid3_to_apptid4(Apptid_3 *from, Apptid_4 *to)
471 if (from==NULL || to==NULL) return;
472 id3_to_id4(from->oid, to->oid);
473 to->new_appt = appt3_to_appt4(from->new_appt);
474 /* do_all is the default, the caller needs to
475 * modify it to the appropriate value
477 to->option = do_all_4;
481 reminder3_to_reminder4(Reminder_3 *r3)
483 Reminder_4 *r4, *head, *prev;
488 r4 = (Reminder_4 *)calloc(1, sizeof(Reminder_4));
489 id3_to_id4(&(r3->appt_id), &(r4->appt_id));
491 attr4 = attr3_to_attr4(&(r3->attr));
507 static Table_Res_Type_4
508 tablerestype3_to_tablerestype4(Table_Res_Type_3 t)
525 tablereslist3_to_tablereslist4(Table_Res_List_3 *from, Table_Res_List_4 *to)
527 if (from==NULL || to==NULL) return;
528 to->tag = tablerestype3_to_tablerestype4(from->tag);
531 to->Table_Res_List_4_u.a = appt3_to_appt4(
532 from->Table_Res_List_3_u.a);
535 to->Table_Res_List_4_u.r = reminder3_to_reminder4(
536 from->Table_Res_List_3_u.r);
539 to->Table_Res_List_4_u.b = abb3_to_abb4(
540 from->Table_Res_List_3_u.b);
543 to->Table_Res_List_4_u.i = uid3_to_uid4(
544 from->Table_Res_List_3_u.i);
551 static Access_Entry_4 *
552 acclist3_to_acclist4(Access_Entry_3 *l3)
554 Access_Entry_4 *l4, *head, *prev;
558 l4 = (Access_Entry_4 *)calloc(1, sizeof(Access_Entry_4));
559 l4->who = buffer3_to_buffer4(l3->who);
560 l4->access_type = l3->access_type;
575 range3_to_range4(Range_3 *r3)
577 Range_4 *r4, *head, *prev;
581 r4 = (Range_4 *)calloc(1, sizeof(Range_4));
598 keyrange3_to_keyrange4(Keyrange_3 *r3)
600 Keyrange_4 *r4, *head, *prev;
604 r4 = (Keyrange_4 *)calloc(1, sizeof(Keyrange_4));
606 r4->tick1 = r3->tick1;
607 r4->tick2 = r3->tick2;
621 static Table_Args_Type_4
622 argstag3_to_argstag4(Table_Args_Type_3 t)
643 args3_to_args4(Args_3 *from, Args_4 *to)
645 if (from==NULL || to==NULL) return;
646 to->tag = argstag3_to_argstag4(from->tag);
649 to->Args_4_u.tick = from->Args_3_u.tick;
652 to->Args_4_u.apptid.oid = (Id_4 *)calloc(1, sizeof(Id_4));
654 &(from->Args_3_u.apptid),
655 &(to->Args_4_u.apptid));
658 to->Args_4_u.key = uid3_to_uid4(from->Args_3_u.key);
661 to->Args_4_u.appt = appt3_to_appt4(from->Args_3_u.appt);
664 to->Args_4_u.range = range3_to_range4(from->Args_3_u.range);
667 to->Args_4_u.keyrange = keyrange3_to_keyrange4(
668 from->Args_3_u.keyrange);
675 uid3_to_uidopt(Uid_3 *uid3, Options_4 opt)
677 Uidopt_4 *uidopt, *head, *prev;
680 while (uid3 != NULL) {
681 uidopt = (Uidopt_4 *)calloc(1, sizeof(Uidopt_4));
682 id3_to_id4(&(uid3->appt_id), &(uidopt->appt_id));
683 uidopt->option = opt;