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/xdr.c | |
parent | 516d718a39eb540abca2915499b925962886ded9 (diff) | |
download | glibc-50f301a819f48c6e64232f2cd22d8e77f59d0f29.tar.gz |
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/xdr.c')
-rw-r--r-- | sunrpc/xdr.c | 106 |
1 files changed, 84 insertions, 22 deletions
diff --git a/sunrpc/xdr.c b/sunrpc/xdr.c index 57552c4427..6f1aed742f 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]; |