utils: use GUINT32_FROM_LE() instead of readLEuint32()

Eliminate code already provided by GLib.
This commit is contained in:
Max Kellermann 2008-11-01 14:11:19 +01:00
parent b996108675
commit 35710a81ea
3 changed files with 8 additions and 17 deletions

View File

@ -125,9 +125,9 @@ struct tag *tag_ape_load(const char *file)
struct { struct {
unsigned char id[8]; unsigned char id[8];
unsigned char version[4]; uint32_t version;
unsigned char length[4]; uint32_t length;
unsigned char tagCount[4]; uint32_t tagCount;
unsigned char flags[4]; unsigned char flags[4];
unsigned char reserved[8]; unsigned char reserved[8];
} footer; } footer;
@ -166,11 +166,11 @@ struct tag *tag_ape_load(const char *file)
goto fail; goto fail;
if (memcmp(footer.id, "APETAGEX", sizeof(footer.id)) != 0) if (memcmp(footer.id, "APETAGEX", sizeof(footer.id)) != 0)
goto fail; goto fail;
if (readLEuint32(footer.version) != 2000) if (GUINT32_FROM_LE(footer.version) != 2000)
goto fail; goto fail;
/* find beginning of ape tag */ /* find beginning of ape tag */
tagLen = readLEuint32(footer.length); tagLen = GUINT32_FROM_LE(footer.length);
if (tagLen < sizeof(footer)) if (tagLen < sizeof(footer))
goto fail; goto fail;
if (fseek(fp, size - tagLen, SEEK_SET)) if (fseek(fp, size - tagLen, SEEK_SET))
@ -185,13 +185,13 @@ struct tag *tag_ape_load(const char *file)
goto fail; goto fail;
/* read tags */ /* read tags */
tagCount = readLEuint32(footer.tagCount); tagCount = GUINT32_FROM_LE(footer.tagCount);
p = buffer; p = buffer;
while (tagCount-- && tagLen > 10) { while (tagCount-- && tagLen > 10) {
size = readLEuint32((unsigned char *)p); size = GUINT32_FROM_LE(*(const uint32_t *)p);
p += 4; p += 4;
tagLen -= 4; tagLen -= 4;
flags = readLEuint32((unsigned char *)p); flags = GUINT32_FROM_LE(*(const uint32_t *)p);
p += 4; p += 4;
tagLen -= 4; tagLen -= 4;

View File

@ -75,13 +75,6 @@ int ipv6Supported(void)
#endif #endif
} }
unsigned long readLEuint32(const unsigned char *p)
{
return ((unsigned long)p[0] << 0) |
((unsigned long)p[1] << 8) |
((unsigned long)p[2] << 16) | ((unsigned long)p[3] << 24);
}
mpd_malloc char *xstrdup(const char *s) mpd_malloc char *xstrdup(const char *s)
{ {
char *ret = strdup(s); char *ret = strdup(s);

View File

@ -37,8 +37,6 @@ void my_usleep(long usec);
int ipv6Supported(void); int ipv6Supported(void);
unsigned long readLEuint32(const unsigned char *p);
/* trivial functions, keep them inlined */ /* trivial functions, keep them inlined */
static inline void xclose(int fd) static inline void xclose(int fd)
{ {