]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sunrpc/xdr_ref.c
sunrpc: Improvements for UDP client timeout handling [BZ #20257]
[thirdparty/glibc.git] / sunrpc / xdr_ref.c
index 911892ef2de03cc7770ca78aa6509f5cd596b8b3..2b7ebc8e11ca4dab20877cbaec042666195c6f7f 100644 (file)
@@ -1,49 +1,46 @@
-/* @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC */
 /*
- * 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.
+ * xdr_reference.c, Generic XDR routines implementation.
  *
- * 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.
+ * Copyright (c) 2010, Oracle America, Inc.
  *
- * 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.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
  *
- * 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.
+ *     * 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.
  *
- * 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.
+ *   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.
  *
- * Sun Microsystems, Inc.
- * 2550 Garcia Avenue
- * Mountain View, California  94043
- */
-#if !defined(lint) && defined(SCCSIDS)
-static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
-#endif
-
-/*
- * xdr_reference.c, Generic XDR routines implementation.
- *
- * Copyright (C) 1987, Sun Microsystems, Inc.
- *
- * These are the "non-trivial" xdr primitives used to serialize and de-serialize
- * "pointers".  See xdr.h for more info on the interface to xdr.
+ * These are the "non-trivial" xdr primitives used to serialize and
+ * de-serialize "pointers".  See xdr.h for more info on the interface to xdr.
  */
 
 #include <stdio.h>
 #include <string.h>
 #include <rpc/types.h>
 #include <rpc/xdr.h>
+#include <libintl.h>
+#include <wchar.h>
+#include <libio/iolibio.h>
 
 #define LASTUNSIGNED   ((u_int)0-1)
 
@@ -57,11 +54,13 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
  * proc is the routine to handle the referenced structure.
  */
 bool_t
-xdr_reference (xdrs, pp, size, proc)
-     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 */
+xdr_reference (XDR *xdrs,
+              /* the pointer to work on */
+              caddr_t *pp,
+              /* size of the object pointed to */
+              u_int size,
+              /* xdr routine to handle the object */
+              xdrproc_t proc)
 {
   caddr_t loc = *pp;
   bool_t stat;
@@ -73,13 +72,12 @@ xdr_reference (xdrs, pp, size, proc)
        return TRUE;
 
       case XDR_DECODE:
-       *pp = loc = (caddr_t) mem_alloc (size);
+       *pp = loc = (caddr_t) calloc (1, size);
        if (loc == NULL)
          {
-           (void) fputs (_("xdr_reference: out of memory\n"), stderr);
+           (void) __fxprintf (NULL, "%s: %s", __func__, _("out of memory\n"));
            return FALSE;
          }
-       bzero (loc, (int) size);
        break;
       default:
        break;
@@ -94,6 +92,7 @@ xdr_reference (xdrs, pp, size, proc)
     }
   return stat;
 }
+libc_hidden_nolink_sunrpc (xdr_reference, GLIBC_2_0)
 
 
 /*
@@ -116,11 +115,7 @@ xdr_reference (xdrs, pp, size, proc)
  *
  */
 bool_t
-xdr_pointer (xdrs, objpp, obj_size, xdr_obj)
-     XDR *xdrs;
-     char **objpp;
-     u_int obj_size;
-     xdrproc_t xdr_obj;
+xdr_pointer (XDR *xdrs, char **objpp, u_int obj_size, xdrproc_t xdr_obj)
 {
 
   bool_t more_data;
@@ -137,3 +132,8 @@ xdr_pointer (xdrs, objpp, obj_size, xdr_obj)
     }
   return xdr_reference (xdrs, objpp, obj_size, xdr_obj);
 }
+#ifdef EXPORT_RPC_SYMBOLS
+libc_hidden_def (xdr_pointer)
+#else
+libc_hidden_nolink_sunrpc (xdr_pointer, GLIBC_2_0)
+#endif