diff options
-rw-r--r-- | tools/testdbv2.c | 66 |
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 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | 3 | ||
4 | #define ARTISTLEN 32 | 4 | #define ARTISTLEN 60 |
5 | #define ALBUMLEN 68 | 5 | #define ALBUMLEN 64 |
6 | #define SONGLEN 92 | 6 | #define SONGLEN 120 |
7 | #define GENRELEN 20 | 7 | #define GENRELEN 28 |
8 | #define FILELEN 212 | 8 | #define FILELEN 176 |
9 | #define SONGARRAYLEN 48 | 9 | #define SONGARRAYLEN 715 |
10 | #define ALBUMARRAYLEN 38 | 10 | #define ALBUMARRAYLEN 186 |
11 | 11 | ||
12 | 12 | ||
13 | #define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \ | 13 | #define BE32(_x_) (((_x_ & 0xff000000) >> 24) | \ |
@@ -64,7 +64,21 @@ struct AlbumEntry { | |||
64 | int song[SONGARRAYLEN]; | 64 | int song[SONGARRAYLEN]; |
65 | } AlbumEntry; | 65 | } AlbumEntry; |
66 | 66 | ||
67 | FILE *fp; | 67 | struct RundbHeader { |
68 | int version; | ||
69 | int entrycount; | ||
70 | } RundbHeader; | ||
71 | |||
72 | struct RundbEntry { | ||
73 | int file; | ||
74 | int hash; | ||
75 | short rating; | ||
76 | short voladj; | ||
77 | int playcount; | ||
78 | int lastplayed; | ||
79 | } RundbEntry; | ||
80 | |||
81 | FILE *fp,*fp2; | ||
68 | 82 | ||
69 | void showsong(int offset) { | 83 | void showsong(int offset) { |
70 | fseek(fp,offset,SEEK_SET); | 84 | fseek(fp,offset,SEEK_SET); |
@@ -111,8 +125,21 @@ void showartist(int offset) { | |||
111 | } | 125 | } |
112 | } | 126 | } |
113 | 127 | ||
128 | void showrundb(int offset) { | ||
129 | fseek(fp2,offset,SEEK_SET); | ||
130 | fread(&RundbEntry,sizeof(struct RundbEntry),1,fp2); | ||
131 | RundbEntry.hash=BE32(RundbEntry.hash); | ||
132 | RundbEntry.playcount=BE32(RundbEntry.playcount); | ||
133 | RundbEntry.lastplayed=BE32(RundbEntry.lastplayed); | ||
134 | RundbEntry.rating=BE16(RundbEntry.rating); | ||
135 | RundbEntry.voladj=BE16(RundbEntry.voladj); | ||
136 | printf("Offset: 0x%x\nHash: 0x%x\nRating: %d\nVoladj: 0x%x\n",offset,RundbEntry.hash,RundbEntry.rating,RundbEntry.voladj); | ||
137 | printf("Playcount: 0x%x\nLastplayed: %d\n",RundbEntry.playcount,RundbEntry.lastplayed); | ||
138 | } | ||
139 | |||
114 | int main() { | 140 | int main() { |
115 | fp=fopen("rockbox.id3db","r"); | 141 | fp=fopen("rockbox.tagdb","r"); |
142 | fp2=fopen("rockbox.rundb","r"); | ||
116 | int *p,i,temp,temp2,temp3,temp4; | 143 | int *p,i,temp,temp2,temp3,temp4; |
117 | if(fp<0) return -1; | 144 | if(fp<0) return -1; |
118 | fread(&header,sizeof(header),1,fp); | 145 | fread(&header,sizeof(header),1,fp); |
@@ -121,6 +148,14 @@ int main() { | |||
121 | *p=BE32(*p); | 148 | *p=BE32(*p); |
122 | p++; | 149 | p++; |
123 | } | 150 | } |
151 | if(fp2>=0) { | ||
152 | fread(&RundbHeader,sizeof(RundbHeader),1,fp2); | ||
153 | p=&RundbHeader; | ||
154 | for(i=0;i<2;i++) { | ||
155 | *p=BE32(*p); | ||
156 | p++; | ||
157 | } | ||
158 | } | ||
124 | printf("db version : 0x%x\n",header.version&0xFF); | 159 | printf("db version : 0x%x\n",header.version&0xFF); |
125 | printf("Artist start : 0x%x\n",header.artiststart); | 160 | printf("Artist start : 0x%x\n",header.artiststart); |
126 | printf("Album start : 0x%x\n",header.albumstart); | 161 | printf("Album start : 0x%x\n",header.albumstart); |
@@ -138,6 +173,10 @@ int main() { | |||
138 | printf("Songarraylen : %d\n",header.songarraylen); | 173 | printf("Songarraylen : %d\n",header.songarraylen); |
139 | printf("Albumarraylen : %d\n",header.albumarraylen); | 174 | printf("Albumarraylen : %d\n",header.albumarraylen); |
140 | printf("Rundb dirty : %d\n",header.rundbdirty); | 175 | printf("Rundb dirty : %d\n",header.rundbdirty); |
176 | if(fp2>=0) { | ||
177 | printf("Rundb version : 0x%x\n",RundbHeader.version&0xFF); | ||
178 | printf("Rundb entrys : %d\n",RundbHeader.entrycount); | ||
179 | } | ||
141 | if( sizeof(struct SongEntry)!=(header.songlen+header.genrelen+16)) { | 180 | if( sizeof(struct SongEntry)!=(header.songlen+header.genrelen+16)) { |
142 | printf("Song Entry Size mismatch.. update the code to correct size.\n"); | 181 | printf("Song Entry Size mismatch.. update the code to correct size.\n"); |
143 | return; | 182 | return; |
@@ -156,7 +195,9 @@ printf("Artist Entry Size mismatch.. update the code to correct size.\n"); | |||
156 | } | 195 | } |
157 | 196 | ||
158 | do { | 197 | do { |
159 | printf("\n\nShow artist(1)/album(2)/song(3)/file(4) ? "); | 198 | printf("\n\nShow artist(1)/album(2)/song(3)/file(4)"); |
199 | if(fp2>=0) printf("/rundb(5)"); | ||
200 | printf(" ? "); | ||
160 | fflush(stdout); | 201 | fflush(stdout); |
161 | temp=temp2=temp3=0; | 202 | temp=temp2=temp3=0; |
162 | scanf("%d",&temp); | 203 | scanf("%d",&temp); |
@@ -197,6 +238,11 @@ printf("Artist Entry Size mismatch.. update the code to correct size.\n"); | |||
197 | showfile(header.filestart + | 238 | showfile(header.filestart + |
198 | temp2*sizeof(struct FileEntry)); | 239 | temp2*sizeof(struct FileEntry)); |
199 | break; | 240 | break; |
241 | case 5: if(temp2==-1) | ||
242 | showrundb(temp3); | ||
243 | else | ||
244 | showrundb(8+temp2*sizeof(struct RundbEntry)); | ||
245 | break; | ||
200 | default: | 246 | default: |
201 | return; | 247 | return; |
202 | break; | 248 | break; |