1
0
Fork 0
forked from len0rd/rockbox

FS#9221 by Christopher Williams fixing a couple of bugs in keybox

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18138 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2008-07-27 20:36:45 +00:00
parent b2c4a9a0a9
commit 2d337dab7f
5 changed files with 53 additions and 44 deletions

View file

@ -33,14 +33,14 @@ pacbox
/* For all the color targets */ /* For all the color targets */
#if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \ #if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \
(LCD_DEPTH == 2) && !defined(ARCHOS_AV300) (LCD_DEPTH == 2) && !defined(ARCHOS_AV300)
doom //doom
#endif #endif
/* For all the swcodec targets */ /* For all the swcodec targets */
#if CONFIG_CODEC == SWCODEC #if CONFIG_CODEC == SWCODEC
midi midi
/* beatbox */ /* beatbox */
mpegplayer //mpegplayer
#endif #endif
#endif /* IRIVER_IFP7XX_SERIES */ #endif /* IRIVER_IFP7XX_SERIES */

View file

@ -26,7 +26,7 @@ PLUGIN_HEADER
#define BATTERY_LOG "/battery_bench.txt" #define BATTERY_LOG "/battery_bench.txt"
#define BUF_SIZE 16000 #define BUF_SIZE 16000
#define DISK_SPINDOWN_TIMEOUT 3600 #define DISK_SPINDOWN_TIMEOUT 1800
#define EV_EXIT 1337 #define EV_EXIT 1337

View file

