ReactOS  0.4.13-dev-1165-gd2976ca
xdr_sizeof.c File Reference
#include <wintirpc.h>
#include "namespace.h"
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <sys/types.h>
#include <stdlib.h>
#include "un-namespace.h"
Include dependency graph for xdr_sizeof.c:

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 (XDR *xdrs)
 
static bool_t x_setpostn (XDR *xdrs, u_int pos)
 
static int32_tx_inline (XDR *xdrs, u_int len)
 
static int harmless ()
 
static void x_destroy (XDR *xdrs)
 
unsigned long xdr_sizeof (xdrproc_t func, void *data)
 

Function Documentation

◆ harmless()

static int harmless ( )
static

Definition at line 106 of file xdr_sizeof.c.

107 {
108  /* Always return FALSE/NULL, as the case may be */
109  return (0);
110 }

Referenced by xdr_sizeof().

◆ x_destroy()

static void x_destroy ( XDR xdrs)
static

Definition at line 113 of file xdr_sizeof.c.

114 {
115  xdrs->x_handy = 0;
116  xdrs->x_base = 0;
117  if (xdrs->x_private) {
118  free(xdrs->x_private);
119  xdrs->x_private = NULL;
120  }
121  return;
122 }
#define free
Definition: debug_ros.c:5
u_int x_handy
Definition: xdr.h:127
smooth NULL
Definition: ftsmooth.c:416
void * x_private
Definition: xdr.h:125
char * x_base
Definition: xdr.h:126

Referenced by xdr_sizeof().

◆ x_getpostn()

static u_int x_getpostn ( XDR xdrs)
static

Definition at line 64 of file xdr_sizeof.c.

65 {
66  return (xdrs->x_handy);
67 }
u_int x_handy
Definition: xdr.h:127

Referenced by xdr_sizeof().

◆ x_inline()

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

Definition at line 78 of file xdr_sizeof.c.

79 {
80  if (len == 0) {
81  return (NULL);
82  }
83  if (xdrs->x_op != XDR_ENCODE) {
84  return (NULL);
85  }
86  if (len < PtrToUlong(xdrs->x_base)) {
87  /* x_private was already allocated */
88  xdrs->x_handy += len;
89  return ((int32_t *) xdrs->x_private);
90  } else {
91  /* Free the earlier space and allocate new area */
92  if (xdrs->x_private)
93  free(xdrs->x_private);
94  if ((xdrs->x_private = (caddr_t) malloc(len)) == NULL) {
95  xdrs->x_base = 0;
96  return (NULL);
97  }
98  xdrs->x_base = UIntToPtr(len);
99  //xdrs->x_base = len; // XXX Is this right???
100  xdrs->x_handy += len;
101  return ((int32_t *) xdrs->x_private);
102  }
103 }
#define UIntToPtr(ui)
Definition: basetsd.h:90
#define free
Definition: debug_ros.c:5
u_int x_handy
Definition: xdr.h:127
char * caddr_t
Definition: rosdhcp.h:36
smooth NULL
Definition: ftsmooth.c:416
#define PtrToUlong(u)
Definition: config.h:107
enum xdr_op x_op
Definition: xdr.h:104
Definition: xdr.h:85
GLenum GLsizei len
Definition: glext.h:6722
INT32 int32_t
Definition: types.h:71
void * x_private
Definition: xdr.h:125
#define malloc
Definition: debug_ros.c:4
char * x_base
Definition: xdr.h:126

Referenced by xdr_sizeof().

◆ x_putbytes()

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

Definition at line 57 of file xdr_sizeof.c.

58 {
59  xdrs->x_handy += len;
60  return (TRUE);
61 }
#define TRUE
Definition: types.h:120
u_int x_handy
Definition: xdr.h:127
GLenum GLsizei len
Definition: glext.h:6722

Referenced by xdr_sizeof().

◆ x_putlong()

static bool_t x_putlong ( XDR xdrs,
const long longp 
)
static

Definition at line 49 of file xdr_sizeof.c.

50 {
51  xdrs->x_handy += BYTES_PER_XDR_UNIT;
52  return (TRUE);
53 }
#define TRUE
Definition: types.h:120
u_int x_handy
Definition: xdr.h:127
#define BYTES_PER_XDR_UNIT
Definition: xdr.h:93

Referenced by xdr_sizeof().

◆ x_setpostn()

static bool_t x_setpostn ( XDR xdrs,
u_int  pos 
)
static

Definition at line 71 of file xdr_sizeof.c.

72 {
73  /* This is not allowed */
74  return (FALSE);
75 }

Referenced by xdr_sizeof().

◆ xdr_sizeof()

unsigned long xdr_sizeof ( xdrproc_t  func,
void data 
)

Definition at line 125 of file xdr_sizeof.c.

128 {
129  XDR x;
130  struct xdr_ops ops;
131  bool_t stat;
132  /* to stop ANSI-C compiler from complaining */
133  typedef bool_t (* dummyfunc1)(XDR *, long *);
134  typedef bool_t (* dummyfunc2)(XDR *, caddr_t, u_int);
135 
136  ops.x_putlong = x_putlong;
137  ops.x_putbytes = x_putbytes;
138  ops.x_inline = x_inline;
139  ops.x_getpostn = x_getpostn;
140  ops.x_setpostn = x_setpostn;
141  ops.x_destroy = x_destroy;
142 
143  /* the other harmless ones */
144  ops.x_getlong = (dummyfunc1) harmless;
145  ops.x_getbytes = (dummyfunc2) harmless;
146 
147  x.x_op = XDR_ENCODE;
148  x.x_ops = &ops;
149  x.x_handy = 0;
150  x.x_private = (caddr_t) NULL;
151  x.x_base = (caddr_t) 0;
152 
153  stat = func(&x, data);
154  if (x.x_private)
155  free(x.x_private);
156  return (stat == TRUE ? (unsigned) x.x_handy: 0);
157 }
GLenum func
Definition: glext.h:6028
#define TRUE
Definition: types.h:120
int32_t bool_t
Definition: types.h:101
static void x_destroy(XDR *xdrs)
Definition: xdr_sizeof.c:113
#define free
Definition: debug_ros.c:5
static bool_t x_putlong(XDR *xdrs, const long *longp)
Definition: xdr_sizeof.c:49
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
Definition: xdr.h:103
smooth NULL
Definition: ftsmooth.c:416
static u_int x_getpostn(XDR *xdrs)
Definition: xdr_sizeof.c:64
static int32_t * x_inline(XDR *xdrs, u_int len)
Definition: xdr_sizeof.c:78
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: xdr.h:85
Definition: stat.h:55
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define caddr_t
Definition: ftp.c:24
UINT32 u_int
Definition: types.h:82
static bool_t x_putbytes(XDR *xdrs, const char *bp, u_int len)
Definition: xdr_sizeof.c:57
static int harmless()
Definition: xdr_sizeof.c:106
static bool_t x_setpostn(XDR *xdrs, u_int pos)
Definition: xdr_sizeof.c:71