2 * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior written
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
18 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 static char *rcsid = "$FreeBSD: src/lib/libc/yp/xdryp.c,v 1.9.2.1 2002/02/15 00:46:53 des Exp $";
35 #include <rpcsvc/yp.h>
39 extern int (*ypresp_allfn)();
40 extern void *ypresp_data;
43 * I'm leaving the xdr_datum() function in purely for backwards
44 * compatibility. yplib.c doesn't actually use it, but it's listed
45 * in yp_prot.h as being available, so it's probably a good idea to
46 * leave it in in case somebody goes looking for it.
58 if (!xdr_bytes(xdrs, (char **)&objp->dptr, (u_int *)&objp->dsize, YPMAXRECORD)) {
65 xdr_ypresp_all_seq(xdrs, objp)
69 struct ypresp_all out;
74 bzero(&out, sizeof out);
76 if (!xdr_ypresp_all(xdrs, &out)) {
77 xdr_free(xdr_ypresp_all, (char *)&out);
82 xdr_free(xdr_ypresp_all, (char *)&out);
86 status = out.ypresp_all_u.val.stat;
89 key = (char *)malloc(out.ypresp_all_u.val.key.keydat_len + 1);
90 bcopy(out.ypresp_all_u.val.key.keydat_val, key,
91 out.ypresp_all_u.val.key.keydat_len);
92 key[out.ypresp_all_u.val.key.keydat_len] = '\0';
93 val = (char *)malloc(out.ypresp_all_u.val.val.valdat_len + 1);
94 bcopy(out.ypresp_all_u.val.val.valdat_val, val,
95 out.ypresp_all_u.val.val.valdat_len);
96 val[out.ypresp_all_u.val.val.valdat_len] = '\0';
97 xdr_free(xdr_ypresp_all, (char *)&out);
99 r = (*ypresp_allfn)(status,
100 key, out.ypresp_all_u.val.key.keydat_len,
101 val, out.ypresp_all_u.val.val.valdat_len,
110 xdr_free(xdr_ypresp_all, (char *)&out);
114 xdr_free(xdr_ypresp_all, (char *)&out);