@ -5,7 +5,7 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* $Id:$ * $Id$
* *
* Copyright (C) 2008 Nils Wallménius * Copyright (C) 2008 Nils Wallménius
* *
@ -111,13 +111,13 @@ MENUITEM_RETURNVALUE(context_add_entry, "Add entry", 0,
NULL, Icon_NOICON); NULL, Icon_NOICON);
MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1, MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1,
&context_item_cb, Icon_NOICON); &context_item_cb, Icon_NOICON);
MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 1, MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 2,
&context_item_cb, Icon_NOICON); &context_item_cb, Icon_NOICON);
MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 2, MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 3,
&context_item_cb, Icon_NOICON); &context_item_cb, Icon_NOICON);
MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 3, MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 4,
&context_item_cb, Icon_NOICON); &context_item_cb, Icon_NOICON);
MENUITEM_RETURNVALUE(context_debug, "debug", 4, MENUITEM_RETURNVALUE(context_debug, "debug", 5,
&context_item_cb, Icon_NOICON); &context_item_cb, Icon_NOICON);
MAKE_MENU(context_m, "Context menu", MAKE_MENU(context_m, "Context menu",
@ -144,9 +144,12 @@ static char * kb_list_cb(int selected_item, void *data,
struct pw_entry *entry = pw_list.first.next; struct pw_entry *entry = pw_list.first.next;
for (i = 0; i < selected_item; i++) for (i = 0; i < selected_item; i++)
{ {
if (entry->next) if (entry)
entry = entry->next; entry = entry->next;
} }
if (!entry)
return NULL;
rb->snprintf(buffer, buffer_len, "%s", entry->title); rb->snprintf(buffer, buffer_len, "%s", entry->title);
return buffer; return buffer;
@ -162,20 +165,19 @@ static void init_ll(void)
static void delete_entry(int selected_item) static void delete_entry(int selected_item)
{ {
int i; int i;
struct pw_entry *entry = pw_list.first.next; struct pw_entry *entry = &pw_list.first;
struct pw_entry *entry2; struct pw_entry *entry2;
/* find the entry before the one to delete */ /* find the entry before the one to delete */
for (i = 0; i < selected_item - 1; i++) for (i = 0; i < selected_item; i++)
{ {
if (entry->next) if (entry->next)
entry = entry->next; entry = entry->next;
} }
if (entry->next)
entry2 = entry->next; entry2 = entry->next;
else if (!entry2)
return; return;
if (entry2->next)
entry->next = entry2->next; entry->next = entry2->next;
entry2->used = false; entry2->used = false;
@ -201,10 +203,13 @@ static void add_entry(int selected_item)
} }
rb->splash(HZ, "Enter title"); rb->splash(HZ, "Enter title");
pw_list.entries[i].title[0] = '\0';
rb->kbd_input(pw_list.entries[i].title, FIELD_LEN); rb->kbd_input(pw_list.entries[i].title, FIELD_LEN);
rb->splash(HZ, "Enter name"); rb->splash(HZ, "Enter name");
pw_list.entries[i].name[0] = '\0';
rb->kbd_input(pw_list.entries[i].name, FIELD_LEN); rb->kbd_input(pw_list.entries[i].name, FIELD_LEN);
rb->splash(HZ, "Enter password"); rb->splash(HZ, "Enter password");
pw_list.entries[i].password[0] = '\0';
rb->kbd_input(pw_list.entries[i].password, FIELD_LEN); rb->kbd_input(pw_list.entries[i].password, FIELD_LEN);
for (j = 0; j < selected_item; j++) for (j = 0; j < selected_item; j++)
@ -392,7 +397,7 @@ static void encrypt_buffer(char *buf, size_t size, uint32_t *key)
static int parse_buffer(void) static int parse_buffer(void)
{ {
int i; int i;
intptr_t len; int len;
struct pw_entry *entry = pw_list.first.next; struct pw_entry *entry = pw_list.first.next;
char *start, *end; char *start, *end;
start = &buffer[HEADER_LEN]; start = &buffer[HEADER_LEN];
@ -411,36 +416,32 @@ static int parse_buffer(void)
for (i = 0; i < MAX_ENTRIES; i++) for (i = 0; i < MAX_ENTRIES; i++)
{ {
end = rb->strchr(start, '\0'); /* find eol */ end = rb->strchr(start, '\0'); /* find eol */
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; len = end - &buffer[HEADER_LEN];
if ((len > bytes_read + HEADER_LEN) if ((len > bytes_read + HEADER_LEN) || start == end)
|| (intptr_t)start == (intptr_t)end)
{ {
break; break;
} }
rb->strncpy(entry->title, start, rb->strncpy(entry->title, start, FIELD_LEN);
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
start = end + 1; start = end + 1;
end = rb->strchr(start, '\0'); /* find eol */ end = rb->strchr(start, '\0'); /* find eol */
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; len = end - &buffer[HEADER_LEN];
if (len > bytes_read + HEADER_LEN) if (len > bytes_read + HEADER_LEN)
{ {
break; break;
} }
rb->strncpy(entry->name, start, rb->strncpy(entry->name, start, FIELD_LEN);
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
start = end + 1; start = end + 1;
end = rb->strchr(start, '\0'); /* find eol */ end = rb->strchr(start, '\0'); /* find eol */
len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; len = end - &buffer[HEADER_LEN];
if (len > bytes_read + HEADER_LEN) if (len > bytes_read + HEADER_LEN)
{ {
break; break;
} }
rb->strncpy(entry->password, start, rb->strncpy(entry->password, start, FIELD_LEN);
MIN((intptr_t)end - (intptr_t)start, FIELD_LEN));
start = end + 1; start = end + 1;
entry->used = true; entry->used = true;
if (i + 1 < MAX_ENTRIES - 1) if (i + 1 < MAX_ENTRIES - 1)
@ -483,9 +484,10 @@ static void write_output(int fd)
if (entry->next) if (entry->next)
entry = entry->next; entry = entry->next;
} }
*p++ = '\0'; /* mark the end of the list */
/* round up to a number divisible by BLOCK_SIZE */ /* round up to a number divisible by BLOCK_SIZE */
size = (((intptr_t)p - (intptr_t)&buffer) / BLOCK_SIZE + 1) * BLOCK_SIZE; size = ((p - buffer + BLOCK_SIZE - 1) / BLOCK_SIZE) * BLOCK_SIZE;
salt = rb->rand(); salt = rb->rand();
make_key(); make_key();

View file

@ -162,10 +162,12 @@ struct GPatch * gusload(char * filename)
int file = rb->open(filename, O_RDONLY); int file = rb->open(filename, O_RDONLY);
DEBUGF("filename: %s\n", filename);
if(file == -1) if(file == -1)
{ {
char message[50]; char message[MAX_PATH];
rb->snprintf(message, 50, "Error opening %s", filename); rb->snprintf(message, MAX_PATH, "Error opening %s", filename);
rb->splash(HZ*2, message); rb->splash(HZ*2, message);
return NULL; return NULL;
} }
@ -197,12 +199,12 @@ struct GPatch * gusload(char * filename)
/* printf("\nFILE: %s", filename); */ /* printf("\nFILE: %s", filename); */
/* printf("\nlayerSamples=%d", gp->numWaves); */ /* printf("\nlayerSamples=%d", gp->numWaves); */
DEBUGF("hej\n");
int a=0; int a=0;
for(a=0; a<gp->numWaves; a++) for(a=0; a<gp->numWaves; a++)
gp->waveforms[a] = loadWaveform(file); gp->waveforms[a] = loadWaveform(file);
DEBUGF("hej2\n");
/* printf("\nPrecomputing note table"); */ /* printf("\nPrecomputing note table"); */
for(a=0; a<128; a++) for(a=0; a<128; a++)
@ -210,7 +212,7 @@ struct GPatch * gusload(char * filename)
gp->noteTable[a] = selectWaveform(gp, a); gp->noteTable[a] = selectWaveform(gp, a);
} }
rb->close(file); rb->close(file);
DEBUGF("hej3\n");
return gp; return gp;
} }

View file

@ -140,10 +140,11 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
return -1; return -1;
} }
char name[40]; char name[MAX_PATH];
char fn[40]; char fn[MAX_PATH];
/* Scan our config file and load the right patches as needed */ /* Scan our config file and load the right patches as needed */
char *p;
int c = 0; int c = 0;
name[0] = '\0'; name[0] = '\0';
printf("Loading instruments"); printf("Loading instruments");
@ -151,8 +152,12 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
{ {
while(readChar(file)!=' ' && !eof(file)); while(readChar(file)!=' ' && !eof(file));
readTextBlock(file, name); readTextBlock(file, name);
DEBUGF("name: %s\n", name);
rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); p = rb->strrchr(name, '.');
if (!p || rb->strncmp(p, ".pat", 4))
rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
else
rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s", name);
/* printf("\nLOADING: <%s> ", fn); */ /* printf("\nLOADING: <%s> ", fn); */
if(patchUsed[a]==1) if(patchUsed[a]==1)
@ -167,7 +172,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
c = readChar(file); c = readChar(file);
} }
rb->close(file); rb->close(file);
DEBUGF("drums!!\n");
file = rb->open(drumConfig, O_RDONLY); file = rb->open(drumConfig, O_RDONLY);
if(file < 0) if(file < 0)
{ {
@ -183,7 +188,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
{ {
readTextBlock(file, number); readTextBlock(file, number);
readTextBlock(file, name); readTextBlock(file, name);
rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
idx = rb->atoi(number); idx = rb->atoi(number);
if(idx == 0) if(idx == 0)