8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-27 06:03:02 +01:00
firebird-mirror/src/remote/xdr.h

101 lines
3.0 KiB
C
Raw Normal View History

2001-05-23 15:26:42 +02:00
/*
* PROGRAM: External Data Representation
* MODULE: xdr.h
* DESCRIPTION: GDS version of Sun's XDR Package.
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
2002-02-16 04:05:21 +01:00
*
* 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "DELTA" port
*
2002-10-30 07:40:58 +01:00
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
*
2001-05-23 15:26:42 +02:00
*/
#ifndef REMOTE_XDR_H
#define REMOTE_XDR_H
#include "../jrd/common.h"
#include <sys/types.h>
2009-03-01 14:23:58 +01:00
#ifdef WIN_NT
#include <winsock2.h>
2009-03-01 14:23:58 +01:00
typedef char* caddr_t;
2004-05-17 12:22:34 +02:00
#else // WIN_NT
2001-05-23 15:26:42 +02:00
#include <netinet/in.h>
2004-05-17 12:22:34 +02:00
#endif // WIN_NT
2001-05-23 15:26:42 +02:00
#if defined(__hpux) && !defined(ntohl)
// this include is only for HP 11i v2.
// ntohl is not defined in <netinet/in.h> when _XOPEN_SOURCE_EXTENDED
// is defined, even though ntohl is defined by POSIX
#include <arpa/inet.h>
#endif
2004-05-17 12:22:34 +02:00
typedef int XDR_INT;
typedef int bool_t;
2009-01-16 10:55:38 +01:00
//#ifndef enum_t
//#define enum_t enum xdr_op
//#endif
2001-05-23 15:26:42 +02:00
2009-01-16 10:55:38 +01:00
#define xdr_getpostn(xdr) ((*(*xdr).x_ops->x_getpostn)(xdr)) // unused?
#define xdr_destroy(xdr) (*(*xdr).x_ops->x_destroy)() // unused?
2001-05-23 15:26:42 +02:00
enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 };
2004-06-09 20:23:27 +02:00
typedef struct xdr_t
2001-05-23 15:26:42 +02:00
{
2009-08-14 12:03:19 +02:00
xdr_op x_op; // operation; fast additional param
2001-05-23 15:26:42 +02:00
struct xdr_ops
{
2009-08-14 12:03:19 +02:00
bool_t (*x_getlong)(struct xdr_t*, SLONG*); // get a long from underlying stream
bool_t (*x_putlong)(struct xdr_t*, const SLONG*); // put a long to "
bool_t (*x_getbytes)(struct xdr_t*, SCHAR *, u_int); // get some bytes from "
bool_t (*x_putbytes)(struct xdr_t*, const SCHAR*, u_int); // put some bytes to "
u_int (*x_getpostn)(struct xdr_t*); // returns bytes offset from beginning
bool_t (*x_setpostn)(struct xdr_t*, u_int); // repositions position in stream
caddr_t (*x_inline)(struct xdr_t*, u_int); // buf quick ptr to buffered data
XDR_INT (*x_destroy)(struct xdr_t*); // free privates of this xdr_stream
2001-05-23 15:26:42 +02:00
} const *x_ops;
2009-08-14 12:03:19 +02:00
caddr_t x_public; // Users' data
caddr_t x_private; // pointer to private data
caddr_t x_base; // private used for position info
int x_handy; // extra private word
public:
xdr_t() :
x_op(XDR_ENCODE), x_ops(0), x_public(0), x_private(0), x_base(0), x_handy(0)
{ }
2004-06-09 20:23:27 +02:00
} XDR;
2001-05-23 15:26:42 +02:00
2009-08-14 12:03:19 +02:00
// Discriminated union crud
2001-05-23 15:26:42 +02:00
// CVC: Restore the old definition if some compilation failure happens.
//typedef bool_t (*xdrproc_t)();
typedef bool_t (*xdrproc_t)(xdr_t*, SCHAR*);
2009-01-16 10:55:38 +01:00
//#define NULL_xdrproc_t ((xdrproc_t) 0)
2001-05-23 15:26:42 +02:00
struct xdr_discrim
{
2009-01-16 10:55:38 +01:00
xdr_op value;
2001-05-23 15:26:42 +02:00
xdrproc_t proc;
};
2009-08-14 12:03:19 +02:00
#endif // REMOTE_XDR_H