2 * SPDX-License-Identifier: BSD-3-Clause
4 * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote
16 * products derived from this software without specific prior written
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
36 #include <rpcsvc/yp.h>
40 extern int (*ypresp_allfn)();
41 extern void *ypresp_data;
44 * I'm leaving the xdr_datum() function in purely for backwards
45 * compatibility. yplib.c doesn't actually use it, but it's listed
46 * in yp_prot.h as being available, so it's probably a good idea to
47 * leave it in case somebody goes looking for it.
55 xdr_datum(XDR *xdrs, datum *objp)
57 if (!xdr_bytes(xdrs, (char **)&objp->dptr, (u_int *)&objp->dsize, YPMAXRECORD)) {
64 xdr_ypresp_all_seq(XDR *xdrs, u_long *objp)
66 struct ypresp_all out;
71 bzero(&out, sizeof out);
73 if (!xdr_ypresp_all(xdrs, &out)) {
74 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
79 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
83 status = out.ypresp_all_u.val.stat;
86 key = (char *)malloc(out.ypresp_all_u.val.key.keydat_len + 1);
88 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
92 bcopy(out.ypresp_all_u.val.key.keydat_val, key,
93 out.ypresp_all_u.val.key.keydat_len);
94 key[out.ypresp_all_u.val.key.keydat_len] = '\0';
95 val = (char *)malloc(out.ypresp_all_u.val.val.valdat_len + 1);
98 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
102 bcopy(out.ypresp_all_u.val.val.valdat_val, val,
103 out.ypresp_all_u.val.val.valdat_len);
104 val[out.ypresp_all_u.val.val.valdat_len] = '\0';
105 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
107 r = (*ypresp_allfn)(status,
108 key, out.ypresp_all_u.val.key.keydat_len,
109 val, out.ypresp_all_u.val.val.valdat_len,
118 xdr_free((xdrproc_t)xdr_ypresp_all, &out);
122 xdr_free((xdrproc_t)xdr_ypresp_all, &out);