home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xdr.zip / XDR.H < prev    next >
C/C++ Source or Header  |  1993-08-04  |  3KB  |  96 lines

  1. /*************************************************************************
  2. *
  3. * File Name     : XDR.H
  4. *
  5. * Description: OS/2 XDR library header file
  6. *               For further information about XDR see:
  7. *                - RFC 1014
  8. *                - John R. Corbin: The Art of Distributed Applications,
  9. *                  Springer Verlag, 1991
  10. *
  11. * Data Types : XDR            - XDR stream handle
  12. *               XDR_OP        - XDR options (encode, decode, free)
  13. *               xdrproc_t    - XDR decoding/encoding procedure
  14. *               xdr_discrim    - XDR discriminated union structure
  15. *
  16. * Procedures : xdrstdio_create()       xdrmem_create()        xdr_destroy()
  17. *               xdr_free()            xdrmem_base()        xdr_getpos()
  18. *               xdr_setpos()            xdr_char()            xdr_short()
  19. *               xdr_u_short()        xdr_int()            xdr_u_int()
  20. *               xdr_long()            xdr_u_long()        xdr_void()
  21. *               xdr_enum()            xdr_string()        xdr_opaque()
  22. *               xdr_bytes()            xdr_vector()        xdr_array()
  23. *               xdr_union()
  24. *
  25. * copyright (c) Jörg Caumanns, 1993 [caumanns@cs.tu-berlin.de]
  26. *
  27. *      DISCLAIMER OF WARRANTIES.
  28. *      The code is provided "AS IS", without warranty of any kind.
  29. *
  30. *************************************************************************/
  31. #ifndef _XDR_INCLUDED
  32. #define _XDR_INCLUDED
  33.  
  34. #include <os2def.h>
  35. #include <stdio.h>
  36.  
  37.  
  38. /*
  39. * XDR: dummy for the 'real' XDR-structure (defined in XDR.cpp)
  40. */
  41. typedef struct XDR    {
  42.     CHAR    dummy[32];
  43.     };
  44.  
  45. /*
  46. * XDR_OP: XDR options
  47. */
  48. typedef enum XDR_OP {
  49.             XDR_ENCODE,                // encode XDR stream
  50.             XDR_DECODE,                // decode XDR stream
  51.             XDR_FREE    };            // free memory allocated at decoding
  52.  
  53. /*
  54. * xdrproc_t
  55. */
  56. typedef BOOL(*xdrproc_t)(XDR *, VOID *);
  57.  
  58. /*
  59. * xdr_discrim
  60. */
  61. typedef struct xdr_discrim    {
  62.     SHORT        discr;                // discriminator
  63.     xdrproc_t   proc;                // XDR procedure for this arm of the union
  64.     };
  65.  
  66.  
  67. /*
  68. * function prototypes
  69. */
  70. VOID xdrstdio_create(XDR *, FILE *, XDR_OP);
  71. VOID xdrmem_create(XDR *, CHAR *, ULONG, XDR_OP);
  72. VOID xdr_destroy(XDR *);
  73. VOID xdr_free(xdrproc_t proc, CHAR *);
  74. CHAR *xdrmem_base(XDR *);
  75. UINT xdr_getpos(XDR *);
  76. BOOL xdr_setpos(XDR *, UINT);
  77.  
  78. BOOL xdr_char    (XDR *, CHAR *    );
  79. BOOL xdr_short    (XDR *, SHORT *    );
  80. BOOL xdr_u_short(XDR *, USHORT *);
  81. BOOL xdr_int    (XDR *, INT *    );
  82. BOOL xdr_u_int    (XDR *, UINT *    );
  83. BOOL xdr_long    (XDR *, LONG *    );
  84. BOOL xdr_u_long    (XDR *, ULONG *    );
  85. BOOL xdr_void    (XDR *, VOID *    );
  86. BOOL xdr_enum    (XDR *, INT *    );
  87.  
  88. BOOL xdr_string(XDR *, CHAR **, UINT);
  89. BOOL xdr_opaque(XDR *, CHAR * , UINT);
  90. BOOL xdr_bytes (XDR *, BYTE **, UINT *, UINT);
  91. BOOL xdr_vector(XDR *, CHAR *,  UINT,     UINT, xdrproc_t);
  92. BOOL xdr_array (XDR *, CHAR **, UINT *, UINT, UINT,    xdrproc_t);
  93. BOOL xdr_union (XDR *, INT  *,  CHAR *, xdr_discrim *, xdrproc_t);
  94.  
  95.  
  96. #endif /* _XDR_INCLUDED */