c - transferring binary files between systems -


I am trying to move my files between 2 Unix clusters, the data numerically pure (in the binary form) Vector). Unfortunately one of the systems is IBM PPC 997 and the second is AMD Opteron, it seems that the binary number format in these systems is different.

I have tried three ways so far:

1- My files have been converted to ASCII format (i.e. a number saved in each line in a text file) , They were sent to the destination and

2- The net binary sent to the destination

3- is used - the UUNcode sent them to the destination and decoded them

Unfortunately, none of these methods work (destination sit) Generates my code garbage system, while it is already working on the system, I am 100% sure that the code itself is portable). I do not know what can I do? Do you have any ideas I am not a professional, please do not use the terminology of computer scientists!

And: My code is in C, so by binary I mean there is a mapping between memory and hard disk.

Thank you

If you are writing files to memory content, then code 100% Not portable

You should need something by the name of serialization , the word of computer science, but basically it means that you can get your data and it's bytes Can convert into a well-defined and documented sequence, which will be the same or any other program later I can read back in memory. This sequence of bytes is architecture and platform-independent.

Most Unix environments already come with the implementation, which provides a routine for data serialization.

A simple example encoding can allow 4 dables to stdout (you can use shell redirection, or use fopen () to open a file instead of stdout:

  XDR xdrs; double data [4] = {1.0, 255.41, -357.1, 123.4}; for int i; xdrstdio_create (& xdrs, stdout, xDR_ENCODE); for (i = 0; i < 4; i ++) xdr_ double (& amp; xdrs, & amp; data [i]);  

Now, to get these dables back (from stdin) and print them Do:

  XDR xdrs; double data; Int i; Xdrstdio_create (& xdrs, stdin, XDR_DECODE); (I = 0; i <4; i ++) (Xdr_double (& amp; xdrs, & amp; ); Printf ("% g \ n", data);}  

You can convert and decode complex structures using XDR. There was a very silent way to send a couple, and generally you should write / write some data types of arrays to use xrayray (). In this sequence, in the same order, save and execute while loading the file should go. In fact, you can use C Structures and their associated XRR to automatically generate tasks.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -