aboutsummaryrefslogtreecommitdiff
path: root/sunrpc/xdr_rec.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-03-08 11:46:22 +0000
committerUlrich Drepper <drepper@redhat.com>1999-03-08 11:46:22 +0000
commit7d1de115db4c8b660d12ad1a72cb95ffa7f7a234 (patch)
treeca94f7d2b4d2e78a93ae8e653cd5ab5528fab2ed /sunrpc/xdr_rec.c
parentb74656f98231fc1d31f8200b3306e2d821ec2cf4 (diff)
downloadglibc-7d1de115db4c8b660d12ad1a72cb95ffa7f7a234.tar
glibc-7d1de115db4c8b660d12ad1a72cb95ffa7f7a234.tar.gz
glibc-7d1de115db4c8b660d12ad1a72cb95ffa7f7a234.tar.bz2
glibc-7d1de115db4c8b660d12ad1a72cb95ffa7f7a234.zip
Update.
1999-03-08 Andreas Schwab <schwab@issan.cs.uni-dortmund.de> * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Undo last change. /dev/pts status may change during runtime. 1999-03-08 Andreas Schwab <schwab@issan.cs.uni-dortmund.de> * sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Undo last change. /dev/pts status can change during runtime. 1999-03-07 Thorsten Kukuk <kukuk@suse.de> * sunrpc/svc_tcp.c (readtcp): go into fatal error state if poll reports error. * nis/nss_nisplus/nisplus-parser.c: Avoid duplicate strlen calls, add some more sanity checks. * nis/nss_nisplus/nisplus-pwd.c: Include nisplus-parser.h for parser prototype. 1999-03-05 Thorsten Kukuk <kukuk@suse.de> * sunrpc/rpc/xdr.h: Add x_getint32/x_putint32 to xdr_ops, change XDR_GETINT32/XDR_PUTINT32 to sue new functions. * sunrpc/xdr_mem.c: Add xdrmem_getint32, xdrmem_putint32. * sunrpc/xdr_rec.c: Add xdrrec_getint32, xdrrec_putint32. * sunrpc/xdr_sizeof.c: Add x_putint32, add dummy function for x_getint32. * sunrpc/xdr_stdio.c: Add xdrstdio_getint32, xdrstdio_putint32. * nis/nis_print.c: Fix ctime argument for platforms where sizeof (time_t) != sizeof (int). 255. Patch by Bruno Haible <haible@ilog.fr> [PR libc/1010].
Diffstat (limited to 'sunrpc/xdr_rec.c')
-rw-r--r--sunrpc/xdr_rec.c60
1 files changed, 54 insertions, 6 deletions
diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c
index 30be6393a2..e0f22c5595 100644
--- a/sunrpc/xdr_rec.c
+++ b/sunrpc/xdr_rec.c
@@ -66,6 +66,8 @@ static u_int xdrrec_getpos (const XDR *);
static bool_t xdrrec_setpos (XDR *, u_int);
static long *xdrrec_inline (XDR *, int);
static void xdrrec_destroy (XDR *);
+static bool_t xdrrec_getint32 (XDR *, int32_t *);
+static bool_t xdrrec_putint32 (XDR *, const int32_t *);
static const struct xdr_ops xdrrec_ops =
{
@@ -76,7 +78,9 @@ static const struct xdr_ops xdrrec_ops =
xdrrec_getpos,
xdrrec_setpos,
xdrrec_inline,
- xdrrec_destroy
+ xdrrec_destroy,
+ xdrrec_getint32,
+ xdrrec_putint32
};
/*
@@ -251,11 +255,8 @@ xdrrec_putlong (xdrs, lp)
return TRUE;
}
-static bool_t /* must manage buffers, fragments, and records */
-xdrrec_getbytes (xdrs, addr, len)
- XDR *xdrs;
- caddr_t addr;
- u_int len;
+static bool_t /* must manage buffers, fragments, and records */
+xdrrec_getbytes (XDR *xdrs, caddr_t addr, u_int len)
{
RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
u_int current;
@@ -420,6 +421,53 @@ xdrrec_destroy (xdrs)
mem_free ((caddr_t) rstrm, sizeof (RECSTREAM));
}
+static bool_t
+xdrrec_getint32 (XDR *xdrs, int32_t *ip)
+{
+ RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
+ int32_t *bufip = (int32_t *) rstrm->in_finger;
+ int32_t mylong;
+
+ /* first try the inline, fast case */
+ if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT &&
+ rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT)
+ {
+ *ip = ntohl (*bufip);
+ rstrm->fbtbc -= BYTES_PER_XDR_UNIT;
+ rstrm->in_finger += BYTES_PER_XDR_UNIT;
+ }
+ else
+ {
+ if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong,
+ BYTES_PER_XDR_UNIT))
+ return FALSE;
+ *ip = ntohl (mylong);
+ }
+ return TRUE;
+}
+
+static bool_t
+xdrrec_putint32 (XDR *xdrs, const int32_t *ip)
+{
+ RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
+ int32_t *dest_ip = (int32_t *) rstrm->out_finger;
+
+ if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry)
+ {
+ /*
+ * this case should almost never happen so the code is
+ * inefficient
+ */
+ rstrm->out_finger -= BYTES_PER_XDR_UNIT;
+ rstrm->frag_sent = TRUE;
+ if (!flush_out (rstrm, FALSE))
+ return FALSE;
+ dest_ip = (int32_t *) rstrm->out_finger;
+ rstrm->out_finger += BYTES_PER_XDR_UNIT;
+ }
+ *dest_ip = htonl (*ip);
+ return TRUE;
+}
/*
* Exported routines to manage xdr records