255 lines
9.6 KiB
C
Executable File
255 lines
9.6 KiB
C
Executable File
/******************************************************************************
|
|
*
|
|
* unirpc.h - include for rpc
|
|
*
|
|
* Module %M% Version %I% Date %H%
|
|
*
|
|
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
|
|
* This is unpublished proprietary source code of Ardent Software Inc.
|
|
* The copyright notice above does not evidence any actual or intended
|
|
* publication of such source code.
|
|
*
|
|
*******************************************************************************
|
|
*
|
|
* Maintenence log - insert most recent change descriptions at top
|
|
*
|
|
* Date.... GTAR# WHO Description........................................
|
|
* 10/14/98 23801 SAP Change copyrights.
|
|
* 09/10/98 23617 JAG uvrpc.h is now named unirpc.h
|
|
* 06/10/98 23088 OGO Added version 2 RPC support stuff
|
|
* 11/21/96 19003 SAP Previous fix will not work on NT - changed fix.
|
|
* 11/20/96 19003 SAP Changed SOCKET to SOCKETtype
|
|
* 05/31/96 18530 EAP Changed UVRPC_PIPE_NAME
|
|
* 04/29/96 18256 DJD Fix for some compiler warnings due to function defines
|
|
* not being in the right place.
|
|
* 01/02/96 17698 GMM Added NT pipe name and included UVRPC_DEFAULT_PORT
|
|
* 08/24/95 17162 DJD Added 16bit support for the rpc to this module.
|
|
* 08/23/95 17162 GMM Moved public stuff into rpc_public.h
|
|
* 03/08/95 17088 DJD Addition of WINNT and WIN16 defs and reordering of module
|
|
* to make insertion of additions easier at a later date.
|
|
* 07/25/95 16843 TMC return different error messages
|
|
* 04/04/95 16267 AGM Add declaration of uvrpc library entry points
|
|
* 03/28/95 15921 TMC increase max # of arguments to 2048
|
|
* 03/27/95 15921 TMC change TCP to UVTCP
|
|
* 03/27/95 15921 TMC put ifdef around define of TRUE and FALSE
|
|
* 11/03/94 14073 TMC porting problem
|
|
* 10/10/94 14073 TMC Network licensing
|
|
* 09/08/93 12220 DWT Port 7.3.2 to ptx
|
|
* 09/02/93 11392 TMC Change memory delallocation/allocation algorithm
|
|
* 08/27/93 11392 TMC change RPC header structure
|
|
* 07/28/93 11392 TMC Increase max # RPC arguments for RPC
|
|
* 07/24/93 11392 JWT Remove extern decl's to fix encore make
|
|
* 06/23/93 11392 TMC Add timeouts
|
|
* 06/17/93 11392 TMC Add RPC for uniVerse
|
|
*
|
|
****************************************************************************/
|
|
|
|
#if COMPUTER == NCR486
|
|
#undef SOCKET /* SOCKET previously defined in sys/memory.h */
|
|
#endif
|
|
|
|
#ifndef MSWIN
|
|
typedef int SOCKET; /* typedef SOCKET type to an int */
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#endif
|
|
|
|
#ifndef FALSE
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
/* This library is called unirpc externally and in the build process, because
|
|
it is shared between UniVerse and UniData, and is somewhat visible to users,
|
|
for example in the Uni RPC daemon. But it is called uvrpc internally, for
|
|
historical reasons. Also, the /etc/services service name of the RPC
|
|
daemon is still "uvrpc", partly due to the awkwardness of changing it, but
|
|
mainly because we didn't have time to change it when we changed
|
|
everything else.
|
|
*/
|
|
|
|
/* UVRPC version numbers */
|
|
#define UVRPC_VERSION 2
|
|
#define UVRPC_VERSION_LOWEST 1
|
|
|
|
/* The following is the port number in the /etc/services file that is
|
|
used for UVRPC networking. */
|
|
#define UVTCP "tcp"
|
|
#define UVRPCNAM "uvrpc"
|
|
|
|
/* Default uvrpc port number */
|
|
#define UVRPC_DEFAULT_PORT 31438
|
|
|
|
/* define the NT uvrpc LAN pipe name */
|
|
#define UVRPC_PIPE_NAME "\\\\.\\PIPE\\VMARK\\Universe\\uvrpc"
|
|
|
|
/* maximum number of RPC connextions */
|
|
#define UVRPC_MAX_CONNECTIONS 64
|
|
|
|
/* this increment is used to expand and decrease the buffer size
|
|
* it should be a round power of two and is only used to round off */
|
|
#define INCR_ARG_DATA_BYTES 8192
|
|
#define UVRPC_BUFMAX 8192
|
|
|
|
/* number of packets before we free the memory we were using */
|
|
#define INCR_PACKET 100
|
|
|
|
/* sizes of the fixed header (This must be a multiple of four bytes). */
|
|
#define FIXED_MSG_HDR_BYTES 24
|
|
|
|
/* tokens for position of fields in message format */
|
|
#define VERSION_POSN 0
|
|
#define MESSAGE_LEN_POSN 1
|
|
#define MESSAGE_KEY_POSN 2
|
|
#define VER_COM_ENC_POSN 3
|
|
#define RET_CODE_POSN 4
|
|
#define NUM_ARGS_POSN 5
|
|
|
|
/* Global variables */
|
|
|
|
/* Function extern's needed for use with this module */
|
|
#ifdef MSWIN /* WIN support */
|
|
EXTERN int ConvertDouble(char *, int, int);
|
|
#else
|
|
EXTERN int ConvertDouble();
|
|
EXTERN int close();
|
|
#endif
|
|
|
|
/* define macro's */
|
|
|
|
|
|
#ifdef MSWIN /* WIN support */
|
|
#define GETERROR WSAGetLastError()
|
|
#define CLOSESOCKET(sock) closesocket(sock)
|
|
|
|
/* If the compiler we are using supports function prototyping then these
|
|
macros will include the parameter definitions in the function
|
|
definitions (ANSII style), otherwise it will not include them (K&R
|
|
style) */
|
|
|
|
#define proto(x) x
|
|
#define ARG0() (void)
|
|
#define ARG1(p1t, p1n) (p1t p1n)
|
|
#define ARG2(p1t, p1n, p2t, p2n) (p1t p1n, p2t p2n)
|
|
#define ARG3(p1t, p1n, p2t, p2n, p3t, p3n) (p1t p1n, p2t p2n, p3t p3n)
|
|
#define ARG4(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n) \
|
|
(p1t p1n, p2t p2n, p3t p3n, p4t p4n)
|
|
#define ARG5(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n) \
|
|
(p1t p1n, p2t p2n, p3t p3n, p4t p4n, p5t p5n)
|
|
#define ARG6(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n, p6t, p6n) \
|
|
(p1t p1n, p2t p2n, p3t p3n, p4t p4n, p5t p5n, p6t p6n)
|
|
#define ARG7(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n, p6t, p6n, p7t, p7n) \
|
|
(p1t p1n, p2t p2n, p3t p3n, p4t p4n, p5t p5n, p6t p6n, p7t p7n)
|
|
|
|
#else /* UNIX */
|
|
#define INVALID_SOCKET -1 /* This is a winsock token name, it should not be changed */
|
|
#define SOCKET_ERROR -1 /* This is a winsock token name, it should not be changed */
|
|
#define WSAEINTR EINTR /* This is a winsock token name, it should not be changed */
|
|
#define WSAECONNREFUSED ECONNREFUSED /* This is a winsock token name, it should not be changed */
|
|
#define WSAETIMEDOUT ETIMEDOUT /* This is a winsock token name, it should not be changed */
|
|
#ifndef INADDR_NONE
|
|
#define INADDR_NONE -1
|
|
#endif
|
|
|
|
#define GETERROR errno
|
|
#define CLOSESOCKET(sock) close(sock)
|
|
|
|
#define proto(x) ()
|
|
#define ARG0() ()
|
|
#define ARG1(p1t, p1n) (p1n) p1t p1n;
|
|
#define ARG2(p1t, p1n, p2t, p2n) (p1n, p2n) p1t p1n; p2t p2n;
|
|
#define ARG3(p1t, p1n, p2t, p2n, p3t, p3n) \
|
|
(p1n, p2n, p3n) p1t p1n; p2t p2n; p3t p3n;
|
|
#define ARG4(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n) \
|
|
(p1n, p2n, p3n, p4n) p1t p1n; p2t p2n; p3t p3n; p4t p4n;
|
|
#define ARG5(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n) \
|
|
(p1n, p2n, p3n, p4n, p5n) p1t p1n; p2t p2n; p3t p3n; p4t p4n; p5t p5n;
|
|
#define ARG6(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n, p6t, p6n) \
|
|
(p1n, p2n, p3n, p4n, p5n, p6n) p1t p1n; p2t p2n; p3t p3n; p4t p4n; p5t p5n; p6t p6n;
|
|
#define ARG7(p1t, p1n, p2t, p2n, p3t, p3n, p4t, p4n, p5t, p5n, p6t, p6n, p7t, p7n) \
|
|
(p1n, p2n, p3n, p4n, p5n, p6n, p7n) p1t p1n; p2t p2n; p3t p3n; p4t p4n; p5t p5n; p6t p6n; p7t p7n;
|
|
#endif
|
|
|
|
|
|
#define SHORTINT(int_32_bit) ((int16)((int_32_bit) & 0xFFFF))
|
|
|
|
#define BYTEINT(int_32_bit) ((int16)((int_32_bit) & 0xFF))
|
|
|
|
#define RPCPACKINTS(int_32_bit, high_short, low_short) \
|
|
((int_32_bit) = (((int32) (SHORTINT(high_short)) << 16) | SHORTINT(low_short)))
|
|
|
|
#define RPCPACK_4_INTS(int_32_bit, high_high_byte, high_low_byte, low_high_byte, low_low_byte) \
|
|
((int_32_bit) = ( ((int32)((high_high_byte) & 0xFF) << 24) \
|
|
| ((int32)((high_low_byte) & 0xFF) << 16) \
|
|
| ((int32)((low_high_byte) & 0xFF) << 8) \
|
|
| ((int32)((low_low_byte) & 0xFF) << 0) ) )
|
|
|
|
#define HIGH16(int_32_bit) (((int_32_bit) >> 16) & 0xFFFF)
|
|
|
|
#define LOW16(int_32_bit) ((int_32_bit) & 0xFFFF)
|
|
|
|
#define HIGH16_HIGH8(int_32_bit) (((int_32_bit) >> 24) & 0xFF)
|
|
#define HIGH16_LOW8(int_32_bit) (((int_32_bit) >> 16) & 0xFF)
|
|
#define LOW16_HIGH8(int_32_bit) (((int_32_bit) >> 8) & 0xFF)
|
|
#define LOW16_LOW8(int_32_bit) ((int_32_bit) & 0xFF)
|
|
|
|
/* define macros used for setting, getting and checking the RPC version.
|
|
* We use a bit pattern in the top of the version number to check that
|
|
* it looks like the message really is for PI+ (uniVerse).
|
|
* So far we only accept one RPC_VERSION. */
|
|
|
|
#define UVRPC_PATT_CHECK 0x6c00 /* 01101100 in top byte */
|
|
|
|
#define UVRPC_SET_VERSION(version) ((version) | (UVRPC_PATT_CHECK))
|
|
|
|
#define UVRPC_GET_VERSION(version) \
|
|
(((version & 0xFF00) == UVRPC_PATT_CHECK) ? \
|
|
version & ~(UVRPC_PATT_CHECK) : -1)
|
|
|
|
#define UVRPC_VERSION_VALID(version) \
|
|
((version <= UVRPC_VERSION) && (version >= UVRPC_VERSION_LOWEST))
|
|
|
|
/* total size of the message buffer. */
|
|
#define INIT_MESSAGE_BUFFER_SIZE (FIXED_MSG_HDR_BYTES + INCR_ARG_DATA_BYTES)
|
|
|
|
|
|
/* ALIGNNUM(): Return the value of the supplied number rounded up to the
|
|
* nearest boundary required by the given variable type. */
|
|
|
|
#define ALIGNNUM(num, bas, typ) \
|
|
( \
|
|
(((num) + sizeof(typ) - 1) & ~(sizeof(typ) - 1)) + (bas) \
|
|
)
|
|
|
|
/* AlignPtr(): Return the value of the supplied pointer rounded up to the
|
|
* nearest boundary required by the given variable type.
|
|
*
|
|
* On 16 bit we have to pass the start point which malloc returned to us,
|
|
* this is because, we are using a segmented memory architecture and also
|
|
* because address are 16 bits not 32. */
|
|
|
|
#define ALIGNPTR(ptr, base, type) \
|
|
( \
|
|
ALIGNNUM((ptr) - (base), base, type)\
|
|
)
|
|
|
|
|
|
/* Structure def's. */
|
|
|
|
/* define the message buffer pointer structure. */
|
|
typedef struct
|
|
{
|
|
union {
|
|
unsigned char *buffer;
|
|
u_int32 *lptr;
|
|
} hdr;
|
|
union {
|
|
unsigned char *buffer;
|
|
u_int32 *lptr;
|
|
} data;
|
|
} uvrpc_buffer_type;
|
|
|
|
/* End of File */
|
|
|