endian-port is a module that supports reading and writing of integers, IEEE floating-point numbers, and byte vectors while taking into account byte order. It is based on routines from the C++ advanced I/O library and TIFF reader written by Oleg Kiselyov.
A record that represents and endian port. Field fileno is the file handle for that port. Field filename is the file name for that port. Field byte-order can be one of (MSB) or (LSB). The type byte-order is defined in the C module endian-lowio.
Opens an endian port to the specified file. Mode can be one of 'read or 'write. In write mode, the file is created if it doesn't exist, otherwise the new data is appended to its end. The default endianness of the newly created endian port is MSB.
Creates an endian port to the file specified by the given port. The default endianness of the newly created endian port is MSB.
Closes the endian port.
Sets the endianness of the given endian port to MSB.
Sets the endianness of the given endian port to LSB.
Sets the file position of the given endian port to the specified position. The optional argument WHENCE is one of seek/set, seek/cur, seek/end. The default is seek/set (current position).
Returns the current file position of the given endian port, relative to the beginning of the file.
Returns true if the current file position of the given endian port is at the end of the file, false otherwise
Reads an unsigned integer of size 1 byte. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads an unsigned integer of size 2 bytes. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads an unsigned integer of size 4 bytes. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads an unsigned integer of size 8 bytes. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads an IEEE 754 single precision floating-point number. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads an IEEE 754 double precision floating-point number. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads a bit vector of the specified size (in bits) and returns an iset bit vector (see module iset). Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Reads a byte vector of the specified size and returns a Scheme byte vector. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an unsigned integer of size 1 byte. Returns the number of bytes written (always 1). Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an unsigned integer of size 2 bytes. Returns the number of bytes written (always 2). Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an unsigned integer of size 4 bytes. Returns the number of bytes written (always 4). Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an unsigned integer of size 8 bytes. Returns the number of bytes written (always 8). Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an IEEE 754 single precision floating-point number. Returns the number of bytes written (always 4) bytes. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes an IEEE 754 double precision floating-point number. Returns the number of bytes written (always 8) bytes. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes the given byte vector and returns the number of bytes written. The argument must be a Scheme byte vector object. Optional argument BYTE-ORDER is one of (MSB) or (LSB). If byte order is not specified, the procedure uses the byte order setting of the given endian port.
Writes the given bit vector and returns the number of bytes written. The argument must be a bit vector as defined in the iset module. Optional argument BIT-ORDER is one of (MSB) or (LSB). If bit order is not specified, the procedure uses the byte order setting of the given endian port.
Note that here the "byte order" type is interpreted as bit order: the order argument specifies that the bits are ordered in MSB or LSB order, not the bytes that comprise the bit vector.
Copyright 2005-2008 Ivan Raikov and the Georgia Institute of Technology This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at <http://www.gnu.org/licenses/>.