2001-12-31 16:32:04 +03:00
|
|
|
/* Maarten Boekhold (maarten.boekhold@reuters.com) oktober 1995 */
|
2001-05-10 18:41:23 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "dbf.h"
|
|
|
|
/*
|
|
|
|
* routine to change little endian long to host long
|
|
|
|
*/
|
2001-10-25 09:50:21 +04:00
|
|
|
long
|
|
|
|
get_long(u_char *cp)
|
2001-05-10 18:41:23 +04:00
|
|
|
{
|
2001-10-25 09:50:21 +04:00
|
|
|
long ret;
|
2001-05-10 18:41:23 +04:00
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
ret = *cp++;
|
|
|
|
ret += ((*cp++) << 8);
|
|
|
|
ret += ((*cp++) << 16);
|
|
|
|
ret += ((*cp++) << 24);
|
2001-05-10 18:41:23 +04:00
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
return ret;
|
2001-05-10 18:41:23 +04:00
|
|
|
}
|
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
void
|
|
|
|
put_long(u_char *cp, long lval)
|
2001-05-10 18:41:23 +04:00
|
|
|
{
|
2001-10-25 09:50:21 +04:00
|
|
|
cp[0] = lval & 0xff;
|
|
|
|
cp[1] = (lval >> 8) & 0xff;
|
|
|
|
cp[2] = (lval >> 16) & 0xff;
|
|
|
|
cp[3] = (lval >> 24) & 0xff;
|
2001-05-10 18:41:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* routine to change little endian short to host short
|
|
|
|
*/
|
2001-10-25 09:50:21 +04:00
|
|
|
short
|
|
|
|
get_short(u_char *cp)
|
2001-05-10 18:41:23 +04:00
|
|
|
{
|
2001-10-25 09:50:21 +04:00
|
|
|
short ret;
|
2001-05-10 18:41:23 +04:00
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
ret = *cp++;
|
|
|
|
ret += ((*cp++) << 8);
|
2001-05-10 18:41:23 +04:00
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
return ret;
|
2001-05-10 18:41:23 +04:00
|
|
|
}
|
|
|
|
|
2001-10-25 09:50:21 +04:00
|
|
|
void
|
|
|
|
put_short(u_char *cp, short sval)
|
2001-05-10 18:41:23 +04:00
|
|
|
{
|
2001-10-25 09:50:21 +04:00
|
|
|
cp[0] = sval & 0xff;
|
|
|
|
cp[1] = (sval >> 8) & 0xff;
|
2001-05-10 18:41:23 +04:00
|
|
|
}
|