Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / csa / cmcbxdr.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 /* $XConsortium: cmcbxdr.c /main/1 1996/04/21 19:22:05 drk $ */
24 /*
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.
29  */
30
31 /*
32  * xdr routines for v2 callback protocol data structures
33  */
34
35 #include <EUSCompat.h>
36 #include "cmcb.h"
37 #include "csa.h"
38
39
40 /*
41  * cal_attr_data - contain names of calendar attributes updated
42  */
43
44 bool_t
45 xdr_cmcb_cal_attr_data(register XDR *xdrs, cmcb_cal_attr_data *objp)
46 {
47
48         register long *buf;
49
50         if (!xdr_array(xdrs, (char **)&objp->names, (u_int *) &objp->num_names,
51             ~0, sizeof (cms_name), (xdrproc_t) xdr_cms_name))
52                 return (FALSE);
53         return (TRUE);
54 }
55
56 /*
57  * add_entry_data - contain information of the deleted entry
58  */
59
60 bool_t
61 xdr_cmcb_add_entry_data(register XDR *xdrs, cmcb_add_entry_data *objp)
62 {
63
64         register long *buf;
65
66         if (!xdr_string(xdrs, &objp->id, ~0))
67                 return (FALSE);
68         return (TRUE);
69 }
70
71 /*
72  * delete_entry_data - contain information of the deleted entry
73  */
74
75 bool_t
76 xdr_cmcb_delete_entry_data(register XDR *xdrs, cmcb_delete_entry_data *objp)
77 {
78
79         register long *buf;
80
81         if (!xdr_string(xdrs, &objp->id, ~0))
82                 return (FALSE);
83         if (!xdr_int(xdrs, &objp->scope))
84                 return (FALSE);
85         if (!xdr_long(xdrs, &objp->time))
86                 return (FALSE);
87         return (TRUE);
88 }
89
90 /*
91  * update_entry_data - contain information of the updated entry
92  * if new entry id is not resulted from the update, oldid will be
93  * set to a NULL string ("").
94  */
95
96 bool_t
97 xdr_cmcb_update_entry_data(register XDR *xdrs, cmcb_update_entry_data *objp)
98 {
99
100         register long *buf;
101
102         if (!xdr_string(xdrs, &objp->newid, ~0))
103                 return (FALSE);
104         if (!xdr_string(xdrs, &objp->oldid, ~0))
105                 return (FALSE);
106         if (!xdr_int(xdrs, &objp->scope))
107                 return (FALSE);
108         if (!xdr_long(xdrs, &objp->time))
109                 return (FALSE);
110         return (TRUE);
111 }
112
113 bool_t
114 xdr_cmcb_update_data(register XDR *xdrs, cmcb_update_data *objp)
115 {
116
117         register long *buf;
118
119         if (!xdr_int(xdrs, &objp->reason))
120                 return (FALSE);
121
122         switch (objp->reason) {
123         case CSA_CB_CALENDAR_ATTRIBUTE_UPDATED:
124                 if (!xdr_pointer(xdrs, (char **)&objp->data.cdata,
125                     sizeof (cmcb_cal_attr_data),
126                     (xdrproc_t) xdr_cmcb_cal_attr_data))
127                         return (FALSE);
128                 break;
129         case CSA_CB_ENTRY_ADDED:
130                 if (!xdr_pointer(xdrs, (char **)&objp->data.adata,
131                     sizeof (cmcb_add_entry_data),
132                     (xdrproc_t) xdr_cmcb_add_entry_data))
133                         return (FALSE);
134                 break;
135         case CSA_CB_ENTRY_DELETED:
136                 if (!xdr_pointer(xdrs, (char **)&objp->data.ddata,
137                     sizeof (cmcb_delete_entry_data),
138                     (xdrproc_t) xdr_cmcb_delete_entry_data))
139                         return (FALSE);
140                 break;
141         case CSA_CB_ENTRY_UPDATED:
142                 if (!xdr_pointer(xdrs, (char **)&objp->data.udata,
143                     sizeof (cmcb_update_entry_data),
144                     (xdrproc_t) xdr_cmcb_update_entry_data))
145                         return (FALSE);
146                 break;
147         }
148         return (TRUE);
149 }
150
151 bool_t
152 xdr_cmcb_update_callback_args(register XDR *xdrs, cmcb_update_callback_args *objp)
153 {
154
155         register long *buf;
156
157         if (!xdr_string(xdrs, &objp->calendar, ~0))
158                 return (FALSE);
159         if (!xdr_string(xdrs, &objp->user, ~0))
160                 return (FALSE);
161         if (!xdr_cmcb_update_data(xdrs, &objp->data))
162                 return (FALSE);
163         return (TRUE);
164 }