From b68707d4651876435161729beab68a329e6d9b6d Mon Sep 17 00:00:00 2001 From: Mohamed Tarek Date: Sat, 16 May 2009 19:05:50 +0000 Subject: Add read_uint8() and read_uint16be() to metadata_common.c/h git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20968 a1c6a512-1295-4272-9138-f99709370657 --- apps/metadata/metadata_common.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'apps/metadata/metadata_common.c') diff --git a/apps/metadata/metadata_common.c b/apps/metadata/metadata_common.c index 37768bdd4a..38761e3dae 100644 --- a/apps/metadata/metadata_common.c +++ b/apps/metadata/metadata_common.c @@ -96,8 +96,25 @@ long read_string(int fd, char* buf, long buf_size, int eos, long size) *buf = 0; return read_bytes; } +/* Read an unsigned 8-bit integer from a file. */ +int read_uint8(int fd, uint8_t* buf) +{ + size_t n; + + n = read(fd, (char*) buf, 1); + return n; +} #ifdef ROCKBOX_LITTLE_ENDIAN +/* Read an unsigned 16-bit integer from a big-endian file. */ +int read_uint16be(int fd, uint16_t* buf) +{ + size_t n; + + n = read(fd, (char*) buf, 2); + *buf = betoh16(*buf); + return n; +} /* Read an unsigned 32-bit integer from a big-endian file. */ int read_uint32be(int fd, uint32_t* buf) { -- cgit v1.2.3