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 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>
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. */
29 xdr_nis_attr (XDR
*xdrs
, nis_attr
*objp
)
31 if (!xdr_string (xdrs
, &objp
->zattr_ndx
, ~0))
33 if (!xdr_bytes (xdrs
, (char **) &objp
->zattr_val
.zattr_val_val
,
34 (u_int
*) & objp
->zattr_val
.zattr_val_len
, ~0))
40 _xdr_nis_name (XDR
*xdrs
, nis_name
*objp
)
42 if (!xdr_string (xdrs
, objp
, ~0))
48 xdr_zotypes (XDR
*xdrs
, zotypes
*objp
)
50 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
56 xdr_nstype (XDR
*xdrs
, nstype
*objp
)
58 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
64 xdr_oar_mask (XDR
*xdrs
, oar_mask
*objp
)
66 if (!xdr_u_long (xdrs
, &objp
->oa_rights
))
68 if (!xdr_zotypes (xdrs
, &objp
->oa_otype
))
74 xdr_endpoint (XDR
*xdrs
, endpoint
*objp
)
76 if (!xdr_string (xdrs
, &objp
->uaddr
, ~0))
78 if (!xdr_string (xdrs
, &objp
->family
, ~0))
80 if (!xdr_string (xdrs
, &objp
->proto
, ~0))
86 _xdr_nis_server (XDR
*xdrs
, nis_server
*objp
)
88 if (!_xdr_nis_name (xdrs
, &objp
->name
))
90 if (!xdr_array (xdrs
, (char **) &objp
->ep
.ep_val
, (u_int
*) &objp
->ep
.ep_len
,
91 ~0, sizeof (endpoint
), (xdrproc_t
) xdr_endpoint
))
93 if (!xdr_u_long (xdrs
, &objp
->key_type
))
95 if (!xdr_netobj (xdrs
, &objp
->pkey
))
101 _xdr_directory_obj (XDR
*xdrs
, directory_obj
*objp
)
103 if (!_xdr_nis_name (xdrs
, &objp
->do_name
))
105 if (!xdr_nstype (xdrs
, &objp
->do_type
))
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
))
112 if (!xdr_u_long (xdrs
, &objp
->do_ttl
))
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
))
122 xdr_entry_col (XDR
*xdrs
, entry_col
*objp
)
124 if (!xdr_u_long (xdrs
, &objp
->ec_flags
))
126 if (!xdr_bytes (xdrs
, (char **) &objp
->ec_value
.ec_value_val
,
127 (u_int
*) &objp
->ec_value
.ec_value_len
, ~0))
133 xdr_entry_obj (XDR
*xdrs
, entry_obj
*objp
)
135 if (!xdr_string (xdrs
, &objp
->en_type
, ~0))
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
))
145 xdr_group_obj (XDR
*xdrs
, group_obj
*objp
)
147 if (!xdr_u_long (xdrs
, &objp
->gr_flags
))
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
))
157 xdr_link_obj (XDR
*xdrs
, link_obj
*objp
)
159 if (!xdr_zotypes (xdrs
, &objp
->li_rtype
))
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
))
165 if (!_xdr_nis_name (xdrs
, &objp
->li_name
))
171 xdr_table_col (XDR
*xdrs
, table_col
*objp
)
173 if (!xdr_string (xdrs
, &objp
->tc_name
, 64))
175 if (!xdr_u_long (xdrs
, &objp
->tc_flags
))
177 if (!xdr_u_long (xdrs
, &objp
->tc_rights
))
183 xdr_table_obj (XDR
*xdrs
, table_obj
*objp
)
185 if (!xdr_string (xdrs
, &objp
->ta_type
, 64))
187 if (!xdr_int (xdrs
, &objp
->ta_maxcol
))
189 if (!xdr_u_char (xdrs
, &objp
->ta_sep
))
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
))
195 if (!xdr_string (xdrs
, &objp
->ta_path
, ~0))
201 xdr_objdata (XDR
*xdrs
, objdata
*objp
)
203 if (!xdr_zotypes (xdrs
, &objp
->zo_type
))
205 switch (objp
->zo_type
)
207 case NIS_DIRECTORY_OBJ
:
208 if (!_xdr_directory_obj (xdrs
, &objp
->objdata_u
.di_data
))
212 if (!xdr_group_obj (xdrs
, &objp
->objdata_u
.gr_data
))
216 if (!xdr_table_obj (xdrs
, &objp
->objdata_u
.ta_data
))
220 if (!xdr_entry_obj (xdrs
, &objp
->objdata_u
.en_data
))
224 if (!xdr_link_obj (xdrs
, &objp
->objdata_u
.li_data
))
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))
243 xdr_nis_oid (XDR
*xdrs
, nis_oid
*objp
)
245 if (!xdr_u_long (xdrs
, &objp
->ctime
))
247 if (!xdr_u_long (xdrs
, &objp
->mtime
))
253 _xdr_nis_object (XDR
*xdrs
, nis_object
*objp
)
255 if (!xdr_nis_oid (xdrs
, &objp
->zo_oid
))
257 if (!_xdr_nis_name (xdrs
, &objp
->zo_name
))
259 if (!_xdr_nis_name (xdrs
, &objp
->zo_owner
))
261 if (!_xdr_nis_name (xdrs
, &objp
->zo_group
))
263 if (!_xdr_nis_name (xdrs
, &objp
->zo_domain
))
265 if (!xdr_u_long (xdrs
, &objp
->zo_access
))
267 if (!xdr_u_long (xdrs
, &objp
->zo_ttl
))
269 if (!xdr_objdata (xdrs
, &objp
->zo_data
))
275 _xdr_nis_error (XDR
*xdrs
, nis_error
*objp
)
277 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
283 _xdr_nis_result (XDR
*xdrs
, nis_result
*objp
)
287 if (xdrs
->x_op
== XDR_ENCODE
)
289 if (!_xdr_nis_error (xdrs
, &objp
->status
))
291 if (!xdr_array (xdrs
, (char **) &objp
->objects
.objects_val
,
292 (u_int
*) &objp
->objects
.objects_len
, ~0,
293 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
))
295 if (!xdr_netobj (xdrs
, &objp
->cookie
))
297 buf
= XDR_INLINE (xdrs
, 4 * BYTES_PER_XDR_UNIT
);
300 if (!xdr_u_long (xdrs
, &objp
->zticks
))
302 if (!xdr_u_long (xdrs
, &objp
->dticks
))
304 if (!xdr_u_long (xdrs
, &objp
->aticks
))
306 if (!xdr_u_long (xdrs
, &objp
->cticks
))
311 IXDR_PUT_U_LONG (buf
, objp
->zticks
);
312 IXDR_PUT_U_LONG (buf
, objp
->dticks
);
313 IXDR_PUT_U_LONG (buf
, objp
->aticks
);
314 IXDR_PUT_U_LONG (buf
, objp
->cticks
);
318 else if (xdrs
->x_op
== XDR_DECODE
)
320 if (!_xdr_nis_error (xdrs
, &objp
->status
))
322 if (!xdr_array (xdrs
, (char **) &objp
->objects
.objects_val
,
323 (u_int
*) &objp
->objects
.objects_len
, ~0,
324 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
))
326 if (!xdr_netobj (xdrs
, &objp
->cookie
))
328 buf
= XDR_INLINE (xdrs
, 4 * BYTES_PER_XDR_UNIT
);
331 if (!xdr_u_long (xdrs
, &objp
->zticks
))
333 if (!xdr_u_long (xdrs
, &objp
->dticks
))
335 if (!xdr_u_long (xdrs
, &objp
->aticks
))
337 if (!xdr_u_long (xdrs
, &objp
->cticks
))
342 objp
->zticks
= IXDR_GET_U_LONG (buf
);
343 objp
->dticks
= IXDR_GET_U_LONG (buf
);
344 objp
->aticks
= IXDR_GET_U_LONG (buf
);
345 objp
->cticks
= IXDR_GET_U_LONG (buf
);
350 if (!_xdr_nis_error (xdrs
, &objp
->status
))
352 if (!xdr_array (xdrs
, (char **) &objp
->objects
.objects_val
,
353 (u_int
*) &objp
->objects
.objects_len
, ~0,
354 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
))
356 if (!xdr_netobj (xdrs
, &objp
->cookie
))
358 if (!xdr_u_long (xdrs
, &objp
->zticks
))
360 if (!xdr_u_long (xdrs
, &objp
->dticks
))
362 if (!xdr_u_long (xdrs
, &objp
->aticks
))
364 if (!xdr_u_long (xdrs
, &objp
->cticks
))
370 _xdr_ns_request (XDR
*xdrs
, ns_request
*objp
)
372 if (!_xdr_nis_name (xdrs
, &objp
->ns_name
))
374 if (!xdr_array (xdrs
, (char **) &objp
->ns_object
.ns_object_val
,
375 (u_int
*) &objp
->ns_object
.ns_object_len
, 1,
376 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
))
382 _xdr_ib_request (XDR
*xdrs
, ib_request
*objp
)
384 if (!_xdr_nis_name (xdrs
, &objp
->ibr_name
))
386 if (!xdr_array (xdrs
, (char **) &objp
->ibr_srch
.ibr_srch_val
,
387 (u_int
*) &objp
->ibr_srch
.ibr_srch_len
, ~0,
388 sizeof (nis_attr
), (xdrproc_t
) xdr_nis_attr
))
390 if (!xdr_u_long (xdrs
, &objp
->ibr_flags
))
392 if (!xdr_array (xdrs
, (char **) &objp
->ibr_obj
.ibr_obj_val
,
393 (u_int
*) &objp
->ibr_obj
.ibr_obj_len
, 1,
394 sizeof (nis_object
), (xdrproc_t
) _xdr_nis_object
))
396 if (!xdr_array (xdrs
, (char **) &objp
->ibr_cbhost
.ibr_cbhost_val
,
397 (u_int
*) &objp
->ibr_cbhost
.ibr_cbhost_len
, 1,
398 sizeof (nis_server
), (xdrproc_t
) _xdr_nis_server
))
400 if (!xdr_u_long (xdrs
, &objp
->ibr_bufsize
))
402 if (!xdr_netobj (xdrs
, &objp
->ibr_cookie
))
408 _xdr_ping_args (XDR
*xdrs
, ping_args
*objp
)
410 if (!_xdr_nis_name (xdrs
, &objp
->dir
))
412 if (!xdr_u_long (xdrs
, &objp
->stamp
))
418 _xdr_cp_result (XDR
*xdrs
, cp_result
*objp
)
420 if (!_xdr_nis_error (xdrs
, &objp
->cp_status
))
422 if (!xdr_u_long (xdrs
, &objp
->cp_zticks
))
424 if (!xdr_u_long (xdrs
, &objp
->cp_dticks
))
430 _xdr_nis_tag (XDR
*xdrs
, nis_tag
*objp
)
432 if (!xdr_u_long (xdrs
, &objp
->tag_type
))
436 if (!xdr_string (xdrs
, &objp
->tag_val
, 1024))
444 _xdr_nis_taglist (XDR
*xdrs
, nis_taglist
*objp
)
446 if (!xdr_array (xdrs
, (char **) &objp
->tags
.tags_val
,
447 (u_int
*) &objp
->tags
.tags_len
, ~0, sizeof (nis_tag
),
448 (xdrproc_t
) _xdr_nis_tag
))
454 _xdr_fd_args (XDR
*xdrs
, fd_args
*objp
)
456 if (!_xdr_nis_name (xdrs
, &objp
->dir_name
))
458 if (!_xdr_nis_name (xdrs
, &objp
->requester
))
464 _xdr_fd_result (XDR
*xdrs
, fd_result
*objp
)
466 if (!_xdr_nis_error (xdrs
, &objp
->status
))
468 if (!_xdr_nis_name (xdrs
, &objp
->source
))
470 if (!xdr_bytes (xdrs
, (char **) &objp
->dir_data
.dir_data_val
,
471 (u_int
*) &objp
->dir_data
.dir_data_len
, ~0))
473 if (!xdr_bytes (xdrs
, (char **) &objp
->signature
.signature_val
,
474 (u_int
*) &objp
->signature
.signature_len
, ~0))
479 /* The following functions have prototypes in nis_callback.h. So
480 we make them public */
482 xdr_obj_p (XDR
*xdrs
, obj_p
*objp
)
484 if (!xdr_pointer (xdrs
, (char **)objp
, sizeof (nis_object
),
485 (xdrproc_t
)_xdr_nis_object
))
491 xdr_cback_data (XDR
*xdrs
, cback_data
*objp
)
493 if (!xdr_array (xdrs
, (char **)&objp
->entries
.entries_val
,
494 (u_int
*) &objp
->entries
.entries_len
, ~0,
495 sizeof (obj_p
), (xdrproc_t
) xdr_obj_p
))