Correct function declaration to avoid warning.
[glibc/history.git] / nis / nis_xdr.c
blob82df04e44990f81594271782471b90edb95869d6
1 /* Copyright (c) 1997 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <rpcsvc/nis.h>
22 bool_t
23 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
25 if (!xdr_string (xdrs, &objp->zattr_ndx, ~0))
26 return FALSE;
27 if (!xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
28 (u_int *) & objp->zattr_val.zattr_val_len, ~0))
29 return FALSE;
30 return TRUE;
33 bool_t
34 xdr_nis_name (XDR *xdrs, nis_name *objp)
36 if (!xdr_string (xdrs, objp, ~0))
37 return FALSE;
38 return TRUE;
41 bool_t
42 xdr_zotypes (XDR *xdrs, zotypes *objp)
44 if (!xdr_enum (xdrs, (enum_t *) objp))
45 return FALSE;
46 return TRUE;
49 bool_t
50 xdr_nstype (XDR *xdrs, nstype *objp)
52 if (!xdr_enum (xdrs, (enum_t *) objp))
53 return FALSE;
54 return TRUE;
57 bool_t
58 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
60 if (!xdr_u_long (xdrs, &objp->oa_rights))
61 return FALSE;
62 if (!xdr_zotypes (xdrs, &objp->oa_otype))
63 return FALSE;
64 return TRUE;
67 bool_t
68 xdr_endpoint (XDR *xdrs, endpoint *objp)
70 if (!xdr_string (xdrs, &objp->uaddr, ~0))
71 return FALSE;
72 if (!xdr_string (xdrs, &objp->family, ~0))
73 return FALSE;
74 if (!xdr_string (xdrs, &objp->proto, ~0))
75 return FALSE;
76 return TRUE;
79 bool_t
80 xdr_nis_server (XDR *xdrs, nis_server *objp)
82 if (!xdr_nis_name (xdrs, &objp->name))
83 return FALSE;
84 if (!xdr_array (xdrs, (char **) &objp->ep.ep_val, (u_int *) &objp->ep.ep_len,
85 ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint))
86 return FALSE;
87 if (!xdr_u_long (xdrs, &objp->key_type))
88 return FALSE;
89 if (!xdr_netobj (xdrs, &objp->pkey))
90 return FALSE;
91 return TRUE;
94 bool_t
95 xdr_directory_obj (XDR *xdrs, directory_obj *objp)
97 if (!xdr_nis_name (xdrs, &objp->do_name))
98 return FALSE;
99 if (!xdr_nstype (xdrs, &objp->do_type))
100 return FALSE;
101 if (!xdr_array (xdrs, (char **) &objp->do_servers.do_servers_val,
102 (u_int *) & objp->do_servers.do_servers_len, ~0,
103 sizeof (nis_server), (xdrproc_t) xdr_nis_server))
104 return FALSE;
106 if (!xdr_u_long (xdrs, &objp->do_ttl))
107 return FALSE;
108 if (!xdr_array (xdrs, (char **) &objp->do_armask.do_armask_val,
109 (u_int *) & objp->do_armask.do_armask_len, ~0,
110 sizeof (oar_mask), (xdrproc_t) xdr_oar_mask))
111 return FALSE;
112 return TRUE;
115 bool_t
116 xdr_entry_col (XDR *xdrs, entry_col *objp)
118 if (!xdr_u_long (xdrs, &objp->ec_flags))
119 return FALSE;
120 if (!xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
121 (u_int *) &objp->ec_value.ec_value_len, ~0))
122 return FALSE;
123 return TRUE;
126 bool_t
127 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
129 if (!xdr_string (xdrs, &objp->en_type, ~0))
130 return FALSE;
131 if (!xdr_array (xdrs, (char **) &objp->en_cols.en_cols_val,
132 (u_int *) &objp->en_cols.en_cols_len, ~0,
133 sizeof (entry_col), (xdrproc_t) xdr_entry_col))
134 return FALSE;
135 return TRUE;
138 bool_t
139 xdr_group_obj (XDR *xdrs, group_obj *objp)
141 if (!xdr_u_long (xdrs, &objp->gr_flags))
142 return FALSE;
143 if (!xdr_array (xdrs, (char **) &objp->gr_members.gr_members_val,
144 (u_int *) &objp->gr_members.gr_members_len, ~0,
145 sizeof (nis_name), (xdrproc_t) xdr_nis_name))
146 return FALSE;
147 return TRUE;
150 bool_t
151 xdr_link_obj (XDR *xdrs, link_obj *objp)
153 if (!xdr_zotypes (xdrs, &objp->li_rtype))
154 return FALSE;
155 if (!xdr_array (xdrs, (char **) &objp->li_attrs.li_attrs_val,
156 (u_int *) &objp->li_attrs.li_attrs_len, ~0,
157 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
158 return FALSE;
159 if (!xdr_nis_name (xdrs, &objp->li_name))
160 return FALSE;
161 return TRUE;
164 bool_t
165 xdr_table_col (XDR *xdrs, table_col *objp)
167 if (!xdr_string (xdrs, &objp->tc_name, 64))
168 return FALSE;
169 if (!xdr_u_long (xdrs, &objp->tc_flags))
170 return FALSE;
171 if (!xdr_u_long (xdrs, &objp->tc_rights))
172 return FALSE;
173 return TRUE;
176 bool_t
177 xdr_table_obj (XDR *xdrs, table_obj *objp)
179 if (!xdr_string (xdrs, &objp->ta_type, 64))
180 return FALSE;
181 if (!xdr_int (xdrs, &objp->ta_maxcol))
182 return FALSE;
183 if (!xdr_u_char (xdrs, &objp->ta_sep))
184 return FALSE;
185 if (!xdr_array (xdrs, (char **) &objp->ta_cols.ta_cols_val,
186 (u_int *) &objp->ta_cols.ta_cols_len, ~0,
187 sizeof (table_col), (xdrproc_t) xdr_table_col))
188 return FALSE;
189 if (!xdr_string (xdrs, &objp->ta_path, ~0))
190 return FALSE;
191 return TRUE;
194 bool_t
195 xdr_objdata (XDR *xdrs, objdata *objp)
197 if (!xdr_zotypes (xdrs, &objp->zo_type))
198 return FALSE;
199 switch (objp->zo_type)
201 case DIRECTORY_OBJ:
202 if (!xdr_directory_obj (xdrs, &objp->objdata_u.di_data))
203 return FALSE;
204 break;
205 case GROUP_OBJ:
206 if (!xdr_group_obj (xdrs, &objp->objdata_u.gr_data))
207 return FALSE;
208 break;
209 case TABLE_OBJ:
210 if (!xdr_table_obj (xdrs, &objp->objdata_u.ta_data))
211 return FALSE;
212 break;
213 case ENTRY_OBJ:
214 if (!xdr_entry_obj (xdrs, &objp->objdata_u.en_data))
215 return FALSE;
216 break;
217 case LINK_OBJ:
218 if (!xdr_link_obj (xdrs, &objp->objdata_u.li_data))
219 return FALSE;
220 break;
221 case PRIVATE_OBJ:
222 if (!xdr_bytes (xdrs, (char **) &objp->objdata_u.po_data.po_data_val,
223 (u_int *) & objp->objdata_u.po_data.po_data_len, ~0))
224 return FALSE;
225 break;
226 case NO_OBJ:
227 break;
228 case BOGUS_OBJ:
229 break;
230 default:
231 break;
233 return TRUE;
236 bool_t
237 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
239 if (!xdr_u_long (xdrs, &objp->ctime))
240 return FALSE;
241 if (!xdr_u_long (xdrs, &objp->mtime))
242 return FALSE;
243 return TRUE;
246 bool_t
247 xdr_nis_object (XDR *xdrs, nis_object *objp)
249 if (!xdr_nis_oid (xdrs, &objp->zo_oid))
250 return FALSE;
251 if (!xdr_nis_name (xdrs, &objp->zo_name))
252 return FALSE;
253 if (!xdr_nis_name (xdrs, &objp->zo_owner))
254 return FALSE;
255 if (!xdr_nis_name (xdrs, &objp->zo_group))
256 return FALSE;
257 if (!xdr_nis_name (xdrs, &objp->zo_domain))
258 return FALSE;
259 if (!xdr_u_long (xdrs, &objp->zo_access))
260 return FALSE;
261 if (!xdr_u_long (xdrs, &objp->zo_ttl))
262 return FALSE;
263 if (!xdr_objdata (xdrs, &objp->zo_data))
264 return FALSE;
265 return TRUE;
268 bool_t
269 xdr_nis_error (XDR *xdrs, nis_error *objp)
271 if (!xdr_enum (xdrs, (enum_t *) objp))
272 return FALSE;
273 return TRUE;
276 bool_t
277 xdr_nis_result (XDR *xdrs, nis_result *objp)
279 register long *buf;
281 if (xdrs->x_op == XDR_ENCODE)
283 if (!xdr_nis_error (xdrs, &objp->status))
284 return FALSE;
285 if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
286 (u_int *) &objp->objects.objects_len, ~0,
287 sizeof (nis_object), (xdrproc_t) xdr_nis_object))
288 return FALSE;
289 if (!xdr_netobj (xdrs, &objp->cookie))
290 return FALSE;
291 buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
292 if (buf == NULL)
294 if (!xdr_u_long (xdrs, &objp->zticks))
296 return FALSE;
298 if (!xdr_u_long (xdrs, &objp->dticks))
300 return FALSE;
302 if (!xdr_u_long (xdrs, &objp->aticks))
304 return FALSE;
306 if (!xdr_u_long (xdrs, &objp->cticks))
308 return FALSE;
312 else
314 IXDR_PUT_U_LONG (buf, objp->zticks);
315 IXDR_PUT_U_LONG (buf, objp->dticks);
316 IXDR_PUT_U_LONG (buf, objp->aticks);
317 IXDR_PUT_U_LONG (buf, objp->cticks);
320 return TRUE;
322 else if (xdrs->x_op == XDR_DECODE)
324 if (!xdr_nis_error (xdrs, &objp->status))
326 return FALSE;
328 if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
329 (u_int *) &objp->objects.objects_len, ~0,
330 sizeof (nis_object), (xdrproc_t) xdr_nis_object))
332 return FALSE;
334 if (!xdr_netobj (xdrs, &objp->cookie))
336 return FALSE;
338 buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT);
339 if (buf == NULL)
341 if (!xdr_u_long (xdrs, &objp->zticks))
343 return FALSE;
345 if (!xdr_u_long (xdrs, &objp->dticks))
347 return FALSE;
349 if (!xdr_u_long (xdrs, &objp->aticks))
351 return FALSE;
353 if (!xdr_u_long (xdrs, &objp->cticks))
355 return FALSE;
359 else
361 objp->zticks = IXDR_GET_U_LONG (buf);
362 objp->dticks = IXDR_GET_U_LONG (buf);
363 objp->aticks = IXDR_GET_U_LONG (buf);
364 objp->cticks = IXDR_GET_U_LONG (buf);
366 return TRUE;
369 if (!xdr_nis_error (xdrs, &objp->status))
371 return FALSE;
373 if (!xdr_array (xdrs, (char **) &objp->objects.objects_val,
374 (u_int *) &objp->objects.objects_len, ~0,
375 sizeof (nis_object), (xdrproc_t) xdr_nis_object))
377 return FALSE;
379 if (!xdr_netobj (xdrs, &objp->cookie))
381 return FALSE;
383 if (!xdr_u_long (xdrs, &objp->zticks))
385 return FALSE;
387 if (!xdr_u_long (xdrs, &objp->dticks))
389 return FALSE;
391 if (!xdr_u_long (xdrs, &objp->aticks))
393 return FALSE;
395 if (!xdr_u_long (xdrs, &objp->cticks))
397 return FALSE;
399 return TRUE;
402 bool_t
403 xdr_ns_request (XDR *xdrs, ns_request *objp)
405 if (!xdr_nis_name (xdrs, &objp->ns_name))
406 return FALSE;
407 if (!xdr_array (xdrs, (char **) &objp->ns_object.ns_object_val,
408 (u_int *) &objp->ns_object.ns_object_len, 1,
409 sizeof (nis_object), (xdrproc_t) xdr_nis_object))
410 return FALSE;
411 return TRUE;
414 bool_t
415 xdr_ib_request (XDR *xdrs, ib_request *objp)
417 if (!xdr_nis_name (xdrs, &objp->ibr_name))
418 return FALSE;
419 if (!xdr_array (xdrs, (char **) &objp->ibr_srch.ibr_srch_val,
420 (u_int *) &objp->ibr_srch.ibr_srch_len, ~0,
421 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
422 return FALSE;
423 if (!xdr_u_long (xdrs, &objp->ibr_flags))
424 return FALSE;
425 if (!xdr_array (xdrs, (char **) &objp->ibr_obj.ibr_obj_val,
426 (u_int *) &objp->ibr_obj.ibr_obj_len, 1,
427 sizeof (nis_object), (xdrproc_t) xdr_nis_object))
428 return FALSE;
429 if (!xdr_array (xdrs, (char **) &objp->ibr_cbhost.ibr_cbhost_val,
430 (u_int *) &objp->ibr_cbhost.ibr_cbhost_len, 1,
431 sizeof (nis_server), (xdrproc_t) xdr_nis_server))
432 return FALSE;
433 if (!xdr_u_long (xdrs, &objp->ibr_bufsize))
434 return FALSE;
435 if (!xdr_netobj (xdrs, &objp->ibr_cookie))
436 return FALSE;
437 return TRUE;
440 bool_t
441 xdr_ping_args (XDR *xdrs, ping_args *objp)
443 if (!xdr_nis_name (xdrs, &objp->dir))
444 return FALSE;
445 if (!xdr_u_long (xdrs, &objp->stamp))
446 return FALSE;
447 return TRUE;
450 bool_t
451 xdr_log_entry_t (XDR *xdrs, log_entry_t *objp)
453 if (!xdr_enum (xdrs, (enum_t *) objp))
454 return FALSE;
455 return TRUE;
458 bool_t
459 xdr_log_entry (XDR *xdrs, log_entry *objp)
461 if (!xdr_u_long (xdrs, &objp->le_time))
462 return FALSE;
463 if (!xdr_log_entry_t (xdrs, &objp->le_type))
464 return FALSE;
465 if (!xdr_nis_name (xdrs, &objp->le_princp))
466 return FALSE;
467 if (!xdr_nis_name (xdrs, &objp->le_name))
468 return FALSE;
469 if (!xdr_array (xdrs, (char **) &objp->le_attrs.le_attrs_val,
470 (u_int *) &objp->le_attrs.le_attrs_len, ~0,
471 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr))
472 return FALSE;
473 if (!xdr_nis_object (xdrs, &objp->le_object))
474 return FALSE;
475 return TRUE;
478 bool_t
479 xdr_log_result (XDR *xdrs, log_result *objp)
481 if (!xdr_nis_error (xdrs, &objp->lr_status))
483 return FALSE;
485 if (!xdr_netobj (xdrs, &objp->lr_cookie))
487 return FALSE;
489 if (!xdr_array (xdrs, (char **) &objp->lr_entries.lr_entries_val,
490 (u_int *) &objp->lr_entries.lr_entries_len, ~0,
491 sizeof (log_entry), (xdrproc_t) xdr_log_entry))
493 return FALSE;
495 return TRUE;
498 bool_t
499 xdr_cp_result (XDR *xdrs, cp_result *objp)
501 if (!xdr_nis_error (xdrs, &objp->cp_status))
502 return FALSE;
503 if (!xdr_u_long (xdrs, &objp->cp_zticks))
504 return FALSE;
505 if (!xdr_u_long (xdrs, &objp->cp_dticks))
506 return FALSE;
507 return TRUE;
510 bool_t
511 xdr_nis_tag (XDR *xdrs, nis_tag *objp)
513 if (!xdr_u_long (xdrs, &objp->tag_type))
515 return FALSE;
517 if (!xdr_string (xdrs, &objp->tag_val, 1024))
519 return FALSE;
521 return TRUE;
524 bool_t
525 xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
527 if (!xdr_array (xdrs, (char **) &objp->tags.tags_val,
528 (u_int *) &objp->tags.tags_len, ~0, sizeof (nis_tag),
529 (xdrproc_t) xdr_nis_tag))
530 return FALSE;
531 return TRUE;
534 bool_t
535 xdr_dump_args (XDR *xdrs, dump_args *objp)
537 if (!xdr_nis_name (xdrs, &objp->da_dir))
538 return FALSE;
539 if (!xdr_u_long (xdrs, &objp->da_time))
540 return FALSE;
541 if (!xdr_array (xdrs, (char **) &objp->da_cbhost.da_cbhost_val,
542 (u_int *) &objp->da_cbhost.da_cbhost_len, 1,
543 sizeof (nis_server), (xdrproc_t) xdr_nis_server))
544 return FALSE;
545 return TRUE;
548 bool_t
549 xdr_fd_args (XDR *xdrs, fd_args *objp)
551 if (!xdr_nis_name (xdrs, &objp->dir_name))
552 return FALSE;
553 if (!xdr_nis_name (xdrs, &objp->requester))
554 return FALSE;
555 return TRUE;
558 bool_t
559 xdr_fd_result (XDR *xdrs, fd_result *objp)
561 if (!xdr_nis_error (xdrs, &objp->status))
562 return FALSE;
563 if (!xdr_nis_name (xdrs, &objp->source))
564 return FALSE;
565 if (!xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
566 (u_int *) &objp->dir_data.dir_data_len, ~0))
567 return FALSE;
568 if (!xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
569 (u_int *) &objp->signature.signature_len, ~0))
570 return FALSE;
571 return TRUE;