Update iso14651_t1_common file to ISO14651_2016_TABLE1_en.txt [BZ #14095]
[glibc.git] / nis / nis_xdr.c
blob0dacaa87e1635764aaa1c25949122dd7b19e7835
1 /* Copyright (c) 1997-2018 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 <stdint.h>
20 #include <rpcsvc/nis.h>
21 #include <rpcsvc/nis_callback.h> /* for "official" Solaris xdr functions */
22 #include <shlib-compat.h>
24 /* This functions do exist without beginning "_" under Solaris 2.x, but
25 we have no prototypes for them. To avoid the same problems as with the
26 YP xdr functions, we don't make them public. */
27 #include "nis_xdr.h"
29 static bool_t
30 xdr_nis_attr (XDR *xdrs, nis_attr *objp)
32 bool_t res = xdr_string (xdrs, &objp->zattr_ndx, ~0);
33 if (__builtin_expect (res, TRUE))
34 res = xdr_bytes (xdrs, (char **) &objp->zattr_val.zattr_val_val,
35 &objp->zattr_val.zattr_val_len, ~0);
36 return res;
39 static __always_inline bool_t
40 xdr_nis_name (XDR *xdrs, nis_name *objp)
42 return xdr_string (xdrs, objp, ~0);
45 bool_t
46 _xdr_nis_name (XDR *xdrs, nis_name *objp)
48 return xdr_nis_name (xdrs, objp);
51 static __always_inline bool_t
52 xdr_zotypes (XDR *xdrs, zotypes *objp)
54 return xdr_enum (xdrs, (enum_t *) objp);
57 static __always_inline bool_t
58 xdr_nstype (XDR *xdrs, nstype *objp)
60 return xdr_enum (xdrs, (enum_t *) objp);
63 static bool_t
64 xdr_oar_mask (XDR *xdrs, oar_mask *objp)
66 bool_t res = xdr_u_int (xdrs, &objp->oa_rights);
67 if (__builtin_expect (res, TRUE))
68 res = xdr_zotypes (xdrs, &objp->oa_otype);
69 return res;
72 static bool_t
73 xdr_endpoint (XDR *xdrs, endpoint *objp)
75 bool_t res = xdr_string (xdrs, &objp->uaddr, ~0);
76 if (__builtin_expect (res, TRUE))
78 res = xdr_string (xdrs, &objp->family, ~0);
79 if (__glibc_likely (res))
80 res = xdr_string (xdrs, &objp->proto, ~0);
82 return res;
85 bool_t
86 _xdr_nis_server (XDR *xdrs, nis_server *objp)
88 bool_t res = xdr_nis_name (xdrs, &objp->name);
89 if (__builtin_expect (res, TRUE))
91 res = xdr_array (xdrs, (void *) &objp->ep.ep_val, &objp->ep.ep_len,
92 ~0, sizeof (endpoint), (xdrproc_t) xdr_endpoint);
93 if (__builtin_expect (res, TRUE))
95 res = xdr_u_int (xdrs, &objp->key_type);
96 if (__builtin_expect (res, TRUE))
97 res = xdr_netobj (xdrs, &objp->pkey);
100 return res;
103 bool_t
104 _xdr_directory_obj (XDR *xdrs, directory_obj *objp)
106 bool_t res = xdr_nis_name (xdrs, &objp->do_name);
107 if (__builtin_expect (res, TRUE))
109 res = xdr_nstype (xdrs, &objp->do_type);
110 if (__builtin_expect (res, TRUE))
112 res = xdr_array (xdrs, (void *) &objp->do_servers.do_servers_val,
113 &objp->do_servers.do_servers_len, ~0,
114 sizeof (nis_server), (xdrproc_t) _xdr_nis_server);
115 if (__builtin_expect (res, TRUE))
117 res = xdr_uint32_t (xdrs, &objp->do_ttl);
118 if (__builtin_expect (res, TRUE))
119 res = xdr_array (xdrs,
120 (void *) &objp->do_armask.do_armask_val,
121 &objp->do_armask.do_armask_len, ~0,
122 sizeof (oar_mask), (xdrproc_t) xdr_oar_mask);
126 return res;
129 static bool_t
130 xdr_entry_col (XDR *xdrs, entry_col *objp)
132 bool_t res = xdr_u_int (xdrs, &objp->ec_flags);
133 if (__builtin_expect (res, TRUE))
134 res = xdr_bytes (xdrs, (char **) &objp->ec_value.ec_value_val,
135 &objp->ec_value.ec_value_len, ~0);
136 return res;
139 static bool_t
140 xdr_entry_obj (XDR *xdrs, entry_obj *objp)
142 bool_t res = xdr_string (xdrs, &objp->en_type, ~0);
143 if (__builtin_expect (res, TRUE))
144 res = xdr_array (xdrs, (void *) &objp->en_cols.en_cols_val,
145 &objp->en_cols.en_cols_len, ~0,
146 sizeof (entry_col), (xdrproc_t) xdr_entry_col);
147 return res;
150 static bool_t
151 xdr_group_obj (XDR *xdrs, group_obj *objp)
153 bool_t res = xdr_u_int (xdrs, &objp->gr_flags);
154 if (__builtin_expect (res, TRUE))
155 res = xdr_array (xdrs, (void *) &objp->gr_members.gr_members_val,
156 &objp->gr_members.gr_members_len, ~0,
157 sizeof (nis_name), (xdrproc_t) _xdr_nis_name);
158 return res;
161 static bool_t
162 xdr_link_obj (XDR *xdrs, link_obj *objp)
164 bool_t res = xdr_zotypes (xdrs, &objp->li_rtype);
165 if (__builtin_expect (res, TRUE))
167 res = xdr_array (xdrs, (void *) &objp->li_attrs.li_attrs_val,
168 &objp->li_attrs.li_attrs_len, ~0,
169 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
170 if (__builtin_expect (res, TRUE))
171 res = xdr_nis_name (xdrs, &objp->li_name);
173 return res;
176 static bool_t
177 xdr_table_col (XDR *xdrs, table_col *objp)
179 bool_t res = xdr_string (xdrs, &objp->tc_name, 64);
180 if (__builtin_expect (res, TRUE))
182 res = xdr_u_int (xdrs, &objp->tc_flags);
183 if (__builtin_expect (res, TRUE))
184 res = xdr_u_int (xdrs, &objp->tc_rights);
186 return res;
189 static bool_t
190 xdr_table_obj (XDR *xdrs, table_obj *objp)
192 bool_t res = xdr_string (xdrs, &objp->ta_type, 64);
193 if (__builtin_expect (res, TRUE))
195 res = xdr_int (xdrs, &objp->ta_maxcol);
196 if (__builtin_expect (res, TRUE))
198 res = xdr_u_char (xdrs, &objp->ta_sep);
199 if (__builtin_expect (res, TRUE))
201 res = xdr_array (xdrs, (void *) &objp->ta_cols.ta_cols_val,
202 &objp->ta_cols.ta_cols_len, ~0,
203 sizeof (table_col), (xdrproc_t) xdr_table_col);
204 if (__builtin_expect (res, TRUE))
205 res = xdr_string (xdrs, &objp->ta_path, ~0);
209 return res;
212 static bool_t
213 xdr_objdata (XDR *xdrs, objdata *objp)
215 bool_t res = xdr_zotypes (xdrs, &objp->zo_type);
216 if (!__builtin_expect (res, TRUE))
217 return res;
218 switch (objp->zo_type)
220 case NIS_DIRECTORY_OBJ:
221 return _xdr_directory_obj (xdrs, &objp->objdata_u.di_data);
222 case NIS_GROUP_OBJ:
223 return xdr_group_obj (xdrs, &objp->objdata_u.gr_data);
224 case NIS_TABLE_OBJ:
225 return xdr_table_obj (xdrs, &objp->objdata_u.ta_data);
226 case NIS_ENTRY_OBJ:
227 return xdr_entry_obj (xdrs, &objp->objdata_u.en_data);
228 case NIS_LINK_OBJ:
229 return xdr_link_obj (xdrs, &objp->objdata_u.li_data);
230 case NIS_PRIVATE_OBJ:
231 return xdr_bytes (xdrs, &objp->objdata_u.po_data.po_data_val,
232 &objp->objdata_u.po_data.po_data_len, ~0);
233 case NIS_NO_OBJ:
234 case NIS_BOGUS_OBJ:
235 default:
236 return TRUE;
240 static bool_t
241 xdr_nis_oid (XDR *xdrs, nis_oid *objp)
243 bool_t res = xdr_uint32_t (xdrs, &objp->ctime);
244 if (__builtin_expect (res, TRUE))
245 res = xdr_uint32_t (xdrs, &objp->mtime);
246 return res;
249 bool_t
250 _xdr_nis_object (XDR *xdrs, nis_object *objp)
252 bool_t res = xdr_nis_oid (xdrs, &objp->zo_oid);
253 if (__builtin_expect (res, TRUE))
255 res = xdr_nis_name (xdrs, &objp->zo_name);
256 if (__builtin_expect (res, TRUE))
258 res = xdr_nis_name (xdrs, &objp->zo_owner);
259 if (__builtin_expect (res, TRUE))
261 res = xdr_nis_name (xdrs, &objp->zo_group);
262 if (__builtin_expect (res, TRUE))
264 res = xdr_nis_name (xdrs, &objp->zo_domain);
265 if (__builtin_expect (res, TRUE))
267 res = xdr_u_int (xdrs, &objp->zo_access);
268 if (__builtin_expect (res, TRUE))
270 res = xdr_uint32_t (xdrs, &objp->zo_ttl);
271 if (__builtin_expect (res, TRUE))
272 res = xdr_objdata (xdrs, &objp->zo_data);
279 return res;
282 static __always_inline bool_t
283 xdr_nis_error (XDR *xdrs, nis_error *objp)
285 return xdr_enum (xdrs, (enum_t *) objp);
288 bool_t
289 _xdr_nis_error (XDR *xdrs, nis_error *objp)
291 return xdr_nis_error (xdrs, objp);
294 bool_t
295 _xdr_nis_result (XDR *xdrs, nis_result *objp)
297 bool_t res = xdr_nis_error (xdrs, &objp->status);
298 if (__builtin_expect (res, TRUE))
300 res = xdr_array (xdrs, (void *) &objp->objects.objects_val,
301 &objp->objects.objects_len, ~0,
302 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
303 if (__builtin_expect (res, TRUE))
305 res = xdr_netobj (xdrs, &objp->cookie);
306 if (__builtin_expect (res, TRUE))
308 res = xdr_uint32_t (xdrs, &objp->zticks);
309 if (__builtin_expect (res, TRUE))
311 res = xdr_uint32_t (xdrs, &objp->dticks);
312 if (__builtin_expect (res, TRUE))
314 res = xdr_uint32_t (xdrs, &objp->aticks);
315 if (__builtin_expect (res, TRUE))
316 res = xdr_uint32_t (xdrs, &objp->cticks);
322 return res;
324 libnsl_hidden_nolink_def (_xdr_nis_result, GLIBC_PRIVATE)
326 bool_t
327 _xdr_ns_request (XDR *xdrs, ns_request *objp)
329 bool_t res = xdr_nis_name (xdrs, &objp->ns_name);
330 if (__builtin_expect (res, TRUE))
331 res = xdr_array (xdrs, (void *) &objp->ns_object.ns_object_val,
332 &objp->ns_object.ns_object_len, 1,
333 sizeof (nis_object), (xdrproc_t) _xdr_nis_object);
334 return res;
337 bool_t
338 _xdr_ib_request (XDR *xdrs, ib_request *objp)
340 bool_t res = xdr_nis_name (xdrs, &objp->ibr_name);
341 if (__builtin_expect (res, TRUE))
343 res = xdr_array (xdrs, (void *) &objp->ibr_srch.ibr_srch_val,
344 &objp->ibr_srch.ibr_srch_len, ~0,
345 sizeof (nis_attr), (xdrproc_t) xdr_nis_attr);
346 if (__builtin_expect (res, TRUE))
348 res = xdr_u_int (xdrs, &objp->ibr_flags);
349 if (__builtin_expect (res, TRUE))
351 res = xdr_array (xdrs, (void *) &objp->ibr_obj.ibr_obj_val,
352 &objp->ibr_obj.ibr_obj_len, 1,
353 sizeof (nis_object),
354 (xdrproc_t) _xdr_nis_object);
355 if (__builtin_expect (res, TRUE))
357 res = xdr_array (xdrs,
358 (void *) &objp->ibr_cbhost.ibr_cbhost_val,
359 &objp->ibr_cbhost.ibr_cbhost_len, 1,
360 sizeof (nis_server),
361 (xdrproc_t) _xdr_nis_server);
362 if (__builtin_expect (res, TRUE))
364 res = xdr_u_int (xdrs, &objp->ibr_bufsize);
365 if (__builtin_expect (res, TRUE))
366 res = xdr_netobj (xdrs, &objp->ibr_cookie);
372 return res;
374 libnsl_hidden_nolink_def (_xdr_ib_request, GLIBC_PRIVATE)
376 bool_t
377 _xdr_ping_args (XDR *xdrs, ping_args *objp)
379 bool_t res = xdr_nis_name (xdrs, &objp->dir);
380 if (__builtin_expect (res, TRUE))
381 res = xdr_uint32_t (xdrs, &objp->stamp);
382 return res;
385 bool_t
386 _xdr_cp_result (XDR *xdrs, cp_result *objp)
388 bool_t res = xdr_nis_error (xdrs, &objp->cp_status);
389 if (__builtin_expect (res, TRUE))
391 res = xdr_uint32_t (xdrs, &objp->cp_zticks);
392 if (__builtin_expect (res, TRUE))
393 res = xdr_uint32_t (xdrs, &objp->cp_dticks);
395 return res;
398 bool_t
399 _xdr_nis_tag (XDR *xdrs, nis_tag *objp)
401 bool_t res = xdr_u_int (xdrs, &objp->tag_type);
402 if (__builtin_expect (res, TRUE))
403 res = xdr_string (xdrs, &objp->tag_val, ~0);
404 return res;
407 bool_t
408 _xdr_nis_taglist (XDR *xdrs, nis_taglist *objp)
410 return xdr_array (xdrs, (void *) &objp->tags.tags_val,
411 &objp->tags.tags_len, ~0, sizeof (nis_tag),
412 (xdrproc_t) _xdr_nis_tag);
415 bool_t
416 _xdr_fd_args (XDR *xdrs, fd_args *objp)
418 bool_t res = xdr_nis_name (xdrs, &objp->dir_name);
419 if (__builtin_expect (res, TRUE))
420 res = xdr_nis_name (xdrs, &objp->requester);
421 return res;
424 bool_t
425 _xdr_fd_result (XDR *xdrs, fd_result *objp)
427 bool_t res = xdr_nis_error (xdrs, &objp->status);
428 if (__builtin_expect (res, TRUE))
430 res = xdr_nis_name (xdrs, &objp->source);
431 if (__builtin_expect (res, TRUE))
433 res = xdr_bytes (xdrs, (char **) &objp->dir_data.dir_data_val,
434 &objp->dir_data.dir_data_len, ~0);
435 if (__builtin_expect (res, TRUE))
436 res = xdr_bytes (xdrs, (char **) &objp->signature.signature_val,
437 &objp->signature.signature_len, ~0);
440 return res;
443 /* The following functions have prototypes in nis_callback.h. So
444 we make them public */
445 bool_t
446 xdr_obj_p (XDR *xdrs, obj_p *objp)
448 return xdr_pointer (xdrs, (char **)objp, sizeof (nis_object),
449 (xdrproc_t)_xdr_nis_object);
451 libnsl_hidden_nolink_def (xdr_obj_p, GLIBC_2_1)
453 bool_t
454 xdr_cback_data (XDR *xdrs, cback_data *objp)
456 return xdr_array (xdrs, (void *) &objp->entries.entries_val,
457 &objp->entries.entries_len, ~0,
458 sizeof (obj_p), (xdrproc_t) xdr_obj_p);
460 libnsl_hidden_nolink_def (xdr_cback_data, GLIBC_2_1)