alpha: Fix all users of SYSCALL_ERROR_HANDLER
[glibc.git] / nis / nis_xdr.c
blob8d0a60ba62d4c4ecd0188a62dcb2acd5e3be3920
1 /* Copyright (c) 1997, 1998, 2005, 2006, 2007 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, see
17 <http://www.gnu.org/licenses/>. */
19 #include <rpcsvc/nis.h>
20 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
22 /* This functions do exist without beginning "_" under Solaris 2.x, but
23 we have no prototypes for them. To avoid the same problems as with the
24 YP xdr functions, we don't make them public. */
25 #include "nis_xdr.h"
27 static bool_t
28 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
30 bool_t res = xdr_string (xdrs, &objp->zattr_ndx, ~0);
31 if (__builtin_expect (res, TRUE))
32 res = xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
33 &objp->zattr_val.zattr_val_len, ~0);
34 return res;
37 static __always_inline bool_t
38 xdr_nis_name (XDR *xdrs, nis_name *objp)
40 return xdr_string (xdrs, objp, ~0);
43 bool_t
44 _xdr_nis_name (XDR *xdrs, nis_name *objp)
46 return xdr_nis_name (xdrs, objp);
49 static __always_inline bool_t
50 xdr_zotypes (XDR *xdrs, zotypes *objp)
52 return xdr_enum (xdrs, (enum_t *) objp);
55 static __always_inline bool_t
56 xdr_nstype (XDR *xdrs, nstype *objp)
58 return xdr_enum (xdrs, (enum_t *) objp);
61 static bool_t
62 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
64 bool_t res = xdr_u_int (xdrs, &objp->oa_rights);
65 if (__builtin_expect (res, TRUE))
66 res = xdr_zotypes (xdrs, &objp->oa_otype);
67 return res;
70 static bool_t
71 xdr_endpoint (XDR *xdrs, endpoint *objp)
73 bool_t res = xdr_string (xdrs, &objp->uaddr, ~0);
74 if (__builtin_expect (res, TRUE))
76 res = xdr_string (xdrs, &objp->family, ~0);
77 if (__builtin_expect (res, 1))
78 res = xdr_string (xdrs, &objp->proto, ~0);
80 return res;
83 bool_t
84 _xdr_nis_server (XDR *xdrs, nis_server *objp)
86 bool_t res = xdr_nis_name (xdrs, &objp->name);
87 if (__builtin_expect (res, TRUE))
89 res = xdr_array (xdrs, (void *) &objp->ep.ep_val, &objp->ep.ep_len,
90 ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint);
91 if (__builtin_expect (res, TRUE))
93 res = xdr_u_int (xdrs, &objp->key_type);
94 if (__builtin_expect (res, TRUE))
95 res = xdr_netobj (xdrs, &objp->pkey);
98 return res;
101 bool_t
102 _xdr_directory_obj (XDR *xdrs, directory_obj *objp)
104 bool_t res = xdr_nis_name (xdrs, &objp->do_name);
105 if (__builtin_expect (res, TRUE))
107 res = xdr_nstype (xdrs, &objp->do_type);
108 if (__builtin_expect (res, TRUE))
110 res = xdr_array (xdrs, (void *) &objp->do_servers.do_servers_val,
111 &objp->do_servers.do_servers_len, ~0,
112 sizeof (nis_server), (xdrproc_t) _xdr_nis_server);
113 if (__builtin_expect (res, TRUE))
115 res = xdr_uint32_t (xdrs, &objp->do_ttl);
116 if (__builtin_expect (res, TRUE))
117 res = xdr_array (xdrs,
118 (void *) &objp->do_armask.do_armask_val,
119 &objp->do_armask.do_armask_len, ~0,
120 sizeof (oar_mask), (xdrproc_t) xdr_oar_mask);
124 return res;
127 static bool_t
128 xdr_entry_col (XDR *xdrs, entry_col *objp)
130 bool_t res = xdr_u_int (xdrs, &objp->ec_flags);
131 if (__builtin_expect (res, TRUE))
132 res = xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
133 &objp->ec_value.ec_value_len, ~0);
134 return res;
137 static bool_t
138 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
140 bool_t res = xdr_string (xdrs, &objp->en_type, ~0);
141 if (__builtin_expect (res, TRUE))
142 res = xdr_array (xdrs, (void *) &objp->en_cols.en_cols_val,
143 &objp->en_cols.en_cols_len, ~0,
144 sizeof (entry_col), (xdrproc_t) xdr_entry_col);
145 return res;
148 static bool_t
149 xdr_group_obj (XDR *xdrs, group_obj *objp)
151 bool_t res = xdr_u_int (xdrs, &objp->gr_flags);
152 if (__builtin_expect (res, TRUE))
153 res = xdr_array (xdrs, (void *) &objp->gr_members.gr_members_val,
154 &objp->gr_members.gr_members_len, ~0,
155 sizeof (nis_name), (xdrproc_t) _xdr_nis_name);
156 return res;
159 static bool_t
160 xdr_link_obj (XDR *xdrs, link_obj *objp)
162 bool_t res = xdr_zotypes (xdrs, &objp->li_rtype);
163 if (__builtin_expect (res, TRUE))
165 res = xdr_array (xdrs, (void *) &objp->li_attrs.li_attrs_val,
166 &objp->li_attrs.li_attrs_len, ~0,
167 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
168 if (__builtin_expect (res, TRUE))
169 res = xdr_nis_name (xdrs, &objp->li_name);
171 return res;
174 static bool_t
175 xdr_table_col (XDR *xdrs, table_col *objp)
177 bool_t res = xdr_string (xdrs, &objp->tc_name, 64);
178 if (__builtin_expect (res, TRUE))
180 res = xdr_u_int (xdrs, &objp->tc_flags);
181 if (__builtin_expect (res, TRUE))
182 res = xdr_u_int (xdrs, &objp->tc_rights);
184 return res;
187 static bool_t
188 xdr_table_obj (XDR *xdrs, table_obj *objp)
190 bool_t res = xdr_string (xdrs, &objp->ta_type, 64);
191 if (__builtin_expect (res, TRUE))
193 res = xdr_int (xdrs, &objp->ta_maxcol);
194 if (__builtin_expect (res, TRUE))
196 res = xdr_u_char (xdrs, &objp->ta_sep);
197 if (__builtin_expect (res, TRUE))
199 res = xdr_array (xdrs, (void *) &objp->ta_cols.ta_cols_val,
200 &objp->ta_cols.ta_cols_len, ~0,
201 sizeof (table_col), (xdrproc_t) xdr_table_col);
202 if (__builtin_expect (res, TRUE))
203 res = xdr_string (xdrs, &objp->ta_path, ~0);
207 return res;
210 static bool_t
211 xdr_objdata (XDR *xdrs, objdata *objp)
213 bool_t res = xdr_zotypes (xdrs, &objp->zo_type);
214 if (!__builtin_expect (res, TRUE))
215 return res;
216 switch (objp->zo_type)
218 case NIS_DIRECTORY_OBJ:
219 return _xdr_directory_obj (xdrs, &objp->objdata_u.di_data);
220 case NIS_GROUP_OBJ:
221 return xdr_group_obj (xdrs, &objp->objdata_u.gr_data);
222 case NIS_TABLE_OBJ:
223 return xdr_table_obj (xdrs, &objp->objdata_u.ta_data);
224 case NIS_ENTRY_OBJ:
225 return xdr_entry_obj (xdrs, &objp->objdata_u.en_data);
226 case NIS_LINK_OBJ:
227 return xdr_link_obj (xdrs, &objp->objdata_u.li_data);
228 case NIS_PRIVATE_OBJ:
229 return xdr_bytes (xdrs, &objp->objdata_u.po_data.po_data_val,
230 &objp->objdata_u.po_data.po_data_len, ~0);
231 case NIS_NO_OBJ:
232 case NIS_BOGUS_OBJ:
233 default:
234 return TRUE;
238 static bool_t
239 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
241 bool_t res = xdr_uint32_t (xdrs, &objp->ctime);
242 if (__builtin_expect (res, TRUE))
243 res = xdr_uint32_t (xdrs, &objp->mtime);
244 return res;
247 bool_t
248 _xdr_nis_object (XDR *xdrs, nis_object *objp)
250 bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid);
251 if (__builtin_expect (res, TRUE))
253 res = xdr_nis_name (xdrs, &objp->zo_name);
254 if (__builtin_expect (res, TRUE))
256 res = xdr_nis_name (xdrs, &objp->zo_owner);
257 if (__builtin_expect (res, TRUE))
259 res = xdr_nis_name (xdrs, &objp->zo_group);
260 if (__builtin_expect (res, TRUE))
262 res = xdr_nis_name (xdrs, &objp->zo_domain);
263 if (__builtin_expect (res, TRUE))
265 res = xdr_u_int (xdrs, &objp->zo_access);
266 if (__builtin_expect (res, TRUE))
268 res = xdr_uint32_t (xdrs, &objp->zo_ttl);
269 if (__builtin_expect (res, TRUE))
270 res = xdr_objdata (xdrs, &objp->zo_data);
277 return res;
280 static __always_inline bool_t
281 xdr_nis_error (XDR *xdrs, nis_error *objp)
283 return xdr_enum (xdrs, (enum_t *) objp);
286 bool_t
287 _xdr_nis_error (XDR *xdrs, nis_error *objp)
289 return xdr_nis_error (xdrs, objp);
292 bool_t
293 _xdr_nis_result (XDR *xdrs, nis_result *objp)
295 bool_t res = xdr_nis_error (xdrs, &objp->status);
296 if (__builtin_expect (res, TRUE))
298 res = xdr_array (xdrs, (void *) &objp->objects.objects_val,
299 &objp->objects.objects_len, ~0,
300 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
301 if (__builtin_expect (res, TRUE))
303 res = xdr_netobj (xdrs, &objp->cookie);
304 if (__builtin_expect (res, TRUE))
306 res = xdr_uint32_t (xdrs, &objp->zticks);
307 if (__builtin_expect (res, TRUE))
309 res = xdr_uint32_t (xdrs, &objp->dticks);
310 if (__builtin_expect (res, TRUE))
312 res = xdr_uint32_t (xdrs, &objp->aticks);
313 if (__builtin_expect (res, TRUE))
314 res = xdr_uint32_t (xdrs, &objp->cticks);
320 return res;
322 libnsl_hidden_def (_xdr_nis_result)
324 bool_t
325 _xdr_ns_request (XDR *xdrs, ns_request *objp)
327 bool_t res = xdr_nis_name (xdrs, &objp->ns_name);
328 if (__builtin_expect (res, TRUE))
329 res = xdr_array (xdrs, (void *) &objp->ns_object.ns_object_val,
330 &objp->ns_object.ns_object_len, 1,
331 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
332 return res;
335 bool_t
336 _xdr_ib_request (XDR *xdrs, ib_request *objp)
338 bool_t res = xdr_nis_name (xdrs, &objp->ibr_name);
339 if (__builtin_expect (res, TRUE))
341 res = xdr_array (xdrs, (void *) &objp->ibr_srch.ibr_srch_val,
342 &objp->ibr_srch.ibr_srch_len, ~0,
343 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
344 if (__builtin_expect (res, TRUE))
346 res = xdr_u_int (xdrs, &objp->ibr_flags);
347 if (__builtin_expect (res, TRUE))
349 res = xdr_array (xdrs, (void *) &objp->ibr_obj.ibr_obj_val,
350 &objp->ibr_obj.ibr_obj_len, 1,
351 sizeof (nis_object),
352 (xdrproc_t) _xdr_nis_object);
353 if (__builtin_expect (res, TRUE))
355 res = xdr_array (xdrs,
356 (void *) &objp->ibr_cbhost.ibr_cbhost_val,
357 &objp->ibr_cbhost.ibr_cbhost_len, 1,
358 sizeof (nis_server),
359 (xdrproc_t) _xdr_nis_server);
360 if (__builtin_expect (res, TRUE))
362 res = xdr_u_int (xdrs, &objp->ibr_bufsize);
363 if (__builtin_expect (res, TRUE))
364 res = xdr_netobj (xdrs, &objp->ibr_cookie);
370 return res;
372 libnsl_hidden_def (_xdr_ib_request)
374 bool_t
375 _xdr_ping_args (XDR *xdrs, ping_args *objp)
377 bool_t res = xdr_nis_name (xdrs, &objp->dir);
378 if (__builtin_expect (res, TRUE))
379 res = xdr_uint32_t (xdrs, &objp->stamp);
380 return res;
383 bool_t
384 _xdr_cp_result (XDR *xdrs, cp_result *objp)
386 bool_t res = xdr_nis_error (xdrs, &objp->cp_status);
387 if (__builtin_expect (res, TRUE))
389 res = xdr_uint32_t (xdrs, &objp->cp_zticks);
390 if (__builtin_expect (res, TRUE))
391 res = xdr_uint32_t (xdrs, &objp->cp_dticks);
393 return res;
396 bool_t
397 _xdr_nis_tag (XDR *xdrs, nis_tag *objp)
399 bool_t res = xdr_u_int (xdrs, &objp->tag_type);
400 if (__builtin_expect (res, TRUE))
401 res = xdr_string (xdrs, &objp->tag_val, ~0);
402 return res;
405 bool_t
406 _xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
408 return xdr_array (xdrs, (void *) &objp->tags.tags_val,
409 &objp->tags.tags_len, ~0, sizeof (nis_tag),
410 (xdrproc_t) _xdr_nis_tag);
413 bool_t
414 _xdr_fd_args (XDR *xdrs, fd_args *objp)
416 bool_t res = xdr_nis_name (xdrs, &objp->dir_name);
417 if (__builtin_expect (res, TRUE))
418 res = xdr_nis_name (xdrs, &objp->requester);
419 return res;
422 bool_t
423 _xdr_fd_result (XDR *xdrs, fd_result *objp)
425 bool_t res = xdr_nis_error (xdrs, &objp->status);
426 if (__builtin_expect (res, TRUE))
428 res = xdr_nis_name (xdrs, &objp->source);
429 if (__builtin_expect (res, TRUE))
431 res = xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
432 &objp->dir_data.dir_data_len, ~0);
433 if (__builtin_expect (res, TRUE))
434 res = xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
435 &objp->signature.signature_len, ~0);
438 return res;
441 /* The following functions have prototypes in nis_callback.h. So
442 we make them public */
443 bool_t
444 xdr_obj_p (XDR *xdrs, obj_p *objp)
446 return xdr_pointer (xdrs, (char **)objp, sizeof (nis_object),
447 (xdrproc_t)_xdr_nis_object);
449 libnsl_hidden_def (xdr_obj_p)
451 bool_t
452 xdr_cback_data (XDR *xdrs, cback_data *objp)
454 return xdr_array (xdrs, (void *) &objp->entries.entries_val,
455 &objp->entries.entries_len, ~0,
456 sizeof (obj_p), (xdrproc_t) xdr_obj_p);
458 libnsl_hidden_def (xdr_cback_data)