Skip to Content.
Sympa Menu

freetds - RE: BIGENDIAN

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: RE: BIGENDIAN
  • Date: Thu, 12 Jul 2001 07:13:16 -0400 (EDT)


Mark,

Is this limited to an MS-SQL server? It seems to be the date problem all
over again. I'm thinking that we will support a 'emulate little endian'
mode for big end machines that will be used with TDS 7 and for big end
machines connecting to broken versions of SQL Server. Which version is
the server that exhibits this behaviour?

I added your byte swap macros to tds.h.in (although i called them
TDS_BYTE_SWAPxx() to keep with convention) but haven't checked them in
yet, but the patch itself needs to be optional since it will break big end
-> sybase users.

Brian

On Wed, 11 Jul 2001, Mark J. Lilback wrote:

> 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))
>
>





Archive powered by MHonArc 2.6.24.

Top of Page