Skip to Content.
Sympa Menu

freetds - Re: killer query

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: killer query
  • Date: Wed, 26 Jun 2002 14:39:20 +0200


Another solution should be

TDS_UNIQUE uniq;
memcpy(uniq,src,sizeof(uniq));
sprintf(any.c,"%08X-04X-04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
uniq.Data1,uniq.Data2,uniq.Data3,
uniq.Data4[0],uniq.Data4[1],

uniq.Data5[0],uniq.Data5[1],uniq.Data5[2],uniq.Data5[3],uniq.Data5[4],uniq.D
ata5[5]);

Also note that win32 implementation do not split Data4 and Data5 but have
only a aingle array.
Also we can remove a memcpy and remove malloc

tds_convert_unique(int srctype,TDS_CHAR *src, TDS_INT srclen,
int desttype,TDS_CHAR *dest,TDS_INT destlen)
{
DBANY any;
TDS_UCHAR buf[37];

memcpy (&(any.u), src, sizeof(TDS_UNIQUE));

switch(desttype) {
case SYBCHAR:
case SYBVARCHAR:
sprintf(buf,"%08X-%04X-%04X-%02X%0
2X-%02X%02X%02X%02X%02X%02X",
(int)any.u.Data1, (int)any.u.Data2,
(int)any.u.Data3,
any.u.Data4[0], any.u.Data4[1],
any.u.Data5[0], any.u.Data5[1],
any.u.Data5[2], any.u.Data5[3], any.u.Data5[4], any.u.Data5[5]);
any.c = buf;
break;
case SYBUNIQUE:
/* copy already done */
break;
default:
return TDS_FAIL;
}
return tds_convert_any(dest, desttype, destlen, &any);
}

freddy77

>
> Fair comment,
>
> I guess it should read
>
> #ifdef WORDS_BIGENDIAN
>
> sprintf(any.c,"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02
> X%02X%02X%02X%02X%02X",
>
> buf[0], buf[1], buf[2], buf[3],
> buf[4], buf[5],
> buf[6], buf[7],
> buf[8], buf[9],
> buf[10], buf[11], buf[12], buf[13],
> buf[14], buf[15]);
> #else
>
> sprintf(any.c,"%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02
> X%02X%02X%02X%02X%02X",
>
> buf[3], buf[2], buf[1], buf[0],
> buf[5], buf[4],
> buf[7], buf[6],
> buf[8], buf[9],
> buf[10], buf[11], buf[12], buf[13],
> buf[14], buf[15]);
> #endif
>
> Perhaps someone could commit that...
>
> Bill
>
>
>
> ---
> You are currently subscribed to freetds as:
> [Frediano.Ziglio AT vodafoneomnitel.it]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')
>

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================




Archive powered by MHonArc 2.6.24.

Top of Page