Binary data file compatibility across machines

KnightRider prk at planet.bt.co.uk
Tue Nov 27 00:15:26 AEST 1990


stiber at cs.ucla.edu (Michael D Stiber) writes:


>On different machines, the implementation of C data types is different.
>I forget what fixed types' lengths are, but I know that at least some of
>them may vary.  I also know that doubles can have different encoding
>schemes (ie, IEEE vs. DEC).  Then, there's little endian machines versus
>big endian ones.

>So, my question is this:  Say you want to share data files among
>different machines.  You also want to be able to use the same code on
>each machine.  Therefore, you want to have either a uniform file format,
>or you want the code to be able to figure out what the file format is,
>and convert it to the native data type representation.  Now, one alternative
>would be ASCII files --- this is guaranteed to work (assuming that you
>can get C on an IBM 3090 to write ASCII).  However, in my application,
>ASCII would produce files that are way too huge --- I must use a binary
>format.  So, is there an already-existing, standard solution to this
>problem of binary data file transfer?
>--
>			    Michael Stiber
>			  stiber at cs.ucla.edu
>		   ...{ucbvax,ihpn4}!ucla-cs!stiber
>		     UCLA Computer Science Dept.

The short, easy, answer is yes - Use the facilities provided by the 
presentation layer services provided by your communications system, 
if you have one.  For OSI systems this will ASN.1 -Abstract Syntax 
Notation 1.  If you use Sun systems, you may be able to use XDR 
-External Data Representation.

However, these are difficult services to encode, usually, so you may
want to go to an external vendor to support these.  

Peter Knight
BT Research 

#include <std.disclaimer>



More information about the Comp.lang.c mailing list