diff options
author | Bruce Momjian | 2001-05-10 14:41:23 +0000 |
---|---|---|
committer | Bruce Momjian | 2001-05-10 14:41:23 +0000 |
commit | c2a062b7fe55a0d29a8b2f7dffd4f6dd1202af31 (patch) | |
tree | b9785ea644f509b6816b5dd482c1f5f3395a092f /contrib/dbase/endian.c | |
parent | 72c8af51fd8080c9659c2b54264aa4fd78f2e151 (diff) |
Add dbase conversion utility to /contrib.
Diffstat (limited to 'contrib/dbase/endian.c')
-rw-r--r-- | contrib/dbase/endian.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/dbase/endian.c b/contrib/dbase/endian.c new file mode 100644 index 00000000000..55c53d89800 --- /dev/null +++ b/contrib/dbase/endian.c @@ -0,0 +1,45 @@ +/* Maarten Boekhold ([email protected]) oktober 1995 */ + +#include <sys/types.h> +#include "dbf.h" +/* + * routine to change little endian long to host long + */ +long get_long(u_char *cp) +{ + long ret; + + ret = *cp++; + ret += ((*cp++)<<8); + ret += ((*cp++)<<16); + ret += ((*cp++)<<24); + + return ret; +} + +void put_long(u_char *cp, long lval) +{ + cp[0] = lval & 0xff; + cp[1] = (lval >> 8) & 0xff; + cp[2] = (lval >> 16) & 0xff; + cp[3] = (lval >> 24) & 0xff; +} + +/* + * routine to change little endian short to host short + */ +short get_short(u_char *cp) +{ + short ret; + + ret = *cp++; + ret += ((*cp++)<<8); + + return ret; +} + +void put_short(u_char *cp, short sval) +{ + cp[0] = sval & 0xff; + cp[1] = (sval >> 8) & 0xff; +} |