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