From 1490b52a6b96b6a69a0c4fe9e0515dc717425128 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 22 Mar 2012 09:34:34 +0000 Subject: NetSurf options rework (a=vince r=daniels,jmb) svn path=/trunk/netsurf/; revision=13548 --- content/fetch.c | 6 ++--- content/fetchers/about.c | 4 ++-- content/fetchers/curl.c | 58 ++++++++++++++++++++++++++---------------------- content/urldb.c | 4 +++- 4 files changed, 39 insertions(+), 33 deletions(-) (limited to 'content') diff --git a/content/fetch.c b/content/fetch.c index 2a91ffef1..8c725af0e 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -278,7 +278,7 @@ struct fetch * fetch_start(nsurl *url, nsurl *referer, /* Not a problem if referer has no scheme */ /* Determine whether to send the Referer header */ - if (option_send_referer && ref_scheme != NULL) { + if (nsoption_bool(send_referer) && ref_scheme != NULL) { /* User permits us to send the header * Only send it if: * 1) The fetch and referer schemes match @@ -389,7 +389,7 @@ void fetch_dispatch_jobs(void) } #endif - while ( all_queued && all_active < option_max_fetchers ) { + while ( all_queued && all_active < nsoption_int(max_fetchers) ) { /*LOG(("%d queued, %d fetching", all_queued, all_active));*/ if (fetch_choose_and_dispatch()) { all_queued--; @@ -426,7 +426,7 @@ bool fetch_choose_and_dispatch(void) int countbyhost; RING_COUNTBYLWCHOST(struct fetch, fetch_ring, countbyhost, queueitem->host); - if (countbyhost < option_max_fetchers_per_host) { + if (countbyhost < nsoption_int(max_fetchers_per_host)) { /* We can dispatch this item in theory */ return fetch_dispatch_job(queueitem); } diff --git a/content/fetchers/about.c b/content/fetchers/about.c index 9b6ec88db..a52aa120e 100644 --- a/content/fetchers/about.c +++ b/content/fetchers/about.c @@ -320,7 +320,7 @@ static bool fetch_about_config_handler(struct fetch_about_context *ctx) "\n"); do { - res = options_snoptionf(buffer + slen, sizeof buffer - slen, + res = nsoption_snoptionf(buffer + slen, sizeof buffer - slen, opt_loop, "%k%t%V\n"); if (res <= 0) @@ -382,7 +382,7 @@ static bool fetch_about_choices_handler(struct fetch_about_context *ctx) "# Automatically generated current NetSurf browser Choices\n"); do { - res = options_snoptionf(buffer + slen, + res = nsoption_snoptionf(buffer + slen, sizeof buffer - slen, opt_loop, "%k:%v\n"); diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c index dab7d2b93..6b94390d4 100644 --- a/content/fetchers/curl.c +++ b/content/fetchers/curl.c @@ -25,7 +25,7 @@ * * * The CURL handles are cached in the curl_handle_ring. There are at most - * ::option_max_cached_fetch_handles in this ring. + * ::max_cached_fetch_handles in this ring. */ #include @@ -195,7 +195,7 @@ void fetch_curl_register(void) SETOPT(CURLOPT_VERBOSE, 0); } SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer); - if (option_suppress_curl_debug) + if (nsoption_bool(suppress_curl_debug)) SETOPT(CURLOPT_DEBUGFUNCTION, fetch_curl_ignore_debug); SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data); SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header); @@ -208,13 +208,14 @@ void fetch_curl_register(void) SETOPT(CURLOPT_NOSIGNAL, 1L); SETOPT(CURLOPT_CONNECTTIMEOUT, 30L); - if (option_ca_bundle && strcmp(option_ca_bundle, "")) { - LOG(("option_ca_bundle: '%s'", option_ca_bundle)); - SETOPT(CURLOPT_CAINFO, option_ca_bundle); + if (nsoption_charp(ca_bundle) && + strcmp(nsoption_charp(ca_bundle), "")) { + LOG(("ca_bundle: '%s'", nsoption_charp(ca_bundle))); + SETOPT(CURLOPT_CAINFO, nsoption_charp(ca_bundle)); } - if (option_ca_path && strcmp(option_ca_path, "")) { - LOG(("option_ca_path: '%s'", option_ca_path)); - SETOPT(CURLOPT_CAPATH, option_ca_path); + if (nsoption_charp(ca_path) && strcmp(nsoption_charp(ca_path), "")) { + LOG(("ca_path: '%s'", nsoption_charp(ca_path))); + SETOPT(CURLOPT_CAPATH, nsoption_charp(ca_path)); } /* Detect whether the SSL CTX function API works */ @@ -405,20 +406,20 @@ void * fetch_curl_setup(struct fetch *parent_fetch, nsurl *url, * which fails with lighttpd, so disable it (see bug 1429054) */ APPEND(fetch->headers, "Expect:"); - if (option_accept_language != NULL && - option_accept_language[0] != '\0') { + if ((nsoption_charp(accept_language) != NULL) && + (nsoption_charp(accept_language)[0] != '\0')) { char s[80]; snprintf(s, sizeof s, "Accept-Language: %s, *;q=0.1", - option_accept_language); + nsoption_charp(accept_language)); s[sizeof s - 1] = 0; APPEND(fetch->headers, s); } - if (option_accept_charset != NULL && - option_accept_charset[0] != '\0') { + if (nsoption_charp(accept_charset) != NULL && + nsoption_charp(accept_charset)[0] != '\0') { char s[80]; snprintf(s, sizeof s, "Accept-Charset: %s, *;q=0.1", - option_accept_charset); + nsoption_charp(accept_charset)); s[sizeof s - 1] = 0; APPEND(fetch->headers, s); } @@ -525,11 +526,13 @@ void fetch_curl_cache_handle(CURL *handle, lwc_string *host) } /* We do not have a handle cached, first up determine if the cache is full */ RING_GETSIZE(struct cache_handle, curl_handle_ring, c); - if (c >= option_max_cached_fetch_handles) { - /* Cache is full, so, we rotate the ring by one and replace the - * oldest handle with this one. We do this without freeing/allocating - * memory (except the hostname) and without removing the entry from the - * ring and then re-inserting it, in order to be as efficient as we can. + if (c >= nsoption_int(max_cached_fetch_handles)) { + /* Cache is full, so, we rotate the ring by one and + * replace the oldest handle with this one. We do this + * without freeing/allocating memory (except the + * hostname) and without removing the entry from the + * ring and then re-inserting it, in order to be as + * efficient as we can. */ if (curl_handle_ring != NULL) { h = curl_handle_ring; @@ -605,21 +608,22 @@ fetch_curl_set_options(struct curl_fetch_info *f) SETOPT(CURLOPT_USERPWD, NULL); } - if (option_http_proxy && option_http_proxy_host && - strncmp(nsurl_access(f->url), "file:", 5) != 0) { - SETOPT(CURLOPT_PROXY, option_http_proxy_host); - SETOPT(CURLOPT_PROXYPORT, (long) option_http_proxy_port); - if (option_http_proxy_auth != OPTION_HTTP_PROXY_AUTH_NONE) { + if (nsoption_bool(http_proxy) && + (nsoption_charp(http_proxy_host) != NULL) && + (strncmp(nsurl_access(f->url), "file:", 5) != 0)) { + SETOPT(CURLOPT_PROXY, nsoption_charp(http_proxy_host)); + SETOPT(CURLOPT_PROXYPORT, (long) nsoption_int(http_proxy_port)); + if (nsoption_int(http_proxy_auth) != OPTION_HTTP_PROXY_AUTH_NONE) { SETOPT(CURLOPT_PROXYAUTH, - option_http_proxy_auth == + nsoption_int(http_proxy_auth) == OPTION_HTTP_PROXY_AUTH_BASIC ? (long) CURLAUTH_BASIC : (long) CURLAUTH_NTLM); snprintf(fetch_proxy_userpwd, sizeof fetch_proxy_userpwd, "%s:%s", - option_http_proxy_auth_user, - option_http_proxy_auth_pass); + nsoption_charp(http_proxy_auth_user), + nsoption_charp(http_proxy_auth_pass)); SETOPT(CURLOPT_PROXYUSERPWD, fetch_proxy_userpwd); } } else { diff --git a/content/urldb.c b/content/urldb.c index 4d206e720..733875638 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -545,7 +545,9 @@ void urldb_save_search_tree(struct search_node *parent, FILE *fp) unsigned int path_count = 0; char *path, *p, *end; int path_alloc = 64, path_used = 1; - time_t expiry = time(NULL) - (60 * 60 * 24) * option_expire_url; + time_t expiry; + + expiry = time(NULL) - ((60 * 60 * 24) * nsoption_int(expire_url)); if (parent == &empty) return; -- cgit v1.2.3