Use strlcpy instead of a memset&strcpy combo. Guarantees \0-terminaltion and gives...
[kugel-rb.git] / apps / metadata / metadata_common.h
blobf7539950e1c1e6cbc30475faa6d40449b38ef36a
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Dave Chapman
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "metadata.h"
23 #ifdef ROCKBOX_BIG_ENDIAN
24 #define IS_BIG_ENDIAN 1
25 #else
26 #define IS_BIG_ENDIAN 0
27 #endif
29 #define TAG_NAME_LENGTH 32
30 #define TAG_VALUE_LENGTH 128
32 enum tagtype { TAGTYPE_APE = 1, TAGTYPE_VORBIS };
34 bool read_ape_tags(int fd, struct mp3entry* id3);
35 long read_vorbis_tags(int fd, struct mp3entry *id3,
36 long tag_remaining);
38 bool skip_id3v2(int fd, struct mp3entry *id3);
39 long read_string(int fd, char* buf, long buf_size, int eos, long size);
41 int read_uint8(int fd, uint8_t* buf);
42 #ifdef ROCKBOX_BIG_ENDIAN
43 #define read_uint16be(fd,buf) read((fd), (buf), 2)
44 #define read_uint32be(fd,buf) read((fd), (buf), 4)
45 #define read_uint64be(fd,buf) read((fd), (buf), 8)
46 int read_uint16le(int fd, uint16_t* buf);
47 int read_uint32le(int fd, uint32_t* buf);
48 int read_uint64le(int fd, uint64_t* buf);
49 #else
50 int read_uint16be(int fd, uint16_t* buf);
51 int read_uint32be(int fd, uint32_t* buf);
52 int read_uint64be(int fd, uint64_t* buf);
53 #define read_uint16le(fd,buf) read((fd), (buf), 2)
54 #define read_uint32le(fd,buf) read((fd), (buf), 4)
55 #define read_uint64le(fd,buf) read((fd), (buf), 8)
56 #endif
58 unsigned long get_long_le(void* buf);
59 unsigned short get_short_le(void* buf);
60 unsigned long get_long_be(void* buf);
61 long get_slong(void* buf);
62 unsigned long get_itunes_int32(char* value, int count);
63 long parse_tag(const char* name, char* value, struct mp3entry* id3,
64 char* buf, long buf_remaining, enum tagtype type);