summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2008-07-27 20:36:45 +0000
committerNils Wallménius <nils@rockbox.org>2008-07-27 20:36:45 +0000
commit2d337dab7f6d32f8a0ddd035dd904b3f51909afb (patch)
tree333fa2ce3137b6967c3005cd745b326d2a071d7c
parentb2c4a9a0a95a62fa4ef9c5800f9e5ab014932a4d (diff)
downloadrockbox-2d337dab7f6d32f8a0ddd035dd904b3f51909afb.tar.gz
rockbox-2d337dab7f6d32f8a0ddd035dd904b3f51909afb.zip
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
-rw-r--r--apps/plugins/SUBDIRS4
-rw-r--r--apps/plugins/battery_bench.c2
-rw-r--r--apps/plugins/keybox.c62
-rw-r--r--apps/plugins/midi/guspat.c12
-rw-r--r--apps/plugins/midi/synth.c17
5 files changed, 53 insertions, 44 deletions
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index 94614e2f12..5ecb22e049 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -33,14 +33,14 @@ pacbox
33/* For all the color targets */ 33/* For all the color targets */
34#if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \ 34#if defined(HAVE_LCD_COLOR) || defined(MROBE_100) || \
35 (LCD_DEPTH == 2) && !defined(ARCHOS_AV300) 35 (LCD_DEPTH == 2) && !defined(ARCHOS_AV300)
36doom 36//doom
37#endif 37#endif
38 38
39/* For all the swcodec targets */ 39/* For all the swcodec targets */
40#if CONFIG_CODEC == SWCODEC 40#if CONFIG_CODEC == SWCODEC
41midi 41midi
42/* beatbox */ 42/* beatbox */
43mpegplayer 43//mpegplayer
44#endif 44#endif
45 45
46#endif /* IRIVER_IFP7XX_SERIES */ 46#endif /* IRIVER_IFP7XX_SERIES */
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 0cc028ebd0..116781e773 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -26,7 +26,7 @@ PLUGIN_HEADER
26 26
27#define BATTERY_LOG "/battery_bench.txt" 27#define BATTERY_LOG "/battery_bench.txt"
28#define BUF_SIZE 16000 28#define BUF_SIZE 16000
29#define DISK_SPINDOWN_TIMEOUT 3600 29#define DISK_SPINDOWN_TIMEOUT 1800
30 30
31#define EV_EXIT 1337 31#define EV_EXIT 1337
32 32
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c
index d3b03f28a7..389299d580 100644
--- a/apps/plugins/keybox.c
+++ b/apps/plugins/keybox.c
@@ -5,7 +5,7 @@
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id:$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2008 Nils Wallménius 10 * Copyright (C) 2008 Nils Wallménius
11 * 11 *
@@ -111,13 +111,13 @@ MENUITEM_RETURNVALUE(context_add_entry, "Add entry", 0,
111 NULL, Icon_NOICON); 111 NULL, Icon_NOICON);
112MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1, 112MENUITEM_RETURNVALUE(context_edit_title, "Edit title", 1,
113 &context_item_cb, Icon_NOICON); 113 &context_item_cb, Icon_NOICON);
114MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 1, 114MENUITEM_RETURNVALUE(context_edit_name, "Edit user name", 2,
115 &context_item_cb, Icon_NOICON); 115 &context_item_cb, Icon_NOICON);
116MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 2, 116MENUITEM_RETURNVALUE(context_edit_password, "Edit password", 3,
117 &context_item_cb, Icon_NOICON); 117 &context_item_cb, Icon_NOICON);
118MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 3, 118MENUITEM_RETURNVALUE(context_delete_entry, "Delete entry", 4,
119 &context_item_cb, Icon_NOICON); 119 &context_item_cb, Icon_NOICON);
120MENUITEM_RETURNVALUE(context_debug, "debug", 4, 120MENUITEM_RETURNVALUE(context_debug, "debug", 5,
121 &context_item_cb, Icon_NOICON); 121 &context_item_cb, Icon_NOICON);
122 122
123MAKE_MENU(context_m, "Context menu", 123MAKE_MENU(context_m, "Context menu",
@@ -144,9 +144,12 @@ static char * kb_list_cb(int selected_item, void *data,
144 struct pw_entry *entry = pw_list.first.next; 144 struct pw_entry *entry = pw_list.first.next;
145 for (i = 0; i < selected_item; i++) 145 for (i = 0; i < selected_item; i++)
146 { 146 {
147 if (entry->next) 147 if (entry)
148 entry = entry->next; 148 entry = entry->next;
149 } 149 }
150 if (!entry)
151 return NULL;
152
150 rb->snprintf(buffer, buffer_len, "%s", entry->title); 153 rb->snprintf(buffer, buffer_len, "%s", entry->title);
151 154
152 return buffer; 155 return buffer;
@@ -162,21 +165,20 @@ static void init_ll(void)
162static void delete_entry(int selected_item) 165static void delete_entry(int selected_item)
163{ 166{
164 int i; 167 int i;
165 struct pw_entry *entry = pw_list.first.next; 168 struct pw_entry *entry = &pw_list.first;
166 struct pw_entry *entry2; 169 struct pw_entry *entry2;
167 170
168 /* find the entry before the one to delete */ 171 /* find the entry before the one to delete */
169 for (i = 0; i < selected_item - 1; i++) 172 for (i = 0; i < selected_item; i++)
170 { 173 {
171 if (entry->next) 174 if (entry->next)
172 entry = entry->next; 175 entry = entry->next;
173 } 176 }
174 if (entry->next) 177 entry2 = entry->next;
175 entry2 = entry->next; 178 if (!entry2)
176 else
177 return; 179 return;
178 if (entry2->next) 180
179 entry->next = entry2->next; 181 entry->next = entry2->next;
180 182
181 entry2->used = false; 183 entry2->used = false;
182 entry2->name[0] = '\0'; 184 entry2->name[0] = '\0';
@@ -201,10 +203,13 @@ static void add_entry(int selected_item)
201 } 203 }
202 204
203 rb->splash(HZ, "Enter title"); 205 rb->splash(HZ, "Enter title");
206 pw_list.entries[i].title[0] = '\0';
204 rb->kbd_input(pw_list.entries[i].title, FIELD_LEN); 207 rb->kbd_input(pw_list.entries[i].title, FIELD_LEN);
205 rb->splash(HZ, "Enter name"); 208 rb->splash(HZ, "Enter name");
209 pw_list.entries[i].name[0] = '\0';
206 rb->kbd_input(pw_list.entries[i].name, FIELD_LEN); 210 rb->kbd_input(pw_list.entries[i].name, FIELD_LEN);
207 rb->splash(HZ, "Enter password"); 211 rb->splash(HZ, "Enter password");
212 pw_list.entries[i].password[0] = '\0';
208 rb->kbd_input(pw_list.entries[i].password, FIELD_LEN); 213 rb->kbd_input(pw_list.entries[i].password, FIELD_LEN);
209 214
210 for (j = 0; j < selected_item; j++) 215 for (j = 0; j < selected_item; j++)
@@ -392,7 +397,7 @@ static void encrypt_buffer(char *buf, size_t size, uint32_t *key)
392static int parse_buffer(void) 397static int parse_buffer(void)
393{ 398{
394 int i; 399 int i;
395 intptr_t len; 400 int len;
396 struct pw_entry *entry = pw_list.first.next; 401 struct pw_entry *entry = pw_list.first.next;
397 char *start, *end; 402 char *start, *end;
398 start = &buffer[HEADER_LEN]; 403 start = &buffer[HEADER_LEN];
@@ -408,40 +413,36 @@ static int parse_buffer(void)
408 return -1; 413 return -1;
409 } 414 }
410 415
411 for (i=0; i < MAX_ENTRIES; i++) 416 for (i = 0; i < MAX_ENTRIES; i++)
412 { 417 {
413 end = rb->strchr(start, '\0'); /* find eol */ 418 end = rb->strchr(start, '\0'); /* find eol */
414 len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; 419 len = end - &buffer[HEADER_LEN];
415 if ((len > bytes_read + HEADER_LEN) 420 if ((len > bytes_read + HEADER_LEN) || start == end)
416 || (intptr_t)start == (intptr_t)end)
417 { 421 {
418 break; 422 break;
419 } 423 }
420 424
421 rb->strncpy(entry->title, start, 425 rb->strncpy(entry->title, start, FIELD_LEN);
422 MIN((intptr_t)end - (intptr_t)start, FIELD_LEN)); 426 start = end + 1;
423 start = end +1;
424 427
425 end = rb->strchr(start, '\0'); /* find eol */ 428 end = rb->strchr(start, '\0'); /* find eol */
426 len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; 429 len = end - &buffer[HEADER_LEN];
427 if (len > bytes_read + HEADER_LEN) 430 if (len > bytes_read + HEADER_LEN)
428 { 431 {
429 break; 432 break;
430 } 433 }
431 434
432 rb->strncpy(entry->name, start, 435 rb->strncpy(entry->name, start, FIELD_LEN);
433 MIN((intptr_t)end - (intptr_t)start, FIELD_LEN)); 436 start = end + 1;
434 start = end +1;
435 437
436 end = rb->strchr(start, '\0'); /* find eol */ 438 end = rb->strchr(start, '\0'); /* find eol */
437 len = (intptr_t)end - (intptr_t)&buffer[HEADER_LEN]; 439 len = end - &buffer[HEADER_LEN];
438 if (len > bytes_read + HEADER_LEN) 440 if (len > bytes_read + HEADER_LEN)
439 { 441 {
440 break; 442 break;
441 } 443 }
442 rb->strncpy(entry->password, start, 444 rb->strncpy(entry->password, start, FIELD_LEN);
443 MIN((intptr_t)end - (intptr_t)start, FIELD_LEN)); 445 start = end + 1;
444 start = end +1;
445 entry->used = true; 446 entry->used = true;
446 if (i + 1 < MAX_ENTRIES - 1) 447 if (i + 1 < MAX_ENTRIES - 1)
447 { 448 {
@@ -483,9 +484,10 @@ static void write_output(int fd)
483 if (entry->next) 484 if (entry->next)
484 entry = entry->next; 485 entry = entry->next;
485 } 486 }
487 *p++ = '\0'; /* mark the end of the list */
486 488
487 /* round up to a number divisible by BLOCK_SIZE */ 489 /* round up to a number divisible by BLOCK_SIZE */
488 size = (((intptr_t)p - (intptr_t)&buffer) / BLOCK_SIZE + 1) * BLOCK_SIZE; 490 size = ((p - buffer + BLOCK_SIZE - 1) / BLOCK_SIZE) * BLOCK_SIZE;
489 491
490 salt = rb->rand(); 492 salt = rb->rand();
491 make_key(); 493 make_key();
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c
index 419cfa3ad0..1b310d2de8 100644
--- a/apps/plugins/midi/guspat.c
+++ b/apps/plugins/midi/guspat.c
@@ -162,10 +162,12 @@ struct GPatch * gusload(char * filename)
162 162
163 int file = rb->open(filename, O_RDONLY); 163 int file = rb->open(filename, O_RDONLY);
164 164
165 DEBUGF("filename: %s\n", filename);
166
165 if(file == -1) 167 if(file == -1)
166 { 168 {
167 char message[50]; 169 char message[MAX_PATH];
168 rb->snprintf(message, 50, "Error opening %s", filename); 170 rb->snprintf(message, MAX_PATH, "Error opening %s", filename);
169 rb->splash(HZ*2, message); 171 rb->splash(HZ*2, message);
170 return NULL; 172 return NULL;
171 } 173 }
@@ -197,12 +199,12 @@ struct GPatch * gusload(char * filename)
197 199
198/* printf("\nFILE: %s", filename); */ 200/* printf("\nFILE: %s", filename); */
199/* printf("\nlayerSamples=%d", gp->numWaves); */ 201/* printf("\nlayerSamples=%d", gp->numWaves); */
200 202DEBUGF("hej\n");
201 int a=0; 203 int a=0;
202 for(a=0; a<gp->numWaves; a++) 204 for(a=0; a<gp->numWaves; a++)
203 gp->waveforms[a] = loadWaveform(file); 205 gp->waveforms[a] = loadWaveform(file);
204 206
205 207DEBUGF("hej2\n");
206/* printf("\nPrecomputing note table"); */ 208/* printf("\nPrecomputing note table"); */
207 209
208 for(a=0; a<128; a++) 210 for(a=0; a<128; a++)
@@ -210,7 +212,7 @@ struct GPatch * gusload(char * filename)
210 gp->noteTable[a] = selectWaveform(gp, a); 212 gp->noteTable[a] = selectWaveform(gp, a);
211 } 213 }
212 rb->close(file); 214 rb->close(file);
213 215DEBUGF("hej3\n");
214 return gp; 216 return gp;
215} 217}
216 218
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c
index 0819722030..09ea1c68c2 100644
--- a/apps/plugins/midi/synth.c
+++ b/apps/plugins/midi/synth.c
@@ -140,10 +140,11 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
140 return -1; 140 return -1;
141 } 141 }
142 142
143 char name[40]; 143 char name[MAX_PATH];
144 char fn[40]; 144 char fn[MAX_PATH];
145 145
146 /* Scan our config file and load the right patches as needed */ 146 /* Scan our config file and load the right patches as needed */
147 char *p;
147 int c = 0; 148 int c = 0;
148 name[0] = '\0'; 149 name[0] = '\0';
149 printf("Loading instruments"); 150 printf("Loading instruments");
@@ -151,8 +152,12 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
151 { 152 {
152 while(readChar(file)!=' ' && !eof(file)); 153 while(readChar(file)!=' ' && !eof(file));
153 readTextBlock(file, name); 154 readTextBlock(file, name);
154 155 DEBUGF("name: %s\n", name);
155 rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); 156 p = rb->strrchr(name, '.');
157 if (!p || rb->strncmp(p, ".pat", 4))
158 rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
159 else
160 rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s", name);
156/* printf("\nLOADING: <%s> ", fn); */ 161/* printf("\nLOADING: <%s> ", fn); */
157 162
158 if(patchUsed[a]==1) 163 if(patchUsed[a]==1)
@@ -167,7 +172,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
167 c = readChar(file); 172 c = readChar(file);
168 } 173 }
169 rb->close(file); 174 rb->close(file);
170 175DEBUGF("drums!!\n");
171 file = rb->open(drumConfig, O_RDONLY); 176 file = rb->open(drumConfig, O_RDONLY);
172 if(file < 0) 177 if(file < 0)
173 { 178 {
@@ -183,7 +188,7 @@ int initSynth(struct MIDIfile * mf, char * filename, char * drumConfig)
183 { 188 {
184 readTextBlock(file, number); 189 readTextBlock(file, number);
185 readTextBlock(file, name); 190 readTextBlock(file, name);
186 rb->snprintf(fn, 40, ROCKBOX_DIR "/patchset/%s.pat", name); 191 rb->snprintf(fn, MAX_PATH, ROCKBOX_DIR "/patchset/%s.pat", name);
187 192
188 idx = rb->atoi(number); 193 idx = rb->atoi(number);
189 if(idx == 0) 194 if(idx == 0)