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: 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>
37 #include "convert4-3.h"
40 * forward declaration of static functions
42 static void free_excpt3(Except_3 *e);
43 static Abb_Appt_3 * abb4_to_abb3(Abb_Appt_4 *a4);
44 static void apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to);
45 static Reminder_3 * reminder4_to_reminder3(Reminder_4 *r4);
46 static Table_Res_Type_3 tablerestype4_to_tablerestype3(Table_Res_Type_4 t);
47 static void tablereslist4_to_tablereslist3(Table_Res_List_4 *from,
48 Table_Res_List_3 *to);
49 static void period4_to_period3(Period_4 *p4, Period_3 *p3);
50 static void assign_tag4to3(Tag_4 *t4, Tag_3 *t3);
51 static void assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3);
52 static void assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3);
53 static Buffer_3 buffer4_to_buffer3(Buffer_4 b);
54 static Tag_3 * tag4_to_tag3(Tag_4 *t4);
55 static Attribute_3 * attr4_to_attr3(Attribute_4 *a4);
56 static Except_3 * except4_to_except3(Except_4 *e4);
57 static Table_Args_Type_3 argstag4_to_argstag3(Table_Args_Type_4 t);
58 static void args4_to_args3(Args_4 *from, Args_3 *to);
59 static Table_Args_3 * tableargs4_to_tableargs3(Table_Args_4 *a4);
60 static Registration_3 * reg4_to_reg3(Registration_4 *r4);
61 static void free_tag3(Tag_3 *t);
63 /**************** DATA TYPE (4->3) CONVERSION ROUTINES **************/
66 _DtCm_id4_to_id3(Id_4 *from, Id_3 *to)
68 if ((from==NULL) || (to==NULL)) return;
69 to->tick = from->tick;
74 _DtCm_uid4_to_uid3(Uid_4 *ui4)
76 Uid_3 *ui3, *head, *prev;
80 ui3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
81 _DtCm_id4_to_id3(&(ui4->appt_id), &(ui3->appt_id));
96 _DtCm_appt4_to_appt3(Appt_4 *a4)
98 Appt_3 *a3, *head, *prev;
102 a3 = (Appt_3 *)calloc(1, sizeof(Appt_3));
103 _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
104 a3->tag = tag4_to_tag3(a4->tag);
105 a3->duration = a4->duration;
106 a3->ntimes = a4->ntimes;
107 a3->what = buffer4_to_buffer3(a4->what);
108 period4_to_period3(&(a4->period), &(a3->period));
109 a3->author = buffer4_to_buffer3(a4->author);
110 a3->client_data = buffer4_to_buffer3(a4->client_data);
111 a3->exception = except4_to_except3(a4->exception);
112 a3->attr = attr4_to_attr3(a4->attr);
113 assign_status4to3(&a4->appt_status, &a3->appt_status);
114 assign_privacy4to3(&a4->privacy, &a3->privacy);
129 _DtCm_free_appt3(Appt_3 *a)
142 if (a->author != NULL)
145 if (a->client_data != NULL)
146 free(a->client_data);
149 _DtCm_free_attr3(a->attr);
151 if (a->exception != NULL)
152 free_excpt3(a->exception);
161 _DtCm_free_attr3(Attribute_3 *a)
169 if (a->value != NULL)
171 if (a->clientdata != NULL)
180 free_excpt3(Except_3 *e)
192 abb4_to_abb3(Abb_Appt_4 *a4)
194 Abb_Appt_3 *a3, *head, *prev;
198 a3 = (Abb_Appt_3 *)calloc(1, sizeof(Abb_Appt_3));
199 _DtCm_id4_to_id3(&(a4->appt_id), &(a3->appt_id));
200 a3->tag = tag4_to_tag3(a4->tag);
201 a3->what = buffer4_to_buffer3(a4->what);
202 a3->duration = a4->duration;
203 period4_to_period3(&(a4->period), &(a3->period));
204 assign_status4to3(&a4->appt_status, &a3->appt_status);
205 assign_privacy4to3(&a4->privacy, &a3->privacy);
220 apptid4_to_apptid3(Apptid_4 *from, Apptid_3 *to)
222 if (from==NULL || to==NULL) return;
223 _DtCm_id4_to_id3(from->oid, to->oid);
224 to->new_appt = _DtCm_appt4_to_appt3(from->new_appt);
228 reminder4_to_reminder3(Reminder_4 *r4)
230 Reminder_3 *r3, *head, *prev;
235 r3 = (Reminder_3 *)calloc(1, sizeof(Reminder_3));
236 _DtCm_id4_to_id3(&(r4->appt_id), &(r3->appt_id));
238 attr3 = attr4_to_attr3(&(r4->attr));
254 static Table_Res_Type_3
255 tablerestype4_to_tablerestype3(Table_Res_Type_4 t)
272 tablereslist4_to_tablereslist3(Table_Res_List_4 *from, Table_Res_List_3 *to)
274 if (from==NULL || to==NULL) return;
275 to->tag = tablerestype4_to_tablerestype3(from->tag);
278 to->Table_Res_List_3_u.a = _DtCm_appt4_to_appt3(
279 from->Table_Res_List_4_u.a);
282 to->Table_Res_List_3_u.r = reminder4_to_reminder3(
283 from->Table_Res_List_4_u.r);
286 to->Table_Res_List_3_u.b = abb4_to_abb3(
287 from->Table_Res_List_4_u.b);
290 to->Table_Res_List_3_u.i = _DtCm_uid4_to_uid3(
291 from->Table_Res_List_4_u.i);
297 extern Access_Status_3
298 _DtCm_accstat4_to_accstat3(Access_Status_4 s)
304 return(access_added_3);
305 case access_removed_4:
306 return(access_removed_3);
307 case access_failed_4:
308 return(access_failed_3);
309 case access_exists_4:
310 return(access_exists_3);
311 case access_partial_4:
312 return(access_partial_3);
315 return(access_other_3);
320 _DtCm_tableres4_to_tableres3(Table_Res_4 *r4)
324 if (r4==NULL) return((Table_Res_3 *)NULL);
325 r3 = (Table_Res_3 *)calloc(1, sizeof(Table_Res_3));
326 r3->status = _DtCm_accstat4_to_accstat3(r4->status);
327 tablereslist4_to_tablereslist3(&(r4->res), &(r3->res));
331 extern Access_Entry_3 *
332 _DtCm_acclist4_to_acclist3(Access_Entry_4 *l4)
334 Access_Entry_3 *l3, *head, *prev;
338 l3 = (Access_Entry_3 *)calloc(1, sizeof(Access_Entry_3));
339 l3->who = buffer4_to_buffer3(l4->who);
340 l3->access_type = l4->access_type;
354 extern Access_Args_3 *
355 _DtCm_accargs4_to_accargs3(Access_Args_4 *a4)
359 if (a4==NULL) return((Access_Args_3 *)NULL);
360 a3 = (Access_Args_3 *)calloc(1, sizeof(Access_Args_3));
361 a3->target = buffer4_to_buffer3(a4->target);
362 a3->access_list = _DtCm_acclist4_to_acclist3(a4->access_list);
367 _DtCm_range4_to_range3(Range_4 *r4)
369 Range_3 *r3, *head, *prev;
373 r3 = (Range_3 *)calloc(1, sizeof(Range_3));
390 _DtCm_keyrange4_to_keyrange3(Keyrange_4 *r4)
392 Keyrange_3 *r3, *head, *prev;
396 r3 = (Keyrange_3 *)calloc(1, sizeof(Keyrange_3));
398 r3->tick1 = r4->tick1;
399 r3->tick2 = r4->tick2;
413 extern Registration_Status_3
414 _DtCm_regstat4_to_regstat3(Registration_Status_4 s)
418 return(registered_3);
422 return(deregistered_3);
431 extern Table_Status_3
432 _DtCm_tablestat4_to_tablestat3(Table_Status_4 s)
452 _DtCm_uidopt4_to_uid3(Uidopt_4 *uidopt)
454 Uid_3 *uid3, *head, *prev;
457 while (uidopt != NULL) {
458 uid3 = (Uid_3 *)calloc(1, sizeof(Uid_3));
459 _DtCm_id4_to_id3(&(uidopt->appt_id), &(uid3->appt_id));
468 uidopt = uidopt->next;
474 * Repeating event types beyond "yearly" are mapped to "single"
475 * because the old front end does not recognize any other types
476 * Worse yet it uses Interval to index into an array which
477 * contains strings up to "yearly", any period types beyond that
478 * would index beyond the array and cause the front end to dump core.
481 period4_to_period3(Period_4 *p4, Period_3 *p3)
483 if (p3 == NULL || p4 == NULL) return;
485 switch (p4->period) {
487 case single_4: p3->period = single_3;
491 case daily_4: p3->period = daily_3;
495 case weekly_4: p3->period = weekly_3;
499 case biweekly_4: p3->period = biweekly_3;
503 case monthly_4: p3->period = monthly_3;
507 case yearly_4: p3->period = yearly_3;
511 default: p3->period = single_3;
519 assign_tag4to3(Tag_4 *t4, Tag_3 *t3)
523 case appointment_4: t3->tag = appointment_3;
526 case reminder_4: t3->tag = reminder_3;
529 case otherTag_4: t3->tag = otherTag_3;
532 case holiday_4: t3->tag = holiday_3;
535 case toDo_4: t3->tag = toDo_3;
542 assign_status4to3(Appt_Status_4 *s4, Appt_Status_3 *s3)
546 case active_4: *s3 = active_3;
549 case pendingAdd_4: *s3 = pendingAdd_3;
552 case pendingDelete_4: *s3 = pendingDelete_3;
555 case committed_4: *s3 = committed_3;
558 case cancelled_4: *s3 = cancelled_3;
561 case completed_4: *s3 = completed_3;
568 assign_privacy4to3(Privacy_Level_4 *p4, Privacy_Level_3 *p3)
572 case public_4: *p3 = public_3;
575 case private_4: *p3 = private_3;
578 case semiprivate_4: *p3 = semiprivate_3;
587 buffer4_to_buffer3(Buffer_4 b)
598 tag4_to_tag3(Tag_4 *t4)
600 Tag_3 *t3, *head, *prev;
604 t3 = (Tag_3 *)calloc(1, sizeof(Tag_3));
605 assign_tag4to3(t4, t3);
606 t3->showtime = t4->showtime;
621 attr4_to_attr3(Attribute_4 *a4)
623 Attribute_3 *a3, *head, *prev;
627 a3 = (Attribute_3 *)calloc(1, sizeof(Attribute_3));
629 a3->attr = buffer4_to_buffer3(a4->attr);
630 a3->value = buffer4_to_buffer3(a4->value);
631 a3->clientdata = buffer4_to_buffer3(a4->clientdata);
645 except4_to_except3(Except_4 *e4)
647 Except_3 *e3, *head, *prev;
651 e3 = (Except_3 *)calloc(1, sizeof(Except_3));
652 e3->ordinal = e4->ordinal;
666 static Table_Args_Type_3
667 argstag4_to_argstag3(Table_Args_Type_4 t)
688 args4_to_args3(Args_4 *from, Args_3 *to)
690 if (from==NULL || to==NULL) return;
691 to->tag = argstag4_to_argstag3(from->tag);
694 to->Args_3_u.tick = from->Args_4_u.tick;
697 to->Args_3_u.apptid.oid = (Id_3 *)calloc(1, sizeof(Id_3));
699 &(from->Args_4_u.apptid),
700 &(to->Args_3_u.apptid));
703 to->Args_3_u.key = _DtCm_uid4_to_uid3(from->Args_4_u.key);
706 to->Args_3_u.appt = _DtCm_appt4_to_appt3(from->Args_4_u.appt);
709 to->Args_3_u.range = _DtCm_range4_to_range3(from->Args_4_u.range);
712 to->Args_3_u.keyrange = _DtCm_keyrange4_to_keyrange3(
713 from->Args_4_u.keyrange);
719 static Table_Args_3 *
720 tableargs4_to_tableargs3(Table_Args_4 *a4)
724 if (a4==NULL) return((Table_Args_3 *)NULL);
725 a3 = (Table_Args_3 *)calloc(1, sizeof(Table_Args_3));
726 a3->target = buffer4_to_buffer3(a4->target);
727 args4_to_args3(&(a4->args), &(a3->args));
732 static Registration_3 *
733 reg4_to_reg3(Registration_4 *r4)
735 Registration_3 *r3, *head, *prev;
739 r3 = (Registration_3 *)calloc(1, sizeof(Registration_3));
740 r3->target = buffer4_to_buffer3(r4->target);
741 r3->prognum = r4->prognum;
742 r3->versnum = r4->versnum;
743 r3->procnum = r4->procnum;