ReactOS 0.4.16-dev-311-g9382aa2
xdr_stdio.c File Reference
#include <wintirpc.h>
#include "namespace.h"
#include <stdio.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "un-namespace.h"
Include dependency graph for xdr_stdio.c:

Go to the source code of this file.

Functions

static void xdrstdio_destroy (XDR *)
 
static bool_t xdrstdio_getlong (XDR *, long *)
 
static bool_t xdrstdio_putlong (XDR *, const long *)
 
static bool_t xdrstdio_getbytes (XDR *, char *, u_int)
 
static bool_t xdrstdio_putbytes (XDR *, const char *, u_int)
 
static u_int xdrstdio_getpos (XDR *)
 
static bool_t xdrstdio_setpos (XDR *, u_int)
 
static int32_txdrstdio_inline (XDR *, u_int)
 
void xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
 

Variables

static const struct xdr_ops xdrstdio_ops
 

Function Documentation

◆ xdrstdio_create()

void xdrstdio_create ( XDR xdrs,
FILE file,
enum xdr_op  op 
)

Definition at line 79 of file xdr_stdio.c.

83{
84
85 xdrs->x_op = op;
86 xdrs->x_ops = &xdrstdio_ops;
87 xdrs->x_private = file;
88 xdrs->x_handy = 0;
89 xdrs->x_base = 0;
90}
UINT op
Definition: effect.c:236
const struct __rpc_xdr::xdr_ops * x_ops
enum xdr_op x_op
Definition: xdr.h:104
char * x_base
Definition: xdr.h:126
void * x_private
Definition: xdr.h:125
u_int x_handy
Definition: xdr.h:127
Definition: fci.c:127
static const struct xdr_ops xdrstdio_ops
Definition: xdr_stdio.c:62

◆ xdrstdio_destroy()

static void xdrstdio_destroy ( XDR xdrs)
static

Definition at line 97 of file xdr_stdio.c.

99{
100 (void)fflush((FILE *)xdrs->x_private);
101 /* XXX: should we close the file ?? */
102}
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)

◆ xdrstdio_getbytes()

static bool_t xdrstdio_getbytes ( XDR xdrs,
char addr,
u_int  len 
)
static

Definition at line 129 of file xdr_stdio.c.

133{
134
135 if ((len != 0) && (fread(addr, (size_t)len, 1, (FILE *)xdrs->x_private) != 1))
136 return (FALSE);
137 return (TRUE);
138}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)

◆ xdrstdio_getlong()

static bool_t xdrstdio_getlong ( XDR xdrs,
long lp 
)
static

Definition at line 105 of file xdr_stdio.c.

108{
109
110 if (fread(lp, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
111 return (FALSE);
112 *lp = (long)ntohl((u_int32_t)*lp);
113 return (TRUE);
114}
INT32 int32_t
Definition: types.h:71
#define ntohl(x)
Definition: module.h:205
#define long
Definition: qsort.c:33
unsigned int u_int32_t
Definition: rosdhcp.h:35

◆ xdrstdio_getpos()

static u_int xdrstdio_getpos ( XDR xdrs)
static

Definition at line 154 of file xdr_stdio.c.

156{
157
158 return ((u_int) ftell((FILE *)xdrs->x_private));
159}
UINT32 u_int
Definition: types.h:82
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)

◆ xdrstdio_inline()

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

Definition at line 173 of file xdr_stdio.c.

176{
177
178 /*
179 * Must do some work to implement this: must insure
180 * enough data in the underlying stdio buffer,
181 * that the buffer is aligned so that we can indirect through a
182 * long *, and stuff this pointer in xdrs->x_buf. Doing
183 * a fread or fwrite to a scratch buffer would defeat
184 * most of the gains to be had here and require storage
185 * management on this buffer, so we don't do this.
186 */
187 return (NULL);
188}
#define NULL
Definition: types.h:112

◆ xdrstdio_putbytes()

static bool_t xdrstdio_putbytes ( XDR xdrs,
const char addr,
u_int  len 
)
static

Definition at line 141 of file xdr_stdio.c.

145{
146
147 if ((len != 0) && (fwrite(addr, (size_t)len, 1,
148 (FILE *)xdrs->x_private) != 1))
149 return (FALSE);
150 return (TRUE);
151}
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)

◆ xdrstdio_putlong()

static bool_t xdrstdio_putlong ( XDR xdrs,
const long lp 
)
static

Definition at line 117 of file xdr_stdio.c.

120{
121 long mycopy = (long)htonl((u_int32_t)*lp);
122
123 if (fwrite(&mycopy, sizeof(int32_t), 1, (FILE *)xdrs->x_private) != 1)
124 return (FALSE);
125 return (TRUE);
126}
#define htonl(x)
Definition: module.h:214

◆ xdrstdio_setpos()

static bool_t xdrstdio_setpos ( XDR xdrs,
u_int  pos 
)
static

Definition at line 162 of file xdr_stdio.c.

165{
166
167 return ((fseek((FILE *)xdrs->x_private, (long)pos, 0) < 0) ?
168 FALSE : TRUE);
169}
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)

Variable Documentation

◆ xdrstdio_ops

const struct xdr_ops xdrstdio_ops
static
Initial value:
= {
}
static bool_t xdrstdio_setpos(XDR *, u_int)
Definition: xdr_stdio.c:162
static bool_t xdrstdio_getlong(XDR *, long *)
Definition: xdr_stdio.c:105
static int32_t * xdrstdio_inline(XDR *, u_int)
Definition: xdr_stdio.c:173
static void xdrstdio_destroy(XDR *)
Definition: xdr_stdio.c:97
static u_int xdrstdio_getpos(XDR *)
Definition: xdr_stdio.c:154
static bool_t xdrstdio_putlong(XDR *, const long *)
Definition: xdr_stdio.c:117
static bool_t xdrstdio_putbytes(XDR *, const char *, u_int)
Definition: xdr_stdio.c:141
static bool_t xdrstdio_getbytes(XDR *, char *, u_int)
Definition: xdr_stdio.c:129

Definition at line 62 of file xdr_stdio.c.

Referenced by xdrstdio_create().