410 lines
15 KiB
C
Executable File
410 lines
15 KiB
C
Executable File
#ifndef _h_rpc_public
|
|
#define _h_rpc_public
|
|
/******************************************************************************
|
|
*
|
|
* rpc_public.h - include file for all callers of the 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........................................
|
|
* 04/15/99 24890 RGA Add support for 8-byte field.
|
|
* 11/25/98 23062 SAP Correct previous fix.
|
|
* 11/23/98 23062 SAP Add check for IBM again.
|
|
* 11/19/98 23062 SAP Remove check for IBM, check for defined ints.
|
|
* 10/19/98 23765 CSM Add CHRARGLEN macro to get length of char args
|
|
* 10/14/98 23801 SAP Change copyrights.
|
|
* 10/05/98 23765 CSM Add prototype for uvrpc_get_machid
|
|
* 06/10/98 23088 OGO Add version 2 RPC support stuff
|
|
* 06/08/98 23062 SAP Port 9.5.1 to AIX 4.3
|
|
* 11/31/97 22201 AGM Add casts to remove compiler warnings
|
|
* 11/20/97 21417 WSM Added CLEAROUTARGS and CLEARINARGS macros.
|
|
* 06/26/97 20104 DW Fixed NLSIPMAP,NLSOPMAP for NULL UVRPC_CHARs.
|
|
* 02/04/97 20104 DW Added more NLS support macros and enhanced existing ones.
|
|
* 07/24/96 18900 DJD Added transport type to unpack and build packet.
|
|
* 05/29/96 18530 EAP Added LAN Pipe support
|
|
* 04/23/96 18242 GMM Fixed code cleanup changes for NT build.
|
|
* 04/22/96 18242 TMC Code Cleanup, Phase I, more fixes
|
|
* 04/15/96 18285 EAP Added NLSIPMAP and NLSOPMAP macros.
|
|
* 01/02/96 17698 GMM Moved UVRPC_DEFAULT_PORT into uvrpc.h. Added 81018.
|
|
* 12/05/95 17162 AGM Add UVRPC_SOCKET_INIT_FAILED
|
|
* 09/07/95 17162 GMM Added new rpc routines
|
|
* 09/05/95 17162 DJD Build fixes after 16 bit changes.
|
|
* 08/24/95 17162 DJD Added 16bit changes to this module.
|
|
* 08/14/95 17162 GMM Module Created (from uvrpc.h contents)
|
|
*
|
|
****************************************************************************/
|
|
|
|
/* Variable Defines */
|
|
|
|
#ifdef WIN_32 /* WIN 32 support */
|
|
typedef int int32;
|
|
typedef short int16;
|
|
typedef long long32;
|
|
|
|
typedef int uvint32;
|
|
typedef unsigned int u_int32;
|
|
typedef unsigned short u_int16;
|
|
typedef unsigned long u_long32;
|
|
|
|
#else
|
|
#ifdef WIN_16 /* Windows 16 bit support */
|
|
typedef long int32;
|
|
typedef int int16;
|
|
typedef long long32;
|
|
|
|
typedef long uvint32;
|
|
typedef unsigned long u_int32;
|
|
typedef unsigned int u_int16;
|
|
typedef unsigned long u_long32;
|
|
|
|
#else /* UNIX */
|
|
#if COMPUTER != IBMrios
|
|
#ifndef int32
|
|
typedef int int32;
|
|
#endif
|
|
#ifndef int16
|
|
typedef short int16;
|
|
#endif
|
|
#ifndef long32
|
|
typedef long long32;
|
|
#endif
|
|
#ifndef u_int32
|
|
typedef unsigned int u_int32;
|
|
#endif
|
|
#ifndef u_int16
|
|
typedef unsigned int u_int16;
|
|
#endif
|
|
#endif
|
|
|
|
typedef unsigned long u_long32;
|
|
|
|
typedef int uvint32;
|
|
|
|
/* 16bit args on the functions require FAR and PASCAL, win32 takes care of
|
|
these itself, these are so that UNIX can as well */
|
|
|
|
#define FAR
|
|
#define PASCAL
|
|
|
|
#endif
|
|
#endif
|
|
|
|
/* RPCSTRING is basically the same as STRING (universe internal), but is
|
|
typed to be safe for 16 bit */
|
|
|
|
typedef struct rpcstring
|
|
{
|
|
int32 len;
|
|
unsigned char * text;
|
|
} RPCSTRING;
|
|
|
|
/* maximum number of args the user can pass to the RPC, and maximum
|
|
size of a buffer */
|
|
|
|
#define MAX_NUM_RPC_ARGS 2048
|
|
|
|
/* transport type argument to uvrpc_set_transport () */
|
|
|
|
#define UVRPC_TCPIP 1
|
|
#define UVRPC_LANPIPE 2
|
|
|
|
/* datatypes for uvrpcdata structure */
|
|
|
|
#define UVRPC_INT 0
|
|
#define UVRPC_DOUBLE 1
|
|
#define UVRPC_CHAR 2
|
|
#define UVRPC_STRING 3
|
|
#define UVRPC_INT_PTR 4
|
|
#define UVRPC_DOUBLE_PTR 5
|
|
#define UVRPC_FUNCNAME 6
|
|
|
|
/* encryption and compression constants */
|
|
|
|
#define UVRPC_ENCRYPTION_DISABLED 0
|
|
#define UVRPC_ENCRYPTION_ENABLED 1
|
|
#define UVRPC_ENCRYPTION_ENABLE_REPLY 2
|
|
#define UVRPC_ENCRYPTION_NONE 0
|
|
#define UVRPC_ENCRYPTION_XOR 1
|
|
#define UVRPC_COMPRESSION_NONE 0
|
|
#define UVRPC_COMPRESSION 1
|
|
|
|
|
|
/* error types */
|
|
|
|
#define UVRPC_BAD_CONNECTION 81001
|
|
#define UVRPC_NO_CONNECTION 81002
|
|
#define UVRPC_NOT_INITED 81003
|
|
#define UVRPC_INVALID_ARG_TYPE 81004
|
|
#define UVRPC_WRONG_VERSION 81005
|
|
#define UVRPC_BAD_SEQNO 81006
|
|
#define UVRPC_NO_MORE_CONNECTIONS 81007
|
|
#define UVRPC_BAD_PARAMETER 81008
|
|
#define UVRPC_FAILED 81009
|
|
#define UVRPC_ARG_COUNT 81010
|
|
#define UVRPC_UNKNOWN_HOST 81011
|
|
#define UVRPC_FORK_FAILED 81012
|
|
#define UVRPC_CANT_OPEN_SERV_FILE 81013
|
|
#define UVRPC_CANT_FIND_SERVICE 81014
|
|
#define UVRPC_TIMEOUT 81015
|
|
#define UVRPC_REFUSED 81016
|
|
#define UVRPC_SOCKET_INIT_FAILED 81017
|
|
#define UVRPC_SERVICE_PAUSED 81018
|
|
#define UVRPC_BAD_TRANSPORT 81019
|
|
#define UVRPC_BAD_PIPE 81020
|
|
#define UVRPC_PIPE_WRITE_ERROR 81021
|
|
#define UVRPC_PIPE_READ_ERROR 81022
|
|
#define UVRPC_CONNECTION 81023
|
|
#define UVRPC_NO_MULTIPLEX_SUPPORT 81024
|
|
#define UVRPC_NO_ENCRYPTION_SUPPORT 81025
|
|
#define UVRPC_NO_COMPRESSION_SUPPORT 81026
|
|
#define UVRPC_BAD_ENCRYPTION 81027
|
|
#define UVRPC_BAD_COMPRESSION 81028
|
|
|
|
typedef struct
|
|
{
|
|
int32 datatype;
|
|
int32 datalen;
|
|
union
|
|
{
|
|
int32 uv_int;
|
|
int32 *uv_int_ptr;
|
|
double uv_dbl;
|
|
double *uv_dbl_ptr;
|
|
char *uv_chr;
|
|
RPCSTRING uv_str;
|
|
RPCSTRING uv_int64;
|
|
} arg;
|
|
} uvrpcdata;
|
|
|
|
/* define a set of macros for adding arguments to the given array */
|
|
|
|
#define NLSOPMAP(argarray,index,status) {\
|
|
if (NLSon && NLSsrv_opmap) {\
|
|
if ((argarray)[(index)].datatype == UVRPC_STRING) {\
|
|
STRING temp;\
|
|
temp = NLStSTRmap((argarray)[(index)].arg.uv_str,NLSsrv_opmap,&(status));\
|
|
(argarray)[(index)].arg.uv_str.text = temp.text;\
|
|
(argarray)[(index)].arg.uv_str.len = temp.len;\
|
|
(argarray)[(index)].datalen = (argarray)[(index)].arg.uv_str.len;\
|
|
} else if ((argarray)[(index)].datatype == UVRPC_CHAR) {\
|
|
if ((argarray)[(index)].arg.uv_chr) {\
|
|
(argarray)[(index)].arg.uv_chr =\
|
|
NLStstrmap((argarray)[(index)].arg.uv_chr,NLSsrv_opmap,&(status));\
|
|
(argarray)[(index)].datalen = strlen((argarray)[(index)].arg.uv_chr);\
|
|
}\
|
|
}\
|
|
}\
|
|
}
|
|
|
|
/* macros should not have trailing ;'s
|
|
** so they have been removed */
|
|
|
|
#define PUTINT(argarray, index, value)\
|
|
(argarray)[(index)].datalen = 1;\
|
|
(argarray)[(index)].datatype = UVRPC_INT;\
|
|
(argarray)[(index)].arg.uv_int = (value)
|
|
|
|
#define PUTSTR(argarray, index, value)\
|
|
(argarray)[(index)].datalen = (value).len;\
|
|
(argarray)[(index)].datatype = UVRPC_STRING;\
|
|
(argarray)[(index)].arg.uv_str.len = (value).len;\
|
|
(argarray)[(index)].arg.uv_str.text = (unsigned char *) ((value).text)
|
|
|
|
#define PUTINT64(argarray, index, value)\
|
|
(argarray)[(index)].datalen = (value).len;\
|
|
(argarray)[(index)].datatype = UVRPC_STRING;\
|
|
(argarray)[(index)].arg.uv_int64.len = (value).len;\
|
|
(argarray)[(index)].arg.uv_int64.text = (unsigned char *) ((value).text)
|
|
|
|
#define PUTCHAR(argarray, index, value)\
|
|
if (value) (argarray)[(index)].datalen = strlen(value);\
|
|
else (argarray)[(index)].datalen = 0;\
|
|
(argarray)[(index)].datatype = UVRPC_CHAR;\
|
|
(argarray)[(index)].arg.uv_chr = (value)
|
|
|
|
/* ?? isn't this equivalent to PUTSTR(a,i, (*(value))) */
|
|
/* needed by clients as well */
|
|
#define PUTPSTR(argarray, index, value) PUTSTR((argarray), (index), (*(value)))
|
|
/*#define PUTPSTR(argarray, index, value)\
|
|
(argarray)[(index)].datalen = (value)->len;\
|
|
(argarray)[(index)].datatype = UVRPC_STRING;\
|
|
(argarray)[(index)].arg.uv_str.len = (*(value)).len;\
|
|
(argarray)[(index)].arg.uv_str.text = (*(value)).text */
|
|
|
|
/* and also define equivalents (for existing code), putting the arguments
|
|
in the outargs array */
|
|
|
|
#define INTOUTARG(i,j) PUTINT(outargs, i, j)
|
|
|
|
#define INT64OUTARG(i,j) PUTINT64(outargs, i, j)
|
|
|
|
#define STROUTARG(i,j) PUTSTR(outargs, i, j)
|
|
|
|
#define CHROUTARG(i,j) PUTCHAR(outargs, i, j)
|
|
|
|
#define PSTROUTARG(i,j) PUTPSTR(outargs, i, j)
|
|
|
|
/* now define macros for both testing and extracting argument values from the
|
|
given array */
|
|
|
|
#define ARGISINT(argarray,index) ((argarray)[(index)].datatype == UVRPC_INT)
|
|
#define ARGISCHAR(argarray,index) ((argarray)[(index)].datatype == UVRPC_CHAR)
|
|
#define ARGISSTR(argarray,index) ((argarray)[(index)].datatype == UVRPC_STRING)
|
|
|
|
#define NLSIPMAP(argarray,index,status) {\
|
|
if (NLSon && NLSsrv_ipmap) {\
|
|
if ((argarray)[(index)].datatype == UVRPC_STRING) {\
|
|
STRING temp;\
|
|
temp = NLStSTRmap((argarray)[(index)].arg.uv_str,NLSsrv_ipmap,&(status));\
|
|
(argarray)[(index)].arg.uv_str.text = temp.text;\
|
|
(argarray)[(index)].arg.uv_str.len = temp.len;\
|
|
(argarray)[(index)].datalen = (argarray)[(index)].arg.uv_str.len;\
|
|
} else if ((argarray)[(index)].datatype == UVRPC_CHAR) {\
|
|
if ((argarray)[(index)].arg.uv_chr) {\
|
|
(argarray)[(index)].arg.uv_chr =\
|
|
NLStstrmap((argarray)[(index)].arg.uv_chr,NLSsrv_ipmap,&(status));\
|
|
(argarray)[(index)].datalen = strlen((argarray)[(index)].arg.uv_chr);\
|
|
}\
|
|
}\
|
|
}\
|
|
}
|
|
|
|
#define GETINT(argarray, index) (argarray)[index].arg.uv_int
|
|
#define GETCHAR(argarray, index) (argarray)[index].arg.uv_chr
|
|
#define GETCHARLEN(argarray, index) (argarray)[index].datalen
|
|
#define GETSTR(argarray, index) (argarray)[index].arg.uv_str
|
|
#define GETINT64(argarray, index) (argarray)[index].arg.uv_int64
|
|
|
|
/* and again define macros for data from inargs, for existing code */
|
|
|
|
#define INTARGVAL(i) GETINT(inargs, i)
|
|
#define CHRARGVAL(i) GETCHAR(inargs, i)
|
|
#define CHRARGLEN(i) GETCHARLEN(inargs, i)
|
|
#define STRARGVAL(i) GETSTR(inargs, i)
|
|
#define INT64ARGVAL(i) GETINT64(inargs,i)
|
|
|
|
#define INTINARG(i) ARGISINT(inargs, i)
|
|
#define CHRINARG(i) ARGISCHAR(inargs, i)
|
|
#define STRINARG(i) ARGISSTR(inargs, i)
|
|
|
|
#define IFINTINARG(i, errvar, glabel)\
|
|
if(!INTINARG(i)) { warning(80001); errvar=80001; goto glabel; }
|
|
|
|
|
|
#define STRINARGVAL(assignstr, i, errvar, glabel)\
|
|
if (!STRINARG(i))\
|
|
{\
|
|
warning(80001);\
|
|
errvar = 80001;\
|
|
goto glabel;\
|
|
}\
|
|
if (inargs[i].datatype == UVRPC_CHAR)\
|
|
{\
|
|
assignstr.text = inargs[i].arg.uv_chr;\
|
|
assignstr.len = inargs[i].datalen;\
|
|
}\
|
|
else\
|
|
{\
|
|
assignstr.len = inargs[i].arg.uv_str.len;\
|
|
assignstr.text = inargs[i].arg.uv_str.text;\
|
|
}
|
|
|
|
|
|
#define CLEARRPCARGS(argarray) ((void)memset((argarray), 0, sizeof(argarray)))
|
|
|
|
#define CLEAROUTPACKET CLEARRPCARGS(outargs)
|
|
#define CLEARINPACKET CLEARRPCARGS(inargs)
|
|
|
|
#define CLEAROUTARGS(numargs)\
|
|
if ((numargs) > 0 && (numargs) <= MAX_NUM_RPC_ARGS)\
|
|
{\
|
|
(void)memset(outargs, 0, sizeof(uvrpcdata) * (numargs));\
|
|
}
|
|
|
|
#define CLEARINARGS(numargs)\
|
|
if ((numargs) > 0 && (numargs) <= MAX_NUM_RPC_ARGS)\
|
|
{\
|
|
(void)memset(inargs, 0, sizeof(uvrpcdata) * (numargs));\
|
|
}
|
|
|
|
/* add string macros with mapping - note that we are not interested in status
|
|
** OPPUTSTR can replace PUTSTR, OPPUTPSTR can replace PUTPSTR.
|
|
** IPGETSTR/CHAR must precede GETSTR/CHAR but only once as they are usually called
|
|
** as a pair to get the len and text from the parameter and we do not want
|
|
** to map twice. */
|
|
|
|
#define OPPUTSTR(a,i,v) {int unused; PUTSTR((a),(i),(v)); NLSOPMAP((a),(i),unused); }
|
|
#define IPGETSTR(a,i) {int unused; NLSIPMAP((a),(i),unused); }
|
|
#define IPGETCHAR(a,i) {int unused; NLSIPMAP((a),(i),unused); }
|
|
|
|
/* Declarations of public entrypoints into the UVRPC library */
|
|
|
|
#ifdef MSWIN /* WIN support */
|
|
int32 FAR PASCAL uvrpc_add_connect(void * socknum);
|
|
int32 FAR PASCAL uvrpc_build_packet(int32 transport_type, int32 key, int32 arg_count, uvrpcdata FAR * arg_list, unsigned char FAR *proc_name, unsigned char FAR **return_ptr, int32 FAR *return_len);
|
|
int32 FAR PASCAL uvrpc_call(int32 connection_id, unsigned char FAR * proc_name, int32 arg_count, uvrpcdata FAR * arg_list, int32 FAR * res_count, uvrpcdata FAR * res_list, struct timeval FAR *timeout);
|
|
int32 FAR PASCAL uvrpc_close(int32 connection_id);
|
|
int32 FAR PASCAL uvrpc_connect(char FAR * node_name, char FAR * service_name, struct timeval FAR * timeout, int32 FAR * status);
|
|
int32 FAR PASCAL uvrpc_init(void);
|
|
int32 FAR PASCAL uvrpc_read_packet(int32 connection_id, int32 FAR * arg_count, uvrpcdata FAR * arg_list, struct timeval FAR *timeout);
|
|
void FAR PASCAL uvrpc_set_debug(int32 value);
|
|
int32 FAR PASCAL uvrpc_send_packet(int32 connection_id, int32 key, int32 arg_count, uvrpcdata FAR * arg_list, unsigned char FAR *proc_name, struct timeval FAR *timeout);
|
|
int32 FAR PASCAL uvrpc_read_message(int32 connection_id, int32 FAR *arg_count, unsigned char FAR **message_buf, int32 FAR *message_len, int32 FAR *proc_name_len, struct timeval FAR *timeout);
|
|
int32 FAR PASCAL uvrpc_unpack_args(int32 transport_type, unsigned char FAR *message_buf, int32 message_len, int32 FAR * tot_args, int32 arg_count, int32 proc_name_len, uvrpcdata FAR *arg_list);
|
|
int32 FAR PASCAL uvrpc_write_message(int32 connection_id, struct timeval FAR *timeout, unsigned char FAR *message_buf, int32 message_len);
|
|
int32 FAR PASCAL uvrpc_set_transport(int32 connection_id, int32 transport_type);
|
|
int32 FAR PASCAL uvrpc_get_transport(int32 connection_id);
|
|
HANDLE FAR PASCAL uvrpc_get_handle(int32 connection_id);
|
|
int32 FAR PASCAL uvrpc_get_compression_threshold(void);
|
|
int32 FAR PASCAL uvrpc_get_current_version(void);
|
|
int32 FAR PASCAL uvrpc_get_encryption_state(void);
|
|
int32 FAR PASCAL uvrpc_get_encryption_type(void);
|
|
int32 FAR PASCAL uvrpc_get_encryption_type_last(void);
|
|
int32 FAR PASCAL uvrpc_set_compression_threshold(int32 compression_threshold);
|
|
int32 FAR PASCAL uvrpc_set_current_version(int32 current_version);
|
|
int32 FAR PASCAL uvrpc_set_encryption_state(int32 encryption_state);
|
|
int32 FAR PASCAL uvrpc_set_encryption_type(int32 encryption_type);
|
|
int32 FAR PASCAL uvrpc_get_machid(char FAR *macaddr, char FAR *devname, u_long32 *ipaddr);
|
|
|
|
#else /* UNIX */
|
|
uvint32 uvrpc_add_connect();
|
|
uvint32 uvrpc_build_packet();
|
|
uvint32 uvrpc_call();
|
|
uvint32 uvrpc_close();
|
|
uvint32 uvrpc_connect();
|
|
uvint32 uvrpc_init();
|
|
uvint32 uvrpc_read_packet();
|
|
void uvrpc_set_debug();
|
|
uvint32 uvrpc_send_packet();
|
|
uvint32 uvrpc_read_message();
|
|
uvint32 uvrpc_unpack_args();
|
|
uvint32 uvrpc_write_message();
|
|
uvint32 uvrpc_set_transport();
|
|
uvint32 uvrpc_get_transport();
|
|
uvint32 uvrpc_get_compression_threshold();
|
|
uvint32 uvrpc_get_current_version();
|
|
uvint32 uvrpc_get_encryption_state();
|
|
uvint32 uvrpc_get_encryption_type();
|
|
uvint32 uvrpc_get_encryption_type_last();
|
|
uvint32 uvrpc_set_compression_threshold();
|
|
uvint32 uvrpc_set_current_version();
|
|
uvint32 uvrpc_set_encryption_state();
|
|
uvint32 uvrpc_set_encryption_type();
|
|
|
|
#endif
|
|
|
|
/* End of File */
|
|
|
|
#endif
|
|
|
|
|