Back to index

glibc  2.9
Functions
xdr_sizeof.c File Reference
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <sys/types.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

static bool_t x_putlong (XDR *xdrs, const long *longp)
static bool_t x_putbytes (XDR *xdrs, const char *bp, u_int len)
static u_int x_getpostn (const XDR *xdrs)
static bool_t x_setpostn (XDR *xdrs, u_int len)
static int32_tx_inline (XDR *xdrs, u_int len)
static int harmless (void)
static void x_destroy (XDR *xdrs)
static bool_t x_putint32 (XDR *xdrs, const int32_t *int32p)
unsigned long xdr_sizeof (xdrproc_t func, void *data)

Function Documentation

static int harmless ( void  ) [static]

Definition at line 102 of file xdr_sizeof.c.

{
  /* Always return FALSE/NULL, as the case may be */
  return 0;
}

Here is the caller graph for this function:

static void x_destroy ( XDR xdrs) [static]

Definition at line 109 of file xdr_sizeof.c.

{
  xdrs->x_handy = 0;
  xdrs->x_base = 0;
  if (xdrs->x_private)
    {
      free (xdrs->x_private);
      xdrs->x_private = NULL;
    }
  return;
}

Here is the caller graph for this function:

static u_int x_getpostn ( const XDR xdrs) [static]

Definition at line 60 of file xdr_sizeof.c.

{
  return xdrs->x_handy;
}

Here is the caller graph for this function:

static int32_t* x_inline ( XDR xdrs,
u_int  len 
) [static]

Definition at line 74 of file xdr_sizeof.c.

{
  if (len == 0)
    return NULL;
  if (xdrs->x_op != XDR_ENCODE)
    return NULL;
  if (len < (u_int) (long int) xdrs->x_base)
    {
      /* x_private was already allocated */
      xdrs->x_handy += len;
      return (int32_t *) xdrs->x_private;
    }
  else
    {
      /* Free the earlier space and allocate new area */
      free (xdrs->x_private);
      if ((xdrs->x_private = (caddr_t) malloc (len)) == NULL)
       {
         xdrs->x_base = 0;
         return NULL;
       }
      xdrs->x_base = (void *) (long) len;
      xdrs->x_handy += len;
      return (int32_t *) xdrs->x_private;
    }
}

Here is the caller graph for this function:

static bool_t x_putbytes ( XDR xdrs,
const char *  bp,
u_int  len 
) [static]

Definition at line 53 of file xdr_sizeof.c.

{
  xdrs->x_handy += len;
  return TRUE;
}

Here is the caller graph for this function:

static bool_t x_putint32 ( XDR xdrs,
const int32_t int32p 
) [static]

Definition at line 122 of file xdr_sizeof.c.

{
  xdrs->x_handy += BYTES_PER_XDR_UNIT;
  return TRUE;
}

Here is the caller graph for this function:

static bool_t x_putlong ( XDR xdrs,
const long *  longp 
) [static]

Definition at line 45 of file xdr_sizeof.c.

{
  xdrs->x_handy += BYTES_PER_XDR_UNIT;
  return TRUE;
}

Here is the caller graph for this function:

static bool_t x_setpostn ( XDR xdrs,
u_int  len 
) [static]

Definition at line 67 of file xdr_sizeof.c.

{
  /* This is not allowed */
  return FALSE;
}

Here is the caller graph for this function:

unsigned long xdr_sizeof ( xdrproc_t  func,
void *  data 
)

Definition at line 129 of file xdr_sizeof.c.

{
  XDR x;
  struct xdr_ops ops;
  bool_t stat;
  /* to stop ANSI-C compiler from complaining */
  typedef bool_t (*dummyfunc1) (XDR *, long *);
  typedef bool_t (*dummyfunc2) (XDR *, caddr_t, u_int);
  typedef bool_t (*dummyfunc3) (XDR *, int32_t *);

  ops.x_putlong = x_putlong;
  ops.x_putbytes = x_putbytes;
  ops.x_inline = x_inline;
  ops.x_getpostn = x_getpostn;
  ops.x_setpostn = x_setpostn;
  ops.x_destroy = x_destroy;
  ops.x_putint32 = x_putint32;

  /* the other harmless ones */
  ops.x_getlong = (dummyfunc1) harmless;
  ops.x_getbytes = (dummyfunc2) harmless;
  ops.x_getint32 = (dummyfunc3) harmless;

  x.x_op = XDR_ENCODE;
  x.x_ops = &ops;
  x.x_handy = 0;
  x.x_private = (caddr_t) NULL;
  x.x_base = (caddr_t) 0;

  stat = func (&x, data);
  free (x.x_private);
  return stat == TRUE ? x.x_handy : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: