1/*
2 * Copyright (c) 1997-2006 Erez Zadok
3 * Copyright (c) 1990 Jan-Simon Pendry
4 * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 *    must display the following acknowledgment:
21 *      This product includes software developed by the University of
22 *      California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 *    may be used to endorse or promote products derived from this software
25 *    without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 *
40 * File: am-utils/amq/amq_xdr.c
41 *
42 */
43
44#ifdef HAVE_CONFIG_H
45# include <config.h>
46#endif /* HAVE_CONFIG_H */
47#include <am_defs.h>
48#include <amq.h>
49
50
51bool_t
52xdr_time_type(XDR *xdrs, time_type *objp)
53{
54  if (!xdr_long(xdrs, (long *) objp)) {
55    return (FALSE);
56  }
57  return (TRUE);
58}
59
60
61bool_t
62xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
63{
64
65  if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) {
66    return (FALSE);
67  }
68
69  if (!xdr_amq_string(xdrs, &objp->mt_directory)) {
70    return (FALSE);
71  }
72
73  if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) {
74    return (FALSE);
75  }
76
77  if (!xdr_amq_string(xdrs, &objp->mt_type)) {
78    return (FALSE);
79  }
80
81  if (!xdr_time_type(xdrs, &objp->mt_mounttime)) {
82    return (FALSE);
83  }
84
85  if (!xdr_u_short(xdrs, &objp->mt_mountuid)) {
86    return (FALSE);
87  }
88
89  if (!xdr_int(xdrs, &objp->mt_getattr)) {
90    return (FALSE);
91  }
92
93  if (!xdr_int(xdrs, &objp->mt_lookup)) {
94    return (FALSE);
95  }
96
97  if (!xdr_int(xdrs, &objp->mt_readdir)) {
98    return (FALSE);
99  }
100
101  if (!xdr_int(xdrs, &objp->mt_readlink)) {
102    return (FALSE);
103  }
104
105  if (!xdr_int(xdrs, &objp->mt_statfs)) {
106    return (FALSE);
107  }
108
109  if (!xdr_pointer(xdrs,
110		   (char **) ((voidp) &objp->mt_next),
111		   sizeof(amq_mount_tree),
112		   (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
113    return (FALSE);
114  }
115
116  if (!xdr_pointer(xdrs,
117		   (char **) ((voidp) &objp->mt_child),
118		   sizeof(amq_mount_tree),
119		   (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
120    return (FALSE);
121  }
122
123  return (TRUE);
124}
125
126
127bool_t
128xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp)
129{
130  if (!xdr_pointer(xdrs,
131		   (char **) objp,
132		   sizeof(amq_mount_tree),
133		   (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
134    return (FALSE);
135  }
136  return (TRUE);
137}
138
139
140bool_t
141xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp)
142{
143
144  if (!xdr_amq_string(xdrs, &objp->mi_type)) {
145    return (FALSE);
146  }
147
148  if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) {
149    return (FALSE);
150  }
151
152  if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) {
153    return (FALSE);
154  }
155
156  if (!xdr_amq_string(xdrs, &objp->mi_fserver)) {
157    return (FALSE);
158  }
159
160  if (!xdr_int(xdrs, &objp->mi_error)) {
161    return (FALSE);
162  }
163
164  if (!xdr_int(xdrs, &objp->mi_refc)) {
165    return (FALSE);
166  }
167
168  if (!xdr_int(xdrs, &objp->mi_up)) {
169    return (FALSE);
170  }
171
172  return (TRUE);
173}
174
175
176bool_t
177xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp)
178{
179  if (!xdr_array(xdrs,
180		 (char **) ((voidp) &objp->amq_mount_info_list_val),
181		 (u_int *) &objp->amq_mount_info_list_len,
182		 ~0,
183		 sizeof(amq_mount_info),
184		 (XDRPROC_T_TYPE) xdr_amq_mount_info)) {
185    return (FALSE);
186  }
187  return (TRUE);
188}
189
190
191bool_t
192xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp)
193{
194  if (!xdr_array(xdrs,
195		 (char **) ((voidp) &objp->amq_mount_tree_list_val),
196		 (u_int *) &objp->amq_mount_tree_list_len,
197		 ~0,
198		 sizeof(amq_mount_tree_p),
199		 (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) {
200    return (FALSE);
201  }
202  return (TRUE);
203}
204
205
206bool_t
207xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp)
208{
209
210  if (!xdr_int(xdrs, &objp->as_drops)) {
211    return (FALSE);
212  }
213
214  if (!xdr_int(xdrs, &objp->as_stale)) {
215    return (FALSE);
216  }
217
218  if (!xdr_int(xdrs, &objp->as_mok)) {
219    return (FALSE);
220  }
221
222  if (!xdr_int(xdrs, &objp->as_merr)) {
223    return (FALSE);
224  }
225
226  if (!xdr_int(xdrs, &objp->as_uerr)) {
227    return (FALSE);
228  }
229
230  return (TRUE);
231}
232
233
234bool_t
235xdr_amq_opt(XDR *xdrs, amq_opt *objp)
236{
237  if (!xdr_enum(xdrs, (enum_t *) objp)) {
238    return (FALSE);
239  }
240  return (TRUE);
241}
242
243
244bool_t
245xdr_amq_setopt(XDR *xdrs, amq_setopt *objp)
246{
247
248  if (!xdr_amq_opt(xdrs, &objp->as_opt)) {
249    return (FALSE);
250  }
251
252  if (!xdr_amq_string(xdrs, &objp->as_str)) {
253    return (FALSE);
254  }
255
256  return (TRUE);
257}
258
259
260bool_t
261xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr)
262{
263  XDR xdr;
264
265  xdr.x_op = XDR_FREE;
266  return ((*xdr_args) (&xdr, (caddr_t *) args_ptr));
267}
268