From fca1b6c9d8620e706309b23e1ae61017e3639870 Mon Sep 17 00:00:00 2001 From: skidder Date: Tue, 19 Nov 2002 15:37:55 +0000 Subject: [PATCH] Move xdr_hyper to the correct place and remove duplicate definitions --- src/burp/canonical.cpp | 77 +---------------------------------------- src/remote/protocol.cpp | 68 ------------------------------------ src/remote/xdr.cpp | 61 ++++++++++++++++++++++++++++++++ src/remote/xdr_proto.h | 12 +------ 4 files changed, 63 insertions(+), 155 deletions(-) diff --git a/src/burp/canonical.cpp b/src/burp/canonical.cpp index 08a81de092..5cd5b68cc9 100644 --- a/src/burp/canonical.cpp +++ b/src/burp/canonical.cpp @@ -28,7 +28,7 @@ * */ /* -$Id: canonical.cpp,v 1.11 2002-11-16 23:57:18 hippoman Exp $ +$Id: canonical.cpp,v 1.12 2002-11-19 15:37:52 skidder Exp $ */ #include "firebird.h" @@ -71,12 +71,6 @@ static bool_t xdr_quad(register XDR*, register SLONG*); static int xdr_init(XDR*, LSTRING*, enum xdr_op); static bool_t xdr_slice(XDR*, LSTRING*, USHORT, UCHAR*); -#ifdef HAVE_XDR_HYPER -extern bool_t xdr_hyper(register XDR *, SINT64 *); -#else -static bool_t xdr_hyper(register XDR *, SINT64 *); -#endif - static xdr_t::xdr_ops burp_ops = { burp_getlong, @@ -937,73 +931,4 @@ static bool_t xdr_slice(XDR* xdrs, } -#ifndef HAVE_XDR_HYPER -static bool_t xdr_hyper(register XDR* xdrs, SINT64* pi64) -{ -/************************************** - * - * x d r _ h y p e r - * - ************************************** - * - * Functional description - * Map a 64-bit Integer from external to internal representation - * (or vice versa). - * - * Enable this for all platforms except those which supply - * xdr_hyper as part of the system xdr library (initially only - * Solaris, but we expect more over time). This function (normally) - * would have been implemented in REMOTE/xdr.c. Since some system - * XDR libraries (HP-UX) do not implement this function, we have it - * in this module. At a later date, when the function is available - * on all platforms, we can start using the system-provided version. - * - * Handles "swapping" of the 2 long's to be "Endian" sensitive. - * - **************************************/ - union - { - SINT64 temp_int64; - SLONG temp_long[2]; - } temp; - - switch (xdrs->x_op) - { - case XDR_ENCODE: - temp.temp_int64 = *pi64; -#ifndef WORDS_BIGENDIAN - if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) && - (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0])) - return TRUE; -#else - if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) && - (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1])) - return TRUE; -#endif - return FALSE; - - case XDR_DECODE: -#ifndef WORDS_BIGENDIAN - if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) || - !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0])) - return FALSE; -#else - if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) || - !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1])) - return FALSE; -#endif - *pi64 = temp.temp_int64; - return TRUE; - - case XDR_FREE: - return TRUE; - } - -/* TMN: Now what? 'assert(0)'? 'abort()'? Anyone having a */ -/* clue, feel free to fix the cludge 'return FALSE' */ - return FALSE; -} -#endif /* HAVE_XDR_HYPER */ - - } // extern "C" diff --git a/src/remote/protocol.cpp b/src/remote/protocol.cpp index 9e5d048519..1fa965e4a0 100644 --- a/src/remote/protocol.cpp +++ b/src/remote/protocol.cpp @@ -71,10 +71,6 @@ static bool_t xdr_cstring(XDR *, CSTRING *); static bool_t xdr_datum(XDR *, DSC *, BLOB_PTR *); static bool_t xdr_debug_packet(XDR *, enum xdr_op, PACKET *); -#ifndef HAVE_XDR_HYPER -static bool_t xdr_hyper(register XDR *, SINT64 *); -#endif - static bool_t xdr_longs(XDR *, CSTRING *); static bool_t xdr_message(XDR *, REM_MSG, FMT); static bool_t xdr_quad(register XDR *, register struct bid *); @@ -1138,70 +1134,6 @@ static bool_t xdr_debug_packet( XDR * xdrs, enum xdr_op xop, PACKET * packet) #endif -#ifndef HAVE_XDR_HYPER -static bool_t xdr_hyper( register XDR * xdrs, SINT64 * pi64) -{ -/************************************** - * - * x d r _ h y p e r ( n o n - S O L A R I S ) - * - ************************************** - * - * Functional description - * Map a 64-bit Integer from external to internal representation - * (or vice versa). - * - * Enable this for all platforms except Solaris (since it is - * available in the XDR library on Solaris). This function (normally) - * would have been implemented in REMOTE/xdr.c. Since some system - * XDR libraries (HP-UX) do not implement this function, we have it - * in this module. At a later date, when the function is available - * on all platforms, we can start using the system-provided version. - * - * Handles "swapping" of the 2 long's to be "Endian" sensitive. - * - **************************************/ - union { - SINT64 temp_int64; - SLONG temp_long[2]; - } temp; - - switch (xdrs->x_op) { - case XDR_ENCODE: - temp.temp_int64 = *pi64; -#ifndef WORDS_BIGENDIAN - if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) && - (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0])) - return TRUE; -#else - if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) && - (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1])) - return TRUE; -#endif - return FALSE; - - case XDR_DECODE: -#ifndef WORDS_BIGENDIAN - if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) || - !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0])) - return FALSE; -#else - if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) || - !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1])) - return FALSE; -#endif - *pi64 = temp.temp_int64; - return TRUE; - - case XDR_FREE: - return TRUE; - } -// TMN: added compiler silencier return FALSE. - return FALSE; -} -#endif /* HAVE_XDR_HYPER */ - - static bool_t xdr_longs( XDR * xdrs, CSTRING * cstring) { /************************************** diff --git a/src/remote/xdr.cpp b/src/remote/xdr.cpp index 742b588f04..d11e369b01 100644 --- a/src/remote/xdr.cpp +++ b/src/remote/xdr.cpp @@ -109,6 +109,67 @@ static const XDR::xdr_ops mem_ops = static SCHAR zeros[4] = { 0, 0, 0, 0 }; +bool_t xdr_hyper( register XDR * xdrs, SINT64 * pi64) +{ +/************************************** + * + * x d r _ h y p e r ( n o n - S O L A R I S ) + * + ************************************** + * + * Functional description + * Map a 64-bit Integer from external to internal representation + * (or vice versa). + * + * Enable this for all platforms except Solaris (since it is + * available in the XDR library on Solaris). This function (normally) + * would have been implemented in REMOTE/xdr.c. Since some system + * XDR libraries (HP-UX) do not implement this function, we have it + * in this module. At a later date, when the function is available + * on all platforms, we can start using the system-provided version. + * + * Handles "swapping" of the 2 long's to be "Endian" sensitive. + * + **************************************/ + union { + SINT64 temp_int64; + SLONG temp_long[2]; + } temp; + + switch (xdrs->x_op) { + case XDR_ENCODE: + temp.temp_int64 = *pi64; +#ifndef WORDS_BIGENDIAN + if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1]) && + (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0])) + return TRUE; +#else + if ((*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[0]) && + (*xdrs->x_ops->x_putlong) (xdrs, &temp.temp_long[1])) + return TRUE; +#endif + return FALSE; + + case XDR_DECODE: +#ifndef WORDS_BIGENDIAN + if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1]) || + !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0])) + return FALSE; +#else + if (!(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[0]) || + !(*xdrs->x_ops->x_getlong) (xdrs, &temp.temp_long[1])) + return FALSE; +#endif + *pi64 = temp.temp_int64; + return TRUE; + + case XDR_FREE: + return TRUE; + } +// TMN: added compiler silencier return FALSE. + return FALSE; +} + bool_t xdr_bool( register XDR * xdrs, register bool_t * bp) { /************************************** diff --git a/src/remote/xdr_proto.h b/src/remote/xdr_proto.h index b34b20fd4c..04127118db 100644 --- a/src/remote/xdr_proto.h +++ b/src/remote/xdr_proto.h @@ -48,17 +48,7 @@ extern bool_t xdr_u_long (register XDR *, register u_long *); extern bool_t xdr_u_short (register XDR *, register u_short *); extern int xdr_union (XDR *, enum xdr_op *, SCHAR *, struct xdr_discrim *, xdrproc_t); extern bool_t xdr_wrapstring (register XDR *, register SCHAR **); - -/* I assume all of these should be from the rpc/xdr.h file - * rather than having the definitions here, but since I don't - * want to create more trouble than I need, Im adding this - * definition here, where it is supplied by the OS. Otherwise - * a local function is defined to do the same task. - * MOD 12-Nov-2002 */ - -//#ifdef HAVE_XDR_HYPER -//extern bool_t xdr_hyper(register XDR *, SINT64 *); -//#endif +extern bool_t xdr_hyper(register XDR *, SINT64 *);