summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/metadata/metadata_common.c17
-rw-r--r--apps/metadata/metadata_common.h3
2 files changed, 20 insertions, 0 deletions
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)
{
diff --git a/apps/metadata/metadata_common.h b/apps/metadata/metadata_common.h
index 2a48b25dc6..c8c0dc463f 100644
--- a/apps/metadata/metadata_common.h
+++ b/apps/metadata/metadata_common.h
@@ -38,12 +38,15 @@ bool read_vorbis_tags(int fd, struct mp3entry *id3,
bool skip_id3v2(int fd, struct mp3entry *id3);
long read_string(int fd, char* buf, long buf_size, int eos, long size);
+int read_uint8(int fd, uint8_t* buf);
#ifdef ROCKBOX_BIG_ENDIAN
+#define read_uint16be(fd,buf) read((fd), (buf), 2)
#define read_uint32be(fd,buf) read((fd), (buf), 4)
int read_uint16le(int fd, uint16_t* buf);
int read_uint32le(int fd, uint32_t* buf);
int read_uint64le(int fd, uint64_t* buf);
#else
+int read_uint16be(int fd, uint16_t* buf);
int read_uint32be(int fd, uint32_t* buf);
#define read_uint16le(fd,buf) read((fd), (buf), 2)
#define read_uint32le(fd,buf) read((fd), (buf), 4)