look at the routines net2host() in
http://root.cern.ch/lxr/source/base/inc/Bytes.h
I assume you read this file on a little endian machine. In that
case you can directly use the host2net() functions.
Cheers, Fons.
--
Org: CERN, European Laboratory for Particle Physics.
Mail: 1211 Geneve 23, Switzerland
E-Mail: Fons.Ra...@cern.ch Phone: +41 22 7679248
WWW: http://root.cern.ch/~rdm/ Fax: +41 22 7677910
The question you posted sounds to general to provide any
reasonable concrete answer.
The generic answer is
"You should WRITE the piece of the code. That reads your "big indian"
swap data "somehow" and write in back in the proper order.
Depends of your format this code could either 10 or 1000 lines of the code.
One can use the ROOT TBuffer class source as a pattern
Hope this helps
Valery
Depending upon what the platform of your host computer is there
are some simple untility in unix called:
htonl, htons, ntohl, ntohs
check out the "man pages":
"htonl, htons, ntohl, ntohs - convert values between host
and network byte order
...
On the i80x86 the host byte order is Least Significant
Byte first, whereas the network byte order, as used on the
Internet, is Most Significant Byte first."
I hope this helps.
Tim Smith
_____________________________________________________________________
Timothy Paul Smith Research Scientist
MIT Bates Lab tim_...@mit.edu
21 Manning Rd. tel: (617) 253-9207
Middleton, MA 01949 fax: (617) 253-9599
Here is a C function which will do a standard endian byte swap. If it's not
exactly what you need it will probably be close.
Cheers,
Steve
/******************************************************************
/- file: endian_swap.c
/-
/-
/- usage: endian_swap(char * pdata, int dsize, int nelements)
/---------
/-
/- inputs:
/---------
/- char * pdata = pointer to data to be converted
/- int dsize = size of datatype (in bytes) stored at memory location
/- int nelements = number of data elements of size dsize to process
/-
/-
/- Modification Log:
/-------------------
/- 23 dec 99 S.Lautenschlager Created
/-
/-******************************************************************/
void endian_swap(char * pdata, int dsize, int nelements)
{
int i,j,indx;
char tempbyte;
if (dsize <= 1) return;
for (i=0; i<nelements; i++)
{
indx = dsize;
for (j=0; j<dsize/2; j++)
{
tempbyte = pdata[j];
indx = indx - 1;
pdata[j] = pdata[indx];
pdata[indx] = tempbyte;
}
pdata = pdata + dsize;
}
return;
}
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
>
>
> Depending upon what the platform of your host computer is there
> are some simple untility in unix called:
>
> htonl, htons, ntohl, ntohs
>
>
> check out the "man pages":
>
> "htonl, htons, ntohl, ntohs - convert values between host
> and network byte order
>
> ...
I would like to call the ROOTTALK attention those subroutines do not take in account
8 bytes. This means they are no use for "double" and 64-bits int and 64-bits pointers.
And the main obstacle - one must write the piece of code and must know in advance what
the "type" of the next byte of his/her binary format. Does it belong "char", "short", "long" or
"double" to select the proper conversion subroutine ?
Valery