summaryrefslogtreecommitdiffstats
path: root/tools/testdbv2.c
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-06-30 20:34:03 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-06-30 20:34:03 +0000
commit05c3cc297814543d68065389b08ef2123020b0b9 (patch)
treebe7dc165a48e0c3c09d15390f54ee98ef873a6ab /tools/testdbv2.c
parent87d4d1203c502b7ad0c90f39f3de2b48f7c4f9af (diff)
downloadrockbox-05c3cc297814543d68065389b08ef2123020b0b9.tar.gz
rockbox-05c3cc297814543d68065389b08ef2123020b0b9.tar.bz2
rockbox-05c3cc297814543d68065389b08ef2123020b0b9.zip
runtime database support for the tester..
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6955 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/testdbv2.c')
-rw-r--r--tools/testdbv2.c66
1 files changed, 56 insertions, 10 deletions
diff --git a/tools/testdbv2.c b/tools/testdbv2.c
index 378eef21e3..60cdcc77f5 100644
--- a/tools/testdbv2.c
+++ b/tools/testdbv2.c
@@ -1,13 +1,13 @@
#include <stdlib.h>
#include <stdio.h>
-#define ARTISTLEN 32
-#define ALBUMLEN 68
-#define SONGLEN 92
-#define GENRELEN 20
-#define FILELEN 212
-#define SONGARRAYLEN 48
-#define ALBUMARRAYLEN 38
+#define ARTISTLEN 60
+#define ALBUMLEN 64
+#define SONGLEN 120
+#define GENRELEN 28
+#define FILELEN 176
+#define SONGARRAYLEN 715
+#define ALBUMARRAYLEN 186
#define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \
@@ -64,7 +64,21 @@ struct AlbumEntry {
int song[SONGARRAYLEN];
} AlbumEntry;
-FILE *fp;
+struct RundbHeader {
+ int version;
+ int entrycount;
+} RundbHeader;
+
+struct RundbEntry {
+ int file;
+ int hash;
+ short rating;
+ short voladj;
+ int playcount;
+ int lastplayed;
+} RundbEntry;
+
+FILE *fp,*fp2;
void showsong(int offset) {
fseek(fp,offset,SEEK_SET);
@@ -111,8 +125,21 @@ void showartist(int offset) {
}
}
+void showrundb(int offset) {
+ fseek(fp2,offset,SEEK_SET);
+ fread(&RundbEntry,sizeof(struct RundbEntry),1,fp2);
+ RundbEntry.hash=BE32(RundbEntry.hash);
+ RundbEntry.playcount=BE32(RundbEntry.playcount);
+ RundbEntry.lastplayed=BE32(RundbEntry.lastplayed);
+ RundbEntry.rating=BE16(RundbEntry.rating);
+ RundbEntry.voladj=BE16(RundbEntry.voladj);
+ printf("Offset: 0x%x\nHash: 0x%x\nRating: %d\nVoladj: 0x%x\n",offset,RundbEntry.hash,RundbEntry.rating,RundbEntry.voladj);
+ printf("Playcount: 0x%x\nLastplayed: %d\n",RundbEntry.playcount,RundbEntry.lastplayed);
+}
+
int main() {
- fp=fopen("rockbox.id3db","r");
+ fp=fopen("rockbox.tagdb","r");
+ fp2=fopen("rockbox.rundb","r");
int *p,i,temp,temp2,temp3,temp4;
if(fp<0) return -1;
fread(&header,sizeof(header),1,fp);
@@ -121,6 +148,14 @@ int main() {
*p=BE32(*p);
p++;
}
+ if(fp2>=0) {
+ fread(&RundbHeader,sizeof(RundbHeader),1,fp2);
+ p=&RundbHeader;
+ for(i=0;i<2;i++) {
+ *p=BE32(*p);
+ p++;
+ }
+ }
printf("db version : 0x%x\n",header.version&0xFF);
printf("Artist start : 0x%x\n",header.artiststart);
printf("Album start : 0x%x\n",header.albumstart);
@@ -138,6 +173,10 @@ int main() {
printf("Songarraylen : %d\n",header.songarraylen);
printf("Albumarraylen : %d\n",header.albumarraylen);
printf("Rundb dirty : %d\n",header.rundbdirty);
+ if(fp2>=0) {
+ printf("Rundb version : 0x%x\n",RundbHeader.version&0xFF);
+ printf("Rundb entrys : %d\n",RundbHeader.entrycount);
+ }
if( sizeof(struct SongEntry)!=(header.songlen+header.genrelen+16)) {
printf("Song Entry Size mismatch.. update the code to correct size.\n");
return;
@@ -156,7 +195,9 @@ printf("Artist Entry Size mismatch.. update the code to correct size.\n");
}
do {
- printf("\n\nShow artist(1)/album(2)/song(3)/file(4) ? ");
+ printf("\n\nShow artist(1)/album(2)/song(3)/file(4)");
+ if(fp2>=0) printf("/rundb(5)");
+ printf(" ? ");
fflush(stdout);
temp=temp2=temp3=0;
scanf("%d",&temp);
@@ -197,6 +238,11 @@ printf("Artist Entry Size mismatch.. update the code to correct size.\n");
showfile(header.filestart +
temp2*sizeof(struct FileEntry));
break;
+ case 5: if(temp2==-1)
+ showrundb(temp3);
+ else
+ showrundb(8+temp2*sizeof(struct RundbEntry));
+ break;
default:
return;
break;