diff options
Diffstat (limited to 'lib/libc/xdr')
-rw-r--r-- | lib/libc/xdr/Makefile.inc | 15 | ||||
-rw-r--r-- | lib/libc/xdr/xdr.3 | 87 | ||||
-rw-r--r-- | lib/libc/xdr/xdr.c | 321 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_array.c | 50 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_float.c | 89 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_mem.c | 136 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_rec.c | 256 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_reference.c | 31 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_sizeof.c | 4 | ||||
-rw-r--r-- | lib/libc/xdr/xdr_stdio.c | 63 |
10 files changed, 646 insertions, 406 deletions
diff --git a/lib/libc/xdr/Makefile.inc b/lib/libc/xdr/Makefile.inc index 1837ef8..62ab805 100644 --- a/lib/libc/xdr/Makefile.inc +++ b/lib/libc/xdr/Makefile.inc @@ -3,12 +3,19 @@ .PATH: ${.CURDIR}/../libc/xdr ${.CURDIR}/. SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c xdr_sizeof.c + xdr_rec.c xdr_reference.c xdr_stdio.c .if ${LIB} == "c" MAN3+= xdr.3 -MLINKS+= xdr.3 xdr_array.3 \ +MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \ + rpc_xdr.3 xdr_authsys_parms.3 \ + rpc_xdr.3 xdr_callhdr.3 \ + rpc_xdr.3 xdr_callmsg.3 \ + rpc_xdr.3 xdr_opaque_auth.3 \ + rpc_xdr.3 xdr_rejected_reply.3 \ + rpc_xdr.3 xdr_replymsg.3 \ + xdr.3 xdr_array.3 \ xdr.3 xdr_bool.3 \ xdr.3 xdr_bytes.3 \ xdr.3 xdr_char.3 \ @@ -32,6 +39,8 @@ MLINKS+= xdr.3 xdr_array.3 \ xdr.3 xdr_setpos.3 \ xdr.3 xdr_short.3 \ xdr.3 xdrstdio_create.3 \ + xdr.3 xdr_short.3 \ + xdr.3 xdrstdio_create.3 \ xdr.3 xdr_string.3 \ xdr.3 xdr_u_char.3 \ xdr.3 xdr_u_long.3 \ @@ -39,5 +48,5 @@ MLINKS+= xdr.3 xdr_array.3 \ xdr.3 xdr_union.3 \ xdr.3 xdr_vector.3 \ xdr.3 xdr_void.3 \ - xdr.3 xdr_wrapstring.3 + xdr.3 xdr_wrapstring.3 .endif diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3 index 49266e5..35554a7 100644 --- a/lib/libc/xdr/xdr.3 +++ b/lib/libc/xdr/xdr.3 @@ -5,7 +5,44 @@ .Dt XDR 3 .Os .Sh NAME -.Nm xdr +.Nm xdr , +.Nm xdr_array , +.Nm xdr_bool , +.Nm xdr_bytes , +.Nm xdr_char , +.Nm xdr_destroy , +.Nm xdr_double , +.Nm xdr_enum , +.Nm xdr_float , +.Nm xdr_free , +.Nm xdr_getpos , +.Nm xdr_hyper , +.Nm xdr_inline , +.Nm xdr_int , +.Nm xdr_long , +.Nm xdr_longlong_t , +.Nm xdrmem_create , +.Nm xdr_opaque , +.Nm xdr_pointer , +.Nm xdrrec_create , +.Nm xdrrec_endofrecord , +.Nm xdrrec_eof , +.Nm xdrrec_skiprecord , +.Nm xdr_reference , +.Nm xdr_setpos , +.Nm xdr_short , +.Nm xdrstdio_create , +.Nm xdr_string , +.Nm xdr_u_char , +.Nm xdr_u_hyper , +.Nm xdr_u_int , +.Nm xdr_u_long , +.Nm xdr_u_longlong_t , +.Nm xdr_u_short , +.Nm xdr_union , +.Nm xdr_vector , +.Nm xdr_void , +.Nm xdr_wrapstring .Nd "library routines for external data representation" .Sh LIBRARY .Lb libc @@ -212,6 +249,17 @@ although the stream instances need not guarantee this. .Pp .It Xo +.Ft int +.Xc +.It Xo +.Fn xdr_hyper "XDR *xdrs" "longlong_t *llp" +.Xc +A filter primitive that translates between ANSI C +.Vt "long long" +integers and their external representations. +This routine returns one if it succeeds, zero otherwise. +.Pp +.It Xo .Ft "long *" .Xc .It Xo @@ -262,6 +310,17 @@ integers and their external representations. This routine returns one if it succeeds, zero otherwise. .Pp .It Xo +.Ft int +.Xc +.It Xo +.Fn xdr_longlong_t "XDR *xdrs" "longlong_t *llp" +.Xc +A filter primitive that translates between ANSI C +.Vt "long long" +integers and their external representations. +This routine returns one if it succeeds, zero otherwise. +.Pp +.It Xo .Ft void .Xc .It Xo @@ -568,6 +627,19 @@ This routine returns one if it succeeds, zero otherwise. .Ft int .Xc .It Xo +.Fn xdr_u_hyper "XDR *xdrs" "u_longlong_t *ullp" +.Xc +A filter primitive that translates between +.Vt unsigned +ANSI C +.Vt long long +integers and their external representations. +This routine returns one if it succeeds, zero otherwise. +.Pp +.It Xo +.Ft int +.Xc +.It Xo .Fn xdr_u_int "XDR *xdrs" "unsigned *up" .Xc .Pp @@ -592,6 +664,19 @@ This routine returns one if it succeeds, zero otherwise. .Ft int .Xc .It Xo +.Fn xdr_u_longlong_t "XDR *xdrs" "u_longlong_t *ullp" +.Xc +A filter primitive that translates between +.Vt unsigned +ANSI C +.Vt "long long" +integers and their external representations. +This routine returns one if it succeeds, zero otherwise. +.Pp +.It Xo +.Ft int +.Xc +.It Xo .Fn xdr_u_short "XDR *xdrs" "unsigned short *usp" .Xc .Pp diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c index 50b68fb..113ac3c 100644 --- a/lib/libc/xdr/xdr.c +++ b/lib/libc/xdr/xdr.c @@ -1,3 +1,5 @@ +/* $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 @@ -27,6 +29,7 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr.c 1.35 87/08/12";*/ /*static char *sccsid = "from: @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";*/ @@ -43,12 +46,18 @@ static char *rcsid = "$FreeBSD$"; * xdr. */ +#include "namespace.h" +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <rpc/types.h> #include <rpc/xdr.h> +#include "un-namespace.h" + +typedef quad_t longlong_t; /* ANSI long long type */ +typedef u_quad_t u_longlong_t; /* ANSI unsigned long long type */ /* * constants specific to the xdr "protocol" @@ -60,7 +69,7 @@ static char *rcsid = "$FreeBSD$"; /* * for unit alignment */ -static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; +static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; /* * Free a data structure using XDR @@ -72,7 +81,7 @@ xdr_free(proc, objp) char *objp; { XDR x; - + x.x_op = XDR_FREE; (*proc)(&x, objp); } @@ -116,6 +125,7 @@ xdr_int(xdrs, ip) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -145,6 +155,7 @@ xdr_u_int(xdrs, up) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -155,7 +166,7 @@ xdr_u_int(xdrs, up) */ bool_t xdr_long(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { switch (xdrs->x_op) { @@ -166,7 +177,7 @@ xdr_long(xdrs, lp) case XDR_FREE: return (TRUE); } - + /* NOTREACHED */ return (FALSE); } @@ -176,7 +187,7 @@ xdr_long(xdrs, lp) */ bool_t xdr_u_long(xdrs, ulp) - register XDR *xdrs; + XDR *xdrs; u_long *ulp; { switch (xdrs->x_op) { @@ -187,6 +198,7 @@ xdr_u_long(xdrs, ulp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -197,7 +209,7 @@ xdr_u_long(xdrs, ulp) */ bool_t xdr_int32_t(xdrs, int32_p) - register XDR *xdrs; + XDR *xdrs; int32_t *int32_p; { long l; @@ -218,6 +230,7 @@ xdr_int32_t(xdrs, int32_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -227,7 +240,7 @@ xdr_int32_t(xdrs, int32_p) */ bool_t xdr_u_int32_t(xdrs, u_int32_p) - register XDR *xdrs; + XDR *xdrs; u_int32_t *u_int32_p; { u_long l; @@ -248,71 +261,7 @@ xdr_u_int32_t(xdrs, u_int32_p) case XDR_FREE: return (TRUE); } - return (FALSE); -} - -/* - * XDR 64-bit integers - */ -bool_t -xdr_int64_t(xdrs, int64_p) - register XDR *xdrs; - int64_t *int64_p; -{ - u_long ul[2]; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - ul[0] = (u_long)((u_int64_t)*int64_p >> 32) & 0xffffffff; - ul[1] = (u_long)((u_int64_t)*int64_p) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *int64_p = (int64_t) - (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); - return (TRUE); - case XDR_FREE: - return (TRUE); - } - return (FALSE); -} - -/* - * XDR unsigned 64-bit integers - */ -bool_t -xdr_u_int64_t(xdrs, uint64_p) - register XDR *xdrs; - u_int64_t *uint64_p; -{ - u_long ul[2]; - - switch (xdrs->x_op) { - - case XDR_ENCODE: - ul[0] = (u_long)(*uint64_p >> 32) & 0xffffffff; - ul[1] = (u_long)(*uint64_p) & 0xffffffff; - if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - return (XDR_PUTLONG(xdrs, (long *)&ul[1])); - - case XDR_DECODE: - if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) - return (FALSE); - if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) - return (FALSE); - *uint64_p = (u_int64_t) - (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); - return (TRUE); - case XDR_FREE: - return (TRUE); - } + /* NOTREACHED */ return (FALSE); } @@ -322,7 +271,7 @@ xdr_u_int64_t(xdrs, uint64_p) */ bool_t xdr_short(xdrs, sp) - register XDR *xdrs; + XDR *xdrs; short *sp; { long l; @@ -343,6 +292,7 @@ xdr_short(xdrs, sp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -351,7 +301,7 @@ xdr_short(xdrs, sp) */ bool_t xdr_u_short(xdrs, usp) - register XDR *xdrs; + XDR *xdrs; u_short *usp; { u_long l; @@ -372,6 +322,7 @@ xdr_u_short(xdrs, usp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -381,7 +332,7 @@ xdr_u_short(xdrs, usp) */ bool_t xdr_int16_t(xdrs, int16_p) - register XDR *xdrs; + XDR *xdrs; int16_t *int16_p; { long l; @@ -402,6 +353,7 @@ xdr_int16_t(xdrs, int16_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -410,7 +362,7 @@ xdr_int16_t(xdrs, int16_p) */ bool_t xdr_u_int16_t(xdrs, u_int16_p) - register XDR *xdrs; + XDR *xdrs; u_int16_t *u_int16_p; { u_long l; @@ -431,6 +383,7 @@ xdr_u_int16_t(xdrs, u_int16_p) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -476,7 +429,7 @@ xdr_u_char(xdrs, cp) */ bool_t xdr_bool(xdrs, bp) - register XDR *xdrs; + XDR *xdrs; bool_t *bp; { long lb; @@ -497,6 +450,7 @@ xdr_bool(xdrs, bp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -508,26 +462,20 @@ xdr_enum(xdrs, ep) XDR *xdrs; enum_t *ep; { -#ifndef lint enum sizecheck { SIZEVAL }; /* used to find the size of an enum */ /* * enums are treated as ints */ - if (sizeof (enum sizecheck) == sizeof (long)) { - return (xdr_long(xdrs, (long *)ep)); - } else if (sizeof (enum sizecheck) == sizeof (int)) { - return (xdr_int(xdrs, (int *)ep)); - } else if (sizeof (enum sizecheck) == sizeof (short)) { - return (xdr_short(xdrs, (short *)ep)); + /* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) { + return (xdr_long(xdrs, (long *)(void *)ep)); + } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) { + return (xdr_int(xdrs, (int *)(void *)ep)); + } else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) { + return (xdr_short(xdrs, (short *)(void *)ep)); } else { return (FALSE); } -#else - (void) (xdr_short(xdrs, (short *)ep)); - (void) (xdr_int(xdrs, (int *)ep)); - return (xdr_long(xdrs, (long *)ep)); -#endif } /* @@ -537,12 +485,12 @@ xdr_enum(xdrs, ep) */ bool_t xdr_opaque(xdrs, cp, cnt) - register XDR *xdrs; + XDR *xdrs; caddr_t cp; - register u_int cnt; + u_int cnt; { - register u_int rndup; - static crud[BYTES_PER_XDR_UNIT]; + u_int rndup; + static int crud[BYTES_PER_XDR_UNIT]; /* * if no data we are done @@ -563,7 +511,7 @@ xdr_opaque(xdrs, cp, cnt) } if (rndup == 0) return (TRUE); - return (XDR_GETBYTES(xdrs, (caddr_t)crud, rndup)); + return (XDR_GETBYTES(xdrs, (caddr_t)(void *)crud, rndup)); } if (xdrs->x_op == XDR_ENCODE) { @@ -589,13 +537,13 @@ xdr_opaque(xdrs, cp, cnt) */ bool_t xdr_bytes(xdrs, cpp, sizep, maxsize) - register XDR *xdrs; + XDR *xdrs; char **cpp; - register u_int *sizep; + u_int *sizep; u_int maxsize; { - register char *sp = *cpp; /* sp is the actual string pointer */ - register u_int nodesize; + char *sp = *cpp; /* sp is the actual string pointer */ + u_int nodesize; /* * first deal with the length since xdr bytes are counted @@ -618,13 +566,13 @@ xdr_bytes(xdrs, cpp, sizep, maxsize) return (TRUE); } if (sp == NULL) { - *cpp = sp = (char *)mem_alloc(nodesize); + *cpp = sp = mem_alloc(nodesize); } if (sp == NULL) { - (void) fprintf(stderr, "xdr_bytes: out of memory\n"); + warnx("xdr_bytes: out of memory"); return (FALSE); } - /* fall into ... */ + /* FALLTHROUGH */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, nodesize)); @@ -636,6 +584,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize) } return (TRUE); } + /* NOTREACHED */ return (FALSE); } @@ -664,13 +613,13 @@ xdr_netobj(xdrs, np) */ bool_t xdr_union(xdrs, dscmp, unp, choices, dfault) - register XDR *xdrs; + XDR *xdrs; enum_t *dscmp; /* enum to decide which arm to work on */ char *unp; /* the union itself */ - struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ + const struct xdr_discrim *choices; /* [value, xdr proc] for each arm */ xdrproc_t dfault; /* default xdr routine */ { - register enum_t dscm; + enum_t dscm; /* * we deal with the discriminator; it's an enum @@ -686,14 +635,14 @@ xdr_union(xdrs, dscmp, unp, choices, dfault) */ for (; choices->proc != NULL_xdrproc_t; choices++) { if (choices->value == dscm) - return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); + return ((*(choices->proc))(xdrs, unp)); } /* * no match - execute the default xdr routine if there is one */ return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault)(xdrs, unp, LASTUNSIGNED)); + (*dfault)(xdrs, unp)); } @@ -713,11 +662,11 @@ xdr_union(xdrs, dscmp, unp, choices, dfault) */ bool_t xdr_string(xdrs, cpp, maxsize) - register XDR *xdrs; + XDR *xdrs; char **cpp; u_int maxsize; { - register char *sp = *cpp; /* sp is the actual string pointer */ + char *sp = *cpp; /* sp is the actual string pointer */ u_int size; u_int nodesize; @@ -729,10 +678,12 @@ xdr_string(xdrs, cpp, maxsize) if (sp == NULL) { return(TRUE); /* already free */ } - /* fall through... */ + /* FALLTHROUGH */ case XDR_ENCODE: size = strlen(sp); break; + case XDR_DECODE: + break; } if (! xdr_u_int(xdrs, &size)) { return (FALSE); @@ -752,13 +703,13 @@ xdr_string(xdrs, cpp, maxsize) return (TRUE); } if (sp == NULL) - *cpp = sp = (char *)mem_alloc(nodesize); + *cpp = sp = mem_alloc(nodesize); if (sp == NULL) { - (void) fprintf(stderr, "xdr_string: out of memory\n"); + warnx("xdr_string: out of memory"); return (FALSE); } sp[size] = 0; - /* fall into ... */ + /* FALLTHROUGH */ case XDR_ENCODE: return (xdr_opaque(xdrs, sp, size)); @@ -768,11 +719,12 @@ xdr_string(xdrs, cpp, maxsize) *cpp = NULL; return (TRUE); } + /* NOTREACHED */ return (FALSE); } -/* - * Wrapper for xdr_string that can be called directly from +/* + * Wrapper for xdr_string that can be called directly from * routines like clnt_call */ bool_t @@ -782,3 +734,144 @@ xdr_wrapstring(xdrs, cpp) { return xdr_string(xdrs, cpp, LASTUNSIGNED); } + +/* + * NOTE: xdr_hyper(), xdr_u_hyper(), xdr_longlong_t(), and xdr_u_longlong_t() + * are in the "non-portable" section because they require that a `long long' + * be a 64-bit type. + * + * --thorpej@netbsd.org, November 30, 1999 + */ + +/* + * XDR 64-bit integers + */ +bool_t +xdr_int64_t(xdrs, llp) + XDR *xdrs; + int64_t *llp; +{ + u_long ul[2]; + + switch (xdrs->x_op) { + case XDR_ENCODE: + ul[0] = (u_long)((u_int64_t)*llp >> 32) & 0xffffffff; + ul[1] = (u_long)((u_int64_t)*llp) & 0xffffffff; + if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) + return (FALSE); + return (XDR_PUTLONG(xdrs, (long *)&ul[1])); + case XDR_DECODE: + if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) + return (FALSE); + if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) + return (FALSE); + *llp = (int64_t) + (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); + return (TRUE); + case XDR_FREE: + return (TRUE); + } + /* NOTREACHED */ + return (FALSE); +} + + +/* + * XDR unsigned 64-bit integers + */ +bool_t +xdr_u_int64_t(xdrs, ullp) + XDR *xdrs; + u_int64_t *ullp; +{ + u_long ul[2]; + + switch (xdrs->x_op) { + case XDR_ENCODE: + ul[0] = (u_long)(*ullp >> 32) & 0xffffffff; + ul[1] = (u_long)(*ullp) & 0xffffffff; + if (XDR_PUTLONG(xdrs, (long *)&ul[0]) == FALSE) + return (FALSE); + return (XDR_PUTLONG(xdrs, (long *)&ul[1])); + case XDR_DECODE: + if (XDR_GETLONG(xdrs, (long *)&ul[0]) == FALSE) + return (FALSE); + if (XDR_GETLONG(xdrs, (long *)&ul[1]) == FALSE) + return (FALSE); + *ullp = (u_int64_t) + (((u_int64_t)ul[0] << 32) | ((u_int64_t)ul[1])); + return (TRUE); + case XDR_FREE: + return (TRUE); + } + /* NOTREACHED */ + return (FALSE); +} + + +/* + * XDR hypers + */ +bool_t +xdr_hyper(xdrs, llp) + XDR *xdrs; + longlong_t *llp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_int64_t(). + */ + return (xdr_int64_t(xdrs, (int64_t *)llp)); +} + + +/* + * XDR unsigned hypers + */ +bool_t +xdr_u_hyper(xdrs, ullp) + XDR *xdrs; + u_longlong_t *ullp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_u_int64_t(). + */ + return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); +} + + +/* + * XDR longlong_t's + */ +bool_t +xdr_longlong_t(xdrs, llp) + XDR *xdrs; + longlong_t *llp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_int64_t(). + */ + return (xdr_int64_t(xdrs, (int64_t *)llp)); +} + + +/* + * XDR u_longlong_t's + */ +bool_t +xdr_u_longlong_t(xdrs, ullp) + XDR *xdrs; + u_longlong_t *ullp; +{ + + /* + * Don't bother open-coding this; it's a fair amount of code. Just + * call xdr_u_int64_t(). + */ + return (xdr_u_int64_t(xdrs, (u_int64_t *)ullp)); +} diff --git a/lib/libc/xdr/xdr_array.c b/lib/libc/xdr/xdr_array.c index b7d36fe..8e0a302 100644 --- a/lib/libc/xdr/xdr_array.c +++ b/lib/libc/xdr/xdr_array.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_array.c,v 1.12 2000/01/22 22:19:18 mycroft 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 @@ -27,6 +29,7 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";*/ @@ -42,13 +45,15 @@ static char *rcsid = "$FreeBSD$"; * arrays. See xdr.h for more info on the interface to xdr. */ +#include "namespace.h" +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <rpc/types.h> #include <rpc/xdr.h> - -#define LASTUNSIGNED ((u_int) 0-1) +#include "un-namespace.h" /* * XDR an array of arbitrary elements @@ -59,18 +64,18 @@ static char *rcsid = "$FreeBSD$"; */ bool_t xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) - register XDR *xdrs; + XDR *xdrs; caddr_t *addrp; /* array pointer */ u_int *sizep; /* number of elements */ u_int maxsize; /* max numberof elements */ u_int elsize; /* size in bytes of each element */ xdrproc_t elproc; /* xdr routine to handle each element */ { - register u_int i; - register caddr_t target = *addrp; - register u_int c; /* the actual element count */ - register bool_t stat = TRUE; - register u_int nodesize; + u_int i; + caddr_t target = *addrp; + u_int c; /* the actual element count */ + bool_t stat = TRUE; + u_int nodesize; /* like strings, arrays are really counted arrays */ if (! xdr_u_int(xdrs, sizep)) { @@ -93,8 +98,7 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) return (TRUE); *addrp = target = mem_alloc(nodesize); if (target == NULL) { - (void) fprintf(stderr, - "xdr_array: out of memory\n"); + warnx("xdr_array: out of memory"); return (FALSE); } memset(target, 0, nodesize); @@ -102,13 +106,16 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) case XDR_FREE: return (TRUE); - } + case XDR_ENCODE: + break; + } + /* * now we xdr each element of array */ for (i = 0; (i < c) && stat; i++) { - stat = (*elproc)(xdrs, target, LASTUNSIGNED); + stat = (*elproc)(xdrs, target); target += elsize; } @@ -134,22 +141,21 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) */ bool_t xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem) - register XDR *xdrs; - register char *basep; - register u_int nelem; - register u_int elemsize; - register xdrproc_t xdr_elem; + XDR *xdrs; + char *basep; + u_int nelem; + u_int elemsize; + xdrproc_t xdr_elem; { - register u_int i; - register char *elptr; + u_int i; + char *elptr; elptr = basep; for (i = 0; i < nelem; i++) { - if (! (*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { + if (! (*xdr_elem)(xdrs, elptr)) { return(FALSE); } elptr += elemsize; } - return(TRUE); + return(TRUE); } - diff --git a/lib/libc/xdr/xdr_float.c b/lib/libc/xdr/xdr_float.c index 3966320..024888f 100644 --- a/lib/libc/xdr/xdr_float.c +++ b/lib/libc/xdr/xdr_float.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_float.c,v 1.23 2000/07/17 04:59:51 matt 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 @@ -27,14 +29,15 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -/*static char *sccsid = "from: @(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";*/ -/*static char *sccsid = "from: @(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";*/ +static char *sccsid = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro"; +static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC"; static char *rcsid = "$FreeBSD$"; #endif /* - * xdr_float.c, Generic XDR routines impelmentation. + * xdr_float.c, Generic XDR routines implementation. * * Copyright (C) 1984, Sun Microsystems, Inc. * @@ -43,11 +46,15 @@ static char *rcsid = "$FreeBSD$"; * xdr. */ -#include <stdio.h> +#include "namespace.h" #include <sys/types.h> #include <sys/param.h> + +#include <stdio.h> + #include <rpc/types.h> #include <rpc/xdr.h> +#include "un-namespace.h" /* * NB: Not portable. @@ -56,12 +63,13 @@ static char *rcsid = "$FreeBSD$"; #if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \ defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \ - defined(__arm32__) || defined(__ppc__) || defined(__ia64__) + defined(__arm32__) || defined(__ppc__) || defined(__ia64__) || \ + defined(__arm26__) #include <machine/endian.h> #define IEEEFP #endif -#ifdef vax +#if defined(__vax__) /* What IEEE single precision floating point looks like on a Vax */ struct ieee_single { @@ -94,13 +102,10 @@ static struct sgl_limits { bool_t xdr_float(xdrs, fp) - register XDR *xdrs; - register float *fp; + XDR *xdrs; + float *fp; { -#ifdef IEEEFP - bool_t rv; - long tmpl; -#else +#ifndef IEEEFP struct ieee_single is; struct vax_single vs, *vsp; struct sgl_limits *lim; @@ -110,8 +115,7 @@ xdr_float(xdrs, fp) case XDR_ENCODE: #ifdef IEEEFP - tmpl = *(int32_t *)fp; - return (XDR_PUTLONG(xdrs, &tmpl)); + return (XDR_PUTINT32(xdrs, (int32_t *)fp)); #else vs = *((struct vax_single *)fp); for (i = 0, lim = sgl_limits; @@ -128,17 +132,15 @@ xdr_float(xdrs, fp) is.mantissa = (vs.mantissa1 << 16) | vs.mantissa2; shipit: is.sign = vs.sign; - return (XDR_PUTLONG(xdrs, (long *)&is)); + return (XDR_PUTINT32(xdrs, (int32_t *)&is)); #endif case XDR_DECODE: #ifdef IEEEFP - rv = XDR_GETLONG(xdrs, &tmpl); - *(int32_t *)fp = tmpl; - return (rv); + return (XDR_GETINT32(xdrs, (int32_t *)fp)); #else vsp = (struct vax_single *)fp; - if (!XDR_GETLONG(xdrs, (long *)&is)) + if (!XDR_GETINT32(xdrs, (int32_t *)&is)) return (FALSE); for (i = 0, lim = sgl_limits; i < sizeof(sgl_limits)/sizeof(struct sgl_limits); @@ -160,10 +162,11 @@ xdr_float(xdrs, fp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } -#ifdef vax +#if defined(__vax__) /* What IEEE double precision floating point looks like on a Vax */ struct ieee_double { unsigned int mantissa1 : 20; @@ -201,18 +204,17 @@ static struct dbl_limits { bool_t xdr_double(xdrs, dp) - register XDR *xdrs; + XDR *xdrs; double *dp; { #ifdef IEEEFP - register int32_t *i32p; + int32_t *i32p; bool_t rv; - long tmpl; #else - register long *lp; + int32_t *lp; struct ieee_double id; struct vax_double vd; - register struct dbl_limits *lim; + struct dbl_limits *lim; int i; #endif @@ -220,21 +222,17 @@ xdr_double(xdrs, dp) case XDR_ENCODE: #ifdef IEEEFP - i32p = (int32_t *)dp; + i32p = (int32_t *)(void *)dp; #if BYTE_ORDER == BIG_ENDIAN - tmpl = *i32p++; - rv = XDR_PUTLONG(xdrs, &tmpl); + rv = XDR_PUTINT32(xdrs, i32p); if (!rv) return (rv); - tmpl = *i32p; - rv = XDR_PUTLONG(xdrs, &tmpl); + rv = XDR_PUTINT32(xdrs, i32p+1); #else - tmpl = *(i32p+1); - rv = XDR_PUTLONG(xdrs, &tmpl); + rv = XDR_PUTINT32(xdrs, i32p+1); if (!rv) return (rv); - tmpl = *i32p; - rv = XDR_PUTLONG(xdrs, &tmpl); + rv = XDR_PUTINT32(xdrs, i32p); #endif return (rv); #else @@ -258,32 +256,28 @@ xdr_double(xdrs, dp) ((vd.mantissa4 >> 3) & MASK(13)); shipit: id.sign = vd.sign; - lp = (long *)&id; - return (XDR_PUTLONG(xdrs, lp++) && XDR_PUTLONG(xdrs, lp)); + lp = (int32_t *)&id; + return (XDR_PUTINT32(xdrs, lp++) && XDR_PUTINT32(xdrs, lp)); #endif case XDR_DECODE: #ifdef IEEEFP - i32p = (int32_t *)dp; + i32p = (int32_t *)(void *)dp; #if BYTE_ORDER == BIG_ENDIAN - rv = XDR_GETLONG(xdrs, &tmpl); - *i32p++ = tmpl; + rv = XDR_GETINT32(xdrs, i32p); if (!rv) return (rv); - rv = XDR_GETLONG(xdrs, &tmpl); - *i32p = tmpl; + rv = XDR_GETINT32(xdrs, i32p+1); #else - rv = XDR_GETLONG(xdrs, &tmpl); - *(i32p+1) = tmpl; + rv = XDR_GETINT32(xdrs, i32p+1); if (!rv) return (rv); - rv = XDR_GETLONG(xdrs, &tmpl); - *i32p = tmpl; + rv = XDR_GETINT32(xdrs, i32p); #endif return (rv); #else - lp = (long *)&id; - if (!XDR_GETLONG(xdrs, lp++) || !XDR_GETLONG(xdrs, lp)) + lp = (int32_t *)&id; + if (!XDR_GETINT32(xdrs, lp++) || !XDR_GETINT32(xdrs, lp)) return (FALSE); for (i = 0, lim = dbl_limits; i < sizeof(dbl_limits)/sizeof(struct dbl_limits); @@ -310,5 +304,6 @@ xdr_double(xdrs, dp) case XDR_FREE: return (TRUE); } + /* NOTREACHED */ return (FALSE); } diff --git a/lib/libc/xdr/xdr_mem.c b/lib/libc/xdr/xdr_mem.c index 3193e64..b54fc59 100644 --- a/lib/libc/xdr/xdr_mem.c +++ b/lib/libc/xdr/xdr_mem.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_mem.c,v 1.15 2000/01/22 22:19:18 mycroft 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 @@ -27,6 +29,7 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";*/ @@ -44,24 +47,31 @@ static char *rcsid = "$FreeBSD$"; * */ +#include "namespace.h" +#include <sys/types.h> + +#include <netinet/in.h> + #include <string.h> + #include <rpc/types.h> #include <rpc/xdr.h> -#include <netinet/in.h> - -static bool_t xdrmem_getlong_aligned(); -static bool_t xdrmem_putlong_aligned(); -static bool_t xdrmem_getlong_unaligned(); -static bool_t xdrmem_putlong_unaligned(); -static bool_t xdrmem_getbytes(); -static bool_t xdrmem_putbytes(); -static u_int xdrmem_getpos(); /* XXX w/64-bit pointers, u_int not enough! */ -static bool_t xdrmem_setpos(); -static int32_t *xdrmem_inline_aligned(); -static int32_t *xdrmem_inline_unaligned(); -static void xdrmem_destroy(); - -static struct xdr_ops xdrmem_ops_aligned = { +#include "un-namespace.h" + +static void xdrmem_destroy __P((XDR *)); +static bool_t xdrmem_getlong_aligned __P((XDR *, long *)); +static bool_t xdrmem_putlong_aligned __P((XDR *, const long *)); +static bool_t xdrmem_getlong_unaligned __P((XDR *, long *)); +static bool_t xdrmem_putlong_unaligned __P((XDR *, const long *)); +static bool_t xdrmem_getbytes __P((XDR *, char *, u_int)); +static bool_t xdrmem_putbytes __P((XDR *, const char *, u_int)); +/* XXX: w/64-bit pointers, u_int not enough! */ +static u_int xdrmem_getpos __P((XDR *)); +static bool_t xdrmem_setpos __P((XDR *, u_int)); +static int32_t *xdrmem_inline_aligned __P((XDR *, u_int)); +static int32_t *xdrmem_inline_unaligned __P((XDR *, u_int)); + +static const struct xdr_ops xdrmem_ops_aligned = { xdrmem_getlong_aligned, xdrmem_putlong_aligned, xdrmem_getbytes, @@ -72,7 +82,7 @@ static struct xdr_ops xdrmem_ops_aligned = { xdrmem_destroy }; -static struct xdr_ops xdrmem_ops_unaligned = { +static const struct xdr_ops xdrmem_ops_unaligned = { xdrmem_getlong_unaligned, xdrmem_putlong_unaligned, xdrmem_getbytes, @@ -89,154 +99,156 @@ static struct xdr_ops xdrmem_ops_unaligned = { */ void xdrmem_create(xdrs, addr, size, op) - register XDR *xdrs; - caddr_t addr; + XDR *xdrs; + char *addr; u_int size; enum xdr_op op; { xdrs->x_op = op; - xdrs->x_ops = ((size_t)addr & (sizeof(int32_t) - 1)) - ? &xdrmem_ops_unaligned : &xdrmem_ops_aligned; + xdrs->x_ops = ((unsigned long)addr & (sizeof(int32_t) - 1)) + ? &xdrmem_ops_unaligned : &xdrmem_ops_aligned; xdrs->x_private = xdrs->x_base = addr; xdrs->x_handy = size; } +/*ARGSUSED*/ static void -xdrmem_destroy(/*xdrs*/) - /*XDR *xdrs;*/ +xdrmem_destroy(xdrs) + XDR *xdrs; { } static bool_t xdrmem_getlong_aligned(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - *lp = ntohl(*(int32_t *)(xdrs->x_private)); - xdrs->x_private += sizeof(int32_t); + *lp = ntohl(*(u_int32_t *)xdrs->x_private); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_putlong_aligned(xdrs, lp) - register XDR *xdrs; - long *lp; + XDR *xdrs; + const long *lp; { if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - *(int32_t *)xdrs->x_private = htonl(*lp); - xdrs->x_private += sizeof(int32_t); + *(u_int32_t *)xdrs->x_private = htonl((u_int32_t)*lp); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_getlong_unaligned(xdrs, lp) - register XDR *xdrs; + XDR *xdrs; long *lp; { - int32_t l; + u_int32_t l; if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - memcpy(&l, xdrs->x_private, sizeof(int32_t)); + memmove(&l, xdrs->x_private, sizeof(int32_t)); *lp = ntohl(l); - xdrs->x_private += sizeof(int32_t); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_putlong_unaligned(xdrs, lp) - register XDR *xdrs; - long *lp; + XDR *xdrs; + const long *lp; { - int32_t l; + u_int32_t l; if ((xdrs->x_handy -= sizeof(int32_t)) < 0) return (FALSE); - l = htonl(*lp); - memcpy(xdrs->x_private, &l, sizeof(int32_t)); - xdrs->x_private += sizeof(int32_t); + l = htonl((u_int32_t)*lp); + memmove(xdrs->x_private, &l, sizeof(int32_t)); + xdrs->x_private = (char *)xdrs->x_private + sizeof(int32_t); return (TRUE); } static bool_t xdrmem_getbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; + XDR *xdrs; + char *addr; + u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); - memcpy(addr, xdrs->x_private, len); - xdrs->x_private += len; + memmove(addr, xdrs->x_private, len); + xdrs->x_private = (char *)xdrs->x_private + len; return (TRUE); } static bool_t xdrmem_putbytes(xdrs, addr, len) - register XDR *xdrs; - caddr_t addr; - register u_int len; + XDR *xdrs; + const char *addr; + u_int len; { if ((xdrs->x_handy -= len) < 0) return (FALSE); - memcpy(xdrs->x_private, addr, len); - xdrs->x_private += len; + memmove(xdrs->x_private, addr, len); + xdrs->x_private = (char *)xdrs->x_private + len; return (TRUE); } static u_int xdrmem_getpos(xdrs) - register XDR *xdrs; + XDR *xdrs; { /* XXX w/64-bit pointers, u_int not enough! */ - return ((u_long)xdrs->x_private - (u_long)xdrs->x_base); + return (u_int)((u_long)xdrs->x_private - (u_long)xdrs->x_base); } static bool_t xdrmem_setpos(xdrs, pos) - register XDR *xdrs; + XDR *xdrs; u_int pos; { - register caddr_t newaddr = xdrs->x_base + pos; - register caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; + char *newaddr = xdrs->x_base + pos; + char *lastaddr = (char *)xdrs->x_private + xdrs->x_handy; if ((long)newaddr > (long)lastaddr) return (FALSE); xdrs->x_private = newaddr; - xdrs->x_handy = (long)lastaddr - (long)newaddr; + xdrs->x_handy = (int)((long)lastaddr - (long)newaddr); return (TRUE); } static int32_t * xdrmem_inline_aligned(xdrs, len) - register XDR *xdrs; - int len; + XDR *xdrs; + u_int len; { int32_t *buf = 0; if (xdrs->x_handy >= len) { xdrs->x_handy -= len; - buf = (int32_t *) xdrs->x_private; - xdrs->x_private += len; + buf = (int32_t *)xdrs->x_private; + xdrs->x_private = (char *)xdrs->x_private + len; } return (buf); } +/* ARGSUSED */ static int32_t * xdrmem_inline_unaligned(xdrs, len) - register XDR *xdrs; - int len; + XDR *xdrs; + u_int len; { - + return (0); } diff --git a/lib/libc/xdr/xdr_rec.c b/lib/libc/xdr/xdr_rec.c index 7136463..616dbf6 100644 --- a/lib/libc/xdr/xdr_rec.c +++ b/lib/libc/xdr/xdr_rec.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_rec.c,v 1.18 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 @@ -26,7 +28,9 @@ * 2550 Garcia Avenue * Mountain View, California 94043 */ -#if defined(LIBC_SCCS) && !defined(lint) + +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";*/ static char *rcsid = "$FreeBSD$"; @@ -45,33 +49,35 @@ static char *rcsid = "$FreeBSD$"; * by n bytes of data, where n is contained in the header. The header * is represented as a htonl(u_long). Thegh order bit encodes * whether or not the fragment is the last fragment of the record - * (1 => fragment is last, 0 => more fragments to follow. + * (1 => fragment is last, 0 => more fragments to follow. * The other 31 bits encode the byte length of the fragment. */ +#include "namespace.h" +#include <sys/types.h> + +#include <netinet/in.h> + +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <rpc/types.h> #include <rpc/xdr.h> -#include <netinet/in.h> +#include "un-namespace.h" -static u_int fix_buf_size(); -static bool_t flush_out(); -static bool_t get_input_bytes(); -static bool_t set_input_fragment(); -static bool_t skip_input_bytes(); - -static bool_t xdrrec_getlong(); -static bool_t xdrrec_putlong(); -static bool_t xdrrec_getbytes(); -static bool_t xdrrec_putbytes(); -static u_int xdrrec_getpos(); -static bool_t xdrrec_setpos(); -static int32_t *xdrrec_inline(); -static void xdrrec_destroy(); - -static struct xdr_ops xdrrec_ops = { +static bool_t xdrrec_getlong __P((XDR *, long *)); +static bool_t xdrrec_putlong __P((XDR *, const long *)); +static bool_t xdrrec_getbytes __P((XDR *, char *, u_int)); + +static bool_t xdrrec_putbytes __P((XDR *, const char *, u_int)); +static u_int xdrrec_getpos __P((XDR *)); +static bool_t xdrrec_setpos __P((XDR *, u_int)); +static int32_t *xdrrec_inline __P((XDR *, u_int)); +static void xdrrec_destroy __P((XDR *)); + +static const struct xdr_ops xdrrec_ops = { xdrrec_getlong, xdrrec_putlong, xdrrec_getbytes, @@ -98,31 +104,38 @@ static struct xdr_ops xdrrec_ops = { #define LAST_FRAG ((u_int32_t)(1 << 31)) typedef struct rec_strm { - caddr_t tcp_handle; - caddr_t the_buffer; + char *tcp_handle; + char *the_buffer; /* * out-goung bits */ - int (*writeit) __P((caddr_t, caddr_t, int)); - caddr_t out_base; /* output buffer (points to frag header) */ - caddr_t out_finger; /* next output position */ - caddr_t out_boundry; /* data cannot up to this address */ - u_int32_t *frag_header; /* beginning of current fragment */ + int (*writeit) __P((char *, char *, int)); + char *out_base; /* output buffer (points to frag header) */ + char *out_finger; /* next output position */ + char *out_boundry; /* data cannot up to this address */ + u_int32_t *frag_header; /* beginning of curren fragment */ bool_t frag_sent; /* true if buffer sent in middle of record */ /* * in-coming bits */ - int (*readit) __P((caddr_t, caddr_t, int)); + int (*readit) __P((char *, char *, int)); u_long in_size; /* fixed size of the input buffer */ - caddr_t in_base; - caddr_t in_finger; /* location of next byte to be had */ - caddr_t in_boundry; /* can read up to this location */ + char *in_base; + char *in_finger; /* location of next byte to be had */ + char *in_boundry; /* can read up to this location */ long fbtbc; /* fragment bytes to be consumed */ bool_t last_frag; u_int sendsize; u_int recvsize; } RECSTREAM; +static u_int fix_buf_size __P((u_int)); +static bool_t flush_out __P((RECSTREAM *, bool_t)); +static bool_t fill_input_buf __P((RECSTREAM *)); +static bool_t get_input_bytes __P((RECSTREAM *, char *, int)); +static bool_t set_input_fragment __P((RECSTREAM *)); +static bool_t skip_input_bytes __P((RECSTREAM *, long)); + /* * Create an xdr handle for xdrrec @@ -135,20 +148,21 @@ typedef struct rec_strm { */ void xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) - register XDR *xdrs; - register u_int sendsize; - register u_int recvsize; - caddr_t tcp_handle; - int (*readit)(); /* like read, but pass it a tcp_handle, not sock */ - int (*writeit)(); /* like write, but pass it a tcp_handle, not sock */ + XDR *xdrs; + u_int sendsize; + u_int recvsize; + char *tcp_handle; + /* like read, but pass it a tcp_handle, not sock */ + int (*readit) __P((char *, char *, int)); + /* like write, but pass it a tcp_handle, not sock */ + int (*writeit) __P((char *, char *, int)); { - register RECSTREAM *rstrm = - (RECSTREAM *)mem_alloc(sizeof(RECSTREAM)); + RECSTREAM *rstrm = mem_alloc(sizeof(RECSTREAM)); if (rstrm == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); - /* - * This is bad. Should rework xdrrec_create to + warnx("xdrrec_create: out of memory"); + /* + * This is bad. Should rework xdrrec_create to * return a handle, and in this case return NULL */ return; @@ -160,7 +174,7 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) rstrm->recvsize = recvsize = fix_buf_size(recvsize); rstrm->the_buffer = mem_alloc(sendsize + recvsize + BYTES_PER_XDR_UNIT); if (rstrm->the_buffer == NULL) { - (void)fprintf(stderr, "xdrrec_create: out of memory\n"); + warnx("xdrrec_create: out of memory"); return; } for (rstrm->out_base = rstrm->the_buffer; @@ -171,12 +185,12 @@ xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit) * now the rest ... */ xdrs->x_ops = &xdrrec_ops; - xdrs->x_private = (caddr_t)rstrm; + xdrs->x_private = rstrm; rstrm->tcp_handle = tcp_handle; rstrm->readit = readit; rstrm->writeit = writeit; rstrm->out_finger = rstrm->out_boundry = rstrm->out_base; - rstrm->frag_header = (u_int32_t *)rstrm->out_base; + rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base; rstrm->out_finger += sizeof(u_int32_t); rstrm->out_boundry += sendsize; rstrm->frag_sent = FALSE; @@ -198,8 +212,8 @@ xdrrec_getlong(xdrs, lp) XDR *xdrs; long *lp; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int32_t *buflp = (int32_t *)(rstrm->in_finger); + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + int32_t *buflp = (int32_t *)(void *)(rstrm->in_finger); int32_t mylong; /* first try the inline, fast case */ @@ -209,7 +223,8 @@ xdrrec_getlong(xdrs, lp) rstrm->fbtbc -= sizeof(int32_t); rstrm->in_finger += sizeof(int32_t); } else { - if (! xdrrec_getbytes(xdrs, (caddr_t)&mylong, sizeof(int32_t))) + if (! xdrrec_getbytes(xdrs, (char *)(void *)&mylong, + sizeof(int32_t))) return (FALSE); *lp = (long)ntohl((u_int32_t)mylong); } @@ -219,10 +234,10 @@ xdrrec_getlong(xdrs, lp) static bool_t xdrrec_putlong(xdrs, lp) XDR *xdrs; - long *lp; + const long *lp; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int32_t *dest_lp = ((int32_t *)(rstrm->out_finger)); + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + int32_t *dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); if ((rstrm->out_finger += sizeof(int32_t)) > rstrm->out_boundry) { /* @@ -233,7 +248,7 @@ xdrrec_putlong(xdrs, lp) rstrm->frag_sent = TRUE; if (! flush_out(rstrm, FALSE)) return (FALSE); - dest_lp = ((int32_t *)(rstrm->out_finger)); + dest_lp = ((int32_t *)(void *)(rstrm->out_finger)); rstrm->out_finger += sizeof(int32_t); } *dest_lp = (int32_t)htonl((u_int32_t)(*lp)); @@ -243,14 +258,14 @@ xdrrec_putlong(xdrs, lp) static bool_t /* must manage buffers, fragments, and records */ xdrrec_getbytes(xdrs, addr, len) XDR *xdrs; - register caddr_t addr; - register u_int len; + char *addr; + u_int len; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register int current; + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + int current; while (len > 0) { - current = rstrm->fbtbc; + current = (int)rstrm->fbtbc; if (current == 0) { if (rstrm->last_frag) return (FALSE); @@ -261,7 +276,7 @@ xdrrec_getbytes(xdrs, addr, len) current = (len < current) ? len : current; if (! get_input_bytes(rstrm, addr, current)) return (FALSE); - addr += current; + addr += current; rstrm->fbtbc -= current; len -= current; } @@ -271,17 +286,17 @@ xdrrec_getbytes(xdrs, addr, len) static bool_t xdrrec_putbytes(xdrs, addr, len) XDR *xdrs; - register caddr_t addr; - register u_int len; + const char *addr; + u_int len; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register long current; + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + size_t current; while (len > 0) { - current = (u_long)rstrm->out_boundry - - (u_long)rstrm->out_finger; + current = (size_t)((u_long)rstrm->out_boundry - + (u_long)rstrm->out_finger); current = (len < current) ? len : current; - memcpy(rstrm->out_finger, addr, current); + memmove(rstrm->out_finger, addr, current); rstrm->out_finger += current; addr += current; len -= current; @@ -296,12 +311,12 @@ xdrrec_putbytes(xdrs, addr, len) static u_int xdrrec_getpos(xdrs) - register XDR *xdrs; + XDR *xdrs; { - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - register long pos; + RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + off_t pos; - pos = lseek((int)(long)rstrm->tcp_handle, (off_t) 0, 1); + pos = lseek((int)(u_long)rstrm->tcp_handle, (off_t)0, 1); if (pos != -1) switch (xdrs->x_op) { @@ -314,7 +329,7 @@ xdrrec_getpos(xdrs) break; default: - pos = -1; + pos = (off_t) -1; break; } return ((u_int) pos); @@ -322,20 +337,20 @@ xdrrec_getpos(xdrs) static bool_t xdrrec_setpos(xdrs, pos) - register XDR *xdrs; + XDR *xdrs; u_int pos; { - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; u_int currpos = xdrrec_getpos(xdrs); int delta = currpos - pos; - caddr_t newpos; + char *newpos; if ((int)currpos != -1) switch (xdrs->x_op) { case XDR_ENCODE: newpos = rstrm->out_finger - delta; - if ((newpos > (caddr_t)(rstrm->frag_header)) && + if ((newpos > (char *)(void *)(rstrm->frag_header)) && (newpos < rstrm->out_boundry)) { rstrm->out_finger = newpos; return (TRUE); @@ -352,23 +367,26 @@ xdrrec_setpos(xdrs, pos) return (TRUE); } break; + + case XDR_FREE: + break; } return (FALSE); } static int32_t * xdrrec_inline(xdrs, len) - register XDR *xdrs; - int len; + XDR *xdrs; + u_int len; { - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; - int32_t * buf = NULL; + RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + int32_t *buf = NULL; switch (xdrs->x_op) { case XDR_ENCODE: if ((rstrm->out_finger + len) <= rstrm->out_boundry) { - buf = (int32_t *) rstrm->out_finger; + buf = (int32_t *)(void *)rstrm->out_finger; rstrm->out_finger += len; } break; @@ -376,24 +394,27 @@ xdrrec_inline(xdrs, len) case XDR_DECODE: if ((len <= rstrm->fbtbc) && ((rstrm->in_finger + len) <= rstrm->in_boundry)) { - buf = (int32_t *) rstrm->in_finger; + buf = (int32_t *)(void *)rstrm->in_finger; rstrm->fbtbc -= len; rstrm->in_finger += len; } break; + + case XDR_FREE: + break; } return (buf); } static void xdrrec_destroy(xdrs) - register XDR *xdrs; + XDR *xdrs; { - register RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; + RECSTREAM *rstrm = (RECSTREAM *)xdrs->x_private; mem_free(rstrm->the_buffer, rstrm->sendsize + rstrm->recvsize + BYTES_PER_XDR_UNIT); - mem_free((caddr_t)rstrm, sizeof(RECSTREAM)); + mem_free(rstrm, sizeof(RECSTREAM)); } @@ -409,7 +430,7 @@ bool_t xdrrec_skiprecord(xdrs) XDR *xdrs; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { if (! skip_input_bytes(rstrm, rstrm->fbtbc)) @@ -423,7 +444,7 @@ xdrrec_skiprecord(xdrs) } /* - * Look ahead fuction. + * Look ahead function. * Returns TRUE iff there is no more input in the buffer * after consuming the rest of the current record. */ @@ -431,7 +452,7 @@ bool_t xdrrec_eof(xdrs) XDR *xdrs; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); while (rstrm->fbtbc > 0 || (! rstrm->last_frag)) { if (! skip_input_bytes(rstrm, rstrm->fbtbc)) @@ -456,8 +477,8 @@ xdrrec_endofrecord(xdrs, sendnow) XDR *xdrs; bool_t sendnow; { - register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); - register u_long len; /* fragment length */ + RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); + u_long len; /* fragment length */ if (sendnow || rstrm->frag_sent || ((u_long)rstrm->out_finger + sizeof(u_int32_t) >= @@ -467,8 +488,8 @@ xdrrec_endofrecord(xdrs, sendnow) } len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->frag_header) - sizeof(u_int32_t); - *(rstrm->frag_header) = htonl((u_long)len | LAST_FRAG); - rstrm->frag_header = (u_int32_t *)rstrm->out_finger; + *(rstrm->frag_header) = htonl((u_int32_t)len | LAST_FRAG); + rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_finger; rstrm->out_finger += sizeof(u_int32_t); return (TRUE); } @@ -479,35 +500,36 @@ xdrrec_endofrecord(xdrs, sendnow) */ static bool_t flush_out(rstrm, eor) - register RECSTREAM *rstrm; + RECSTREAM *rstrm; bool_t eor; { - register u_long eormask = (eor == TRUE) ? LAST_FRAG : 0; - register u_int32_t len = (u_long)(rstrm->out_finger) - - (u_long)(rstrm->frag_header) - sizeof(u_int32_t); + u_int32_t eormask = (eor == TRUE) ? LAST_FRAG : 0; + u_int32_t len = (u_int32_t)((u_long)(rstrm->out_finger) - + (u_long)(rstrm->frag_header) - sizeof(u_int32_t)); *(rstrm->frag_header) = htonl(len | eormask); - len = (u_long)(rstrm->out_finger) - (u_long)(rstrm->out_base); + len = (u_int32_t)((u_long)(rstrm->out_finger) - + (u_long)(rstrm->out_base)); if ((*(rstrm->writeit))(rstrm->tcp_handle, rstrm->out_base, (int)len) != (int)len) return (FALSE); - rstrm->frag_header = (u_int32_t *)rstrm->out_base; - rstrm->out_finger = (caddr_t)rstrm->out_base + sizeof(u_int32_t); + rstrm->frag_header = (u_int32_t *)(void *)rstrm->out_base; + rstrm->out_finger = (char *)rstrm->out_base + sizeof(u_int32_t); return (TRUE); } static bool_t /* knows nothing about records! Only about input buffers */ fill_input_buf(rstrm) - register RECSTREAM *rstrm; + RECSTREAM *rstrm; { - register caddr_t where; - u_long i; - register long len; + char *where; + u_int32_t i; + int len; where = rstrm->in_base; - i = (u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT; + i = (u_int32_t)((u_long)rstrm->in_boundry % BYTES_PER_XDR_UNIT); where += i; - len = rstrm->in_size - i; + len = (u_int32_t)(rstrm->in_size - i); if ((len = (*(rstrm->readit))(rstrm->tcp_handle, where, len)) == -1) return (FALSE); rstrm->in_finger = where; @@ -518,21 +540,22 @@ fill_input_buf(rstrm) static bool_t /* knows nothing about records! Only about input buffers */ get_input_bytes(rstrm, addr, len) - register RECSTREAM *rstrm; - register caddr_t addr; - register int len; + RECSTREAM *rstrm; + char *addr; + int len; { - register long current; + size_t current; while (len > 0) { - current = (long)rstrm->in_boundry - (long)rstrm->in_finger; + current = (size_t)((long)rstrm->in_boundry - + (long)rstrm->in_finger); if (current == 0) { if (! fill_input_buf(rstrm)) return (FALSE); continue; } current = (len < current) ? len : current; - memcpy(addr, rstrm->in_finger, current); + memmove(addr, rstrm->in_finger, current); rstrm->in_finger += current; addr += current; len -= current; @@ -542,13 +565,13 @@ get_input_bytes(rstrm, addr, len) static bool_t /* next two bytes of the input stream are treated as a header */ set_input_fragment(rstrm) - register RECSTREAM *rstrm; + RECSTREAM *rstrm; { u_int32_t header; - if (! get_input_bytes(rstrm, (caddr_t)&header, sizeof(header))) + if (! get_input_bytes(rstrm, (char *)(void *)&header, sizeof(header))) return (FALSE); - header = (long)ntohl(header); + header = ntohl(header); rstrm->last_frag = ((header & LAST_FRAG) == 0) ? FALSE : TRUE; /* * Sanity check. Try not to accept wildly incorrect @@ -566,19 +589,20 @@ set_input_fragment(rstrm) static bool_t /* consumes input bytes; knows nothing about records! */ skip_input_bytes(rstrm, cnt) - register RECSTREAM *rstrm; + RECSTREAM *rstrm; long cnt; { - register long current; + u_int32_t current; while (cnt > 0) { - current = (long)rstrm->in_boundry - (long)rstrm->in_finger; + current = (size_t)((long)rstrm->in_boundry - + (long)rstrm->in_finger); if (current == 0) { if (! fill_input_buf(rstrm)) return (FALSE); continue; } - current = (cnt < current) ? cnt : current; + current = (u_int32_t)((cnt < current) ? cnt : current); rstrm->in_finger += current; cnt -= current; } @@ -587,7 +611,7 @@ skip_input_bytes(rstrm, cnt) static u_int fix_buf_size(s) - register u_int s; + u_int s; { if (s < 100) diff --git a/lib/libc/xdr/xdr_reference.c b/lib/libc/xdr/xdr_reference.c index b0cdbce..60e7020 100644 --- a/lib/libc/xdr/xdr_reference.c +++ b/lib/libc/xdr/xdr_reference.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_reference.c,v 1.13 2000/01/22 22:19:18 mycroft 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 @@ -27,7 +29,8 @@ * Mountain View, California 94043 */ -#if defined(LIBC_SCCS) && !defined(lint) +#include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_reference.c 1.11 87/08/11 SMI";*/ /*static char *sccsid = "from: @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";*/ static char *rcsid = "$FreeBSD$"; @@ -42,13 +45,15 @@ static char *rcsid = "$FreeBSD$"; * "pointers". See xdr.h for more info on the interface to xdr. */ +#include "namespace.h" +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <string.h> + #include <rpc/types.h> #include <rpc/xdr.h> - -#define LASTUNSIGNED ((u_int) 0-1) +#include "libc_private.h" /* * XDR an indirect pointer @@ -61,13 +66,13 @@ static char *rcsid = "$FreeBSD$"; */ bool_t xdr_reference(xdrs, pp, size, proc) - register XDR *xdrs; + XDR *xdrs; caddr_t *pp; /* the pointer to work on */ u_int size; /* size of the object pointed to */ xdrproc_t proc; /* xdr routine to handle the object */ { - register caddr_t loc = *pp; - register bool_t stat; + caddr_t loc = *pp; + bool_t stat; if (loc == NULL) switch (xdrs->x_op) { @@ -77,15 +82,17 @@ xdr_reference(xdrs, pp, size, proc) case XDR_DECODE: *pp = loc = (caddr_t) mem_alloc(size); if (loc == NULL) { - (void) fprintf(stderr, - "xdr_reference: out of memory\n"); + warnx("xdr_reference: out of memory"); return (FALSE); } - memset(loc, 0, (int)size); + memset(loc, 0, size); break; - } - stat = (*proc)(xdrs, loc, LASTUNSIGNED); + case XDR_ENCODE: + break; + } + + stat = (*proc)(xdrs, loc); if (xdrs->x_op == XDR_FREE) { mem_free(loc, size); @@ -116,7 +123,7 @@ xdr_reference(xdrs, pp, size, proc) */ bool_t xdr_pointer(xdrs,objpp,obj_size,xdr_obj) - register XDR *xdrs; + XDR *xdrs; char **objpp; u_int obj_size; xdrproc_t xdr_obj; diff --git a/lib/libc/xdr/xdr_sizeof.c b/lib/libc/xdr/xdr_sizeof.c index 5a4c1a7..f90cc34 100644 --- a/lib/libc/xdr/xdr_sizeof.c +++ b/lib/libc/xdr/xdr_sizeof.c @@ -1,4 +1,6 @@ /* + * $FreeBSD$ + * * 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 @@ -35,10 +37,12 @@ * when serialized using XDR. */ +#include "namespace.h" #include <rpc/types.h> #include <rpc/xdr.h> #include <sys/types.h> #include <stdlib.h> +#include "un-namespace.h" /* ARGSUSED */ static bool_t diff --git a/lib/libc/xdr/xdr_stdio.c b/lib/libc/xdr/xdr_stdio.c index 708573c..c4328ec 100644 --- a/lib/libc/xdr/xdr_stdio.c +++ b/lib/libc/xdr/xdr_stdio.c @@ -1,3 +1,5 @@ +/* $NetBSD: xdr_stdio.c,v 1.14 2000/01/22 22:19:19 mycroft 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 @@ -27,6 +29,7 @@ * Mountain View, California 94043 */ +#include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) /*static char *sccsid = "from: @(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";*/ /*static char *sccsid = "from: @(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";*/ @@ -43,23 +46,26 @@ static char *rcsid = "$FreeBSD$"; * from the stream. */ -#include <rpc/types.h> +#include "namespace.h" #include <stdio.h> + +#include <rpc/types.h> #include <rpc/xdr.h> +#include "un-namespace.h" -static bool_t xdrstdio_getlong(); -static bool_t xdrstdio_putlong(); -static bool_t xdrstdio_getbytes(); -static bool_t xdrstdio_putbytes(); -static u_int xdrstdio_getpos(); -static bool_t xdrstdio_setpos(); -static int32_t *xdrstdio_inline(); -static void xdrstdio_destroy(); +static void xdrstdio_destroy __P((XDR *)); +static bool_t xdrstdio_getlong __P((XDR *, long *)); +static bool_t xdrstdio_putlong __P((XDR *, const long *)); +static bool_t xdrstdio_getbytes __P((XDR *, char *, u_int)); +static bool_t xdrstdio_putbytes __P((XDR *, const char *, u_int)); +static u_int xdrstdio_getpos __P((XDR *)); +static bool_t xdrstdio_setpos __P((XDR *, u_int)); +static int32_t *xdrstdio_inline __P((XDR *, u_int)); /* * Ops vector for stdio type XDR */ -static struct xdr_ops xdrstdio_ops = { +static const struct xdr_ops xdrstdio_ops = { xdrstdio_getlong, /* deseraialize a long int */ xdrstdio_putlong, /* seraialize a long int */ xdrstdio_getbytes, /* deserialize counted bytes */ @@ -77,14 +83,14 @@ static struct xdr_ops xdrstdio_ops = { */ void xdrstdio_create(xdrs, file, op) - register XDR *xdrs; + XDR *xdrs; FILE *file; enum xdr_op op; { xdrs->x_op = op; xdrs->x_ops = &xdrstdio_ops; - xdrs->x_private = (caddr_t)file; + xdrs->x_private = file; xdrs->x_handy = 0; xdrs->x_base = 0; } @@ -95,35 +101,32 @@ xdrstdio_create(xdrs, file, op) */ static void xdrstdio_destroy(xdrs) - register XDR *xdrs; + XDR *xdrs; { (void)fflush((FILE *)xdrs->x_private); - /* xx should we close the file ?? */ + /* XXX: should we close the file ?? */ } static bool_t xdrstdio_getlong(xdrs, lp) XDR *xdrs; - register long *lp; + long *lp; { - if (fread((caddr_t)lp, sizeof(int32_t), 1, - (FILE *)xdrs->x_private) != 1) + if (fread(lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) return (FALSE); - *lp = (long)ntohl((int32_t)*lp); + *lp = (long)ntohl((u_int32_t)*lp); return (TRUE); } static bool_t xdrstdio_putlong(xdrs, lp) XDR *xdrs; - long *lp; + const long *lp; { + long mycopy = (long)htonl((u_int32_t)*lp); - long mycopy = (long)htonl((int32_t)*lp); - - if (fwrite((caddr_t)&mycopy, sizeof(int32_t), 1, - (FILE *)xdrs->x_private) != 1) + if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1) return (FALSE); return (TRUE); } @@ -131,11 +134,11 @@ xdrstdio_putlong(xdrs, lp) static bool_t xdrstdio_getbytes(xdrs, addr, len) XDR *xdrs; - caddr_t addr; + char *addr; u_int len; { - if ((len != 0) && (fread(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) + if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1)) return (FALSE); return (TRUE); } @@ -143,11 +146,12 @@ xdrstdio_getbytes(xdrs, addr, len) static bool_t xdrstdio_putbytes(xdrs, addr, len) XDR *xdrs; - caddr_t addr; + const char *addr; u_int len; { - if ((len != 0) && (fwrite(addr, (int)len, 1, (FILE *)xdrs->x_private) != 1)) + if ((len != 0) && (fwrite(addr, (size_t)len, 1, + (FILE *)xdrs->x_private) != 1)) return (FALSE); return (TRUE); } @@ -161,15 +165,16 @@ xdrstdio_getpos(xdrs) } static bool_t -xdrstdio_setpos(xdrs, pos) +xdrstdio_setpos(xdrs, pos) XDR *xdrs; u_int pos; -{ +{ return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ? FALSE : TRUE); } +/* ARGSUSED */ static int32_t * xdrstdio_inline(xdrs, len) XDR *xdrs; |