summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeruaki Kawashima <teru@rockbox.org>2009-12-18 14:17:28 +0000
committerTeruaki Kawashima <teru@rockbox.org>2009-12-18 14:17:28 +0000
commitdc010201a5020b8b468a1a24a8fafb45a8986530 (patch)
treed07b364d2ee16ed4d0c4c9ad9818096c7e57f536
parent3e2aba0c3eded353ba119e5df23968d70b1263c5 (diff)
downloadrockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.tar.gz
rockbox-dc010201a5020b8b468a1a24a8fafb45a8986530.zip
make sure plugin reset backlight setting before exit. do code polish.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24076 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/misc.c70
-rw-r--r--apps/plugins/SOURCES2
-rw-r--r--apps/plugins/blackjack.c2
-rw-r--r--apps/plugins/mosaique.c12
-rw-r--r--apps/plugins/robotfindskitten.c2
-rw-r--r--apps/plugins/rocklife.c23
-rw-r--r--apps/plugins/starfield.c5
-rw-r--r--apps/plugins/text_editor.c4
-rw-r--r--apps/plugins/viewer.c24
9 files changed, 73 insertions, 71 deletions
diff --git a/apps/misc.c b/apps/misc.c
index 939de440b6..8f6da8b5e5 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -124,7 +124,7 @@ char *output_dyn_value(char *buf, int buf_size, int value,
124 snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100); 124 snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100);
125 else 125 else
126 snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10); 126 snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10);
127 127
128 if (buf) 128 if (buf)
129 { 129 {
130 if (strlen(tbuf)) 130 if (strlen(tbuf))
@@ -168,7 +168,7 @@ int read_line(int fd, char* buffer, int buffer_size)
168{ 168{
169 int count = 0; 169 int count = 0;
170 int num_read = 0; 170 int num_read = 0;
171 171
172 errno = 0; 172 errno = 0;
173 173
174 while (count < buffer_size) 174 while (count < buffer_size)
@@ -177,9 +177,9 @@ int read_line(int fd, char* buffer, int buffer_size)
177 177
178 if (1 != read(fd, &c, 1)) 178 if (1 != read(fd, &c, 1))
179 break; 179 break;
180 180
181 num_read++; 181 num_read++;
182 182
183 if ( c == '\n' ) 183 if ( c == '\n' )
184 break; 184 break;
185 185
@@ -201,15 +201,15 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters,
201 char *p, *next; 201 char *p, *next;
202 int rc, pos = 0; 202 int rc, pos = 0;
203 int count = 0; 203 int count = 0;
204 204
205 while ( 1 ) 205 while ( 1 )
206 { 206 {
207 next = NULL; 207 next = NULL;
208 208
209 rc = read(fd, &buf[pos], buf_size - pos - 1); 209 rc = read(fd, &buf[pos], buf_size - pos - 1);
210 if (rc >= 0) 210 if (rc >= 0)
211 buf[pos+rc] = '\0'; 211 buf[pos+rc] = '\0';
212 212
213 if ( (p = strchr(buf, '\r')) != NULL) 213 if ( (p = strchr(buf, '\r')) != NULL)
214 { 214 {
215 *p = '\0'; 215 *p = '\0';
@@ -217,17 +217,17 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters,
217 } 217 }
218 else 218 else
219 p = buf; 219 p = buf;
220 220
221 if ( (p = strchr(p, '\n')) != NULL) 221 if ( (p = strchr(p, '\n')) != NULL)
222 { 222 {
223 *p = '\0'; 223 *p = '\0';
224 next = ++p; 224 next = ++p;
225 } 225 }
226 226
227 rc = callback(count, buf, parameters); 227 rc = callback(count, buf, parameters);
228 if (rc < 0) 228 if (rc < 0)
229 return rc; 229 return rc;
230 230
231 count++; 231 count++;
232 if (next) 232 if (next)
233 { 233 {
@@ -237,7 +237,7 @@ int fast_readline(int fd, char *buf, int buf_size, void *parameters,
237 else 237 else
238 break ; 238 break ;
239 } 239 }
240 240
241 return 0; 241 return 0;
242} 242}
243 243
@@ -338,7 +338,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
338 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY), 338 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY),
339 str(LANG_SHUTTINGDOWN)); 339 str(LANG_SHUTTINGDOWN));
340 } 340 }
341 341
342 if (global_settings.fade_on_stop 342 if (global_settings.fade_on_stop
343 && (audio_stat & AUDIO_STATUS_PLAY)) 343 && (audio_stat & AUDIO_STATUS_PLAY))
344 { 344 {
@@ -371,7 +371,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
371#endif 371#endif
372 372
373#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC 373#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
374 audio_close_recording(); 374 audio_close_recording();
375#endif 375#endif
376 376
377 if(global_settings.talk_menu) 377 if(global_settings.talk_menu)
@@ -461,11 +461,11 @@ static bool waiting_to_resume_play = false;
461static long play_resume_tick; 461static long play_resume_tick;
462 462
463static void car_adapter_mode_processing(bool inserted) 463static void car_adapter_mode_processing(bool inserted)
464{ 464{
465 if (global_settings.car_adapter_mode) 465 if (global_settings.car_adapter_mode)
466 { 466 {
467 if(inserted) 467 if(inserted)
468 { 468 {
469 /* 469 /*
470 * Just got plugged in, delay & resume if we were playing 470 * Just got plugged in, delay & resume if we were playing
471 */ 471 */
@@ -598,7 +598,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
598 case SYS_CHARGER_CONNECTED: 598 case SYS_CHARGER_CONNECTED:
599 car_adapter_mode_processing(true); 599 car_adapter_mode_processing(true);
600 return SYS_CHARGER_CONNECTED; 600 return SYS_CHARGER_CONNECTED;
601 601
602 case SYS_CHARGER_DISCONNECTED: 602 case SYS_CHARGER_DISCONNECTED:
603 car_adapter_mode_processing(false); 603 car_adapter_mode_processing(false);
604 return SYS_CHARGER_DISCONNECTED; 604 return SYS_CHARGER_DISCONNECTED;
@@ -634,12 +634,12 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
634 return SYS_PHONE_UNPLUGGED; 634 return SYS_PHONE_UNPLUGGED;
635#endif 635#endif
636#ifdef IPOD_ACCESSORY_PROTOCOL 636#ifdef IPOD_ACCESSORY_PROTOCOL
637 case SYS_IAP_PERIODIC: 637 case SYS_IAP_PERIODIC:
638 iap_periodic(); 638 iap_periodic();
639 return SYS_IAP_PERIODIC; 639 return SYS_IAP_PERIODIC;
640 case SYS_IAP_HANDLEPKT: 640 case SYS_IAP_HANDLEPKT:
641 iap_handlepkt(); 641 iap_handlepkt();
642 return SYS_IAP_HANDLEPKT; 642 return SYS_IAP_HANDLEPKT;
643#endif 643#endif
644 } 644 }
645 return 0; 645 return 0;
@@ -772,7 +772,7 @@ char* strrsplt(char* str, int c)
772 { 772 {
773 s = str; 773 s = str;
774 } 774 }
775 775
776 return s; 776 return s;
777} 777}
778 778
@@ -857,14 +857,14 @@ void format_time(char* buf, int buf_size, long t)
857{ 857{
858 if ( t < 3600000 ) 858 if ( t < 3600000 )
859 { 859 {
860 snprintf(buf, buf_size, "%d:%02d", 860 snprintf(buf, buf_size, "%d:%02d",
861 (int) (t / 60000), (int) (t % 60000 / 1000)); 861 (int) (t / 60000), (int) (t % 60000 / 1000));
862 } 862 }
863 else 863 else
864 { 864 {
865 snprintf(buf, buf_size, "%d:%02d:%02d", 865 snprintf(buf, buf_size, "%d:%02d:%02d",
866 (int) (t / 3600000), (int) (t % 3600000 / 60000), 866 (int) (t / 3600000), (int) (t % 3600000 / 60000),
867 (int) (t % 60000 / 1000)); 867 (int) (t % 60000 / 1000));
868 } 868 }
869} 869}
870 870
@@ -895,7 +895,7 @@ int open_utf8(const char* pathname, int flags)
895 read(fd, bom, BOM_SIZE); 895 read(fd, bom, BOM_SIZE);
896 /* check for BOM */ 896 /* check for BOM */
897 if(memcmp(bom, BOM, BOM_SIZE)) 897 if(memcmp(bom, BOM, BOM_SIZE))
898 lseek(fd, 0, SEEK_SET); 898 lseek(fd, 0, SEEK_SET);
899 } 899 }
900 return fd; 900 return fd;
901} 901}
@@ -908,8 +908,8 @@ int open_utf8(const char* pathname, int flags)
908 908
909static int hex2dec(int c) 909static int hex2dec(int c)
910{ 910{
911 return (((c) >= '0' && ((c) <= '9')) ? (c) - '0' : 911 return (((c) >= '0' && ((c) <= '9')) ? (c) - '0' :
912 (toupper(c)) - 'A' + 10); 912 (toupper(c)) - 'A' + 10);
913} 913}
914 914
915int hex_to_rgb(const char* hex, int* color) 915int hex_to_rgb(const char* hex, int* color)
@@ -986,7 +986,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
986 986
987 *s = p; 987 *s = p;
988 while (*p && *p != sep) 988 while (*p && *p != sep)
989 p++; 989 p++;
990 set = (s[0][0]!='-') && (s[0][1]!=sep) ; 990 set = (s[0][0]!='-') && (s[0][1]!=sep) ;
991 break; 991 break;
992 992
@@ -1007,9 +1007,9 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
1007 } 1007 }
1008 else 1008 else
1009 { 1009 {
1010 *d = *p++ - '0'; 1010 *d = *p++ - '0';
1011 while (isdigit(*p)) 1011 while (isdigit(*p))
1012 *d = (*d * 10) + (*p++ - '0'); 1012 *d = (*d * 10) + (*p++ - '0');
1013 set = true; 1013 set = true;
1014 if (is_negative) 1014 if (is_negative)
1015 *d *= -1; 1015 *d *= -1;
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES
index 76a0b575b7..a3ce60fbf8 100644
--- a/apps/plugins/SOURCES
+++ b/apps/plugins/SOURCES
@@ -64,7 +64,7 @@ rockblox1d.c
64brickmania.c 64brickmania.c
65calendar.c 65calendar.c
66maze.c 66maze.c
67mazezam.c 67mazezam.c
68text_editor.c 68text_editor.c
69wavview.c 69wavview.c
70robotfindskitten.c 70robotfindskitten.c
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index 3854799fc3..315f21f27b 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -136,7 +136,7 @@ enum {
136#define BJACK_LEFT BUTTON_LEFT 136#define BJACK_LEFT BUTTON_LEFT
137 137
138#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD 138#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
139#define BJACK_SELECT_NAME "PLAY" 139#define BJACK_SELECT_NAME "SELECT"
140#define BJACK_STAY_NAME "REC" 140#define BJACK_STAY_NAME "REC"
141#define BJACK_RESUME_NAME "DOWN" 141#define BJACK_RESUME_NAME "DOWN"
142#define BJACK_QUIT_NAME "POWER" 142#define BJACK_QUIT_NAME "POWER"
diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c
index 51005fdabd..0f3e9ffc08 100644
--- a/apps/plugins/mosaique.c
+++ b/apps/plugins/mosaique.c
@@ -208,20 +208,20 @@ enum plugin_status plugin_start(const void* parameter)
208 x = 2*GFX_WIDTH-x; 208 x = 2*GFX_WIDTH-x;
209 sx=-sx; 209 sx=-sx;
210 } 210 }
211 211
212 if (x<0) 212 if (x<0)
213 { 213 {
214 x = -x; 214 x = -x;
215 sx = -sx; 215 sx = -sx;
216 } 216 }
217 217
218 y+=sy; 218 y+=sy;
219 if (y>GFX_HEIGHT) 219 if (y>GFX_HEIGHT)
220 { 220 {
221 y = 2*GFX_HEIGHT-y; 221 y = 2*GFX_HEIGHT-y;
222 sy=-sy; 222 sy=-sy;
223 } 223 }
224 224
225 if (y<0) 225 if (y<0)
226 { 226 {
227 y = -y; 227 y = -y;
@@ -235,7 +235,7 @@ enum plugin_status plugin_start(const void* parameter)
235 MYLCD(update)(); 235 MYLCD(update)();
236 236
237 rb->sleep(HZ/timer); 237 rb->sleep(HZ/timer);
238 238
239 button = rb->button_get(false); 239 button = rb->button_get(false);
240 switch (button) 240 switch (button)
241 { 241 {
@@ -254,7 +254,7 @@ enum plugin_status plugin_start(const void* parameter)
254 if (timer>20) 254 if (timer>20)
255 timer=5; 255 timer=5;
256 break; 256 break;
257 257
258 case MOSAIQUE_RESTART: 258 case MOSAIQUE_RESTART:
259 259
260 sx = rb->rand() % (GFX_HEIGHT/2) + 1; 260 sx = rb->rand() % (GFX_HEIGHT/2) + 1;
@@ -278,5 +278,3 @@ enum plugin_status plugin_start(const void* parameter)
278 } 278 }
279 } 279 }
280} 280}
281
282
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c
index a2bff3bfbe..5cd0e465f8 100644
--- a/apps/plugins/robotfindskitten.c
+++ b/apps/plugins/robotfindskitten.c
@@ -676,7 +676,7 @@ static void play_game()
676{ 676{
677 int old_x = robot.x; 677 int old_x = robot.x;
678 int old_y = robot.y; 678 int old_y = robot.y;
679 int input = 0; /* Not sure what a reasonable initial value is */ 679 int input = BUTTON_NONE;
680#ifdef __PLUGINLIB_ACTIONS_H__ 680#ifdef __PLUGINLIB_ACTIONS_H__
681 const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions}; 681 const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions};
682#endif 682#endif
diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c
index 5258121ea3..35c848de1d 100644
--- a/apps/plugins/rocklife.c
+++ b/apps/plugins/rocklife.c
@@ -131,7 +131,7 @@ static bool load_cellfile(const char *file, char *pgrid){
131 fd = rb->open(file, O_RDONLY); 131 fd = rb->open(file, O_RDONLY);
132 if (fd<0) 132 if (fd<0)
133 return false; 133 return false;
134 134
135 init_grid(pgrid); 135 init_grid(pgrid);
136 136
137 char c; 137 char c;
@@ -143,7 +143,7 @@ static bool load_cellfile(const char *file, char *pgrid){
143 ymid = (GRID_H>>1) - 2; 143 ymid = (GRID_H>>1) - 2;
144 comment = false; 144 comment = false;
145 145
146 while (true) { 146 while (true) {
147 nc = rb->read(fd, &c, 1); 147 nc = rb->read(fd, &c, 1);
148 if (nc <= 0) 148 if (nc <= 0)
149 break; 149 break;
@@ -343,7 +343,7 @@ static inline bool check_cell(unsigned char *n)
343 343
344 /* now we build the number of non-zero neighbours :-P */ 344 /* now we build the number of non-zero neighbours :-P */
345 alive_cells = 8 - empty_cells; 345 alive_cells = 8 - empty_cells;
346 346
347 if (n[4]) { 347 if (n[4]) {
348 /* If the cell is alive, it stays alive iff it has 2 or 3 alive neighbours */ 348 /* If the cell is alive, it stays alive iff it has 2 or 3 alive neighbours */
349 result = (alive_cells==2 || alive_cells==3); 349 result = (alive_cells==2 || alive_cells==3);
@@ -468,6 +468,7 @@ enum plugin_status plugin_start(const void* parameter)
468 int button = 0; 468 int button = 0;
469 int quit = 0; 469 int quit = 0;
470 int stop = 0; 470 int stop = 0;
471 int usb = 0;
471 int pattern = 0; 472 int pattern = 0;
472 char *pgrid; 473 char *pgrid;
473 char *pnext_grid; 474 char *pnext_grid;
@@ -488,8 +489,7 @@ enum plugin_status plugin_start(const void* parameter)
488 pgrid = (char *)grid_a; 489 pgrid = (char *)grid_a;
489 pnext_grid = (char *)grid_b; 490 pnext_grid = (char *)grid_b;
490 491
491 init_grid(pgrid); 492 init_grid(pgrid);
492
493 493
494 if( parameter == NULL ) 494 if( parameter == NULL )
495 { 495 {
@@ -544,6 +544,11 @@ enum plugin_status plugin_start(const void* parameter)
544 stop = 1; 544 stop = 1;
545 break; 545 break;
546 default: 546 default:
547 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
548 stop = 1;
549 quit = 1;
550 usb = 1;
551 }
547 break; 552 break;
548 } 553 }
549 rb->yield(); 554 rb->yield();
@@ -562,12 +567,12 @@ enum plugin_status plugin_start(const void* parameter)
562 break; 567 break;
563 case ROCKLIFE_QUIT: 568 case ROCKLIFE_QUIT:
564 /* quit plugin */ 569 /* quit plugin */
565 quit=true; 570 quit = 1;
566 return PLUGIN_OK;
567 break; 571 break;
568 default: 572 default:
569 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { 573 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
570 return PLUGIN_USB_CONNECTED; 574 quit = 1;
575 usb = 1;
571 } 576 }
572 break; 577 break;
573 } 578 }
@@ -575,5 +580,5 @@ enum plugin_status plugin_start(const void* parameter)
575 } 580 }
576 581
577 backlight_use_settings(); /* backlight control in lib/helper.c */ 582 backlight_use_settings(); /* backlight control in lib/helper.c */
578 return PLUGIN_OK; 583 return usb? PLUGIN_USB_CONNECTED: PLUGIN_OK;
579} 584}
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index 4a680ee91b..0da3305a6f 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -482,8 +482,6 @@ int plugin_main(void)
482#endif 482#endif
483 case(STARFIELD_QUIT): 483 case(STARFIELD_QUIT):
484 case(SYS_USB_CONNECTED): 484 case(SYS_USB_CONNECTED):
485 /* Turn on backlight timeout (revert to settings) */
486 backlight_use_settings(); /* backlight control in lib/helper.c*/
487 return PLUGIN_OK; 485 return PLUGIN_OK;
488 break; 486 break;
489 } 487 }
@@ -502,6 +500,9 @@ enum plugin_status plugin_start(const void* parameter)
502 500
503 ret = plugin_main(); 501 ret = plugin_main();
504 502
503 /* Turn on backlight timeout (revert to settings) */
504 backlight_use_settings(); /* backlight control in lib/helper.c*/
505
505 return ret; 506 return ret;
506} 507}
507 508
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c
index a8c8c2d836..4d5812ba2c 100644
--- a/apps/plugins/text_editor.c
+++ b/apps/plugins/text_editor.c
@@ -86,7 +86,7 @@ char* _do_action(int action, char* str, int line)
86 break; 86 break;
87 case ACTION_REMOVE: 87 case ACTION_REMOVE:
88 if (line > line_count) 88 if (line > line_count)
89 return 0; 89 return NULL;
90 len = rb->strlen(&buffer[c])+1; 90 len = rb->strlen(&buffer[c])+1;
91 rb->memmove(&buffer[c],&buffer[c+len],char_count-c-len); 91 rb->memmove(&buffer[c],&buffer[c+len],char_count-c-len);
92 char_count -= len; 92 char_count -= len;
@@ -225,7 +225,7 @@ enum {
225}; 225};
226int do_item_menu(int cur_sel, char* copy_buffer) 226int do_item_menu(int cur_sel, char* copy_buffer)
227{ 227{
228 int ret = 0; 228 int ret = MENU_RET_NO_UPDATE;
229 MENUITEM_STRINGLIST(menu, "Line Options", NULL, 229 MENUITEM_STRINGLIST(menu, "Line Options", NULL,
230 "Cut/Delete", "Copy", 230 "Cut/Delete", "Copy",
231 "Insert Above", "Insert Below", 231 "Insert Above", "Insert Below",
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index a212885540..88b43c30b3 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -1,12 +1,11 @@
1/*************************************************************************** 1/***************************************************************************
2 *
3 * __________ __ ___. 2 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
9 * 8 * $Id$
10 * 9 *
11 * Copyright (C) 2002 Gilles Roux, 2003 Garrett Derner 10 * Copyright (C) 2002 Gilles Roux, 2003 Garrett Derner
12 * 11 *
@@ -432,7 +431,6 @@ struct preferences {
432 } scroll_mode; 431 } scroll_mode;
433 432
434 int autoscroll_speed; 433 int autoscroll_speed;
435
436}; 434};
437 435
438struct preferences prefs; 436struct preferences prefs;
@@ -1226,7 +1224,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1226 int settings_fd, i; 1224 int settings_fd, i;
1227 struct bookmark_file_data *data; 1225 struct bookmark_file_data *data;
1228 struct bookmarked_file_info this_bookmark; 1226 struct bookmarked_file_info this_bookmark;
1229 1227
1230 /* read settings file */ 1228 /* read settings file */
1231 settings_fd=rb->open(SETTINGS_FILE, O_RDONLY); 1229 settings_fd=rb->open(SETTINGS_FILE, O_RDONLY);
1232 if ((settings_fd >= 0) && (rb->filesize(settings_fd) == sizeof(struct preferences))) 1230 if ((settings_fd >= 0) && (rb->filesize(settings_fd) == sizeof(struct preferences)))
@@ -1271,7 +1269,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1271 file_pos = screen_pos - screen_top; 1269 file_pos = screen_pos - screen_top;
1272 screen_top_ptr = buffer + screen_top; 1270 screen_top_ptr = buffer + screen_top;
1273 break; 1271 break;
1274 } 1272 }
1275 } 1273 }
1276 1274
1277 this_bookmark.file_position = file_pos; 1275 this_bookmark.file_position = file_pos;
@@ -1284,16 +1282,16 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1284 if (i >= data->bookmarked_files_count) 1282 if (i >= data->bookmarked_files_count)
1285 { 1283 {
1286 if (i < MAX_BOOKMARKED_FILES) 1284 if (i < MAX_BOOKMARKED_FILES)
1287 data->bookmarked_files_count++; 1285 data->bookmarked_files_count++;
1288 else 1286 else
1289 i = MAX_BOOKMARKED_FILES-1; 1287 i = MAX_BOOKMARKED_FILES-1;
1290 } 1288 }
1291 1289
1292 /* write bookmark file with spare slot in first position 1290 /* write bookmark file with spare slot in first position
1293 to be filled in by viewer_save_settings */ 1291 to be filled in by viewer_save_settings */
1294 settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT); 1292 settings_fd = rb->open(BOOKMARKS_FILE, O_WRONLY|O_CREAT);
1295 if (settings_fd >=0 ) 1293 if (settings_fd >=0 )
1296 { 1294 {
1297 /* write count */ 1295 /* write count */
1298 rb->write (settings_fd, &data->bookmarked_files_count, sizeof(signed int)); 1296 rb->write (settings_fd, &data->bookmarked_files_count, sizeof(signed int));
1299 1297
@@ -1336,7 +1334,7 @@ static void viewer_save_settings(void)/* same name as global, but not the same f
1336 rb->close(settings_fd); 1334 rb->close(settings_fd);
1337 } 1335 }
1338 } 1336 }
1339 1337
1340 /* save the bookmark if the position has changed */ 1338 /* save the bookmark if the position has changed */
1341 if (file_pos + screen_top_ptr - buffer != start_position) 1339 if (file_pos + screen_top_ptr - buffer != start_position)
1342 { 1340 {
@@ -1559,11 +1557,11 @@ enum plugin_status plugin_start(const void* file)
1559 } 1557 }
1560 1558
1561 viewer_load_settings(); /* load the preferences and bookmark */ 1559 viewer_load_settings(); /* load the preferences and bookmark */
1562 1560
1563#if LCD_DEPTH > 1 1561#if LCD_DEPTH > 1
1564 rb->lcd_set_backdrop(NULL); 1562 rb->lcd_set_backdrop(NULL);
1565#endif 1563#endif
1566 1564
1567 viewer_draw(col); 1565 viewer_draw(col);
1568 1566
1569 while (!done) { 1567 while (!done) {
@@ -1577,7 +1575,7 @@ enum plugin_status plugin_start(const void* file)
1577 old_tick = *rb->current_tick; 1575 old_tick = *rb->current_tick;
1578 } 1576 }
1579 } 1577 }
1580 1578
1581 button = rb->button_get_w_tmo(HZ/10); 1579 button = rb->button_get_w_tmo(HZ/10);
1582 switch (button) { 1580 switch (button) {
1583 case VIEWER_MENU: 1581 case VIEWER_MENU: