Add read_sXXle/read_uXXbe/etc alias as a test

This commit is contained in:
bnnm 2019-02-23 15:23:00 +01:00
parent e5480f4bb0
commit decf64cf01
2 changed files with 14 additions and 1 deletions

View File

@ -1121,7 +1121,7 @@ void dump_streamfile(STREAMFILE *streamFile, int num) {
char dumpname[PATH_LIMIT];
get_streamfile_filename(streamFile, filename, PATH_LIMIT);
snprintf(dumpname,PATH_LIMIT, "%s_%i.dump", filename, num);
snprintf(dumpname,PATH_LIMIT, "%s_%02i.dump", filename, num);
f = fopen(dumpname,"wb");
if (!f) return;

View File

@ -191,6 +191,19 @@ static inline int8_t read_8bit(off_t offset, STREAMFILE * streamfile) {
return buf[0];
}
/* alias of the above */
static inline int8_t read_s8(off_t offset, STREAMFILE * streamfile) { return read_8bit(offset, streamfile); }
static inline uint8_t read_u8(off_t offset, STREAMFILE * streamfile) { return (uint8_t)read_8bit(offset, streamfile); }
static inline int32_t read_s16le(off_t offset, STREAMFILE * streamfile) { return read_16bitLE(offset, streamfile); }
static inline uint32_t read_u16le(off_t offset, STREAMFILE * streamfile) { return (uint16_t)read_16bitLE(offset, streamfile); }
static inline int32_t read_s16be(off_t offset, STREAMFILE * streamfile) { return read_16bitBE(offset, streamfile); }
static inline uint32_t read_u16be(off_t offset, STREAMFILE * streamfile) { return (uint16_t)read_16bitBE(offset, streamfile); }
static inline int32_t read_s32le(off_t offset, STREAMFILE * streamfile) { return read_32bitLE(offset, streamfile); }
static inline uint32_t read_u32le(off_t offset, STREAMFILE * streamfile) { return (uint32_t)read_32bitLE(offset, streamfile); }
static inline int32_t read_s32be(off_t offset, STREAMFILE * streamfile) { return read_32bitBE(offset, streamfile); }
static inline uint32_t read_u32be(off_t offset, STREAMFILE * streamfile) { return (uint32_t)read_32bitBE(offset, streamfile); }
/* guess byte endianness from a given value, return true if big endian and false if little endian */
static inline int guess_endianness16bit(off_t offset, STREAMFILE * streamfile) {
uint8_t buf[0x02];