diff options
author | Andreas Schwab <schwab@suse.de> | 1999-04-08 02:10:39 +0000 |
---|---|---|
committer | Andreas Schwab <schwab@suse.de> | 1999-04-08 02:10:39 +0000 |
commit | 50f301a819f48c6e64232f2cd22d8e77f59d0f29 (patch) | |
tree | 9a387001ce142a37230f98423cf5db120b6653d5 /sunrpc | |
parent | 516d718a39eb540abca2915499b925962886ded9 (diff) | |
download | glibc-50f301a819f48c6e64232f2cd22d8e77f59d0f29.zip glibc-50f301a819f48c6e64232f2cd22d8e77f59d0f29.tar.gz glibc-50f301a819f48c6e64232f2cd22d8e77f59d0f29.tar.bz2 |
1999-04-01 Thorsten Kukuk <kukuk@suse.de>
* sunrpc/Versions: Add new xdr functions to GLIBC_2.1.1
* sunrpc/xdr.c: Add xdr_hyper, xdr_u_hyper, xdr_longlong_t and
xdr_u_longlong_t. Based on patch from Dan Shechter
<damageboy@isdn.net.il>.
* sunrpc/xdr_intXX_t.c: Implement xdr_int64_t, xdr_uint64_t
* sunrpc/rpc/xdr.h: Add prototypes for new xdr functions.
* nis/nis_lookup.c (nis_lookup): Don't overwrite RPC error code.
Diffstat (limited to 'sunrpc')
-rw-r--r-- | sunrpc/Versions | 4 | ||||
-rw-r--r-- | sunrpc/rpc/xdr.h | 10 | ||||
-rw-r--r-- | sunrpc/xdr.c | 106 | ||||
-rw-r--r-- | sunrpc/xdr_intXX_t.c | 60 |
4 files changed, 153 insertions, 27 deletions
diff --git a/sunrpc/Versions b/sunrpc/Versions index 21df89b..1d90bbe 100644 --- a/sunrpc/Versions +++ b/sunrpc/Versions @@ -103,4 +103,8 @@ libc { xdr_key_netstres; xdr_keybuf; xdr_keystatus; xdr_netnamestr; xdr_sizeof; xdr_uint16_t; xdr_uint32_t; xdr_uint8_t; xdr_unixcred; } + GLIBC_2.1.1 { + xdr_hyper; xdr_u_hyper; xdr_longlong_t; xdr_u_longlong_t; + xdr_int64_t; xdr_uint64_t; + } } diff --git a/sunrpc/rpc/xdr.h b/sunrpc/rpc/xdr.h index 8e74d3c..44bad8a 100644 --- a/sunrpc/rpc/xdr.h +++ b/sunrpc/rpc/xdr.h @@ -290,18 +290,24 @@ struct xdr_discrim * also, the XDR structure is always updated by some of these calls. */ extern bool_t xdr_void __P ((void)); +extern bool_t xdr_short __P ((XDR *__xdrs, short *__sp)); +extern bool_t xdr_u_short __P ((XDR *__xdrs, u_short *__usp)); extern bool_t xdr_int __P ((XDR *__xdrs, int *__ip)); extern bool_t xdr_u_int __P ((XDR *__xdrs, u_int *__up)); extern bool_t xdr_long __P ((XDR *__xdrs, long *__lp)); extern bool_t xdr_u_long __P ((XDR *__xdrs, u_long *__ulp)); -extern bool_t xdr_short __P ((XDR *__xdrs, short *__sp)); -extern bool_t xdr_u_short __P ((XDR *__xdrs, u_short *__usp)); +extern bool_t xdr_hyper __P ((XDR *__xdrs, quad_t *__llp)); +extern bool_t xdr_u_hyper __P ((XDR *__xdrs, u_quad_t *__ullp)); +extern bool_t xdr_longlong_t __P ((XDR *__xdrs, quad_t *__llp)); +extern bool_t xdr_u_longlong_t __P ((XDR *__xdrs, u_quad_t *__ullp)); extern bool_t xdr_int8_t __P ((XDR *__xdrs, int8_t *__ip)); extern bool_t xdr_uint8_t __P ((XDR *__xdrs, uint8_t *__up)); extern bool_t xdr_int16_t __P ((XDR *__xdrs, int16_t *__ip)); extern bool_t xdr_uint16_t __P ((XDR *__xdrs, uint16_t *__up)); extern bool_t xdr_int32_t __P ((XDR *__xdrs, int32_t *__ip)); extern bool_t xdr_uint32_t __P ((XDR *__xdrs, uint32_t *__up)); +extern bool_t xdr_int64_t __P ((XDR *__xdrs, int64_t *__ip)); +extern bool_t xdr_uint64_t __P ((XDR *__xdrs, uint64_t *__up)); extern bool_t xdr_bool __P ((XDR *__xdrs, bool_t *__bp)); extern bool_t xdr_enum __P ((XDR *__xdrs, enum_t *__ep)); extern bool_t xdr_array __P ((XDR * _xdrs, caddr_t *__addrp, u_int *__sizep, diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c index 57552c4..6f1aed7 100644 --- a/sunrpc/xdr.c +++ b/sunrpc/xdr.c @@ -193,12 +193,87 @@ xdr_u_long (XDR *xdrs, u_long *ulp) } /* + * XDR hyper integers + * same as xdr_u_hyper - open coded to save a proc call! + */ +bool_t +xdr_hyper (XDR *xdrs, quad_t *llp) +{ + long t1; + long t2; + + if (xdrs->x_op == XDR_ENCODE) + { + t1 = (long) ((*llp) >> 32); + t2 = (long) (*llp); + return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); + } + + if (xdrs->x_op == XDR_DECODE) + { + if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) + return FALSE; + *llp = ((quad_t) t1) << 32; + *llp |= t2; + return TRUE; + } + + if (xdrs->x_op == XDR_FREE) + return TRUE; + + return FALSE; +} + + +/* + * XDR hyper integers + * same as xdr_hyper - open coded to save a proc call! + */ +bool_t +xdr_u_hyper (XDR *xdrs, u_quad_t *ullp) +{ + unsigned long t1; + unsigned long t2; + + if (xdrs->x_op == XDR_ENCODE) + { + t1 = (unsigned long) ((*ullp) >> 32); + t2 = (unsigned long) (*ullp); + return (XDR_PUTLONG(xdrs, &t1) && XDR_PUTLONG(xdrs, &t2)); + } + + if (xdrs->x_op == XDR_DECODE) + { + if (!XDR_GETLONG(xdrs, &t1) || !XDR_GETLONG(xdrs, &t2)) + return FALSE; + *ullp = ((u_quad_t) t1) << 32; + *ullp |= t2; + return TRUE; + } + + if (xdrs->x_op == XDR_FREE) + return TRUE; + + return FALSE; +} + +bool_t +xdr_longlong_t (XDR *xdrs, quad_t *llp) +{ + return xdr_hyper (xdrs, llp); +} + +bool_t +xdr_u_longlong_t (XDR *xdrs, u_quad_t *ullp) +{ + return xdr_u_hyper (xdrs, ullp); +} + +/* * XDR short integers */ bool_t -xdr_short (xdrs, sp) - XDR *xdrs; - short *sp; +xdr_short (XDR *xdrs, short *sp) { long l; @@ -226,9 +301,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; @@ -257,9 +330,7 @@ xdr_u_short (xdrs, usp) * XDR a char */ bool_t -xdr_char (xdrs, cp) - XDR *xdrs; - char *cp; +xdr_char (XDR *xdrs, char *cp) { int i; @@ -276,9 +347,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; @@ -295,9 +364,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; @@ -325,9 +392,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) { enum sizecheck { @@ -379,10 +444,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 char crud[BYTES_PER_XDR_UNIT]; diff --git a/sunrpc/xdr_intXX_t.c b/sunrpc/xdr_intXX_t.c index 98132cd..e50859e 100644 --- a/sunrpc/xdr_intXX_t.c +++ b/sunrpc/xdr_intXX_t.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1998 Free Software Foundation, Inc. +/* Copyright (c) 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998. @@ -20,6 +20,60 @@ #include <rpc/types.h> #include <rpc/xdr.h> +/* XDR 64bit integers */ +bool_t +xdr_int64_t (XDR *xdrs, int64_t *ip) +{ + int32_t t1; + int32_t t2; + + switch (xdrs->x_op) + { + case XDR_ENCODE: + t1 = (int32_t) ((*ip) >> 32); + t2 = (int32_t) (*ip); + return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2)); + case XDR_DECODE: + if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2)) + return FALSE; + *ip = ((int64_t) t1) << 32; + *ip |= t2; + return TRUE; + case XDR_FREE: + return TRUE; + default: + return FALSE; + } +} + +/* XDR 64bit unsigned integers */ +bool_t +xdr_uint64_t (XDR *xdrs, uint64_t *uip) +{ + uint32_t t1; + uint32_t t2; + + switch (xdrs->x_op) + { + case XDR_ENCODE: + t1 = (uint32_t) ((*uip) >> 32); + t2 = (uint32_t) (*uip); + return (XDR_PUTINT32 (xdrs, (int32_t *) &t1) && + XDR_PUTINT32(xdrs, (int32_t *) &t2)); + case XDR_DECODE: + if (!XDR_GETINT32(xdrs, (int32_t *) &t1) || + !XDR_GETINT32(xdrs, (int32_t *) &t2)) + return FALSE; + *uip = ((uint64_t) t1) << 32; + *uip |= t2; + return TRUE; + case XDR_FREE: + return TRUE; + default: + return FALSE; + } +} + /* XDR 32bit integers */ bool_t xdr_int32_t (XDR *xdrs, int32_t *lp) @@ -43,10 +97,10 @@ xdr_uint32_t (XDR *xdrs, uint32_t *ulp) { switch (xdrs->x_op) { - case XDR_DECODE: - return XDR_GETINT32 (xdrs, (int32_t *) ulp); case XDR_ENCODE: return XDR_PUTINT32 (xdrs, (int32_t *) ulp); + case XDR_DECODE: + return XDR_GETINT32 (xdrs, (int32_t *) ulp); case XDR_FREE: return TRUE; default: |