From ea372bd0cdf45ee80153c318842894394d24633d Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Tue, 28 Aug 2007 16:41:18 +0000 Subject: [PATCH] get_opt_*: Add ses parameter Add a session parameter to get_opt_ and its wrappers in preparation for session-specific and domain-specific options. --- src/bfu/button.c | 3 +- src/bfu/dialog.c | 4 +- src/bfu/hierbox.c | 3 +- src/bfu/hotkey.c | 2 +- src/bfu/inpfield.c | 3 +- src/bfu/leds.c | 4 +- src/bfu/listbox.c | 2 +- src/bfu/menu.c | 4 +- src/bfu/style.c | 6 +- src/bookmarks/backend/common.c | 4 +- src/bookmarks/backend/default.c | 2 +- src/bookmarks/backend/xbel.c | 2 +- src/bookmarks/bookmarks.c | 9 +-- src/bookmarks/dialogs.c | 2 +- src/cache/cache.c | 10 +-- src/cache/dialogs.c | 2 +- src/config/cmdline.c | 4 +- src/config/conf.c | 8 +-- src/config/dialogs.c | 4 +- src/config/options.c | 48 ++++++++------ src/config/options.h | 52 +++++++-------- src/config/opttypes.c | 3 +- src/config/timer.c | 2 +- src/cookies/dialogs.c | 2 +- src/dialogs/menu.c | 8 ++- src/dialogs/options.c | 2 +- src/dialogs/status.c | 17 ++--- src/document/css/css.c | 2 +- src/document/document.c | 14 ++-- src/document/html/parser.c | 2 +- src/document/html/parser/general.c | 6 +- src/document/options.c | 86 ++++++++++++------------- src/document/options.h | 2 +- src/document/refresh.c | 2 +- src/document/renderer.c | 13 ++-- src/ecmascript/ecmascript.h | 2 +- src/ecmascript/see.c | 2 +- src/ecmascript/see/document.c | 5 +- src/ecmascript/see/navigator.c | 5 +- src/ecmascript/see/window.c | 2 +- src/ecmascript/spidermonkey.c | 4 +- src/ecmascript/spidermonkey/document.c | 4 +- src/ecmascript/spidermonkey/navigator.c | 5 +- src/ecmascript/spidermonkey/window.c | 2 +- src/encoding/encoding.c | 4 +- src/globhist/dialogs.c | 5 +- src/intl/gettext/libintl.h | 2 +- src/main/main.c | 5 +- src/mime/backend/default.c | 6 +- src/mime/dialogs.c | 4 +- src/network/connection.c | 17 ++--- src/network/dns.c | 2 +- src/network/socket.c | 4 +- src/network/ssl/socket.c | 11 ++-- src/protocol/bittorrent/bittorrent.c | 4 +- src/protocol/bittorrent/connection.c | 10 +-- src/protocol/bittorrent/dialogs.c | 2 +- src/protocol/bittorrent/peerconnect.c | 10 +-- src/protocol/bittorrent/peerwire.c | 2 +- src/protocol/bittorrent/piececache.c | 10 +-- src/protocol/bittorrent/tracker.c | 15 +++-- src/protocol/file/cgi.c | 14 ++-- src/protocol/file/file.c | 7 +- src/protocol/fsp/fsp.c | 6 +- src/protocol/ftp/ftp.c | 11 ++-- src/protocol/http/codes.c | 2 +- src/protocol/http/http.c | 30 ++++----- src/protocol/proxy.c | 4 +- src/protocol/rewrite/rewrite.c | 2 +- src/protocol/smb/smb2.c | 4 +- src/session/download.c | 8 +-- src/session/history.c | 2 +- src/session/session.c | 14 ++-- src/session/task.c | 15 +++-- src/terminal/draw.c | 16 ++--- src/terminal/event.c | 12 ++-- src/terminal/screen.c | 23 +++---- src/terminal/tab.c | 8 +-- src/terminal/terminal.c | 2 +- src/util/secsave.c | 4 +- src/viewer/action.c | 2 +- src/viewer/dump/dump.c | 30 +++++---- src/viewer/text/draw.c | 9 +-- src/viewer/text/form.c | 16 +++-- src/viewer/text/link.c | 7 +- src/viewer/text/search.c | 31 +++++---- src/viewer/text/textarea.c | 3 +- src/viewer/text/view.c | 28 ++++---- src/viewer/timer.c | 7 +- 89 files changed, 425 insertions(+), 375 deletions(-) diff --git a/src/bfu/button.c b/src/bfu/button.c index 8267c945c..b567251f8 100644 --- a/src/bfu/button.c +++ b/src/bfu/button.c @@ -218,7 +218,8 @@ display_button(struct dialog_data *dlg_data, struct widget_data *widget_data) int hk_pos = widget_data->widget->info.button.hotkey_pos; int attr; - attr = get_opt_bool("ui.dialogs.underline_button_shortcuts") + attr = get_opt_bool("ui.dialogs.underline_button_shortcuts", + NULL) ? SCREEN_ATTR_UNDERLINE : 0; #ifdef CONFIG_UTF8 diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index 6694730d8..f99e78145 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -297,7 +297,7 @@ select_button_by_key(struct dialog_data *dlg_data) #ifdef CONFIG_UTF8 key = unicode_fold_label_case(get_kbd_key(ev)); - codepage = get_opt_codepage_tree(dlg_data->win->term->spec, "charset"); + codepage = get_opt_codepage_tree(dlg_data->win->term->spec, "charset", NULL); #else key = toupper(get_kbd_key(ev)); #endif @@ -659,7 +659,7 @@ draw_dialog(struct dialog_data *dlg_data, int width, int height) draw_box(term, &dlg_data->box, ' ', 0, get_bfu_color(term, "dialog.generic")); - if (get_opt_bool("ui.dialogs.shadows")) { + if (get_opt_bool("ui.dialogs.shadows", NULL)) { /* Draw shadow */ draw_shadow(term, &dlg_data->box, get_bfu_color(term, "dialog.shadow"), 2, 1); diff --git a/src/bfu/hierbox.c b/src/bfu/hierbox.c index c8e3b65b2..5d49e64e5 100644 --- a/src/bfu/hierbox.c +++ b/src/bfu/hierbox.c @@ -939,7 +939,8 @@ search_hierbox_browser(void *data, unsigned char *text) scan_for_matches, context); if (!context->item && *text) { - switch (get_opt_int("document.browse.search.show_not_found")) { + switch (get_opt_int("document.browse.search.show_not_found", + NULL)) { case 2: info_box(term, MSGBOX_FREE_TEXT, N_("Search"), ALIGN_CENTER, diff --git a/src/bfu/hotkey.c b/src/bfu/hotkey.c index c26228599..9502d11f5 100644 --- a/src/bfu/hotkey.c +++ b/src/bfu/hotkey.c @@ -127,7 +127,7 @@ check_hotkeys_common(struct menu *menu, term_event_char_T hotkey, struct termina { #ifdef CONFIG_UTF8 unicode_val_T key = unicode_fold_label_case(hotkey); - int codepage = get_opt_codepage_tree(term->spec, "charset"); + int codepage = get_opt_codepage_tree(term->spec, "charset", NULL); #else unsigned char key = toupper(hotkey); #endif diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index cab51d861..f0b853992 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -692,7 +692,8 @@ kbd_field(struct dialog_data *dlg_data, struct widget_data *widget_data) * is in the terminal's charset. */ ins = u2cp_no_nbsp(get_kbd_key(ev), get_opt_codepage_tree(term->spec, - "charset")); + "charset", + NULL)); inslen = strlen(ins); #endif /* CONFIG_UTF8 */ diff --git a/src/bfu/leds.c b/src/bfu/leds.c index e54d99506..b5e77a903 100644 --- a/src/bfu/leds.c +++ b/src/bfu/leds.c @@ -193,7 +193,7 @@ draw_leds(struct session *ses) /* This should be done elsewhere, but this is very nice place where we * could do that easily. */ - if (get_opt_int("ui.timer.enable") == 2) { + if (get_opt_int("ui.timer.enable", NULL) == 2) { led_color = get_bfu_color(term, "status.status-text"); if (!led_color) goto end; @@ -276,7 +276,7 @@ redraw_leds(void *xxx) struct session *ses; if (!get_leds_panel_enable() - && get_opt_int("ui.timer.enable") != 2) { + && get_opt_int("ui.timer.enable", NULL) != 2) { redraw_timer = TIMER_ID_UNDEF; return; } diff --git a/src/bfu/listbox.c b/src/bfu/listbox.c index 7ec1b6608..2e27abae9 100644 --- a/src/bfu/listbox.c +++ b/src/bfu/listbox.c @@ -51,7 +51,7 @@ dlg_format_listbox(struct terminal *term, struct widget_data *widget_data, /* This is only weird heuristic, it could scale well I hope. */ optimal_h = max_height * 7 / 10 - VERTICAL_LISTBOX_MARGIN; - min = get_opt_int("ui.dialogs.listbox_min_height"); + min = get_opt_int("ui.dialogs.listbox_min_height", NULL); if (max_height - VERTICAL_LISTBOX_MARGIN < min) { /* Big trouble: can't satisfy even the minimum :-(. */ diff --git a/src/bfu/menu.c b/src/bfu/menu.c index 74b60d701..f4501017c 100644 --- a/src/bfu/menu.c +++ b/src/bfu/menu.c @@ -404,7 +404,7 @@ draw_menu_left_text_hk(struct terminal *term, unsigned char *text, { struct color_pair *hk_color = get_bfu_color(term, "menu.hotkey.normal"); struct color_pair *hk_color_sel = get_bfu_color(term, "menu.hotkey.selected"); - enum screen_char_attr hk_attr = get_opt_bool("ui.dialogs.underline_hotkeys") + enum screen_char_attr hk_attr = get_opt_bool("ui.dialogs.underline_hotkeys", NULL) ? SCREEN_ATTR_UNDERLINE : 0; unsigned char c; int xbase = x + L_TEXT_SPACE; @@ -556,7 +556,7 @@ display_menu(struct terminal *term, struct menu *menu) draw_box(term, &box, ' ', 0, normal_color); draw_border(term, &box, frame_color, 1); - if (get_opt_bool("ui.dialogs.shadows")) { + if (get_opt_bool("ui.dialogs.shadows", NULL)) { /* Draw shadow */ draw_shadow(term, &menu->box, get_bfu_color(term, "dialog.shadow"), 2, 1); diff --git a/src/bfu/style.c b/src/bfu/style.c index db06fb2a1..54d7a4dde 100644 --- a/src/bfu/style.c +++ b/src/bfu/style.c @@ -38,7 +38,7 @@ get_bfu_color(struct terminal *term, unsigned char *stylename) if (!term) return NULL; - color_mode = get_opt_int_tree(term->spec, "colors"); + color_mode = get_opt_int_tree(term->spec, "colors", NULL); if (!bfu_colors) { /* Initialize the style hash. */ @@ -86,8 +86,8 @@ get_bfu_color(struct terminal *term, unsigned char *stylename) return NULL; } - entry->foreground = &get_opt_color_tree(opt, "text"); - entry->background = &get_opt_color_tree(opt, "background"); + entry->foreground = &get_opt_color_tree(opt, "text", NULL); + entry->background = &get_opt_color_tree(opt, "background", NULL); } /* Always update the color pair. */ diff --git a/src/bookmarks/backend/common.c b/src/bookmarks/backend/common.c index 4d386cdd8..174b9145b 100644 --- a/src/bookmarks/backend/common.c +++ b/src/bookmarks/backend/common.c @@ -45,7 +45,7 @@ static int loaded_backend_num = -1; void bookmarks_read(void) { - int backend_num = get_opt_int("bookmarks.file_format"); + int backend_num = get_opt_int("bookmarks.file_format", NULL); struct bookmarks_backend *backend = bookmarks_backends[backend_num]; unsigned char *file_name; FILE *f; @@ -76,7 +76,7 @@ bookmarks_read(void) void bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list) { - int backend_num = get_opt_int("bookmarks.file_format"); + int backend_num = get_opt_int("bookmarks.file_format", NULL); struct bookmarks_backend *backend = bookmarks_backends[backend_num]; struct secure_save_info *ssi; unsigned char *file_name; diff --git a/src/bookmarks/backend/default.c b/src/bookmarks/backend/default.c index a098b7d3f..7ba008a40 100644 --- a/src/bookmarks/backend/default.c +++ b/src/bookmarks/backend/default.c @@ -130,7 +130,7 @@ static void write_bookmarks_default(struct secure_save_info *ssi, LIST_OF(struct bookmark) *bookmarks_list) { - int folder_state = get_opt_bool("bookmarks.folder_state"); + int folder_state = get_opt_bool("bookmarks.folder_state", NULL); struct bookmark *bm; foreach (bm, *bookmarks_list) { diff --git a/src/bookmarks/backend/xbel.c b/src/bookmarks/backend/xbel.c index d78a76842..432d3ba6a 100644 --- a/src/bookmarks/backend/xbel.c +++ b/src/bookmarks/backend/xbel.c @@ -136,7 +136,7 @@ static void write_bookmarks_xbel(struct secure_save_info *ssi, LIST_OF(struct bookmarks) *bookmarks_list) { - int folder_state = get_opt_bool("bookmarks.folder_state"); + int folder_state = get_opt_bool("bookmarks.folder_state", NULL); /* We check for readok in filename_bookmarks_xbel(). */ secure_fputs(ssi, diff --git a/src/bookmarks/bookmarks.c b/src/bookmarks/bookmarks.c index 3439d9017..7f6ebf455 100644 --- a/src/bookmarks/bookmarks.c +++ b/src/bookmarks/bookmarks.c @@ -109,7 +109,7 @@ static void bookmark_snapshot(); static enum evhook_status bookmark_write_hook(va_list ap, void *data) { - if (get_opt_bool("ui.sessions.snapshot") + if (get_opt_bool("ui.sessions.snapshot", NULL) && !get_cmd_opt_bool("anonymous")) bookmark_snapshot(); @@ -534,10 +534,10 @@ bookmark_auto_save_tabs(struct terminal *term) unsigned char *foldername; if (get_cmd_opt_bool("anonymous") - || !get_opt_bool("ui.sessions.auto_save")) + || !get_opt_bool("ui.sessions.auto_save", NULL)) return; - foldername = get_opt_str("ui.sessions.auto_save_foldername"); + foldername = get_opt_str("ui.sessions.auto_save_foldername", NULL); if (!*foldername) return; /* Ensure uniqueness of the auto save folder, so it is possible to @@ -559,7 +559,8 @@ bookmark_snapshot(void) #ifdef HAVE_STRFTIME add_to_string(&folderstring, " - "); - add_date_to_string(&folderstring, get_opt_str("ui.date_format"), NULL); + add_date_to_string(&folderstring, get_opt_str("ui.date_format", NULL), + NULL); #endif folder = add_bookmark(NULL, 1, folderstring.source, NULL); diff --git a/src/bookmarks/dialogs.c b/src/bookmarks/dialogs.c index 662110891..2e66a0355 100644 --- a/src/bookmarks/dialogs.c +++ b/src/bookmarks/dialogs.c @@ -698,7 +698,7 @@ bookmark_terminal_tabs_dialog(struct terminal *term) #ifdef HAVE_STRFTIME add_to_string(&string, " - "); - add_date_to_string(&string, get_opt_str("ui.date_format"), NULL); + add_date_to_string(&string, get_opt_str("ui.date_format", NULL), NULL); #endif input_dialog(term, NULL, diff --git a/src/cache/cache.c b/src/cache/cache.c index db9efe1ec..89c55868d 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -188,7 +188,7 @@ get_validated_cache_entry(struct uri *uri, enum cache_mode cache_mode) * remove the redirect or the entry expired. Please enlighten me. * --jonas */ if ((cached->cache_mode == CACHE_MODE_NEVER && cache_mode != CACHE_MODE_ALWAYS) - || (cached->redirect && !get_opt_bool("document.cache.cache_redirects")) + || (cached->redirect && !get_opt_bool("document.cache.cache_redirects", NULL)) || (cached->expire && cache_entry_has_expired(cached))) { if (!is_object_used(cached)) delete_cache_entry(cached); return NULL; @@ -197,8 +197,8 @@ get_validated_cache_entry(struct uri *uri, enum cache_mode cache_mode) if (cached->cache_mode <= CACHE_MODE_CHECK_IF_MODIFIED && cache_mode <= CACHE_MODE_CHECK_IF_MODIFIED && (cached->last_modified || cached->etag) - && get_opt_int("document.cache.revalidation_interval") >= 0) { - if (cached->seconds + get_opt_int("document.cache.revalidation_interval") < time(NULL)) + && get_opt_int("document.cache.revalidation_interval", NULL) >= 0) { + if (cached->seconds + get_opt_int("document.cache.revalidation_interval", NULL) < time(NULL)) return NULL; } @@ -753,7 +753,7 @@ garbage_collection(int whole) /* The maximal cache size tolerated by user. Note that this is only * size of the "just stored" unused cache entries, used cache entries * are not counted to that. */ - unsigned longlong opt_cache_size = get_opt_long("document.cache.memory.size"); + unsigned longlong opt_cache_size = get_opt_long("document.cache.memory.size", NULL); /* The low-treshold cache size. Basically, when the cache size is * higher than opt_cache_size, we free the cache so that there is no * more than this value in the cache anymore. This is to make sure we @@ -895,7 +895,7 @@ shrinked_enough: DBG("garbage collection doesn't work, cache size %ld > %ld, " "document.cache.memory.size set to: %ld bytes", cache_size, gc_cache_size, - get_opt_long("document.cache.memory.size")); + get_opt_long("document.cache.memory.size", NULL)); } #endif } diff --git a/src/cache/dialogs.c b/src/cache/dialogs.c index b0a33b346..c360c5f18 100644 --- a/src/cache/dialogs.c +++ b/src/cache/dialogs.c @@ -123,7 +123,7 @@ get_cache_entry_info(struct listbox_item *item, struct terminal *term) time_t expires = timeval_to_seconds(&cached->max_age); add_format_to_string(&msg, "\n%s: ", _("Expires", term)); - add_date_to_string(&msg, get_opt_str("ui.date_format"), &expires); + add_date_to_string(&msg, get_opt_str("ui.date_format", NULL), &expires); } #endif #ifdef CONFIG_DEBUG diff --git a/src/config/cmdline.c b/src/config/cmdline.c index 27eb83b8f..9a36e26e8 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -144,7 +144,7 @@ eval_cmd(struct option *o, unsigned char ***argv, int *argc) static unsigned char * forcehtml_cmd(struct option *o, unsigned char ***argv, int *argc) { - safe_strncpy(get_opt_str("mime.default_type"), "text/html", MAX_STR_LEN); + safe_strncpy(get_opt_str("mime.default_type", NULL), "text/html", MAX_STR_LEN); return NULL; } @@ -685,7 +685,7 @@ printconfigdump_cmd(struct option *option, unsigned char ***argv, int *argc) unsigned char *config_string; /* Print all. */ - get_opt_int("config.saving_style") = 2; + get_opt_int("config.saving_style", NULL) = 2; config_string = create_config_string("", "", config_options); if (config_string) { diff --git a/src/config/conf.c b/src/config/conf.c index 3376e69da..94e28c69d 100644 --- a/src/config/conf.c +++ b/src/config/conf.c @@ -692,8 +692,8 @@ create_config_string(unsigned char *prefix, unsigned char *name, /* Don't write headers if nothing will be added anyway. */ struct string tmpstring; int origlen; - int savestyle = get_opt_int("config.saving_style"); - int i18n = get_opt_bool("config.i18n"); + int savestyle = get_opt_int("config.saving_style", NULL); + int i18n = get_opt_bool("config.i18n", NULL); if (!init_string(&config)) return NULL; @@ -755,8 +755,8 @@ create_config_string(unsigned char *prefix, unsigned char *name, if (savestyle == 0) goto get_me_out; - indentation = get_opt_int("config.indentation"); - comments = get_opt_int("config.comments"); + indentation = get_opt_int("config.indentation", NULL); + comments = get_opt_int("config.comments", NULL); if (!init_string(&tmpstring)) goto get_me_out; diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 6a11c63f5..e43a66874 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -34,7 +34,7 @@ static void disable_success_msgbox(void *dummy) { - get_opt_bool("ui.success_msgbox") = 0; + get_opt_bool("ui.success_msgbox", NULL) = 0; option_changed(NULL, get_opt_rec(config_options, "ui.success_msgbox")); } @@ -47,7 +47,7 @@ write_config_dialog(struct terminal *term, unsigned char *config_file, unsigned char *strerr; if (secsave_error == SS_ERR_NONE && !stdio_error) { - if (!get_opt_bool("ui.success_msgbox")) return; + if (!get_opt_bool("ui.success_msgbox", NULL)) return; msg_box(term, NULL, MSGBOX_FREE_TEXT, N_("Write config success"), ALIGN_CENTER, diff --git a/src/config/options.c b/src/config/options.c index 025c9def3..c912cef2d 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -248,9 +248,17 @@ get_opt_( #ifdef CONFIG_DEBUG unsigned char *file, int line, enum option_type option_type, #endif - struct option *tree, unsigned char *name) + struct option *tree, unsigned char *name, struct session *ses) { - struct option *opt = get_opt_rec(tree, name); + struct option *opt = NULL; + + /* TODO: Look for a session-specific option. */ + + /* TODO: Look for a domain-specific option. */ + + /* Else, return the real option. */ + if (!opt) + opt = get_opt_rec(tree, name); #ifdef CONFIG_DEBUG errfile = file; @@ -397,7 +405,7 @@ add_opt_rec(struct option *tree, unsigned char *path, struct option *option) object_nolock(option, "option"); if (option->box_item && option->name && !strcmp(option->name, "_template_")) - option->box_item->visible = get_opt_bool("config.show_template"); + option->box_item->visible = get_opt_bool("config.show_template", NULL); if (tree->flags & OPT_AUTOCREATE && !option->desc) { struct option *template = get_opt_rec(tree, "_template_"); @@ -656,25 +664,25 @@ static inline void register_autocreated_options(void) { /* TODO: Use table-driven initialization. --jonas */ - get_opt_int("terminal.linux.type") = 2; - get_opt_int("terminal.linux.colors") = 1; - get_opt_bool("terminal.linux.m11_hack") = 1; - get_opt_int("terminal.vt100.type") = 1; - get_opt_int("terminal.vt110.type") = 1; - get_opt_int("terminal.xterm.type") = 1; - get_opt_bool("terminal.xterm.underline") = 1; - get_opt_int("terminal.xterm-color.type") = 1; - get_opt_int("terminal.xterm-color.colors") = COLOR_MODE_16; - get_opt_bool("terminal.xterm-color.underline") = 1; + get_opt_int("terminal.linux.type", NULL) = 2; + get_opt_int("terminal.linux.colors", NULL) = 1; + get_opt_bool("terminal.linux.m11_hack", NULL) = 1; + get_opt_int("terminal.vt100.type", NULL) = 1; + get_opt_int("terminal.vt110.type", NULL) = 1; + get_opt_int("terminal.xterm.type", NULL) = 1; + get_opt_bool("terminal.xterm.underline", NULL) = 1; + get_opt_int("terminal.xterm-color.type", NULL) = 1; + get_opt_int("terminal.xterm-color.colors", NULL) = COLOR_MODE_16; + get_opt_bool("terminal.xterm-color.underline", NULL) = 1; #ifdef CONFIG_88_COLORS - get_opt_int("terminal.xterm-88color.type") = 1; - get_opt_int("terminal.xterm-88color.colors") = COLOR_MODE_88; - get_opt_bool("terminal.xterm-88color.underline") = 1; + get_opt_int("terminal.xterm-88color.type", NULL) = 1; + get_opt_int("terminal.xterm-88color.colors", NULL) = COLOR_MODE_88; + get_opt_bool("terminal.xterm-88color.underline", NULL) = 1; #endif #ifdef CONFIG_256_COLORS - get_opt_int("terminal.xterm-256color.type") = 1; - get_opt_int("terminal.xterm-256color.colors") = COLOR_MODE_256; - get_opt_bool("terminal.xterm-256color.underline") = 1; + get_opt_int("terminal.xterm-256color.type", NULL) = 1; + get_opt_int("terminal.xterm-256color.colors", NULL) = COLOR_MODE_256; + get_opt_bool("terminal.xterm-256color.underline", NULL) = 1; #endif } @@ -945,7 +953,7 @@ void update_options_visibility(void) { update_visibility(config_options->value.tree, - get_opt_bool("config.show_template")); + get_opt_bool("config.show_template", NULL)); } void diff --git a/src/config/options.h b/src/config/options.h index 15d9d7949..635fc07b2 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -208,41 +208,41 @@ extern void checkout_option_values(struct option_resolver *resolvers, /* Basically, for main hiearchy addressed from root (almost always) you want to * use get_opt_type() and add_opt_type(). For command line options, you want to - * use get_opt_type_tree(cmdline_options, "option"). */ + * use get_opt_type_tree(cmdline_options, "option", NULL). */ extern struct option *get_opt_rec(struct option *, const unsigned char *); extern struct option *get_opt_rec_real(struct option *, const unsigned char *); #ifdef CONFIG_DEBUG -extern union option_value *get_opt_(unsigned char *, int, enum option_type, struct option *, unsigned char *); -#define get_opt(tree, name, type) get_opt_(__FILE__, __LINE__, type, tree, name) +extern union option_value *get_opt_(unsigned char *, int, enum option_type, struct option *, unsigned char *, struct session *); +#define get_opt(tree, name, ses, type) get_opt_(__FILE__, __LINE__, type, tree, name, ses) #else -extern union option_value *get_opt_(struct option *, unsigned char *); -#define get_opt(tree, name, type) get_opt_(tree, name) +extern union option_value *get_opt_(struct option *, unsigned char *, struct session *); +#define get_opt(tree, name, ses, type) get_opt_(tree, name, ses) #endif -#define get_opt_bool_tree(tree, name) get_opt(tree, name, OPT_BOOL)->number -#define get_opt_int_tree(tree, name) get_opt(tree, name, OPT_INT)->number -#define get_opt_long_tree(tree, name) get_opt(tree, name, OPT_LONG)->big_number -#define get_opt_str_tree(tree, name) get_opt(tree, name, OPT_STRING)->string -#define get_opt_codepage_tree(tree, name) get_opt(tree, name, OPT_CODEPAGE)->number -#define get_opt_color_tree(tree, name) get_opt(tree, name, OPT_COLOR)->color -#define get_opt_tree_tree(tree_, name) get_opt(tree_, name, OPT_TREE)->tree +#define get_opt_bool_tree(tree, name, ses) get_opt(tree, name, ses, OPT_BOOL)->number +#define get_opt_int_tree(tree, name, ses) get_opt(tree, name, ses, OPT_INT)->number +#define get_opt_long_tree(tree, name, ses) get_opt(tree, name, ses, OPT_LONG)->big_number +#define get_opt_str_tree(tree, name, ses) get_opt(tree, name, ses, OPT_STRING)->string +#define get_opt_codepage_tree(tree, name, ses) get_opt(tree, name, ses, OPT_CODEPAGE)->number +#define get_opt_color_tree(tree, name, ses) get_opt(tree, name, ses, OPT_COLOR)->color +#define get_opt_tree_tree(tree_, name, ses) get_opt(tree_, name, ses, OPT_TREE)->tree -#define get_opt_bool(name) get_opt_bool_tree(config_options, name) -#define get_opt_int(name) get_opt_int_tree(config_options, name) -#define get_opt_long(name) get_opt_long_tree(config_options, name) -#define get_opt_str(name) get_opt_str_tree(config_options, name) -#define get_opt_codepage(name) get_opt_codepage_tree(config_options, name) -#define get_opt_color(name) get_opt_color_tree(config_options, name) -#define get_opt_tree(name) get_opt_tree_tree(config_options, name) +#define get_opt_bool(name, ses) get_opt_bool_tree(config_options, name, ses) +#define get_opt_int(name, ses) get_opt_int_tree(config_options, name, ses) +#define get_opt_long(name, ses) get_opt_long_tree(config_options, name, ses) +#define get_opt_str(name, ses) get_opt_str_tree(config_options, name, ses) +#define get_opt_codepage(name, ses) get_opt_codepage_tree(config_options, name, ses) +#define get_opt_color(name, ses) get_opt_color_tree(config_options, name, ses) +#define get_opt_tree(name, ses) get_opt_tree_tree(config_options, name, ses) -#define get_cmd_opt_bool(name) get_opt_bool_tree(cmdline_options, name) -#define get_cmd_opt_int(name) get_opt_int_tree(cmdline_options, name) -#define get_cmd_opt_long(name) get_opt_long_tree(cmdline_options, name) -#define get_cmd_opt_str(name) get_opt_str_tree(cmdline_options, name) -#define get_cmd_opt_codepage(name) get_opt_codepage_tree(cmdline_options, name) -#define get_cmd_opt_color(name) get_opt_color_tree(cmdline_options, name) -#define get_cmd_opt_tree(name) get_opt_tree_tree(cmdline_options, name) +#define get_cmd_opt_bool(name) get_opt_bool_tree(cmdline_options, name, NULL) +#define get_cmd_opt_int(name) get_opt_int_tree(cmdline_options, name, NULL) +#define get_cmd_opt_long(name) get_opt_long_tree(cmdline_options, name, NULL) +#define get_cmd_opt_str(name) get_opt_str_tree(cmdline_options, name, NULL) +#define get_cmd_opt_codepage(name) get_opt_codepage_tree(cmdline_options, name, NULL) +#define get_cmd_opt_color(name) get_opt_color_tree(cmdline_options, name, NULL) +#define get_cmd_opt_tree(name) get_opt_tree_tree(cmdline_options, name, NULL) extern struct option *add_opt(struct option *, unsigned char *, unsigned char *, unsigned char *, enum option_flags, enum option_type, diff --git a/src/config/opttypes.c b/src/config/opttypes.c index 3a5c8915d..3aee42161 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -381,12 +381,13 @@ tree_dup(struct option *opt, struct option *template) if (!new_opt) continue; object_nolock(new_opt, "option"); add_to_list_end(*new, new_opt); + object_lock(new_opt); new_opt->root = opt; if (!new_opt->box_item) continue; if (new_opt->name && !strcmp(new_opt->name, "_template_")) - new_opt->box_item->visible = get_opt_bool("config.show_template"); + new_opt->box_item->visible = get_opt_bool("config.show_template", NULL); if (opt->box_item) { add_to_list(opt->box_item->child, diff --git a/src/config/timer.c b/src/config/timer.c index 0a36d00e2..7f4ab2526 100644 --- a/src/config/timer.c +++ b/src/config/timer.c @@ -34,7 +34,7 @@ periodic_save_handler(void *xxx) else trigger_event(periodic_save_event_id); - interval = sec_to_ms(get_opt_int("infofiles.save_interval")); + interval = sec_to_ms(get_opt_int("infofiles.save_interval", NULL)); if (!interval) { /* We should get here only if @periodic_save_handler * is being called from @periodic_save_change_hook or diff --git a/src/cookies/dialogs.c b/src/cookies/dialogs.c index 696cad591..597e9fbc2 100644 --- a/src/cookies/dialogs.c +++ b/src/cookies/dialogs.c @@ -42,7 +42,7 @@ add_cookie_info_to_string(struct string *string, struct cookie *cookie, #ifdef HAVE_STRFTIME } else { add_format_to_string(string, "\n%s: ", _("Expires", term)); - add_date_to_string(string, get_opt_str("ui.date_format"), &cookie->expires); + add_date_to_string(string, get_opt_str("ui.date_format", NULL), &cookie->expires); #endif } diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c index 744a4b788..fab72b216 100644 --- a/src/dialogs/menu.c +++ b/src/dialogs/menu.c @@ -578,7 +578,7 @@ query_file(struct session *ses, struct uri *uri, void *data, if (!init_string(&def)) return; - add_to_string(&def, get_opt_str("document.download.directory")); + add_to_string(&def, get_opt_str("document.download.directory", NULL)); if (def.length && !dir_sep(def.source[def.length - 1])) add_char_to_string(&def, '/'); @@ -812,7 +812,8 @@ enum frame_event_status pass_uri_to_command(struct session *ses, struct document_view *doc_view, int which_type) { - LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing"); + LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing", + NULL); enum pass_uri_type type = which_type; struct menu_item *items; struct option *option; @@ -887,7 +888,8 @@ void add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type, unsigned char *text) { - LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing"); + LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing", + NULL); struct option *option; int commands = 0; enum menu_item_flags flags = NO_FLAG; diff --git a/src/dialogs/options.c b/src/dialogs/options.c index 75a59a8b3..20cf53cf2 100644 --- a/src/dialogs/options.c +++ b/src/dialogs/options.c @@ -50,7 +50,7 @@ charset_list(struct terminal *term, void *xxx, void *ses_) int i, items; int sel = 0; const unsigned char *const sel_mime = get_cp_mime_name( - get_opt_codepage_tree(term->spec, "charset")); + get_opt_codepage_tree(term->spec, "charset", NULL)); struct menu_item *mi = new_menu(FREE_LIST); if (!mi) return; diff --git a/src/dialogs/status.c b/src/dialogs/status.c index cfe14609d..0a803b953 100644 --- a/src/dialogs/status.c +++ b/src/dialogs/status.c @@ -64,15 +64,16 @@ get_download_msg(struct download *download, struct terminal *term, void update_status(void) { - int show_title_bar = get_opt_bool("ui.show_title_bar"); - int show_status_bar = get_opt_bool("ui.show_status_bar"); - int show_tabs_bar = get_opt_int("ui.tabs.show_bar"); - int show_tabs_bar_at_top = get_opt_bool("ui.tabs.top"); + int show_title_bar = get_opt_bool("ui.show_title_bar", NULL); + int show_status_bar = get_opt_bool("ui.show_status_bar", NULL); + int show_tabs_bar = get_opt_int("ui.tabs.show_bar", NULL); + int show_tabs_bar_at_top = get_opt_bool("ui.tabs.top", NULL); #ifdef CONFIG_LEDS - int show_leds = get_opt_bool("ui.leds.enable"); + int show_leds = get_opt_bool("ui.leds.enable", NULL); #endif - int set_window_title = get_opt_bool("ui.window_title"); - int insert_mode = get_opt_bool("document.browse.forms.insert_mode"); + int set_window_title = get_opt_bool("ui.window_title", NULL); + int insert_mode = get_opt_bool("document.browse.forms.insert_mode", + NULL); struct session *ses; int tabs_count = 1; struct terminal *term = NULL; @@ -390,7 +391,7 @@ display_title_bar(struct session *ses, struct terminal *term) int height; /* Clear the old title */ - if (!get_opt_bool("ui.show_menu_bar_always")) { + if (!get_opt_bool("ui.show_menu_bar_always", NULL)) { struct box box; set_box(&box, 0, 0, term->width, 1); diff --git a/src/document/css/css.c b/src/document/css/css.c index 28b717f44..fc24d0ad4 100644 --- a/src/document/css/css.c +++ b/src/document/css/css.c @@ -111,7 +111,7 @@ struct css_stylesheet default_stylesheet = INIT_CSS_STYLESHEET(default_styleshee static void import_default_css(void) { - unsigned char *url = get_opt_str("document.css.stylesheet"); + unsigned char *url = get_opt_str("document.css.stylesheet", NULL); if (!css_selector_set_empty(&default_stylesheet.selectors)) done_css_stylesheet(&default_stylesheet); diff --git a/src/document/document.c b/src/document/document.c index 7288c8a12..c18bc997b 100644 --- a/src/document/document.c +++ b/src/document/document.c @@ -217,12 +217,12 @@ update_cached_document_options(void) struct active_link_options active_link; memset(&active_link, 0, sizeof(active_link)); /* Safer. */ - active_link.fg = get_opt_color("document.browse.links.active_link.colors.text"); - active_link.bg = get_opt_color("document.browse.links.active_link.colors.background"); - active_link.color = get_opt_bool("document.browse.links.active_link.enable_color"); - active_link.invert = get_opt_bool("document.browse.links.active_link.invert"); - active_link.underline = get_opt_bool("document.browse.links.active_link.underline"); - active_link.bold = get_opt_bool("document.browse.links.active_link.bold"); + active_link.fg = get_opt_color("document.browse.links.active_link.colors.text", NULL); + active_link.bg = get_opt_color("document.browse.links.active_link.colors.background", NULL); + active_link.color = get_opt_bool("document.browse.links.active_link.enable_color", NULL); + active_link.invert = get_opt_bool("document.browse.links.active_link.invert", NULL); + active_link.underline = get_opt_bool("document.browse.links.active_link.underline", NULL); + active_link.bold = get_opt_bool("document.browse.links.active_link.bold", NULL); foreach (document, format_cache) { copy_struct(&document->options.active_link, &active_link); @@ -263,7 +263,7 @@ void shrink_format_cache(int whole) { struct document *document, *next; - int format_cache_size = get_opt_int("document.cache.format.size"); + int format_cache_size = get_opt_int("document.cache.format.size", NULL); int format_cache_entries = 0; foreachsafe (document, next, format_cache) { diff --git a/src/document/html/parser.c b/src/document/html/parser.c index 8f83c137f..5d41d9564 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -360,7 +360,7 @@ process_head(struct html_context *html_context, unsigned char *head) mem_free(refresh); - if (!get_opt_bool("document.cache.ignore_cache_control")) { + if (!get_opt_bool("document.cache.ignore_cache_control", NULL)) { unsigned char *d; int no_cache = 0; time_t expires = 0; diff --git a/src/document/html/parser/general.c b/src/document/html/parser/general.c index b28506e4f..1b84796fd 100644 --- a/src/document/html/parser/general.c +++ b/src/document/html/parser/general.c @@ -286,7 +286,7 @@ not_processed: unsigned char *import_url; struct uri *uri; - if (!get_opt_bool("ecmascript.enable")) { + if (!get_opt_bool("ecmascript.enable", NULL)) { mem_free(src); goto not_processed; } @@ -1105,8 +1105,8 @@ html_noscript(struct html_context *html_context, unsigned char *a, /* We shouldn't throw