/home/vlg/develop/libASSA/libassa/assa/XDRHack.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 // $Id: XDRHack.h,v 1.2 2006/07/20 02:30:54 vlg Exp $
00004 //------------------------------------------------------------------------------
00005 //                               XDRHack.h
00006 //------------------------------------------------------------------------------
00007 //  Copyright (c) 2005 by Vladislav Grinchenko
00008 //
00009 //  This library is free software; you can redistribute it and/or
00010 //  modify it under the terms of the GNU Library General Public
00011 //  License as published by the Free Software Foundation; either
00012 //  version 2 of the License, or (at your option) any later version.
00013 //------------------------------------------------------------------------------
00014 //  Created: 04/20/2005
00015 //------------------------------------------------------------------------------
00016 #ifndef XDRHACK_H
00017 #define XDRHACK_H
00018 
00031 #if defined (__CYGWIN32__)
00032 extern "C" {
00033 #include <rpc/types.h>
00034 
00035 enum xdr_op {
00036     XDR_ENCODE=0,
00037     XDR_DECODE=1,
00038     XDR_FREE=2
00039 };
00040 
00041 typedef struct __rpc_xdr {
00042     enum xdr_op x_op;       /* operation; fast additional param */
00043     const struct xdr_ops {
00044         /* get a long from underlying stream 
00045          */
00046         bool_t  (*x_getlong)(struct __rpc_xdr *, long *);
00047         /* put a long to " 
00048          */
00049         bool_t  (*x_putlong)(struct __rpc_xdr *, const long *);
00050         /* get some bytes from " 
00051          */
00052         bool_t  (*x_getbytes)(struct __rpc_xdr *, char *, u_int);
00053         /* put some bytes to " 
00054          */
00055         bool_t  (*x_putbytes)(struct __rpc_xdr *, const char *, u_int);
00056         /* returns bytes off from beginning 
00057          */
00058         u_int   (*x_getpostn)(struct __rpc_xdr *);
00059         /* lets you reposition the stream 
00060          */
00061         bool_t  (*x_setpostn)(struct __rpc_xdr *, u_int);
00062         /* buf quick ptr to buffered data 
00063          */
00064         int32_t *(*x_inline)(struct __rpc_xdr *, u_int);
00065         /* free privates of this xdr_stream 
00066          */
00067         void    (*x_destroy)(struct __rpc_xdr *);
00068         bool_t  (*x_control)(struct __rpc_xdr *, int, void *);
00069     } *x_ops;
00070 
00071     caddr_t     x_public;   /* users' data */
00072     caddr_t     x_private;  /* pointer to private data */
00073     caddr_t     x_base;     /* private used for position info */
00074     int         x_handy;    /* extra private word */
00075 } XDR;
00076 
00077 #define XDR_DESTROY(xdrs) \
00078     if ((xdrs)->x_ops->x_destroy) \
00079         (*(xdrs)->x_ops->x_destroy)(xdrs)
00080 
00081 #define xdr_destroy(xdrs) \
00082     if ((xdrs)->x_ops->x_destroy) \
00083         (*(xdrs)->x_ops->x_destroy)(xdrs)
00084 
00085     typedef bool_t (*xdrproc_t)();
00086 
00087     extern bool_t xdr_opaque      (XDR *, caddr_t, u_int);
00088     extern bool_t xdr_string      (XDR *, char **, u_int);
00089     extern bool_t xdr_vector      (XDR *, char *,  u_int, u_int, xdrproc_t);
00090     extern void   xdrmem_create   (XDR *, char *,  u_int, enum xdr_op);
00091     extern void   xdrstdio_create (XDR *, FILE *,  enum xdr_op);
00092     extern bool_t xdr_int         (XDR *, int *);
00093     extern bool_t xdr_float       (XDR *, float *);
00094     extern bool_t xdr_double      (XDR *, double *);
00095     extern bool_t xdr_char        (XDR *, char *);
00096 }
00097 
00098 #else
00099 #  include <rpc/rpc.h>
00100 #endif
00101 
00102 #endif /* XDRHACK_H */

Generated on Sun Aug 13 15:08:00 2006 for libassa by  doxygen 1.4.6