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-2.c /main/1 1996/04/21 19:22:37 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-2.h"
40 * forward declaration of static functions
42 static void free_excpt2(Except_2 *e);
43 static Buffer_2 buffer4_to_buffer2(Buffer_4 b);
44 static Period_2 period4_to_period2(Period_4 *p);
45 static Tag_2 tag4_to_tag2(Tag_4 *t);
46 static Attribute_2 * attr4_to_attr2(Attribute_4 *a4);
47 static Except_2 * except4_to_except2(Except_4 *e4);
48 static Abb_Appt_2 * abb4_to_abb2(Abb_Appt_4 *a4);
49 static Reminder_2 * reminder4_to_reminder2(Reminder_4 *r4);
50 static Table_Res_Type_2 tablerestype4_to_tablerestype2(Table_Res_Type_4 t);
51 static void tablereslist4_to_tablereslist2(Table_Res_List_4 *from,
52 Table_Res_List_2 *to);
53 static Table_Args_Type_2 argstag4_to_argstag2(Table_Args_Type_4 t);
54 static void args4_to_args2(Args_4 *from, Args_2 *to);
55 static Table_Args_2 * tableargs4_to_tableargs2(Table_Args_4 *a4);
56 static Registration_2 * reg4_to_reg2(Registration_4 *r4);
58 /**************** DATA TYPE (4->2) CONVERSION ROUTINES **************/
61 _DtCm_id4_to_id2(Id_4 *from, Id_2 *to)
63 if ((from==NULL) || (to==NULL)) return;
64 to->tick = from->tick;
69 _DtCm_uid4_to_uid2(Uid_4 *ui4)
71 Uid_2 *ui2, *head, *prev;
75 ui2 = (Uid_2 *)calloc(1, sizeof(Uid_2));
76 _DtCm_id4_to_id2(&(ui4->appt_id), &(ui2->appt_id));
91 _DtCm_appt4_to_appt2(Appt_4 *a4)
93 Appt_2 *a2, *head, *prev;
94 struct Attribute_4 *item;
98 a2 = (Appt_2 *)calloc(1, sizeof(Appt_2));
99 _DtCm_id4_to_id2(&(a4->appt_id), &(a2->appt_id));
100 a2->tag = tag4_to_tag2(a4->tag);
101 a2->duration = a4->duration;
102 a2->ntimes = a4->ntimes;
103 a2->what = buffer4_to_buffer2(a4->what);
105 a2->period = period4_to_period2(&(a4->period));
106 a2->author = buffer4_to_buffer2(a4->author);
107 a2->client_data = buffer4_to_buffer2(a4->client_data);
108 a2->attr = attr4_to_attr2(a4->attr);
110 /* Pick the mailto field out of the attribute list
111 client data field; put it back into the appt struct
116 if (strcmp(item->attr, "ml")==0) {
117 a2->mailto=buffer4_to_buffer2(item->clientdata);
123 a2->exception = except4_to_except2(a4->exception);
137 extern Access_Status_2
138 _DtCm_accstat4_to_accstat2(Access_Status_4 s)
144 return(access_added_2);
145 case access_removed_4:
146 return(access_removed_2);
147 case access_failed_4:
148 return(access_failed_2);
149 case access_exists_4:
150 return(access_exists_2);
151 case access_partial_4:
152 return(access_partial_2);
155 return(access_other_2);
160 _DtCm_tableres4_to_tableres2(Table_Res_4 *r4)
164 if (r4==NULL) return((Table_Res_2 *)NULL);
165 r2 = (Table_Res_2 *)calloc(1, sizeof(Table_Res_2));
166 r2->status = _DtCm_accstat4_to_accstat2(r4->status);
167 tablereslist4_to_tablereslist2(&(r4->res), &(r2->res));
171 extern Access_Entry_2 *
172 _DtCm_acclist4_to_acclist2(Access_Entry_4 *l4)
174 Access_Entry_2 *l2, *head, *prev;
178 l2 = (Access_Entry_2 *)calloc(1, sizeof(Access_Entry_2));
179 l2->who = buffer4_to_buffer2(l4->who);
180 l2->access_type = l4->access_type;
194 extern Access_Args_2 *
195 _DtCm_accargs4_to_accargs2(Access_Args_4 *a4)
199 if (a4==NULL) return((Access_Args_2 *)NULL);
200 a2 = (Access_Args_2 *)calloc(1, sizeof(Access_Args_2));
201 a2->target = buffer4_to_buffer2(a4->target);
202 a2->access_list = _DtCm_acclist4_to_acclist2(a4->access_list);
207 _DtCm_range4_to_range2(Range_4 *r4)
209 Range_2 *r2, *head, *prev;
213 r2 = (Range_2 *)calloc(1, sizeof(Range_2));
229 extern Registration_Status_2
230 _DtCm_regstat4_to_regstat2(Registration_Status_4 s)
234 return(registered_2);
238 return(deregistered_2);
247 extern Table_Status_2
248 _DtCm_tablestat4_to_tablestat2(Table_Status_4 s)
268 _DtCm_uidopt4_to_uid2(Uidopt_4 *uidopt)
270 Uid_2 *uid2, *head, *prev;
273 while (uidopt != NULL) {
274 uid2 = (Uid_2 *)calloc(1, sizeof(Uid_2));
275 _DtCm_id4_to_id2(&(uidopt->appt_id), &(uid2->appt_id));
284 uidopt = uidopt->next;
290 _DtCm_free_attr2(Attribute_2 *a)
298 if (a->value != NULL)
307 _DtCm_free_appt2(Appt_2 *a)
317 if (a->mailto != NULL)
320 if (a->script != NULL)
323 if (a->author != NULL)
326 if (a->client_data != NULL)
327 free(a->client_data);
330 _DtCm_free_attr2(a->attr);
332 if (a->exception != NULL)
333 free_excpt2(a->exception);
342 free_excpt2(Except_2 *e)
354 buffer4_to_buffer2(Buffer_4 b)
365 * Repeating event types beyond "yearly" are mapped to "single"
366 * because the old front end does not recognize any other types
367 * Worse yet it uses Period_2 to index into an array which
368 * contains strings up to "yearly", any period types beyond that
369 * would index beyond the array and cause the front end to dump core.
372 period4_to_period2(Period_4 *p)
374 if (p==NULL) return(otherPeriod_2);
394 tag4_to_tag2(Tag_4 *t)
396 if (t==NULL) return(otherTag_2);
399 return(appointment_2);
411 attr4_to_attr2(Attribute_4 *a4)
413 Attribute_2 *a2, *head, *prev;
417 a2 = (Attribute_2 *)calloc(1, sizeof(Attribute_2));
419 a2->attr = strdup(a4->attr);
420 a2->value = strdup(a4->value);
434 except4_to_except2(Except_4 *e4)
436 Except_2 *e2, *head, *prev;
440 e2 = (Except_2 *)calloc(1, sizeof(Except_2));
441 e2->ordinal = e4->ordinal;
456 abb4_to_abb2(Abb_Appt_4 *a4)
458 Abb_Appt_2 *a2, *head, *prev;
462 a2 = (Abb_Appt_2 *)calloc(1, sizeof(Abb_Appt_2));
463 _DtCm_id4_to_id2(&(a4->appt_id), &(a2->appt_id));
464 a2->what = buffer4_to_buffer2(a4->what);
465 a2->duration = a4->duration;
466 a2->period = period4_to_period2(&(a4->period));
481 apptid4_to_apptid2(Apptid_4 *from, Apptid_2 *to)
483 if (from==NULL || to==NULL) return;
484 _DtCm_id4_to_id2(from->oid, to->oid);
485 to->new_appt = _DtCm_appt4_to_appt2(from->new_appt);
489 reminder4_to_reminder2(Reminder_4 *r4)
491 Reminder_2 *r2, *head, *prev;
496 r2 = (Reminder_2 *)calloc(1, sizeof(Reminder_2));
497 _DtCm_id4_to_id2(&(r4->appt_id), &(r2->appt_id));
499 attr2 = attr4_to_attr2(&(r4->attr));
515 static Table_Res_Type_2
516 tablerestype4_to_tablerestype2(Table_Res_Type_4 t)
533 tablereslist4_to_tablereslist2(Table_Res_List_4 *from, Table_Res_List_2 *to)
535 if (from==NULL || to==NULL) return;
536 to->tag = tablerestype4_to_tablerestype2(from->tag);
539 to->Table_Res_List_2_u.a = _DtCm_appt4_to_appt2(
540 from->Table_Res_List_4_u.a);
543 to->Table_Res_List_2_u.r = reminder4_to_reminder2(
544 from->Table_Res_List_4_u.r);
547 to->Table_Res_List_2_u.b = abb4_to_abb2(
548 from->Table_Res_List_4_u.b);
551 to->Table_Res_List_2_u.i = _DtCm_uid4_to_uid2(
552 from->Table_Res_List_4_u.i);
558 static Table_Args_Type_2
559 argstag4_to_argstag2(Table_Args_Type_4 t)
578 args4_to_args2(Args_4 *from, Args_2 *to)
580 if (from==NULL || to==NULL) return;
581 to->tag = argstag4_to_argstag2(from->tag);
584 to->Args_2_u.tick = from->Args_4_u.tick;
587 to->Args_2_u.apptid.oid = (Id_2 *)calloc(1, sizeof(Id_2));
589 &(from->Args_4_u.apptid),
590 &(to->Args_2_u.apptid));
593 to->Args_2_u.key = _DtCm_uid4_to_uid2(from->Args_4_u.key);
596 to->Args_2_u.appt = _DtCm_appt4_to_appt2(from->Args_4_u.appt);
599 to->Args_2_u.range = _DtCm_range4_to_range2(from->Args_4_u.range);
606 static Table_Args_2 *
607 tableargs4_to_tableargs2(Table_Args_4 *a4)
611 if (a4==NULL) return((Table_Args_2 *)NULL);
612 a2 = (Table_Args_2 *)calloc(1, sizeof(Table_Args_2));
613 a2->target = buffer4_to_buffer2(a4->target);
614 args4_to_args2(&(a4->args), &(a2->args));
618 static Registration_2 *
619 reg4_to_reg2(Registration_4 *r4)
621 Registration_2 *r2, *head, *prev;
625 r2 = (Registration_2 *)calloc(1, sizeof(Registration_2));
626 r2->target = buffer4_to_buffer2(r4->target);
627 r2->prognum = r4->prognum;
628 r2->versnum = r4->versnum;
629 r2->procnum = r4->procnum;