diff options
author | pixel <pixel> | 2003-02-10 12:45:29 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-02-10 12:45:29 +0000 |
commit | 0ddf2fc631fe6db08eed31c9a21438e2829ca024 (patch) | |
tree | b5c8fd1a7f3cf0e16db573b75a4b88f5dfb99f2b /lib/Handle.cc | |
parent | f02d2dd89ee509ebf91c80c2028313349e385f16 (diff) |
Whoups, daily commit...
Diffstat (limited to 'lib/Handle.cc')
-rw-r--r-- | lib/Handle.cc | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/lib/Handle.cc b/lib/Handle.cc index 030eb2c..d028c47 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -1,15 +1,19 @@ #include <stdio.h> #include <string.h> #include <errno.h> +#include <fcntl.h> +#include <byteswap.h> + #ifdef HAVE_CONFIG_H #include "config.h" #endif + #ifdef HAVE_UNISTD_H #include <unistd.h> #else #include <io.h> #endif -#include <fcntl.h> + #include "Handle.h" #include "gettext.h" @@ -330,6 +334,54 @@ off_t Handle::seek(off_t offset, int whence) throw(GeneralException) { } } +Uint8 Handle::readU8() { + Uint8 r; + read(&r, 1); + return r; +} + +Uint16 Handle::readU16() { + Uint16 r; + read(&r, 2); +#ifdef WORDS_BIGENDIAN + return bswap_16(r); +#else + return r; +#endif +} + +Uint32 Handle::readU32() { + Uint32 r; + read(&r, 4); +#ifdef WORDS_BIGENDIAN + return bswap_32(r); +#else + return r; +#endif +} + +void Handle::writeU8(Uint8 v) { + write(&v, 1); +} + +void Handle::writeU16(Uint16 v) { +#ifdef WORDS_BIGENDIAN + Uint16 t = bswap_16(v); + write(&t, 2); +#else + write(&v, 2); +#endif +} + +void Handle::writeU32(Uint32 v) { +#ifdef WORDS_BIGENDIAN + Uint32 t = bswap_32(v); + write(&t, 4); +#else + write(&v, 4); +#endif +} + void copy(Handle * s, Handle * d, ssize_t size) { long i; unsigned char c; |