diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2006-11-10 08:03:33 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-11-10 08:03:33 +0000 |
commit | 0dd7ea2d712944b21ede9f57bebd1009b03932e6 (patch) | |
tree | dc6065067aa862cc6a71c206b67554270fe507bd /firmware | |
parent | ae221f140231cb2fd4833443d7810dfce03c606a (diff) | |
download | rockbox-0dd7ea2d712944b21ede9f57bebd1009b03932e6.tar.gz rockbox-0dd7ea2d712944b21ede9f57bebd1009b03932e6.zip |
Support building tagcache db natively on PC using the core of the
Rockbox tagcache database engine. Only host endian support at the
moment and no command line parameters. Mainly for developers for
debugging at the moment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11497 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/common/dircache.c | 23 | ||||
-rw-r--r-- | firmware/export/config.h | 2 | ||||
-rw-r--r-- | firmware/export/debug.h | 2 | ||||
-rw-r--r-- | firmware/export/logf.h | 10 | ||||
-rw-r--r-- | firmware/id3.c | 12 | ||||
-rw-r--r-- | firmware/include/dir.h | 2 | ||||
-rw-r--r-- | firmware/include/dircache.h | 2 | ||||
-rw-r--r-- | firmware/logf.c | 17 | ||||
-rw-r--r-- | firmware/mp3data.c | 5 |
9 files changed, 51 insertions, 24 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 7222a41221..7227704ffc 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -57,7 +57,7 @@ static unsigned long dircache_size = 0; | |||
57 | static unsigned long entry_count = 0; | 57 | static unsigned long entry_count = 0; |
58 | static unsigned long reserve_used = 0; | 58 | static unsigned long reserve_used = 0; |
59 | static unsigned int cache_build_ticks = 0; | 59 | static unsigned int cache_build_ticks = 0; |
60 | static char dircache_cur_path[MAX_PATH]; | 60 | static char dircache_cur_path[MAX_PATH*2]; |
61 | 61 | ||
62 | static struct event_queue dircache_queue; | 62 | static struct event_queue dircache_queue; |
63 | static long dircache_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; | 63 | static long dircache_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; |
@@ -178,7 +178,7 @@ static int dircache_scan(struct travel_data *td) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | td->ce->attribute = td->entry->attribute; | 180 | td->ce->attribute = td->entry->attribute; |
181 | td->ce->name_len = MIN(254, strlen(td->entry->d_name)) + 1; | 181 | td->ce->name_len = strlen(td->entry->d_name); |
182 | td->ce->d_name = ((char *)dircache_root+dircache_size); | 182 | td->ce->d_name = ((char *)dircache_root+dircache_size); |
183 | td->ce->size = td->entry->size; | 183 | td->ce->size = td->entry->size; |
184 | td->ce->wrtdate = td->entry->wrtdate; | 184 | td->ce->wrtdate = td->entry->wrtdate; |
@@ -192,7 +192,7 @@ static int dircache_scan(struct travel_data *td) | |||
192 | } | 192 | } |
193 | 193 | ||
194 | td->ce->attribute = td->entry.attr; | 194 | td->ce->attribute = td->entry.attr; |
195 | td->ce->name_len = MIN(254, strlen(td->entry.name)) + 1; | 195 | td->ce->name_len = strlen(td->entry.name) + 1; |
196 | td->ce->d_name = ((char *)dircache_root+dircache_size); | 196 | td->ce->d_name = ((char *)dircache_root+dircache_size); |
197 | td->ce->startcluster = td->entry.firstcluster; | 197 | td->ce->startcluster = td->entry.firstcluster; |
198 | td->ce->size = td->entry.filesize; | 198 | td->ce->size = td->entry.filesize; |
@@ -215,9 +215,11 @@ static int dircache_scan(struct travel_data *td) | |||
215 | return -2; | 215 | return -2; |
216 | 216 | ||
217 | td->pathpos = strlen(dircache_cur_path); | 217 | td->pathpos = strlen(dircache_cur_path); |
218 | strncpy(&dircache_cur_path[td->pathpos], "/", MAX_PATH - td->pathpos - 1); | 218 | strncpy(&dircache_cur_path[td->pathpos], "/", |
219 | sizeof(dircache_cur_path) - td->pathpos - 1); | ||
219 | #ifdef SIMULATOR | 220 | #ifdef SIMULATOR |
220 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, MAX_PATH - td->pathpos - 2); | 221 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, |
222 | sizeof(dircache_cur_path) - td->pathpos - 2); | ||
221 | 223 | ||
222 | td->newdir = opendir(dircache_cur_path); | 224 | td->newdir = opendir(dircache_cur_path); |
223 | if (td->newdir == NULL) | 225 | if (td->newdir == NULL) |
@@ -226,7 +228,8 @@ static int dircache_scan(struct travel_data *td) | |||
226 | return -3; | 228 | return -3; |
227 | } | 229 | } |
228 | #else | 230 | #else |
229 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name, MAX_PATH - td->pathpos - 2); | 231 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name, |
232 | sizeof(dircache_cur_path) - td->pathpos - 2); | ||
230 | 233 | ||
231 | td->newdir = *td->dir; | 234 | td->newdir = *td->dir; |
232 | if (fat_opendir(IF_MV2(volume,) &td->newdir, | 235 | if (fat_opendir(IF_MV2(volume,) &td->newdir, |
@@ -360,7 +363,7 @@ static struct dircache_entry* dircache_get_entry(const char *path, | |||
360 | bool get_before, bool only_directories) | 363 | bool get_before, bool only_directories) |
361 | { | 364 | { |
362 | struct dircache_entry *cache_entry, *before; | 365 | struct dircache_entry *cache_entry, *before; |
363 | char namecopy[MAX_PATH]; | 366 | char namecopy[MAX_PATH*2]; |
364 | char* part; | 367 | char* part; |
365 | char* end; | 368 | char* end; |
366 | 369 | ||
@@ -543,7 +546,7 @@ static int dircache_do_rebuild(void) | |||
543 | pdir = &dir; | 546 | pdir = &dir; |
544 | #endif | 547 | #endif |
545 | 548 | ||
546 | memset(dircache_cur_path, 0, MAX_PATH); | 549 | memset(dircache_cur_path, 0, sizeof(dircache_cur_path)); |
547 | dircache_size = sizeof(struct dircache_entry); | 550 | dircache_size = sizeof(struct dircache_entry); |
548 | 551 | ||
549 | cpu_boost_id(true, CPUBOOSTID_DIRCACHE); | 552 | cpu_boost_id(true, CPUBOOSTID_DIRCACHE); |
@@ -837,7 +840,7 @@ static int block_until_ready(void) | |||
837 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) | 840 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) |
838 | { | 841 | { |
839 | struct dircache_entry *entry; | 842 | struct dircache_entry *entry; |
840 | char basedir[MAX_PATH]; | 843 | char basedir[MAX_PATH*2]; |
841 | char *new; | 844 | char *new; |
842 | long last_cache_size = dircache_size; | 845 | long last_cache_size = dircache_size; |
843 | 846 | ||
@@ -1005,7 +1008,7 @@ void dircache_rename(const char *oldpath, const char *newpath) | |||
1005 | { /* Test ok. */ | 1008 | { /* Test ok. */ |
1006 | struct dircache_entry *entry, *newentry; | 1009 | struct dircache_entry *entry, *newentry; |
1007 | struct dircache_entry oldentry; | 1010 | struct dircache_entry oldentry; |
1008 | char absolute_path[MAX_PATH]; | 1011 | char absolute_path[MAX_PATH*2]; |
1009 | char *p; | 1012 | char *p; |
1010 | 1013 | ||
1011 | if (block_until_ready()) | 1014 | if (block_until_ready()) |
diff --git a/firmware/export/config.h b/firmware/export/config.h index 18c0ef7d17..45d974a96f 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h | |||
@@ -20,7 +20,9 @@ | |||
20 | #ifndef __CONFIG_H__ | 20 | #ifndef __CONFIG_H__ |
21 | #define __CONFIG_H__ | 21 | #define __CONFIG_H__ |
22 | 22 | ||
23 | #ifndef __PCTOOL__ | ||
23 | #include "autoconf.h" | 24 | #include "autoconf.h" |
25 | #endif | ||
24 | 26 | ||
25 | /* symbolic names for multiple choice configurations: */ | 27 | /* symbolic names for multiple choice configurations: */ |
26 | 28 | ||
diff --git a/firmware/export/debug.h b/firmware/export/debug.h index 52b6687c6b..ce556d6418 100644 --- a/firmware/export/debug.h +++ b/firmware/export/debug.h | |||
@@ -26,7 +26,7 @@ extern void ldebugf(const char* file, int line, const char *fmt, ...); | |||
26 | #ifdef __GNUC__ | 26 | #ifdef __GNUC__ |
27 | 27 | ||
28 | /* */ | 28 | /* */ |
29 | #if defined(SIMULATOR) | 29 | #if defined(SIMULATOR) && !defined(__PCTOOL__) |
30 | #define DEBUGF debugf | 30 | #define DEBUGF debugf |
31 | #define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__) | 31 | #define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__) |
32 | #else | 32 | #else |
diff --git a/firmware/export/logf.h b/firmware/export/logf.h index 4206173596..35cb7127e4 100644 --- a/firmware/export/logf.h +++ b/firmware/export/logf.h | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #ifdef ROCKBOX_HAS_LOGF | 24 | #ifdef ROCKBOX_HAS_LOGF |
25 | 25 | ||
26 | #ifndef __PCTOOL__ | ||
26 | #define MAX_LOGF_LINES 1000 | 27 | #define MAX_LOGF_LINES 1000 |
27 | #define MAX_LOGF_ENTRY 30 | 28 | #define MAX_LOGF_ENTRY 30 |
28 | #define MAX_LOGF_DATASIZE (MAX_LOGF_ENTRY*MAX_LOGF_LINES) | 29 | #define MAX_LOGF_DATASIZE (MAX_LOGF_ENTRY*MAX_LOGF_LINES) |
@@ -30,11 +31,14 @@ | |||
30 | extern unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY]; | 31 | extern unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY]; |
31 | extern int logfindex; | 32 | extern int logfindex; |
32 | extern bool logfwrap; | 33 | extern bool logfwrap; |
34 | #endif /* __PCTOOL__ */ | ||
33 | 35 | ||
34 | void logf(const char *format, ...); | 36 | #define logf _logf |
35 | #else | 37 | void _logf(const char *format, ...); |
38 | |||
39 | #else /* !ROCKBOX_HAS_LOGF */ | ||
36 | /* built without logf() support enabled */ | 40 | /* built without logf() support enabled */ |
37 | #define logf(...) | 41 | #define logf(...) |
38 | #endif | 42 | #endif /* !ROCKBOX_HAS_LOGF */ |
39 | 43 | ||
40 | #endif /* LOGF_H */ | 44 | #endif /* LOGF_H */ |
diff --git a/firmware/id3.c b/firmware/id3.c index 470f4dc352..90b5b3bdee 100644 --- a/firmware/id3.c +++ b/firmware/id3.c | |||
@@ -457,9 +457,9 @@ static int unicode_munge(char* string, char* utf8buf, int *len) { | |||
457 | long tmp; | 457 | long tmp; |
458 | bool le = false; | 458 | bool le = false; |
459 | int i = 0; | 459 | int i = 0; |
460 | char *str = string; | 460 | unsigned char *str = (unsigned char *)string; |
461 | int templen = 0; | 461 | int templen = 0; |
462 | char* utf8 = utf8buf; | 462 | unsigned char* utf8 = (unsigned char *)utf8buf; |
463 | 463 | ||
464 | switch (str[0]) { | 464 | switch (str[0]) { |
465 | case 0x00: /* Type 0x00 is ordinary ISO 8859-1 */ | 465 | case 0x00: /* Type 0x00 is ordinary ISO 8859-1 */ |
@@ -467,7 +467,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) { | |||
467 | (*len)--; | 467 | (*len)--; |
468 | utf8 = iso_decode(str, utf8, -1, *len); | 468 | utf8 = iso_decode(str, utf8, -1, *len); |
469 | *utf8 = 0; | 469 | *utf8 = 0; |
470 | *len = utf8 - utf8buf; | 470 | *len = (unsigned long)utf8 - (unsigned long)utf8buf; |
471 | break; | 471 | break; |
472 | 472 | ||
473 | case 0x01: /* Unicode with or without BOM */ | 473 | case 0x01: /* Unicode with or without BOM */ |
@@ -524,7 +524,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) { | |||
524 | default: /* Plain old string */ | 524 | default: /* Plain old string */ |
525 | utf8 = iso_decode(str, utf8, -1, *len); | 525 | utf8 = iso_decode(str, utf8, -1, *len); |
526 | *utf8 = 0; | 526 | *utf8 = 0; |
527 | *len = utf8 - utf8buf; | 527 | *len = (unsigned long)utf8 - (unsigned long)utf8buf; |
528 | break; | 528 | break; |
529 | } | 529 | } |
530 | return 0; | 530 | return 0; |
@@ -571,7 +571,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
571 | case 1: | 571 | case 1: |
572 | case 2: | 572 | case 2: |
573 | /* convert string to utf8 */ | 573 | /* convert string to utf8 */ |
574 | utf8 = entry->id3v1buf[i]; | 574 | utf8 = (unsigned char *)entry->id3v1buf[i]; |
575 | utf8 = iso_decode(ptr, utf8, -1, 30); | 575 | utf8 = iso_decode(ptr, utf8, -1, 30); |
576 | /* make sure string is terminated */ | 576 | /* make sure string is terminated */ |
577 | *utf8 = 0; | 577 | *utf8 = 0; |
@@ -579,7 +579,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry) | |||
579 | 579 | ||
580 | case 3: | 580 | case 3: |
581 | ptr[4] = 0; | 581 | ptr[4] = 0; |
582 | entry->year = atoi(ptr); | 582 | entry->year = atoi((char *)ptr); |
583 | break; | 583 | break; |
584 | 584 | ||
585 | case 4: | 585 | case 4: |
diff --git a/firmware/include/dir.h b/firmware/include/dir.h index 948b30ffe2..c10640199f 100644 --- a/firmware/include/dir.h +++ b/firmware/include/dir.h | |||
@@ -20,7 +20,7 @@ | |||
20 | #define _DIR_H_ | 20 | #define _DIR_H_ |
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | #include <file.h> | 23 | #include "file.h" |
24 | 24 | ||
25 | #define ATTR_READ_ONLY 0x01 | 25 | #define ATTR_READ_ONLY 0x01 |
26 | #define ATTR_HIDDEN 0x02 | 26 | #define ATTR_HIDDEN 0x02 |
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h index f6bc153faf..9c3bc68ddc 100644 --- a/firmware/include/dircache.h +++ b/firmware/include/dircache.h | |||
@@ -67,7 +67,7 @@ struct dircache_entry { | |||
67 | long startcluster; | 67 | long startcluster; |
68 | unsigned short wrtdate; | 68 | unsigned short wrtdate; |
69 | unsigned short wrttime; | 69 | unsigned short wrttime; |
70 | unsigned char name_len; | 70 | unsigned long name_len; |
71 | char *d_name; | 71 | char *d_name; |
72 | }; | 72 | }; |
73 | 73 | ||
diff --git a/firmware/logf.c b/firmware/logf.c index fc57bd85bf..2056db5cc4 100644 --- a/firmware/logf.c +++ b/firmware/logf.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <string.h> | 27 | #include <string.h> |
28 | #include <stdio.h> | 28 | #include <stdio.h> |
29 | #include <stdarg.h> | 29 | #include <stdarg.h> |
30 | #include <sprintf.h> | ||
31 | #include "config.h" | 30 | #include "config.h" |
32 | #include "lcd-remote.h" | 31 | #include "lcd-remote.h" |
33 | #include "logf.h" | 32 | #include "logf.h" |
@@ -36,9 +35,11 @@ | |||
36 | /* Only provide all this if asked to */ | 35 | /* Only provide all this if asked to */ |
37 | #ifdef ROCKBOX_HAS_LOGF | 36 | #ifdef ROCKBOX_HAS_LOGF |
38 | 37 | ||
38 | #ifndef __PCTOOL__ | ||
39 | unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY]; | 39 | unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY]; |
40 | int logfindex; | 40 | int logfindex; |
41 | bool logfwrap; | 41 | bool logfwrap; |
42 | #endif | ||
42 | 43 | ||
43 | #ifdef HAVE_REMOTE_LCD | 44 | #ifdef HAVE_REMOTE_LCD |
44 | static void displayremote(void) | 45 | static void displayremote(void) |
@@ -77,7 +78,18 @@ static void displayremote(void) | |||
77 | #define displayremote() | 78 | #define displayremote() |
78 | #endif | 79 | #endif |
79 | 80 | ||
80 | void logf(const char *format, ...) | 81 | #ifdef __PCTOOL__ |
82 | void _logf(const char *format, ...) | ||
83 | { | ||
84 | char buf[1024]; | ||
85 | va_list ap; | ||
86 | va_start(ap, format); | ||
87 | |||
88 | vsnprintf(buf, sizeof buf, format, ap); | ||
89 | printf("DEBUG: %s\n", buf); | ||
90 | } | ||
91 | #else | ||
92 | void _logf(const char *format, ...) | ||
81 | { | 93 | { |
82 | int len; | 94 | int len; |
83 | unsigned char *ptr; | 95 | unsigned char *ptr; |
@@ -104,5 +116,6 @@ void logf(const char *format, ...) | |||
104 | 116 | ||
105 | displayremote(); | 117 | displayremote(); |
106 | } | 118 | } |
119 | #endif | ||
107 | 120 | ||
108 | #endif | 121 | #endif |
diff --git a/firmware/mp3data.c b/firmware/mp3data.c index 0710090b37..49b95f2d9e 100644 --- a/firmware/mp3data.c +++ b/firmware/mp3data.c | |||
@@ -242,6 +242,7 @@ unsigned long find_next_frame(int fd, long *offset, long max_offset, unsigned lo | |||
242 | return __find_next_frame(fd, offset, max_offset, last_header, fileread); | 242 | return __find_next_frame(fd, offset, max_offset, last_header, fileread); |
243 | } | 243 | } |
244 | 244 | ||
245 | #ifndef __PCTOOL__ | ||
245 | static int fnf_read_index; | 246 | static int fnf_read_index; |
246 | static int fnf_buf_len; | 247 | static int fnf_buf_len; |
247 | 248 | ||
@@ -335,6 +336,7 @@ unsigned long mem_find_next_frame(int startpos, long *offset, long max_offset, | |||
335 | 336 | ||
336 | return __find_next_frame(0, offset, max_offset, last_header, mem_getbyte); | 337 | return __find_next_frame(0, offset, max_offset, last_header, mem_getbyte); |
337 | } | 338 | } |
339 | #endif | ||
338 | 340 | ||
339 | int get_mp3file_info(int fd, struct mp3info *info) | 341 | int get_mp3file_info(int fd, struct mp3info *info) |
340 | { | 342 | { |
@@ -543,6 +545,7 @@ static void long2bytes(unsigned char *buf, long val) | |||
543 | buf[3] = val & 0xff; | 545 | buf[3] = val & 0xff; |
544 | } | 546 | } |
545 | 547 | ||
548 | #ifndef __PCTOOL__ | ||
546 | int count_mp3_frames(int fd, int startpos, int filesize, | 549 | int count_mp3_frames(int fd, int startpos, int filesize, |
547 | void (*progressfunc)(int)) | 550 | void (*progressfunc)(int)) |
548 | { | 551 | { |
@@ -762,3 +765,5 @@ int create_xing_header(int fd, long startpos, long filesize, | |||
762 | 765 | ||
763 | return info.frame_size; | 766 | return info.frame_size; |
764 | } | 767 | } |
768 | |||
769 | #endif | ||