9 #define SONGARRAYLEN 715
10 #define ALBUMARRAYLEN 186
13 #define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \
14 ((_x_ & 0x00ff0000) >> 8) | \
15 ((_x_ & 0x0000ff00) << 8) | \
16 ((_x_ & 0x000000ff) << 24))
17 #define BE16(_x_) ( ((_x_&0xff00) >> 8) | ((_x_&0xff)<<8))
58 int album
[ALBUMARRAYLEN
];
64 int song
[SONGARRAYLEN
];
83 void showsong(int offset
) {
84 fseek(fp
,offset
,SEEK_SET
);
85 fread(&SongEntry
,sizeof(struct SongEntry
),1,fp
);
86 SongEntry
.artist
=BE32(SongEntry
.artist
);
87 SongEntry
.album
=BE32(SongEntry
.album
);
88 SongEntry
.file
=BE32(SongEntry
.file
);
89 SongEntry
.year
=BE16(SongEntry
.year
);
90 SongEntry
.bitrate
=BE16(SongEntry
.bitrate
);
91 printf("Offset: 0x%x\nName: %s\nArtist: 0x%x\nAlbum: 0x%x\nFile: 0x%x\nGenre: %s\nBitrate: %d\nYear: %d\n\n",offset
,SongEntry
.name
,SongEntry
.artist
,SongEntry
.album
,SongEntry
.file
,SongEntry
.genre
,SongEntry
.bitrate
,SongEntry
.year
);
94 void showalbum(int offset
) {
96 fseek(fp
,offset
,SEEK_SET
);
97 fread(&AlbumEntry
,sizeof(struct AlbumEntry
),1,fp
);
98 AlbumEntry
.artist
=BE32(AlbumEntry
.artist
);
99 printf("Offset: 0x%x\nAlbum: %s\nArtist: 0x%x\n",offset
,AlbumEntry
.name
,AlbumEntry
.artist
);
100 for(i
=0;i
<header
.songarraylen
;i
++) {
101 AlbumEntry
.song
[i
]=BE32(AlbumEntry
.song
[i
]);
102 printf("Song %d: 0x%x\n",i
,AlbumEntry
.song
[i
]);
106 void showfile(int offset
) {
107 fseek(fp
,offset
,SEEK_SET
);
108 fread(&FileEntry
,sizeof(struct FileEntry
),1,fp
);
109 FileEntry
.hash
=BE32(FileEntry
.hash
);
110 FileEntry
.tagoffset
=BE32(FileEntry
.tagoffset
);
111 FileEntry
.rundboffset
=BE32(FileEntry
.rundboffset
);
112 printf("Offset: 0x%x\nFilename: %s\nHash: 0x%x\nTag: 0x%x\nRunDB: 0x%x\n",
113 offset
,FileEntry
.name
,FileEntry
.hash
,
114 FileEntry
.tagoffset
, FileEntry
.rundboffset
);
117 void showartist(int offset
) {
119 fseek(fp
,offset
,SEEK_SET
);
120 fread(&ArtistEntry
,sizeof(struct ArtistEntry
),1,fp
);
121 printf("Offset: 0x%x\nArtist: %s\n",offset
,ArtistEntry
.name
);
122 for(i
=0;i
<header
.albumarraylen
;i
++) {
123 ArtistEntry
.album
[i
]=BE32(ArtistEntry
.album
[i
]);
124 printf("Album %d: 0x%x\n",i
,ArtistEntry
.album
[i
]);
128 void showrundb(int offset
) {
129 fseek(fp2
,offset
,SEEK_SET
);
130 fread(&RundbEntry
,sizeof(struct RundbEntry
),1,fp2
);
131 RundbEntry
.file
=BE32(RundbEntry
.file
);
132 RundbEntry
.hash
=BE32(RundbEntry
.hash
);
133 RundbEntry
.playcount
=BE32(RundbEntry
.playcount
);
134 RundbEntry
.lastplayed
=BE32(RundbEntry
.lastplayed
);
135 RundbEntry
.rating
=BE16(RundbEntry
.rating
);
136 RundbEntry
.voladj
=BE16(RundbEntry
.voladj
);
137 printf("Offset: 0x%x\nFileEntry: 0x%x\nHash: 0x%x\nRating: %d\nVoladj: 0x%x\n",offset
,RundbEntry
.file
,RundbEntry
.hash
,RundbEntry
.rating
,RundbEntry
.voladj
);
138 printf("Playcount: 0x%x\nLastplayed: %d\n",RundbEntry
.playcount
,RundbEntry
.lastplayed
);
142 fp
=fopen("rockbox.tagdb","r");
143 fp2
=fopen("rockbox.rundb","r");
144 int *p
,i
,temp
,temp2
,temp3
,temp4
;
146 fread(&header
,sizeof(header
),1,fp
);
153 fread(&RundbHeader
,sizeof(RundbHeader
),1,fp2
);
160 printf("db version : 0x%x\n",header
.version
&0xFF);
161 printf("Artist start : 0x%x\n",header
.artiststart
);
162 printf("Album start : 0x%x\n",header
.albumstart
);
163 printf("Song start : 0x%x\n",header
.songstart
);
164 printf("File start : 0x%x\n",header
.filestart
);
165 printf("Artist count : %d\n",header
.artistcount
);
166 printf("Album count : %d\n",header
.albumcount
);
167 printf("Song count : %d\n",header
.songcount
);
168 printf("File count : %d\n",header
.filecount
);
169 printf("Artist len : %d\n",header
.artistlen
);
170 printf("Album len : %d\n",header
.albumlen
);
171 printf("Song len : %d\n",header
.songlen
);
172 printf("Genre len : %d\n",header
.genrelen
);
173 printf("File len : %d\n",header
.filelen
);
174 printf("Songarraylen : %d\n",header
.songarraylen
);
175 printf("Albumarraylen : %d\n",header
.albumarraylen
);
176 printf("Rundb dirty : %d\n",header
.rundbdirty
);
178 printf("Rundb version : 0x%x\n",RundbHeader
.version
&0xFF);
179 printf("Rundb entrys : %d\n",RundbHeader
.entrycount
);
181 if( sizeof(struct SongEntry
)!=(header
.songlen
+header
.genrelen
+16)) {
182 printf("Song Entry Size mismatch.. update the code to correct size.\n");
185 if(sizeof(struct AlbumEntry
)!=(header
.albumlen
+4+header
.songarraylen
*4)) {
186 printf("Album Entry Size mismatch.. update the code to correct size.\n");
189 if(sizeof(struct ArtistEntry
)!=(header
.artistlen
+header
.albumarraylen
*4)) {
190 printf("Artist Entry Size mismatch.. update the code to correct size.\n");
193 if(sizeof(struct FileEntry
)!=(header
.filelen
+12)) {
194 printf("File Entry Size mismatch.. update the code to correct size.\n");
199 printf("\n\nShow artist(1)/album(2)/song(3)/file(4)");
200 if(fp2
>=0) printf("/rundb(5)");
205 printf("Record (-1 for offset) ? ");
209 printf("Offset ? 0x");
218 showartist(header
.artiststart
+
219 temp2
*sizeof(struct ArtistEntry
));
225 showalbum(header
.albumstart
+
226 temp2
*sizeof(struct AlbumEntry
));
232 showsong(header
.songstart
+
233 temp2
*sizeof(struct SongEntry
));
239 showfile(header
.filestart
+
240 temp2
*sizeof(struct FileEntry
));
242 case 5: if(temp2
==-1)
245 showrundb(8+temp2
*sizeof(struct RundbEntry
));