summaryrefslogtreecommitdiffstats
path: root/freebsd/lib/libc/xdr/xdr.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-10-07 15:10:20 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-01-10 09:53:31 +0100
commitc40e45b75eb76d79a05c7fa85c1fa9b5c728a12f (patch)
treead4f2519067709f00ab98b3c591186c26dc3a21f /freebsd/lib/libc/xdr/xdr.c
parentuserspace-header-gen.py: Simplify program ports (diff)
downloadrtems-libbsd-c40e45b75eb76d79a05c7fa85c1fa9b5c728a12f.tar.bz2
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
Diffstat (limited to 'freebsd/lib/libc/xdr/xdr.c')
-rw-r--r--freebsd/lib/libc/xdr/xdr.c186
1 files changed, 63 insertions, 123 deletions
diff --git a/freebsd/lib/libc/xdr/xdr.c b/freebsd/lib/libc/xdr/xdr.c
index 561f179b..c529bb95 100644
--- a/freebsd/lib/libc/xdr/xdr.c
+++ b/freebsd/lib/libc/xdr/xdr.c
@@ -2,33 +2,35 @@
/* $NetBSD: xdr.c,v 1.22 2000/07/06 03:10:35 christos Exp $ */
-/*
- * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
- * unrestricted use provided that this legend is included on all tape
- * media and as a part of the software program in whole or part. Users
- * may copy or modify Sun RPC without charge, but are not authorized
- * to license or distribute it to anyone else except as part of a product or
- * program developed by the user.
- *
- * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
- * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- *
- * Sun RPC is provided with no support and without any obligation on the
- * part of Sun Microsystems, Inc. to assist in its use, correction,
- * modification or enhancement.
+/*-
+ * Copyright (c) 2010, Oracle America, Inc.
*
- * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
- * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
- * OR ANY PART THEREOF.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * In no event will Sun Microsystems, Inc. be liable for any lost revenue
- * or profits or other special, indirect and consequential damages, even if
- * Sun has been advised of the possibility of such damages.
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name of the "Oracle America, Inc." nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
*
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
@@ -41,8 +43,6 @@ __FBSDID("$FreeBSD$");
/*
* xdr.c, Generic XDR routines implementation.
*
- * Copyright (C) 1986, Sun Microsystems, Inc.
- *
* These are the "generic" xdr routines used to serialize and de-serialize
* most common data items. See xdr.h for more info on the interface to
* xdr.
@@ -78,9 +78,7 @@ static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 };
* Not a filter, but a convenient utility nonetheless
*/
void
-xdr_free(proc, objp)
- xdrproc_t proc;
- void *objp;
+xdr_free(xdrproc_t proc, void *objp)
{
XDR x;
@@ -103,9 +101,7 @@ xdr_void(void)
* XDR integers
*/
bool_t
-xdr_int(xdrs, ip)
- XDR *xdrs;
- int *ip;
+xdr_int(XDR *xdrs, int *ip)
{
long l;
@@ -133,9 +129,7 @@ xdr_int(xdrs, ip)
* XDR unsigned integers
*/
bool_t
-xdr_u_int(xdrs, up)
- XDR *xdrs;
- u_int *up;
+xdr_u_int(XDR *xdrs, u_int *up)
{
u_long l;
@@ -165,9 +159,7 @@ xdr_u_int(xdrs, up)
* same as xdr_u_long - open coded to save a proc call!
*/
bool_t
-xdr_long(xdrs, lp)
- XDR *xdrs;
- long *lp;
+xdr_long(XDR *xdrs, long *lp)
{
switch (xdrs->x_op) {
case XDR_ENCODE:
@@ -186,9 +178,7 @@ xdr_long(xdrs, lp)
* same as xdr_long - open coded to save a proc call!
*/
bool_t
-xdr_u_long(xdrs, ulp)
- XDR *xdrs;
- u_long *ulp;
+xdr_u_long(XDR *xdrs, u_long *ulp)
{
switch (xdrs->x_op) {
case XDR_ENCODE:
@@ -208,9 +198,7 @@ xdr_u_long(xdrs, ulp)
* same as xdr_u_int32_t - open coded to save a proc call!
*/
bool_t
-xdr_int32_t(xdrs, int32_p)
- XDR *xdrs;
- int32_t *int32_p;
+xdr_int32_t(XDR *xdrs, int32_t *int32_p)
{
long l;
@@ -239,9 +227,7 @@ xdr_int32_t(xdrs, int32_p)
* same as xdr_int32_t - open coded to save a proc call!
*/
bool_t
-xdr_u_int32_t(xdrs, u_int32_p)
- XDR *xdrs;
- u_int32_t *u_int32_p;
+xdr_u_int32_t(XDR *xdrs, u_int32_t *u_int32_p)
{
u_long l;
@@ -270,9 +256,7 @@ xdr_u_int32_t(xdrs, u_int32_p)
* same as xdr_int32_t - open coded to save a proc call!
*/
bool_t
-xdr_uint32_t(xdrs, u_int32_p)
- XDR *xdrs;
- uint32_t *u_int32_p;
+xdr_uint32_t(XDR *xdrs, uint32_t *u_int32_p)
{
u_long l;
@@ -300,9 +284,7 @@ xdr_uint32_t(xdrs, u_int32_p)
* XDR short integers
*/
bool_t
-xdr_short(xdrs, sp)
- XDR *xdrs;
- short *sp;
+xdr_short(XDR *xdrs, short *sp)
{
long l;
@@ -330,9 +312,7 @@ xdr_short(xdrs, sp)
* XDR unsigned short integers
*/
bool_t
-xdr_u_short(xdrs, usp)
- XDR *xdrs;
- u_short *usp;
+xdr_u_short(XDR *xdrs, u_short *usp)
{
u_long l;
@@ -361,9 +341,7 @@ xdr_u_short(xdrs, usp)
* XDR 16-bit integers
*/
bool_t
-xdr_int16_t(xdrs, int16_p)
- XDR *xdrs;
- int16_t *int16_p;
+xdr_int16_t(XDR *xdrs, int16_t *int16_p)
{
long l;
@@ -391,9 +369,7 @@ xdr_int16_t(xdrs, int16_p)
* XDR unsigned 16-bit integers
*/
bool_t
-xdr_u_int16_t(xdrs, u_int16_p)
- XDR *xdrs;
- u_int16_t *u_int16_p;
+xdr_u_int16_t(XDR *xdrs, u_int16_t *u_int16_p)
{
u_long l;
@@ -421,9 +397,7 @@ xdr_u_int16_t(xdrs, u_int16_p)
* XDR unsigned 16-bit integers
*/
bool_t
-xdr_uint16_t(xdrs, u_int16_p)
- XDR *xdrs;
- uint16_t *u_int16_p;
+xdr_uint16_t(XDR *xdrs, uint16_t *u_int16_p)
{
u_long l;
@@ -452,9 +426,7 @@ xdr_uint16_t(xdrs, u_int16_p)
* XDR a char
*/
bool_t
-xdr_char(xdrs, cp)
- XDR *xdrs;
- char *cp;
+xdr_char(XDR *xdrs, char *cp)
{
int i;
@@ -470,9 +442,7 @@ xdr_char(xdrs, cp)
* XDR an unsigned char
*/
bool_t
-xdr_u_char(xdrs, cp)
- XDR *xdrs;
- u_char *cp;
+xdr_u_char(XDR *xdrs, u_char *cp)
{
u_int u;
@@ -488,9 +458,7 @@ xdr_u_char(xdrs, cp)
* XDR booleans
*/
bool_t
-xdr_bool(xdrs, bp)
- XDR *xdrs;
- bool_t *bp;
+xdr_bool(XDR *xdrs, bool_t *bp)
{
long lb;
@@ -518,9 +486,7 @@ xdr_bool(xdrs, bp)
* XDR enumerations
*/
bool_t
-xdr_enum(xdrs, ep)
- XDR *xdrs;
- enum_t *ep;
+xdr_enum(XDR *xdrs, enum_t *ep)
{
/*
* enums are treated as ints
@@ -542,10 +508,7 @@ xdr_enum(xdrs, ep)
* cp points to the opaque object and cnt gives the byte length.
*/
bool_t
-xdr_opaque(xdrs, cp, cnt)
- XDR *xdrs;
- caddr_t cp;
- u_int cnt;
+xdr_opaque(XDR *xdrs, caddr_t cp, u_int cnt)
{
u_int rndup;
static int crud[BYTES_PER_XDR_UNIT];
@@ -594,11 +557,7 @@ xdr_opaque(xdrs, cp, cnt)
* If *cpp is NULL maxsize bytes are allocated
*/
bool_t
-xdr_bytes(xdrs, cpp, sizep, maxsize)
- XDR *xdrs;
- char **cpp;
- u_int *sizep;
- u_int maxsize;
+xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, u_int maxsize)
{
char *sp = *cpp; /* sp is the actual string pointer */
u_int nodesize;
@@ -650,9 +609,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize)
* Implemented here due to commonality of the object.
*/
bool_t
-xdr_netobj(xdrs, np)
- XDR *xdrs;
- struct netobj *np;
+xdr_netobj(XDR *xdrs, struct netobj *np)
{
return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ));
@@ -670,12 +627,14 @@ xdr_netobj(xdrs, np)
* If there is no specific or default routine an error is returned.
*/
bool_t
-xdr_union(xdrs, dscmp, unp, choices, dfault)
- XDR *xdrs;
- enum_t *dscmp; /* enum to decide which arm to work on */
- char *unp; /* the union itself */
- const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */
- xdrproc_t dfault; /* default xdr routine */
+xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, const struct xdr_discrim *choices, xdrproc_t dfault)
+/*
+ * XDR *xdrs;
+ * enum_t *dscmp; // enum to decide which arm to work on
+ * char *unp; // the union itself
+ * const struct xdr_discrim *choices; // [value, xdr proc] for each arm
+ * xdrproc_t dfault; // default xdr routine
+ */
{
enum_t dscm;
@@ -719,10 +678,7 @@ xdr_union(xdrs, dscmp, unp, choices, dfault)
* of the string as specified by a protocol.
*/
bool_t
-xdr_string(xdrs, cpp, maxsize)
- XDR *xdrs;
- char **cpp;
- u_int maxsize;
+xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
{
char *sp = *cpp; /* sp is the actual string pointer */
u_int size;
@@ -786,9 +742,7 @@ xdr_string(xdrs, cpp, maxsize)
* routines like clnt_call
*/
bool_t
-xdr_wrapstring(xdrs, cpp)
- XDR *xdrs;
- char **cpp;
+xdr_wrapstring(XDR *xdrs, char **cpp)
{
return xdr_string(xdrs, cpp, LASTUNSIGNED);
}
@@ -805,9 +759,7 @@ xdr_wrapstring(xdrs, cpp)
* XDR 64-bit integers
*/
bool_t
-xdr_int64_t(xdrs, llp)
- XDR *xdrs;
- int64_t *llp;
+xdr_int64_t(XDR *xdrs, int64_t *llp)
{
u_long ul[2];
@@ -838,9 +790,7 @@ xdr_int64_t(xdrs, llp)
* XDR unsigned 64-bit integers
*/
bool_t
-xdr_u_int64_t(xdrs, ullp)
- XDR *xdrs;
- u_int64_t *ullp;
+xdr_u_int64_t(XDR *xdrs, u_int64_t *ullp)
{
u_long ul[2];
@@ -870,9 +820,7 @@ xdr_u_int64_t(xdrs, ullp)
* XDR unsigned 64-bit integers
*/
bool_t
-xdr_uint64_t(xdrs, ullp)
- XDR *xdrs;
- uint64_t *ullp;
+xdr_uint64_t(XDR *xdrs, uint64_t *ullp)
{
u_long ul[2];
@@ -903,9 +851,7 @@ xdr_uint64_t(xdrs, ullp)
* XDR hypers
*/
bool_t
-xdr_hyper(xdrs, llp)
- XDR *xdrs;
- longlong_t *llp;
+xdr_hyper(XDR *xdrs, longlong_t *llp)
{
/*
@@ -920,9 +866,7 @@ xdr_hyper(xdrs, llp)
* XDR unsigned hypers
*/
bool_t
-xdr_u_hyper(xdrs, ullp)
- XDR *xdrs;
- u_longlong_t *ullp;
+xdr_u_hyper(XDR *xdrs, u_longlong_t *ullp)
{
/*
@@ -937,9 +881,7 @@ xdr_u_hyper(xdrs, ullp)
* XDR longlong_t's
*/
bool_t
-xdr_longlong_t(xdrs, llp)
- XDR *xdrs;
- longlong_t *llp;
+xdr_longlong_t(XDR *xdrs, longlong_t *llp)
{
/*
@@ -954,9 +896,7 @@ xdr_longlong_t(xdrs, llp)
* XDR u_longlong_t's
*/
bool_t
-xdr_u_longlong_t(xdrs, ullp)
- XDR *xdrs;
- u_longlong_t *ullp;
+xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
{
/*