/*
- * 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.
+ * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking"
+ * layer above tcp (for rpc's use).
*
- * 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.
+ * Copyright (c) 2010, Oracle America, Inc.
*
- * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
*
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California 94043
- */
-
-/*
- * xdr_rec.c, Implements TCP/IP based XDR streams with a "record marking"
- * layer above tcp (for rpc's use).
+ * * 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.
*
- * Copyright (C) 1984, Sun Microsystems, Inc.
+ * 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.
*
* These routines interface XDRSTREAMS to a tcp/ip connection.
* There is a record marking layer between the xdr stream
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <stdint.h>
#include <rpc/rpc.h>
#include <libintl.h>
-
-#ifdef USE_IN_LIBIO
-# include <wchar.h>
-# include <libio/iolibio.h>
-#endif
+#include <wchar.h>
+#include <libio/iolibio.h>
+#include <shlib-compat.h>
static bool_t xdrrec_getlong (XDR *, long *);
static bool_t xdrrec_putlong (XDR *, const long *);
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 curren fragment */
+ uint32_t *frag_header; /* beginning of curren fragment */
bool_t frag_sent; /* true if buffer sent in middle of record */
/*
* in-coming bits
}
RECSTREAM;
-static u_int fix_buf_size (u_int) internal_function;
-static bool_t skip_input_bytes (RECSTREAM *, long) internal_function;
-static bool_t flush_out (RECSTREAM *, bool_t) internal_function;
-static bool_t set_input_fragment (RECSTREAM *) internal_function;
-static bool_t get_input_bytes (RECSTREAM *, caddr_t, int) internal_function;
+static u_int fix_buf_size (u_int);
+static bool_t skip_input_bytes (RECSTREAM *, long);
+static bool_t flush_out (RECSTREAM *, bool_t);
+static bool_t set_input_fragment (RECSTREAM *);
+static bool_t get_input_bytes (RECSTREAM *, caddr_t, int);
/*
* Create an xdr handle for xdrrec
if (rstrm == NULL || buf == NULL)
{
- (void) __fxprintf (NULL, "%s", _("xdrrec_create: out of memory\n"));
+ (void) __fxprintf (NULL, "%s: %s", __func__, _("out of memory\n"));
mem_free (rstrm, sizeof (RECSTREAM));
mem_free (buf, sendsize + recvsize + BYTES_PER_XDR_UNIT);
/*
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 = (uint32_t *) rstrm->out_base;
rstrm->out_finger += 4;
rstrm->out_boundry += sendsize;
rstrm->frag_sent = FALSE;
rstrm->fbtbc = 0;
rstrm->last_frag = TRUE;
}
-INTDEF(xdrrec_create)
+libc_hidden_nolink_sunrpc (xdrrec_create, GLIBC_2_0)
/*
rstrm->last_frag = FALSE;
return TRUE;
}
-INTDEF(xdrrec_skiprecord)
+libc_hidden_nolink_sunrpc (xdrrec_skiprecord, GLIBC_2_0)
/*
* Lookahead function.
return TRUE;
return FALSE;
}
-INTDEF(xdrrec_eof)
+libc_hidden_nolink_sunrpc (xdrrec_eof, GLIBC_2_0)
/*
* The client must tell the package when an end-of-record has occurred.
len = (rstrm->out_finger - (char *) rstrm->frag_header
- BYTES_PER_XDR_UNIT);
*rstrm->frag_header = htonl ((u_long) len | LAST_FRAG);
- rstrm->frag_header = (u_int32_t *) rstrm->out_finger;
+ rstrm->frag_header = (uint32_t *) rstrm->out_finger;
rstrm->out_finger += BYTES_PER_XDR_UNIT;
return TRUE;
}
-INTDEF(xdrrec_endofrecord)
+libc_hidden_nolink_sunrpc (xdrrec_endofrecord, GLIBC_2_0)
/*
* Internal useful routines
*/
static bool_t
-internal_function
flush_out (RECSTREAM *rstrm, bool_t eor)
{
u_long eormask = (eor == TRUE) ? LAST_FRAG : 0;
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->frag_header = (uint32_t *) rstrm->out_base;
rstrm->out_finger = (caddr_t) rstrm->out_base + BYTES_PER_XDR_UNIT;
return TRUE;
}
}
static bool_t /* knows nothing about records! Only about input buffers */
-internal_function
get_input_bytes (RECSTREAM *rstrm, caddr_t addr, int len)
{
int current;
}
static bool_t /* next two bytes of the input stream are treated as a header */
-internal_function
set_input_fragment (RECSTREAM *rstrm)
{
uint32_t header;
}
static bool_t /* consumes input bytes; knows nothing about records! */
-internal_function
skip_input_bytes (RECSTREAM *rstrm, long cnt)
{
int current;
}
static u_int
-internal_function
fix_buf_size (u_int s)
{
if (s < 100)