Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uflorida!novavax!proxftl!bill From: bill@proxftl.UUCP (T. William Wells) Newsgroups: comp.lang.c Subject: Re: Portability across architectures.. Keywords: Portability, common data, files Message-ID: <655@proxftl.UUCP> Date: 29 Aug 88 05:44:58 GMT References: <103@simsdevl.UUCP> Reply-To: bill@proxftl.UUCP (T. William Wells) Distribution: all Organization: Proximity Technology, Ft. Lauderdale Lines: 42 Summary: Expires: Sender: Followup-To: In article <103@simsdevl.UUCP> dandc@simsdevl.UUCP (Dan DeClerck) writes: : I've run across a need to have data files in various forms of UN*X : be portable to each other. Mostly, this deals with Intel to Motorola and : vice-versa. I could write data out to files in ASCII, but this is cumbersome, : slow and may hamper the products' marketability. : : The problem lies in writing integers as well as structures to : files, and allow those files to be transferred between a : multitude of machines without a data transformation taking : place. : : A fellow programmer suggested an "XDR" standard from SUN, but : this seems to only work with inter-process communication. Has : anyone encountered this problem?? As I understand it, XDR includes a description of the data *as it is transmitted* as well as a set of conversion routines. For example, on the man page for our Sun 3 is: xdr_array() translate arrays to/from external representation xdr_bool() translate Booleans to/from external representation xdr_bytes() translate counted byte strings to/from external representation xdr_double() translate double precision to/from external representation xdr_enum() translate enumerations to/from external representation xdr_float() translate floating point to/from external representation xdr_int() translate integers to/from external representation xdr_long() translate long integers to/from external representation xdr_opaque() translate fixed-size opaque data to/from external representation xdr_short() translate short integers to/from external representation xdr_string() translate null-terminated strings to/from external representation xdr_u_int() translate unsigned integers to/from external representation xdr_u_long() translate unsigned long integers to/from external representation xdr_u_short()translate unsigned short integers to/from external representation xdr_union() translate discriminated unions to/from external representation Presumably, what you want to do is to use these routines to convert your data and then write the data to a file; then use them to convert the data back when read it. --- Bill novavax!proxftl!bill