summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-11-10 08:03:33 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-11-10 08:03:33 +0000
commit0dd7ea2d712944b21ede9f57bebd1009b03932e6 (patch)
treedc6065067aa862cc6a71c206b67554270fe507bd /firmware
parentae221f140231cb2fd4833443d7810dfce03c606a (diff)
downloadrockbox-0dd7ea2d712944b21ede9f57bebd1009b03932e6.tar.gz
rockbox-0dd7ea2d712944b21ede9f57bebd1009b03932e6.tar.bz2
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.c23
-rw-r--r--firmware/export/config.h2
-rw-r--r--firmware/export/debug.h2
-rw-r--r--firmware/export/logf.h10
-rw-r--r--firmware/id3.c12
-rw-r--r--firmware/include/dir.h2
-rw-r--r--firmware/include/dircache.h2
-rw-r--r--firmware/logf.c17
-rw-r--r--firmware/mp3data.c5
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;
static unsigned long entry_count = 0;
static unsigned long reserve_used = 0;
static unsigned int cache_build_ticks = 0;
-static char dircache_cur_path[MAX_PATH];
+static char dircache_cur_path[MAX_PATH*2];
static struct event_queue dircache_queue;
static long dircache_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
@@ -178,7 +178,7 @@ static int dircache_scan(struct travel_data *td)
}
td->ce->attribute = td->entry->attribute;
- td->ce->name_len = MIN(254, strlen(td->entry->d_name)) + 1;
+ td->ce->name_len = strlen(td->entry->d_name);
td->ce->d_name = ((char *)dircache_root+dircache_size);
td->ce->size = td->entry->size;
td->ce->wrtdate = td->entry->wrtdate;
@@ -192,7 +192,7 @@ static int dircache_scan(struct travel_data *td)
}
td->ce->attribute = td->entry.attr;
- td->ce->name_len = MIN(254, strlen(td->entry.name)) + 1;
+ td->ce->name_len = strlen(td->entry.name) + 1;
td->ce->d_name = ((char *)dircache_root+dircache_size);
td->ce->startcluster = td->entry.firstcluster;
td->ce->size = td->entry.filesize;
@@ -215,9 +215,11 @@ static int dircache_scan(struct travel_data *td)
return -2;
td->pathpos = strlen(dircache_cur_path);
- strncpy(&dircache_cur_path[td->pathpos], "/", MAX_PATH - td->pathpos - 1);
+ strncpy(&dircache_cur_path[td->pathpos], "/",
+ sizeof(dircache_cur_path) - td->pathpos - 1);
#ifdef SIMULATOR
- strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, MAX_PATH - td->pathpos - 2);
+ strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name,
+ sizeof(dircache_cur_path) - td->pathpos - 2);
td->newdir = opendir(dircache_cur_path);
if (td->newdir == NULL)
@@ -226,7 +228,8 @@ static int dircache_scan(struct travel_data *td)
return -3;
}
#else
- strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name, MAX_PATH - td->pathpos - 2);
+ strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name,
+ sizeof(dircache_cur_path) - td->pathpos - 2);
td->newdir = *td->dir;
if (fat_opendir(IF_MV2(volume,) &td->newdir,
@@ -360,7 +363,7 @@ static struct dircache_entry* dircache_get_entry(const char *path,
bool get_before, bool only_directories)
{
struct dircache_entry *cache_entry, *before;
- char namecopy[MAX_PATH];
+ char namecopy[MAX_PATH*2];
char* part;
char* end;
@@ -543,7 +546,7 @@ static int dircache_do_rebuild(void)
pdir = &dir;
#endif
- memset(dircache_cur_path, 0, MAX_PATH);
+ memset(dircache_cur_path, 0, sizeof(dircache_cur_path));
dircache_size = sizeof(struct dircache_entry);
cpu_boost_id(true, CPUBOOSTID_DIRCACHE);
@@ -837,7 +840,7 @@ static int block_until_ready(void)
static struct dircache_entry* dircache_new_entry(const char *path, int attribute)
{
struct dircache_entry *entry;
- char basedir[MAX_PATH];
+ char basedir[MAX_PATH*2];
char *new;
long last_cache_size = dircache_size;
@@ -1005,7 +1008,7 @@ void dircache_rename(const char *oldpath, const char *newpath)
{ /* Test ok. */
struct dircache_entry *entry, *newentry;
struct dircache_entry oldentry;
- char absolute_path[MAX_PATH];
+ char absolute_path[MAX_PATH*2];
char *p;
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 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
+#ifndef __PCTOOL__
#include "autoconf.h"
+#endif
/* symbolic names for multiple choice configurations: */
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, ...);
#ifdef __GNUC__
/* */
-#if defined(SIMULATOR)
+#if defined(SIMULATOR) && !defined(__PCTOOL__)
#define DEBUGF debugf
#define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
#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 @@
#ifdef ROCKBOX_HAS_LOGF
+#ifndef __PCTOOL__
#define MAX_LOGF_LINES 1000
#define MAX_LOGF_ENTRY 30
#define MAX_LOGF_DATASIZE (MAX_LOGF_ENTRY*MAX_LOGF_LINES)
@@ -30,11 +31,14 @@
extern unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY];
extern int logfindex;
extern bool logfwrap;
+#endif /* __PCTOOL__ */
-void logf(const char *format, ...);
-#else
+#define logf _logf
+void _logf(const char *format, ...);
+
+#else /* !ROCKBOX_HAS_LOGF */
/* built without logf() support enabled */
#define logf(...)
-#endif
+#endif /* !ROCKBOX_HAS_LOGF */
#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) {
long tmp;
bool le = false;
int i = 0;
- char *str = string;
+ unsigned char *str = (unsigned char *)string;
int templen = 0;
- char* utf8 = utf8buf;
+ unsigned char* utf8 = (unsigned char *)utf8buf;
switch (str[0]) {
case 0x00: /* Type 0x00 is ordinary ISO 8859-1 */
@@ -467,7 +467,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
(*len)--;
utf8 = iso_decode(str, utf8, -1, *len);
*utf8 = 0;
- *len = utf8 - utf8buf;
+ *len = (unsigned long)utf8 - (unsigned long)utf8buf;
break;
case 0x01: /* Unicode with or without BOM */
@@ -524,7 +524,7 @@ static int unicode_munge(char* string, char* utf8buf, int *len) {
default: /* Plain old string */
utf8 = iso_decode(str, utf8, -1, *len);
*utf8 = 0;
- *len = utf8 - utf8buf;
+ *len = (unsigned long)utf8 - (unsigned long)utf8buf;
break;
}
return 0;
@@ -571,7 +571,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
case 1:
case 2:
/* convert string to utf8 */
- utf8 = entry->id3v1buf[i];
+ utf8 = (unsigned char *)entry->id3v1buf[i];
utf8 = iso_decode(ptr, utf8, -1, 30);
/* make sure string is terminated */
*utf8 = 0;
@@ -579,7 +579,7 @@ static bool setid3v1title(int fd, struct mp3entry *entry)
case 3:
ptr[4] = 0;
- entry->year = atoi(ptr);
+ entry->year = atoi((char *)ptr);
break;
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 @@
#define _DIR_H_
#include <stdbool.h>
-#include <file.h>
+#include "file.h"
#define ATTR_READ_ONLY 0x01
#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 {
long startcluster;
unsigned short wrtdate;
unsigned short wrttime;
- unsigned char name_len;
+ unsigned long name_len;
char *d_name;
};
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 @@
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
-#include <sprintf.h>
#include "config.h"
#include "lcd-remote.h"
#include "logf.h"
@@ -36,9 +35,11 @@
/* Only provide all this if asked to */
#ifdef ROCKBOX_HAS_LOGF
+#ifndef __PCTOOL__
unsigned char logfbuffer[MAX_LOGF_LINES][MAX_LOGF_ENTRY];
int logfindex;
bool logfwrap;
+#endif
#ifdef HAVE_REMOTE_LCD
static void displayremote(void)
@@ -77,7 +78,18 @@ static void displayremote(void)
#define displayremote()
#endif
-void logf(const char *format, ...)
+#ifdef __PCTOOL__
+void _logf(const char *format, ...)
+{
+ char buf[1024];
+ va_list ap;
+ va_start(ap, format);
+
+ vsnprintf(buf, sizeof buf, format, ap);
+ printf("DEBUG: %s\n", buf);
+}
+#else
+void _logf(const char *format, ...)
{
int len;
unsigned char *ptr;
@@ -104,5 +116,6 @@ void logf(const char *format, ...)
displayremote();
}
+#endif
#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
return __find_next_frame(fd, offset, max_offset, last_header, fileread);
}
+#ifndef __PCTOOL__
static int fnf_read_index;
static int fnf_buf_len;
@@ -335,6 +336,7 @@ unsigned long mem_find_next_frame(int startpos, long *offset, long max_offset,
return __find_next_frame(0, offset, max_offset, last_header, mem_getbyte);
}
+#endif
int get_mp3file_info(int fd, struct mp3info *info)
{
@@ -543,6 +545,7 @@ static void long2bytes(unsigned char *buf, long val)
buf[3] = val & 0xff;
}
+#ifndef __PCTOOL__
int count_mp3_frames(int fd, int startpos, int filesize,
void (*progressfunc)(int))
{
@@ -762,3 +765,5 @@ int create_xing_header(int fd, long startpos, long filesize,
return info.frame_size;
}
+
+#endif