How do I account for endian-ness while reading a Binary File generated from Solaris 5.8 (Sparc) on a Windows XP (x86) system. I just know that its a Binary File. I have no knowledge about the native datatype of the Binary File.
Thanks for the reply.
This file comes in an encapsulated form from some other Unix machine over the network and then the Target OS i.e. Solaris 5.8 reads and extracts the relevant part from the encapsulation as a Binary and writes & saves in a file on the Hard Disk. This saved file is the input binary file for me which I took in a USB or through FTP.
A file endianness as not that much to do with OS endianness. That's the file format that matters so if you have no idea about it, why bother ?
Windows on x86 can certainly create big endian files if the binary format mandates it just like Solaris on SPARC will create binary files with little endian data inside. Any combination of big and little endian can be found in the binary files, just like binary files flowing the internet can be little, big or a mixture of these indianness.
Ok. I agree.
But, the problem is the Unix C Code which parses this Binary File is not working on the WIN32 platform although it is compiling successfully on VS-2005. It starts parsing from the file's base address and tries to read data at particular Hardcoded Offsets from the base & these memory locations return garbage value on Windows. Hence, the question of endian-ness arose.
Not only the data would be garbage but also the offset if not hardcoded.
You didn't tell you had the parser source code. In that case, you need to modify that code for it to be able to correctly parse the data. You can use the htonl family of macros on the x86 machine to convert from network (big endian) to host (little endian) order.
Last edited by jlliagre; 09-06-2009 at 04:47 AM..
I used a HEX Editor and converted the binary file to BIG-endian format. And, then I ran the same parser code. It still returns garbage
So, keeping the original Binary File intact, while reading, how do I judge the native datatype for byte swapping order - because these n/w apis suggest something like this -
ntohs() - “network to host short”
Converts the unsigned short integer netshort from network byte order to host byte order. ntohl() - “network to host long”
Converts the unsigned integer netlong from network byte order to host byte order.
I'd like to add some x/linux-based servers to my current AIX-based TDS/SDS server community. Reading the Fine Install Guide (rtfig ?) I believe this may be covered by the section "Upgrade an instance of a previous version to a different computer" i.e. I'm going to install latest/greatest SDS on a... (4 Replies)
I am new to sloaris and just instlled the solaris 11.2, i know little more about linux, i open the /boot/grub/grub.cfg in solaris and there is many other entries forl solaris 11.2 one of them is for 'Oracle Solaris 11.2 text console' but at boot grub2 only show the first default entry that... (1 Reply)
I have a ubuntu machine and want to know the endianness of the system....
How would i get to know.....
The information of my machine is:
42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 201
1 i686 i686 i386 GNU/Linux
No LSB modules are available.... (6 Replies)
I am unable to login into my terminal hosting Solaris 10 and get the below error message
"Server refused to allocate pty
ld.so.1: sh: fatal: libc.so.1: open failed: No such file or directory "
Is there anyways i can get into my machine and what kind of changes are required to be... (7 Replies)
I have compiled my application on Solaris 10 with following description
SunOS ldg1 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Blade-T6320
The compiler is Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
But when installing the application on Solaris 9
SunOS odcarch02 5.9... (2 Replies)