Check if the file could be modified, error if not.
[Rockbox.git] / apps / database.h
blobfacfb5338e4a3e404ec1388a2077af0b9b41936f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Michiel van der Kolk
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #ifndef DATABASE_H
20 #define DATABASE_H
22 #ifdef ROCKBOX_LITTLE_ENDIAN
23 #define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \
24 ((_x_ & 0x00ff0000) >> 8) | \
25 ((_x_ & 0x0000ff00) << 8) | \
26 ((_x_ & 0x000000ff) << 24))
27 #define BE16(_x_) ( ((_x_&0xFF00) >> 8)|((_x_&0xFF)<<8))
28 #else
29 #define BE32(_x_) _x_
30 #define BE16(_x_) _x_
31 #endif
33 #define SONGENTRY_SIZE (tagdbheader.songlen+12+tagdbheader.genrelen+4)
34 #define FILEENTRY_SIZE (tagdbheader.filelen+12)
35 #define ALBUMENTRY_SIZE (tagdbheader.albumlen+4+tagdbheader.songarraylen*4)
36 #define ARTISTENTRY_SIZE (tagdbheader.artistlen+tagdbheader.albumarraylen*4)
38 #define FILERECORD2OFFSET(_x_) (tagdbheader.filestart + _x_ * FILEENTRY_SIZE)
40 extern int tagdb_initialized;
42 struct tagdb_header {
43 int version;
44 int artiststart;
45 int albumstart;
46 int songstart;
47 int filestart;
48 int artistcount;
49 int albumcount;
50 int songcount;
51 int filecount;
52 int artistlen;
53 int albumlen;
54 int songlen;
55 int genrelen;
56 int filelen;
57 int songarraylen;
58 int albumarraylen;
59 int rundbdirty;
62 struct file_entry {
63 char *name;
64 int hash;
65 int songentry;
66 int rundbentry;
69 extern struct tagdb_header tagdbheader;
70 extern int tagdb_fd;
72 int tagdb_init(void);
73 void tagdb_shutdown(void);
75 #define TAGDB_VERSION 2
77 struct rundb_header {
78 int version;
79 int entrycount;
82 struct rundb_entry {
83 int fileentry;
84 int hash;
85 short rating;
86 short voladjust;
87 int playcount;
88 int lastplayed;
91 extern struct rundb_header rundbheader;
93 #define RUNDB_VERSION 1
95 #endif