libassa  3.5.1
XDRHack.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // $Id: XDRHack.h,v 1.2 2006/07/20 02:30:54 vlg Exp $
4 //------------------------------------------------------------------------------
5 // XDRHack.h
6 //------------------------------------------------------------------------------
7 // Copyright (c) 2005 by Vladislav Grinchenko
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Library General Public
11 // License as published by the Free Software Foundation; either
12 // version 2 of the License, or (at your option) any later version.
13 //------------------------------------------------------------------------------
14 // Created: 04/20/2005
15 //------------------------------------------------------------------------------
16 #ifndef XDRHACK_H
17 #define XDRHACK_H
18 
31 #if defined (__CYGWIN32__)
32 extern "C" {
33 #include <rpc/types.h>
34 
35 enum xdr_op {
36  XDR_ENCODE=0,
37  XDR_DECODE=1,
38  XDR_FREE=2
39 };
40 
41 typedef struct __rpc_xdr {
42  enum xdr_op x_op; /* operation; fast additional param */
43  const struct xdr_ops {
44  /* get a long from underlying stream
45  */
46  bool_t (*x_getlong)(struct __rpc_xdr *, long *);
47  /* put a long to "
48  */
49  bool_t (*x_putlong)(struct __rpc_xdr *, const long *);
50  /* get some bytes from "
51  */
52  bool_t (*x_getbytes)(struct __rpc_xdr *, char *, u_int);
53  /* put some bytes to "
54  */
55  bool_t (*x_putbytes)(struct __rpc_xdr *, const char *, u_int);
56  /* returns bytes off from beginning
57  */
58  u_int (*x_getpostn)(struct __rpc_xdr *);
59  /* lets you reposition the stream
60  */
61  bool_t (*x_setpostn)(struct __rpc_xdr *, u_int);
62  /* buf quick ptr to buffered data
63  */
64  int32_t *(*x_inline)(struct __rpc_xdr *, u_int);
65  /* free privates of this xdr_stream
66  */
67  void (*x_destroy)(struct __rpc_xdr *);
68  bool_t (*x_control)(struct __rpc_xdr *, int, void *);
69  } *x_ops;
70 
71  caddr_t x_public; /* users' data */
72  caddr_t x_private; /* pointer to private data */
73  caddr_t x_base; /* private used for position info */
74  int x_handy; /* extra private word */
75 } XDR;
76 
77 #define XDR_DESTROY(xdrs) \
78  if ((xdrs)->x_ops->x_destroy) \
79  (*(xdrs)->x_ops->x_destroy)(xdrs)
80 
81 #define xdr_destroy(xdrs) \
82  if ((xdrs)->x_ops->x_destroy) \
83  (*(xdrs)->x_ops->x_destroy)(xdrs)
84 
85  typedef bool_t (*xdrproc_t)();
86 
87  extern bool_t xdr_opaque (XDR *, caddr_t, u_int);
88  extern bool_t xdr_string (XDR *, char **, u_int);
89  extern bool_t xdr_vector (XDR *, char *, u_int, u_int, xdrproc_t);
90  extern void xdrmem_create (XDR *, char *, u_int, enum xdr_op);
91  extern void xdrstdio_create (XDR *, FILE *, enum xdr_op);
92  extern bool_t xdr_int (XDR *, int *);
93  extern bool_t xdr_float (XDR *, float *);
94  extern bool_t xdr_double (XDR *, double *);
95  extern bool_t xdr_char (XDR *, char *);
96 }
97 
98 #else
99 # include <rpc/rpc.h>
100 #endif
101 
102 #endif /* XDRHACK_H */
unsigned int u_int
Definition: Logger_Impl.h:40