libDtHelp: Cov 88209
[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 libraries 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(XDR *xdrs, cmcb_cal_attr_data *objp)
46 {
47         if (!xdr_array(xdrs, (char **)&objp->names, (u_int *) &objp->num_names,
48             ~0, sizeof (cms_name), (xdrproc_t) xdr_cms_name))
49                 return (FALSE);
50         return (TRUE);
51 }
52
53 /*
54  * add_entry_data - contain information of the deleted entry
55  */
56
57 bool_t
58 xdr_cmcb_add_entry_data(XDR *xdrs, cmcb_add_entry_data *objp)
59 {
60         if (!xdr_string(xdrs, &objp->id, ~0))
61                 return (FALSE);
62         return (TRUE);
63 }
64
65 /*
66  * delete_entry_data - contain information of the deleted entry
67  */
68
69 bool_t
70 xdr_cmcb_delete_entry_data(XDR *xdrs, cmcb_delete_entry_data *objp)
71 {
72         if (!xdr_string(xdrs, &objp->id, ~0))
73                 return (FALSE);
74         if (!xdr_int(xdrs, &objp->scope))
75                 return (FALSE);
76         if (!xdr_long(xdrs, &objp->time))
77                 return (FALSE);
78         return (TRUE);
79 }
80
81 /*
82  * update_entry_data - contain information of the updated entry
83  * if new entry id is not resulted from the update, oldid will be
84  * set to a NULL string ("").
85  */
86
87 bool_t
88 xdr_cmcb_update_entry_data(XDR *xdrs, cmcb_update_entry_data *objp)
89 {
90         if (!xdr_string(xdrs, &objp->newid, ~0))
91                 return (FALSE);
92         if (!xdr_string(xdrs, &objp->oldid, ~0))
93                 return (FALSE);
94         if (!xdr_int(xdrs, &objp->scope))
95                 return (FALSE);
96         if (!xdr_long(xdrs, &objp->time))
97                 return (FALSE);
98         return (TRUE);
99 }
100
101 bool_t
102 xdr_cmcb_update_data(XDR *xdrs, cmcb_update_data *objp)
103 {
104         if (!xdr_int(xdrs, &objp->reason))
105                 return (FALSE);
106
107         switch (objp->reason) {
108         case CSA_CB_CALENDAR_ATTRIBUTE_UPDATED:
109                 if (!xdr_pointer(xdrs, (char **)&objp->data.cdata,
110                     sizeof (cmcb_cal_attr_data),
111                     (xdrproc_t) xdr_cmcb_cal_attr_data))
112                         return (FALSE);
113                 break;
114         case CSA_CB_ENTRY_ADDED:
115                 if (!xdr_pointer(xdrs, (char **)&objp->data.adata,
116                     sizeof (cmcb_add_entry_data),
117                     (xdrproc_t) xdr_cmcb_add_entry_data))
118                         return (FALSE);
119                 break;
120         case CSA_CB_ENTRY_DELETED:
121                 if (!xdr_pointer(xdrs, (char **)&objp->data.ddata,
122                     sizeof (cmcb_delete_entry_data),
123                     (xdrproc_t) xdr_cmcb_delete_entry_data))
124                         return (FALSE);
125                 break;
126         case CSA_CB_ENTRY_UPDATED:
127                 if (!xdr_pointer(xdrs, (char **)&objp->data.udata,
128                     sizeof (cmcb_update_entry_data),
129                     (xdrproc_t) xdr_cmcb_update_entry_data))
130                         return (FALSE);
131                 break;
132         }
133         return (TRUE);
134 }
135
136 bool_t
137 xdr_cmcb_update_callback_args(XDR *xdrs, cmcb_update_callback_args *objp)
138 {
139         if (!xdr_string(xdrs, &objp->calendar, ~0))
140                 return (FALSE);
141         if (!xdr_string(xdrs, &objp->user, ~0))
142                 return (FALSE);
143         if (!xdr_cmcb_update_data(xdrs, &objp->data))
144                 return (FALSE);
145         return (TRUE);
146 }