00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef _RPC_XDR_H
00044 #define _RPC_XDR_H
00045 #ifndef WIN32
00046 #include <sys/cdefs.h>
00047 #else
00048 #include "cdefs.h"
00049 #endif
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 enum xdr_op {
00087 XDR_ENCODE=0,
00088 XDR_DECODE=1,
00089 XDR_FREE=2
00090 };
00091
00092
00093
00094
00095 #define BYTES_PER_XDR_UNIT (4)
00096 #define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \
00097 * BYTES_PER_XDR_UNIT)
00098
00099
00100
00101
00102
00103
00104
00105 typedef struct __rpc_xdr {
00106 enum xdr_op x_op;
00107 struct xdr_ops {
00108
00109 bool_t (*x_getlong) __P((struct __rpc_xdr *, long *));
00110
00111 bool_t (*x_putlong) __P((struct __rpc_xdr *, long *));
00112
00113 bool_t (*x_getbytes) __P((struct __rpc_xdr *, caddr_t, u_int));
00114
00115 bool_t (*x_putbytes) __P((struct __rpc_xdr *, caddr_t, u_int));
00116
00117 u_int (*x_getpostn) __P((struct __rpc_xdr *));
00118
00119 bool_t (*x_setpostn) __P((struct __rpc_xdr *, u_int));
00120
00121 int32_t *(*x_inline) __P((struct __rpc_xdr *, u_int));
00122
00123 void (*x_destroy) __P((struct __rpc_xdr *));
00124 } *x_ops;
00125 caddr_t x_public;
00126 caddr_t x_private;
00127 caddr_t x_base;
00128 int x_handy;
00129 } XDR;
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 typedef bool_t (*xdrproc_t) __P(());
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 #define XDR_GETLONG(xdrs, longp) \
00153 (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
00154 #define xdr_getlong(xdrs, longp) \
00155 (*(xdrs)->x_ops->x_getlong)(xdrs, longp)
00156
00157 #define XDR_PUTLONG(xdrs, longp) \
00158 (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
00159 #define xdr_putlong(xdrs, longp) \
00160 (*(xdrs)->x_ops->x_putlong)(xdrs, longp)
00161
00162 #define XDR_GETBYTES(xdrs, addr, len) \
00163 (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
00164 #define xdr_getbytes(xdrs, addr, len) \
00165 (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
00166
00167 #define XDR_PUTBYTES(xdrs, addr, len) \
00168 (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
00169 #define xdr_putbytes(xdrs, addr, len) \
00170 (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
00171
00172 #define XDR_GETPOS(xdrs) \
00173 (*(xdrs)->x_ops->x_getpostn)(xdrs)
00174 #define xdr_getpos(xdrs) \
00175 (*(xdrs)->x_ops->x_getpostn)(xdrs)
00176
00177 #define XDR_SETPOS(xdrs, pos) \
00178 (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
00179 #define xdr_setpos(xdrs, pos) \
00180 (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
00181
00182 #define XDR_INLINE(xdrs, len) \
00183 (*(xdrs)->x_ops->x_inline)(xdrs, len)
00184 #define xdr_inline(xdrs, len) \
00185 (*(xdrs)->x_ops->x_inline)(xdrs, len)
00186
00187 #define XDR_DESTROY(xdrs) \
00188 if ((xdrs)->x_ops->x_destroy) \
00189 (*(xdrs)->x_ops->x_destroy)(xdrs)
00190 #define xdr_destroy(xdrs) \
00191 if ((xdrs)->x_ops->x_destroy) \
00192 (*(xdrs)->x_ops->x_destroy)(xdrs)
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 #define NULL_xdrproc_t ((xdrproc_t)0)
00205 struct xdr_discrim {
00206 int value;
00207 xdrproc_t proc;
00208 };
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 #define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++))
00226 #define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v))
00227
00228 #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf))
00229 #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf))
00230 #define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf))
00231 #define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf))
00232 #define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf))
00233
00234 #define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
00235 #define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
00236 #define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
00237 #define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
00238 #define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v)))
00239
00240
00241
00242
00243 __BEGIN_DECLS
00244 extern bool_t xdr_void __P((void));
00245 extern bool_t xdr_int __P((XDR *, int *));
00246 extern bool_t xdr_u_int __P((XDR *, u_int *));
00247 extern bool_t xdr_long __P((XDR *, long *));
00248 extern bool_t xdr_u_long __P((XDR *, u_long *));
00249 extern bool_t xdr_short __P((XDR *, short *));
00250 extern bool_t xdr_u_short __P((XDR *, u_short *));
00251 extern bool_t xdr_int16_t __P((XDR *, int16_t *));
00252 extern bool_t xdr_u_int16_t __P((XDR *, u_int16_t *));
00253 extern bool_t xdr_int32_t __P((XDR *, int32_t *));
00254 extern bool_t xdr_u_int32_t __P((XDR *, u_int32_t *));
00255 extern bool_t xdr_bool __P((XDR *, bool_t *));
00256 extern bool_t xdr_enum __P((XDR *, enum_t *));
00257 extern bool_t xdr_array __P((XDR *, char **, u_int *, u_int, u_int, xdrproc_t));
00258 extern bool_t xdr_bytes __P((XDR *, char **, u_int *, u_int));
00259 extern bool_t xdr_opaque __P((XDR *, caddr_t, u_int));
00260 extern bool_t xdr_string __P((XDR *, char **, u_int));
00261 extern bool_t xdr_union __P((XDR *, enum_t *, char *, struct xdr_discrim *, xdrproc_t));
00262 extern bool_t xdr_char __P((XDR *, char *));
00263 extern bool_t xdr_u_char __P((XDR *, u_char *));
00264 extern bool_t xdr_vector __P((XDR *, char *, u_int, u_int, xdrproc_t));
00265 extern bool_t xdr_float __P((XDR *, float *));
00266 extern bool_t xdr_double __P((XDR *, double *));
00267 extern bool_t xdr_reference __P((XDR *, caddr_t *, u_int, xdrproc_t));
00268 extern bool_t xdr_pointer __P((XDR *, caddr_t *, u_int, xdrproc_t));
00269 extern bool_t xdr_wrapstring __P((XDR *, char **));
00270 extern void xdr_free __P((xdrproc_t, char *));
00271 __END_DECLS
00272
00273
00274
00275
00276
00277 #define MAX_NETOBJ_SZ 1024
00278 struct netobj {
00279 u_int n_len;
00280 char *n_bytes;
00281 };
00282 typedef struct netobj netobj;
00283 extern bool_t xdr_netobj __P((XDR *, struct netobj *));
00284
00285
00286
00287
00288
00289 __BEGIN_DECLS
00290
00291 extern void xdrmem_create __P((XDR *, char *, u_int, enum xdr_op));
00292
00293 #ifdef _STDIO_H_
00294
00295 extern void xdrstdio_create __P((XDR *, FILE *, enum xdr_op));
00296 #endif
00297
00298
00299 extern void xdrrec_create __P((XDR *, u_int, u_int, char *,
00300 int (*) __P((caddr_t, caddr_t, int)),
00301 int (*) __P((caddr_t, caddr_t, int))));
00302
00303
00304 extern bool_t xdrrec_endofrecord __P((XDR *, int));
00305
00306
00307 extern bool_t xdrrec_skiprecord __P((XDR *));
00308
00309
00310 extern bool_t xdrrec_eof __P((XDR *));
00311 __END_DECLS
00312
00313 #endif