TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Pascal Schmidt
from: Bo Simonsen
date: 2004-01-20 02:53:04
subject: Re: Big endian machines

-=> Pascal Schmidt wrote to Bo Simonsen <=-

 PS> Hi Bo! :-)

 BS> struct _pkthdr
 BS> {
 BS>   sword orig_node;        /* originating node */
 BS>   sword dest_node;        /* destination node */
 BS> }  __attribute__((packed, aligned(2)));

 PS> That's not packed, that's aligned on two byte boundaries -
 PS> but that shouldn't matter here.

Aha,

 BS> The structure contains most words and a couple of bytes.
 PS> What is an sword supposed to be? I'd stick to standard names.

signed words afair. Anyhow it has the same lenght as a word have, which 
is 2 bytes..

 BS> It's beeing readed by
 BS> read(fp, &pkthdr, sizeof(struct _pkthdr));
 BS> Should I read every single variable in the structure to get it
 BS> working?

 PS> The main question is whether you know the endianness of the
 PS> input or can easily find it out?

I should be little endian, fidonet packages should be send in little 
endian, so I guess I just run a htonl on the words?

 PS> Reading the full structure at once is okay. After that, you
 PS> can convert all the values that need to be
 PS> byteswapped/converted.

I see.

Bo


... Computer Hacker wanted. Must have own axe.
___ MultiMail/Linux v0.46

--- Maximus/UNIX 3.03b
* Origin: The Night Express - Roennede, Dk (2:236/100)
SEEN-BY: 633/267 270
@PATH: 236/100 237/9 20/11 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.