Update.
[glibc.git] / nis / nis_xdr.c
blob2a75505b31724679d7925afbab7d3f0f96918359
1 /* Copyright (c) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
23 /* This functions do exist without beginning "_" under Solaris 2.x, but
24 we have no prototypes for them. To avoid the same problems as with the
25 YP xdr functions, we don't make them public. */
26 #include "nis_xdr.h"
28 static bool_t
29 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
31 if (!xdr_string (xdrs, &objp->zattr_ndx, ~0))
32 return FALSE;
33 if (!xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
34 (u_int *) & objp->zattr_val.zattr_val_len, ~0))
35 return FALSE;
36 return TRUE;
39 bool_t
40 _xdr_nis_name (XDR *xdrs, nis_name *objp)
42 if (!xdr_string (xdrs, objp, ~0))
43 return FALSE;
44 return TRUE;
47 static bool_t
48 xdr_zotypes (XDR *xdrs, zotypes *objp)
50 if (!xdr_enum (xdrs, (enum_t *) objp))
51 return FALSE;
52 return TRUE;
55 static bool_t
56 xdr_nstype (XDR *xdrs, nstype *objp)
58 if (!xdr_enum (xdrs, (enum_t *) objp))
59 return FALSE;
60 return TRUE;
63 static bool_t
64 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
66 if (!xdr_u_int (xdrs, &objp->oa_rights))
67 return FALSE;
68 if (!xdr_zotypes (xdrs, &objp->oa_otype))
69 return FALSE;
70 return TRUE;
73 static bool_t
74 xdr_endpoint (XDR *xdrs, endpoint *objp)
76 if (!xdr_string (xdrs, &objp->uaddr, ~0))
77 return FALSE;
78 if (!xdr_string (xdrs, &objp->family, ~0))
79 return FALSE;
80 if (!xdr_string (xdrs, &objp->proto, ~0))
81 return FALSE;
82 return TRUE;
85 bool_t
86 _xdr_nis_server (XDR *xdrs, nis_server *objp)
88 if (!_xdr_nis_name (xdrs, &objp->name))
89 return FALSE;
90 if (!xdr_array (xdrs, (char **) &objp->ep.ep_val, (u_int *) &objp->ep.ep_len,
91 ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint))
92 return FALSE;
93 if (!xdr_u_int (xdrs, &objp->key_type))
94 return FALSE;
95 if (!xdr_netobj (xdrs, &objp->pkey))
96 return FALSE;
97 return TRUE;
100 bool_t
101 _xdr_directory_obj (XDR *xdrs, directory_obj *objp)
103 if (!_xdr_nis_name (xdrs, &objp->do_name))
104 return FALSE;
105 if (!xdr_nstype (xdrs, &objp->do_type))
106 return FALSE;
107 if (!xdr_array (xdrs, (char **) &objp->do_servers.do_servers_val,
108 (u_int *) & objp->do_servers.do_servers_len, ~0,
109 sizeof (nis_server), (xdrproc_t) _xdr_nis_server))
110 return FALSE;
112 if (!xdr_uint32_t (xdrs, &objp->do_ttl))
113 return FALSE;
114 if (!xdr_array (xdrs, (char **) &objp->do_armask.do_armask_val,
115 (u_int *) & objp->do_armask.do_armask_len, ~0,
116 sizeof (oar_mask), (xdrproc_t) xdr_oar_mask))
117 return FALSE;
118 return TRUE;
121 static bool_t
122 xdr_entry_col (XDR *xdrs, entry_col *objp)
124 if (!xdr_u_int (xdrs, &objp->ec_flags))
125 return FALSE;
126 if (!xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
127 (u_int *) &objp->ec_value.ec_value_len, ~0))
128 return FALSE;
129 return TRUE;
132 static bool_t
133 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
135 if (!xdr_string (xdrs, &objp->en_type, ~0))
136 return FALSE;
137 if (!xdr_array (xdrs, (char **) &objp->en_cols.en_cols_val,
138 (u_int *) &objp->en_cols.en_cols_len, ~0,
139 sizeof (entry_col), (xdrproc_t) xdr_entry_col))
140 return FALSE;
141 return TRUE;
144 static bool_t
145 xdr_group_obj (XDR *xdrs, group_obj *objp)
147 if (!xdr_u_int (xdrs, &objp->gr_flags))
148 return FALSE;
149 if (!xdr_array (xdrs, (char **) &objp->gr_members.gr_members_val,
150 (u_int *) &objp->gr_members.gr_members_len, ~0,
151 sizeof (nis_name), (xdrproc_t) _xdr_nis_name))
152 return FALSE;
153 return TRUE;
156 static bool_t
157 xdr_link_obj (XDR *xdrs, link_obj *objp)
159 if (!xdr_zotypes (xdrs, &objp->li_rtype))
160 return FALSE;
161 if (!xdr_array (xdrs, (char **) &objp->li_attrs.li_attrs_val,
162 (u_int *) &objp->li_attrs.li_attrs_len, ~0,
163 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
164 return FALSE;
165 if (!_xdr_nis_name (xdrs, &objp->li_name))
166 return FALSE;
167 return TRUE;
170 static bool_t
171 xdr_table_col (XDR *xdrs, table_col *objp)
173 if (!xdr_string (xdrs, &objp->tc_name, 64))
174 return FALSE;
175 if (!xdr_u_int (xdrs, &objp->tc_flags))
176 return FALSE;
177 if (!xdr_u_int (xdrs, &objp->tc_rights))
178 return FALSE;
179 return TRUE;
182 static bool_t
183 xdr_table_obj (XDR *xdrs, table_obj *objp)
185 if (!xdr_string (xdrs, &objp->ta_type, 64))
186 return FALSE;
187 if (!xdr_int (xdrs, &objp->ta_maxcol))
188 return FALSE;
189 if (!xdr_u_char (xdrs, &objp->ta_sep))
190 return FALSE;
191 if (!xdr_array (xdrs, (char **) &objp->ta_cols.ta_cols_val,
192 (u_int *) &objp->ta_cols.ta_cols_len, ~0,
193 sizeof (table_col), (xdrproc_t) xdr_table_col))
194 return FALSE;
195 if (!xdr_string (xdrs, &objp->ta_path, ~0))
196 return FALSE;
197 return TRUE;
200 static bool_t
201 xdr_objdata (XDR *xdrs, objdata *objp)
203 if (!xdr_zotypes (xdrs, &objp->zo_type))
204 return FALSE;
205 switch (objp->zo_type)
207 case NIS_DIRECTORY_OBJ:
208 if (!_xdr_directory_obj (xdrs, &objp->objdata_u.di_data))
209 return FALSE;
210 break;
211 case NIS_GROUP_OBJ:
212 if (!xdr_group_obj (xdrs, &objp->objdata_u.gr_data))
213 return FALSE;
214 break;
215 case NIS_TABLE_OBJ:
216 if (!xdr_table_obj (xdrs, &objp->objdata_u.ta_data))
217 return FALSE;
218 break;
219 case NIS_ENTRY_OBJ:
220 if (!xdr_entry_obj (xdrs, &objp->objdata_u.en_data))
221 return FALSE;
222 break;
223 case NIS_LINK_OBJ:
224 if (!xdr_link_obj (xdrs, &objp->objdata_u.li_data))
225 return FALSE;
226 break;
227 case NIS_PRIVATE_OBJ:
228 if (!xdr_bytes (xdrs, (char **) &objp->objdata_u.po_data.po_data_val,
229 (u_int *) & objp->objdata_u.po_data.po_data_len, ~0))
230 return FALSE;
231 break;
232 case NIS_NO_OBJ:
233 break;
234 case NIS_BOGUS_OBJ:
235 break;
236 default:
237 break;
239 return TRUE;
242 static bool_t
243 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
245 if (!xdr_uint32_t (xdrs, &objp->ctime))
246 return FALSE;
247 if (!xdr_uint32_t (xdrs, &objp->mtime))
248 return FALSE;
249 return TRUE;
252 bool_t
253 _xdr_nis_object (XDR *xdrs, nis_object *objp)
255 if (!xdr_nis_oid (xdrs, &objp->zo_oid))
256 return FALSE;
257 if (!_xdr_nis_name (xdrs, &objp->zo_name))
258 return FALSE;
259 if (!_xdr_nis_name (xdrs, &objp->zo_owner))
260 return FALSE;
261 if (!_xdr_nis_name (xdrs, &objp->zo_group))
262 return FALSE;
263 if (!_xdr_nis_name (xdrs, &objp->zo_domain))
264 return FALSE;
265 if (!xdr_u_int (xdrs, &objp->zo_access))
266 return FALSE;
267 if (!xdr_uint32_t (xdrs, &objp->zo_ttl))
268 return FALSE;
269 if (!xdr_objdata (xdrs, &objp->zo_data))
270 return FALSE;
271 return TRUE;
274 bool_t
275 _xdr_nis_error (XDR *xdrs, nis_error *objp)
277 if (!xdr_enum (xdrs, (enum_t *) objp))
278 return FALSE;
279 return TRUE;
282 bool_t
283 _xdr_nis_result (XDR *xdrs, nis_result *objp)
285 if (!_xdr_nis_error (xdrs, &objp->status))
286 return FALSE;
287 if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
288 (u_int *) &objp->objects.objects_len, ~0,
289 sizeof (nis_object), (xdrproc_t) _xdr_nis_object))
290 return FALSE;
291 if (!xdr_netobj (xdrs, &objp->cookie))
292 return FALSE;
293 if (!xdr_uint32_t (xdrs, &objp->zticks))
294 return FALSE;
295 if (!xdr_uint32_t (xdrs, &objp->dticks))
296 return FALSE;
297 if (!xdr_uint32_t (xdrs, &objp->aticks))
298 return FALSE;
299 if (!xdr_uint32_t (xdrs, &objp->cticks))
300 return FALSE;
301 return TRUE;
304 bool_t
305 _xdr_ns_request (XDR *xdrs, ns_request *objp)
307 if (!_xdr_nis_name (xdrs, &objp->ns_name))
308 return FALSE;
309 if (!xdr_array (xdrs, (char **) &objp->ns_object.ns_object_val,
310 (u_int *) &objp->ns_object.ns_object_len, 1,
311 sizeof (nis_object), (xdrproc_t) _xdr_nis_object))
312 return FALSE;
313 return TRUE;
316 bool_t
317 _xdr_ib_request (XDR *xdrs, ib_request *objp)
319 if (!_xdr_nis_name (xdrs, &objp->ibr_name))
320 return FALSE;
321 if (!xdr_array (xdrs, (char **) &objp->ibr_srch.ibr_srch_val,
322 (u_int *) &objp->ibr_srch.ibr_srch_len, ~0,
323 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
324 return FALSE;
325 if (!xdr_u_int (xdrs, &objp->ibr_flags))
326 return FALSE;
327 if (!xdr_array (xdrs, (char **) &objp->ibr_obj.ibr_obj_val,
328 (u_int *) &objp->ibr_obj.ibr_obj_len, 1,
329 sizeof (nis_object), (xdrproc_t) _xdr_nis_object))
330 return FALSE;
331 if (!xdr_array (xdrs, (char **) &objp->ibr_cbhost.ibr_cbhost_val,
332 (u_int *) &objp->ibr_cbhost.ibr_cbhost_len, 1,
333 sizeof (nis_server), (xdrproc_t) _xdr_nis_server))
334 return FALSE;
335 if (!xdr_u_int (xdrs, &objp->ibr_bufsize))
336 return FALSE;
337 if (!xdr_netobj (xdrs, &objp->ibr_cookie))
338 return FALSE;
339 return TRUE;
342 bool_t
343 _xdr_ping_args (XDR *xdrs, ping_args *objp)
345 if (!_xdr_nis_name (xdrs, &objp->dir))
346 return FALSE;
347 if (!xdr_uint32_t (xdrs, &objp->stamp))
348 return FALSE;
349 return TRUE;
352 bool_t
353 _xdr_cp_result (XDR *xdrs, cp_result *objp)
355 if (!_xdr_nis_error (xdrs, &objp->cp_status))
356 return FALSE;
357 if (!xdr_uint32_t (xdrs, &objp->cp_zticks))
358 return FALSE;
359 if (!xdr_uint32_t (xdrs, &objp->cp_dticks))
360 return FALSE;
361 return TRUE;
364 bool_t
365 _xdr_nis_tag (XDR *xdrs, nis_tag *objp)
367 if (!xdr_u_int (xdrs, &objp->tag_type))
368 return FALSE;
369 if (!xdr_string (xdrs, &objp->tag_val, ~0))
370 return FALSE;
371 return TRUE;
374 bool_t
375 _xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
377 if (!xdr_array (xdrs, (char **) &objp->tags.tags_val,
378 (u_int *) &objp->tags.tags_len, ~0, sizeof (nis_tag),
379 (xdrproc_t) _xdr_nis_tag))
380 return FALSE;
381 return TRUE;
384 bool_t
385 _xdr_fd_args (XDR *xdrs, fd_args *objp)
387 if (!_xdr_nis_name (xdrs, &objp->dir_name))
388 return FALSE;
389 if (!_xdr_nis_name (xdrs, &objp->requester))
390 return FALSE;
391 return TRUE;
394 bool_t
395 _xdr_fd_result (XDR *xdrs, fd_result *objp)
397 if (!_xdr_nis_error (xdrs, &objp->status))
398 return FALSE;
399 if (!_xdr_nis_name (xdrs, &objp->source))
400 return FALSE;
401 if (!xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
402 (u_int *) &objp->dir_data.dir_data_len, ~0))
403 return FALSE;
404 if (!xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
405 (u_int *) &objp->signature.signature_len, ~0))
406 return FALSE;
407 return TRUE;
410 /* The following functions have prototypes in nis_callback.h. So
411 we make them public */
412 bool_t
413 xdr_obj_p (XDR *xdrs, obj_p *objp)
415 if (!xdr_pointer (xdrs, (char **)objp, sizeof (nis_object),
416 (xdrproc_t)_xdr_nis_object))
417 return FALSE;
418 return TRUE;
421 bool_t
422 xdr_cback_data (XDR *xdrs, cback_data *objp)
424 if (!xdr_array (xdrs, (char **)&objp->entries.entries_val,
425 (u_int *) &objp->entries.entries_len, ~0,
426 sizeof (obj_p), (xdrproc_t) xdr_obj_p))
427 return FALSE;
428 return TRUE;