Skip to Content.
Sympa Menu

freetds - RE: BIGENDIAN

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Mark J. Lilback" <mark AT lilback.com>
  • To: "TDS Development Group" <freetds AT franklin.oit.unc.edu>
  • Subject: RE: BIGENDIAN
  • Date: Wed, 11 Jul 2001 17:46:09 -0400


At 4:14 PM -0400 7/11/01, Brian Bruns wrote:
Just to be plain about this, the server does the conversion. Most
protocols in this situation rely on the client to make the switch, or just
agree on network order (which means two conversion for little endian to
little endian comm).


For user data, or for all network traffic?

I've been lazy about submitting patches lately, but I had to add the ifdef below to token.c fix a value that wasn't being properly converted when talking to SQL Server 7:

static int tds_process_msg(TDSSOCKET *tds,int marker)
{
int rc;
int len;
int len_msg;
int len_svr;
int len_sqlstate;

/* packet length */
len = tds_get_smallint(tds);

/* message number */
rc = tds_get_int(tds);
#ifdef WORDS_BIGENDIAN
rc = ByteSwap32(rc);
#endif
tds->msg_info->msg_number = rc;


I also added the following to my copy of tdsutil.h to help with this and a couple of other byte swaps:

#define ByteSwap16(value) \
(((((unsigned short)value)<<8) & 0xFF00) | \
((((unsigned short)value)>>8) & 0x00FF))

#define ByteSwap32(value) \
(((((unsigned long)value)<<24) & 0xFF000000) | \
((((unsigned long)value)<< 8) & 0x00FF0000) | \
((((unsigned long)value)>> 8) & 0x0000FF00) | \
((((unsigned long)value)>>24) & 0x000000FF))

--

__________________________________________________________________________
"The best assumption to have
Mark J. Lilback is that any commonly held
<mark AT lilback.com> belief is wrong." -- Ken Olsen,
http://www.lilback.com/ founder, Digital Equip. Corp.




Archive powered by MHonArc 2.6.24.

Top of Page