reading/writing binary data

Maciej Stachowiak (mstachow@mit.edu)
Fri, 12 Dec 1997 21:34:18 EST

I'd like to write a guile script to communicate with a program that
reads and writes data in binary format - 32 bit numeric values are
written as four bytes in host byte order. I can get Guile to read this
in as a string of four chars, but is there a reasonably portable way
to convert that into a Scheme number (and vice versa for communicating
the other way)? I can think of the simple-minded approach of using
char->integer on each byte, bitshifting and adding, but I'd rather not
put knowledge of the host's endianness into the script, and I'm hoping
there's some primitives that can help do it more efficiently, although
I don't know of any.

- Maciej