From bdad21d51ca884918396fa999fc49701086b6c45 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 8 Jun 2003 04:00:05 +0000 Subject: [project @ 2003-06-08 04:00:05 by jmb] Cope with broken Choices file. svn path=/import/netsurf/; revision=178 --- riscos/gui.c | 37 +++++++++++++++++++++++++++++++++---- riscos/options.c | 14 +++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/riscos/gui.c b/riscos/gui.c index 87c956fb7..ac6efda03 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1,5 +1,5 @@ /** - * $Id: gui.c,v 1.30 2003/06/04 18:42:13 jmb Exp $ + * $Id: gui.c,v 1.31 2003/06/08 04:00:05 jmb Exp $ */ #include "netsurf/desktop/options.h" @@ -1104,6 +1104,10 @@ void gui_init(int argc, char** argv) wimp_icon_create iconbar; wimp_version_no version; char theme_fname[256]; + int *varsize; + char *var; + os_error *e; + fileswitch_object_type *ot; /* __riscosify_control = __RISCOSIFY_NO_PROCESS; */ @@ -1119,10 +1123,35 @@ void gui_init(int argc, char** argv) strcpy(iconbar.icon.data.sprite, "!netsurf"); ro_gui_iconbar_i = wimp_create_icon(&iconbar); - if (OPTIONS.theme != NULL) - sprintf(theme_fname, ".Themes.%s", OPTIONS.theme); - else + if (OPTIONS.theme != NULL) { + + /* get size of */ + e = xos_read_var_val_size ("NetSurf$Dir",0,os_VARTYPE_STRING, + &varsize, NULL, NULL); + var = xcalloc((~((int)varsize) + 10),sizeof(char)); + /* get real value of */ + e = xos_read_var_val ("NetSurf$Dir", var, (~(int)varsize), 0, + os_VARTYPE_STRING, NULL, NULL, NULL); + strcat(var, ".Themes."); + /* check if theme directory exists */ + e = xosfile_read_stamped_path ((const char*)OPTIONS.theme, + (const char*)var, + &ot, NULL, NULL, NULL, NULL, NULL); + xfree(var); + /* yes -> use this theme */ + if (ot != fileswitch_NOT_FOUND && ot == fileswitch_IS_DIR) { + sprintf(theme_fname, ".Themes.%s", OPTIONS.theme); + } + /* no -> use default theme */ + else { + OPTIONS.theme = strdup("Default"); + sprintf(theme_fname, ".Themes.Default"); + } + } + else { sprintf(theme_fname, ".Themes.Default"); + OPTIONS.theme = strdup("Default"); + } LOG(("Using theme '%s' - from '%s'",theme_fname, OPTIONS.theme)); current_theme = ro_theme_create(theme_fname); diff --git a/riscos/options.c b/riscos/options.c index cd05f6ed2..98baa23dd 100644 --- a/riscos/options.c +++ b/riscos/options.c @@ -1,5 +1,5 @@ /** - * $Id: options.c,v 1.3 2003/06/06 02:14:28 jmb Exp $ + * $Id: options.c,v 1.4 2003/06/08 04:00:05 jmb Exp $ */ #include "netsurf/desktop/options.h" @@ -98,7 +98,7 @@ void options_write(struct options* opt, char* filename) void options_init(struct options* opt) { opt->http = 0; - opt->http_proxy = strdup("http://www-cache.freeserve.co.uk"); + opt->http_proxy = strdup(""); opt->http_port = 8080; opt->use_mouse_gestures = 0; opt->allow_text_selection = 1; @@ -120,7 +120,7 @@ void options_read(struct options* opt, char* filename) LOG(("Testing filename")); if (filename == NULL) - fn = "Choices:NetSurf.Choices"; + strcat(fn, "Choices"); else strcat(fn, filename); @@ -128,6 +128,14 @@ void options_read(struct options* opt, char* filename) if (xmessagetrans_file_info(fn, &flags, &size) != NULL) return; + /* catch empty choices file - this is a kludge but should work */ + if (size <= 10) { + + LOG(("Empty Choices file - using defaults")); + options_init(opt); + return; + } + LOG(("Allocating %d bytes", size)); data = xcalloc(size, sizeof(char)); messagetrans_open_file(&cb, fn, data); -- cgit v1.2.3