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: convert2-4.c /main/1 1996/04/21 19:22:26 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 "convert2-4.h"
39 * forward declaration of static functions
41 static Buffer_4 buffer2_to_buffer4(Buffer_2 b);
42 static void period2_to_period4(Period_2 p2, Period_4 *p4);
43 static void tag2_to_tag4(Tag_2 t2, Tag_4 *t4);
44 static Attribute_4 * attr2_to_attr4(Attribute_2 *a2);
45 static Except_4 * except2_to_except4(Except_2 *e2);
46 static void id2_to_id4(Id_2 *from, Id_4 *to);
47 static Uid_4 * uid2_to_uid4(Uid_2 *ui2);
48 static Appt_4 * appt2_to_appt4(Appt_2 *a2);
49 static Abb_Appt_4 * abb2_to_abb4(Abb_Appt_2 *a2);
50 static void apptid2_to_apptid4(Apptid_2 *from, Apptid_4 *to);
51 static Reminder_4 * reminder2_to_reminder4(Reminder_2 *r2);
52 static Table_Res_Type_4 tablerestype2_to_tablerestype4(Table_Res_Type_2 t);
53 static void tablereslist2_to_tablereslist4(Table_Res_List_2 *from,
54 Table_Res_List_4 *to);
55 static Access_Entry_4 * acclist2_to_acclist4(Access_Entry_2 *l2);
56 static Range_4 * range2_to_range4(Range_2 *r2);
57 static Table_Args_Type_4 argstag2_to_argstag4(Table_Args_Type_2 t);
58 static void args2_to_args4(Args_2 *from, Args_4 *to);
59 static Uidopt_4 * uid2_to_uidopt(Uid_2 *uid2, Options_4 opt);
61 /**************** DATA TYPE (2->4) CONVERSION ROUTINES **************/
63 extern Access_Status_4
64 _DtCm_accstat2_to_accstat4(Access_Status_2 s)
70 return(access_added_4);
71 case access_removed_2:
72 return(access_removed_4);
74 return(access_failed_4);
76 return(access_exists_4);
77 case access_partial_2:
78 return(access_partial_4);
81 return(access_other_4);
86 _DtCm_tableres2_to_tableres4(Table_Res_2 *r2)
90 if (r2==NULL) return((Table_Res_4 *)NULL);
91 r4 = (Table_Res_4 *)calloc(1, sizeof(Table_Res_4));
92 r4->status = _DtCm_accstat2_to_accstat4(r2->status);
93 tablereslist2_to_tablereslist4(&(r2->res), &(r4->res));
97 extern Access_Args_4 *
98 _DtCm_accargs2_to_accargs4(Access_Args_2 *a2)
102 if (a2==NULL) return((Access_Args_4 *)NULL);
103 a4 = (Access_Args_4 *)calloc(1, sizeof(Access_Args_4));
104 a4->target = buffer2_to_buffer4(a2->target);
105 a4->access_list = acclist2_to_acclist4(a2->access_list);
109 extern Table_Args_4 *
110 _DtCm_tableargs2_to_tableargs4(Table_Args_2 *a2)
114 if (a2==NULL) return((Table_Args_4 *)NULL);
115 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
116 a4->target = buffer2_to_buffer4(a2->target);
117 args2_to_args4(&(a2->args), &(a4->args));
122 extern Table_Args_4 *
123 _DtCm_tabledelargs2_to_tabledelargs4(Table_Args_2 *a2, Options_4 opt)
128 return((Table_Args_4 *)NULL);
130 a4 = (Table_Args_4 *)calloc(1, sizeof(Table_Args_4));
131 a4->target = buffer2_to_buffer4(a2->target);
133 a4->args.tag = UIDOPT_4;
134 a4->args.Args_4_u.uidopt = uid2_to_uidopt(a2->args.Args_2_u.key, opt);
138 extern Registration_Status_4
139 _DtCm_regstat2_to_regstat4(Registration_Status_2 s)
143 return(registered_4);
147 return(deregistered_4);
155 extern Registration_4 *
156 _DtCm_reg2_to_reg4(Registration_2 *r2)
158 Registration_4 *r4, *head, *prev;
162 r4 = (Registration_4 *)calloc(1, sizeof(Registration_4));
163 r4->target = buffer2_to_buffer4(r2->target);
164 r4->prognum = r2->prognum;
165 r4->versnum = r2->versnum;
166 r4->procnum = r2->procnum;
181 extern Table_Status_4
182 _DtCm_tablestat2_to_tablestat4(Table_Status_2 s)
202 buffer2_to_buffer4(Buffer_2 b)
213 period2_to_period4(Period_2 p2, Period_4 *p4)
215 if (p4==NULL) return;
218 p4->period = single_4;
222 p4->period = daily_4;
226 p4->period = weekly_4;
230 p4->period = biweekly_4;
234 p4->period = monthly_4;
238 p4->period = yearly_4;
242 p4->period = nthWeekday_4;
246 p4->period = everyNthDay_4;
250 p4->period = everyNthWeek_4;
253 case everyNthMonth_2:
254 p4->period = everyNthMonth_4;
258 p4->period = otherPeriod_4;
262 p4->period = single_4;
269 tag2_to_tag4(Tag_2 t2, Tag_4 *t4)
271 if (t4==NULL) return;
274 t4->tag = appointment_4;
275 t4->showtime = B_TRUE;
279 t4->tag = reminder_4;
280 t4->showtime = B_FALSE;
284 t4->tag = otherTag_4;
285 t4->showtime = B_FALSE;
289 t4->tag = appointment_4;
290 t4->showtime = B_TRUE;
297 attr2_to_attr4(Attribute_2 *a2)
299 Attribute_4 *a4, *head, *prev;
303 a4 = (Attribute_4 *)calloc(1, sizeof(Attribute_4));
305 a4->attr = strdup(a2->attr);
306 a4->value = strdup(a2->value);
307 a4->clientdata = NULL;
321 except2_to_except4(Except_2 *e2)
323 Except_4 *e4, *head, *prev;
327 e4 = (Except_4 *)calloc(1, sizeof(Except_4));
328 e4->ordinal = e2->ordinal;
343 id2_to_id4(Id_2 *from, Id_4 *to)
345 if ((from==NULL) || (to==NULL)) return;
346 to->tick = from->tick;
351 uid2_to_uid4(Uid_2 *ui2)
353 Uid_4 *ui4, *head, *prev;
356 while (ui2 != NULL) {
357 ui4 = (Uid_4 *)calloc(1, sizeof(Uid_4));
358 id2_to_id4(&(ui2->appt_id), &(ui4->appt_id));
373 appt2_to_appt4(Appt_2 *a2)
375 Appt_4 *a4, *head, *prev;
379 a4 = (Appt_4 *)calloc(1, sizeof(Appt_4));
380 a4->tag = (Tag_4 *)calloc(1, sizeof(Tag_4));
381 id2_to_id4(&(a2->appt_id), &(a4->appt_id));
382 tag2_to_tag4(a2->tag, a4->tag);
383 a4->duration = a2->duration;
384 a4->ntimes = a2->ntimes;
385 a4->what = buffer2_to_buffer4(a2->what);
386 period2_to_period4(a2->period, &(a4->period));
387 a4->author = buffer2_to_buffer4(a2->author);
388 a4->client_data = buffer2_to_buffer4(a2->client_data);
389 a4->attr = attr2_to_attr4(a2->attr);
391 /* mailto is being removed from the appt struct proper,
392 and held instead as client data on the "ml" attribute */
393 if (a2->mailto != NULL) {
394 struct Attribute_4 *item = a4->attr;
396 if(strcmp(item->attr, "ml")==0) {
397 item->clientdata=buffer2_to_buffer4(a2->mailto);
404 a4->exception = except2_to_except4(a2->exception);
405 a4->appt_status = active_4;
406 a4->privacy = public_4;
421 abb2_to_abb4(Abb_Appt_2 *a2)
423 Abb_Appt_4 *a4, *head, *prev;
427 a4 = (Abb_Appt_4 *)calloc(1, sizeof(Abb_Appt_4));
428 a4->tag = (Tag_4 *)calloc(1, sizeof(Tag_4));
429 id2_to_id4(&(a2->appt_id), &(a4->appt_id));
430 a4->tag->tag = appointment_4;
431 a4->tag->showtime = B_TRUE;
432 a4->tag->next = NULL;
433 a4->what = buffer2_to_buffer4(a2->what);
434 a4->duration = a2->duration;
435 period2_to_period4(a2->period, &(a4->period));
436 a4->appt_status = active_4;
437 a4->privacy = public_4;
452 apptid2_to_apptid4(Apptid_2 *from, Apptid_4 *to)
454 if (from==NULL || to==NULL) return;
455 id2_to_id4(from->oid, to->oid);
456 to->new_appt = appt2_to_appt4(from->new_appt);
457 /* do_all is the default, the caller needs to
458 * modify it to the appropriate value
460 to->option = do_all_4;
464 reminder2_to_reminder4(Reminder_2 *r2)
466 Reminder_4 *r4, *head, *prev;
471 r4 = (Reminder_4 *)calloc(1, sizeof(Reminder_4));
472 id2_to_id4(&(r2->appt_id), &(r4->appt_id));
474 attr4 = attr2_to_attr4(&(r2->attr));
490 static Table_Res_Type_4
491 tablerestype2_to_tablerestype4(Table_Res_Type_2 t)
508 tablereslist2_to_tablereslist4(Table_Res_List_2 *from, Table_Res_List_4 *to)
510 if (from==NULL || to==NULL) return;
511 to->tag = tablerestype2_to_tablerestype4(from->tag);
514 to->Table_Res_List_4_u.a = appt2_to_appt4(
515 from->Table_Res_List_2_u.a);
518 to->Table_Res_List_4_u.r = reminder2_to_reminder4(
519 from->Table_Res_List_2_u.r);
522 to->Table_Res_List_4_u.b = abb2_to_abb4(
523 from->Table_Res_List_2_u.b);
526 to->Table_Res_List_4_u.i = uid2_to_uid4(
527 from->Table_Res_List_2_u.i);
534 static Access_Entry_4 *
535 acclist2_to_acclist4(Access_Entry_2 *l2)
537 Access_Entry_4 *l4, *head, *prev;
541 l4 = (Access_Entry_4 *)calloc(1, sizeof(Access_Entry_4));
542 l4->who = buffer2_to_buffer4(l2->who);
543 l4->access_type = l2->access_type;
558 range2_to_range4(Range_2 *r2)
560 Range_4 *r4, *head, *prev;
564 r4 = (Range_4 *)calloc(1, sizeof(Range_4));
580 static Table_Args_Type_4
581 argstag2_to_argstag4(Table_Args_Type_2 t)
600 args2_to_args4(Args_2 *from, Args_4 *to)
602 if (from==NULL || to==NULL) return;
603 to->tag = argstag2_to_argstag4(from->tag);
606 to->Args_4_u.tick = from->Args_2_u.tick;
609 to->Args_4_u.apptid.oid = (Id_4 *)calloc(1, sizeof(Id_4));
611 &(from->Args_2_u.apptid),
612 &(to->Args_4_u.apptid));
615 to->Args_4_u.key = uid2_to_uid4(from->Args_2_u.key);
618 to->Args_4_u.appt = appt2_to_appt4(from->Args_2_u.appt);
621 to->Args_4_u.range = range2_to_range4(from->Args_2_u.range);
629 uid2_to_uidopt(Uid_2 *uid2, Options_4 opt)
631 Uidopt_4 *uidopt, *head, *prev;
634 while (uid2 != NULL) {
635 uidopt = (Uidopt_4 *)calloc(1, sizeof(Uidopt_4));
636 id2_to_id4(&(uid2->appt_id), &(uidopt->appt_id));
637 uidopt->option = opt;