Add util functions to deal with ISO types.
This commit is contained in:
22
src/util.c
22
src/util.c
@ -514,6 +514,28 @@ void iso_bb(uint8_t *buf, uint32_t num, int bytes)
|
||||
iso_msb(buf+bytes, num, bytes);
|
||||
}
|
||||
|
||||
uint32_t iso_read_lsb(const uint8_t *buf, int bytes)
|
||||
{
|
||||
int i;
|
||||
uint32_t ret = 0;
|
||||
|
||||
for (i=0; i<bytes; i++) {
|
||||
ret += ((uint32_t) buf[i]) << (i*8);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t iso_read_msb(const uint8_t *buf, int bytes)
|
||||
{
|
||||
int i;
|
||||
uint32_t ret = 0;
|
||||
|
||||
for (i=0; i<bytes; i++) {
|
||||
ret += ((uint32_t) buf[bytes-i-1]) << (i*8);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void iso_datetime_7(unsigned char *buf, time_t t)
|
||||
{
|
||||
static int tzsetup = 0;
|
||||
|
@ -93,6 +93,9 @@ void iso_lsb(uint8_t *buf, uint32_t num, int bytes);
|
||||
void iso_msb(uint8_t *buf, uint32_t num, int bytes);
|
||||
void iso_bb(uint8_t *buf, uint32_t num, int bytes);
|
||||
|
||||
uint32_t iso_read_lsb(const uint8_t *buf, int bytes);
|
||||
uint32_t iso_read_msb(const uint8_t *buf, int bytes);
|
||||
|
||||
/** Records the date/time into a 7 byte buffer (ECMA-119, 9.1.5) */
|
||||
void iso_datetime_7(uint8_t *buf, time_t t);
|
||||
|
||||
|
Reference in New Issue
Block a user