ReactOS  0.4.13-dev-1148-g9b75b67
xdr_array.c File Reference
#include <wintirpc.h>
#include "namespace.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "un-namespace.h"
Include dependency graph for xdr_array.c:

Go to the source code of this file.

Functions

bool_t xdr_array (XDR *xdrs, caddr_t *addrp, u_int *sizep, u_int maxsize, u_int elsize, xdrproc_t elproc)
 
bool_t xdr_vector (XDR *xdrs, char *basep, u_int nelem, u_int elemsize, xdrproc_t xdr_elem)
 

Function Documentation

◆ xdr_array()

bool_t xdr_array ( XDR xdrs,
caddr_t addrp,
u_int sizep,
u_int  maxsize,
u_int  elsize,
xdrproc_t  elproc 
)

Definition at line 61 of file xdr_array.c.

68 {
69  u_int i;
70  caddr_t target = *addrp;
71  u_int c; /* the actual element count */
72  bool_t stat = TRUE;
73  u_int nodesize;
74 
75  /* like strings, arrays are really counted arrays */
76  if (!xdr_u_int(xdrs, sizep)) {
77  return (FALSE);
78  }
79  c = *sizep;
80  if ((c > maxsize || UINT_MAX/elsize < c) &&
81  (xdrs->x_op != XDR_FREE)) {
82  return (FALSE);
83  }
84  nodesize = c * elsize;
85 
86  /*
87  * if we are deserializing, we may need to allocate an array.
88  * We also save time by checking for a null array if we are freeing.
89  */
90  if (target == NULL)
91  switch (xdrs->x_op) {
92  case XDR_DECODE:
93  if (c == 0)
94  return (TRUE);
95  *addrp = target = mem_alloc(nodesize);
96  if (target == NULL) {
97  //warnx("xdr_array: out of memory");
98  return (FALSE);
99  }
100  memset(target, 0, nodesize);
101  break;
102 
103  case XDR_FREE:
104  return (TRUE);
105 
106  case XDR_ENCODE:
107  break;
108  }
109 
110  /*
111  * now we xdr each element of array
112  */
113  for (i = 0; (i < c) && stat; i++) {
114  stat = (*elproc)(xdrs, target);
115  target += elsize;
116  }
117 
118  /*
119  * the array may need freeing
120  */
121  if (xdrs->x_op == XDR_FREE) {
122  mem_free(*addrp, nodesize);
123  *addrp = NULL;
124  }
125  return (stat);
126 }
#define TRUE
Definition: types.h:120
int32_t bool_t
Definition: types.h:101
XDR xdrs
Definition: svc_vc.c:97
char * caddr_t
Definition: rosdhcp.h:36
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define mem_alloc(bsize)
Definition: types.h:123
smooth NULL
Definition: ftsmooth.c:416
bool_t xdr_u_int(XDR *xdrs, u_int *up)
Definition: xdr.c:133
const GLubyte * c
Definition: glext.h:8905
enum xdr_op x_op
Definition: xdr.h:104
Definition: xdr.h:85
Definition: stat.h:55
#define UINT_MAX
Definition: limits.h:41
UINT32 u_int
Definition: types.h:82
Definition: xdr.h:87
#define c
Definition: ke_i.h:80
Definition: xdr.h:86
GLenum target
Definition: glext.h:7315
#define mem_free(ptr, bsize)
Definition: types.h:124
#define memset(x, y, z)
Definition: compat.h:39

Referenced by decode_file_attrs(), decode_op_secinfo(), decode_op_secinfo_noname(), decode_op_test_stateid(), encode_op_create_session(), encode_op_test_stateid(), op_cb_notify_deviceid_args(), op_cb_sequence_args(), op_cb_sequence_ref_list(), proc_cb_compound_args(), proc_cb_compound_res(), xdr_authunix_parms(), xdr_nfsacl41(), xdr_nfsdacl41(), and xdr_unixcred().

◆ xdr_vector()

bool_t xdr_vector ( XDR xdrs,
char basep,
u_int  nelem,
u_int  elemsize,
xdrproc_t  xdr_elem 
)

Definition at line 139 of file xdr_array.c.

145 {
146  u_int i;
147  char *elptr;
148 
149  elptr = basep;
150  for (i = 0; i < nelem; i++) {
151  if (!(*xdr_elem)(xdrs, elptr)) {
152  return(FALSE);
153  }
154  elptr += elemsize;
155  }
156  return(TRUE);
157 }
#define TRUE
Definition: types.h:120
XDR xdrs
Definition: svc_vc.c:97
#define nelem(x)
Definition: shaptest.c:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT elemsize
Definition: safearray.c:332
UINT32 u_int
Definition: types.h:82

Referenced by xdr_rpcb_stat_byvers(), and xdr_rpcbs_proc().