2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
2007-05-06 10:11:00 +04:00
|
|
|
* Copyright 2007 James Bursa <bursa@users.sourceforge.net>
|
2004-07-27 00:13:45 +04:00
|
|
|
* Copyright 2004 Andrew Timmins <atimmins@blueyonder.co.uk>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-09-11 18:24:02 +04:00
|
|
|
*/
|
|
|
|
|
2008-10-14 03:32:21 +04:00
|
|
|
#include <locale.h>
|
2007-10-31 18:39:55 +03:00
|
|
|
#include <signal.h>
|
2003-11-06 22:41:41 +03:00
|
|
|
#include <stdbool.h>
|
2004-09-27 09:21:00 +04:00
|
|
|
#include <stdio.h>
|
2003-11-06 22:41:41 +03:00
|
|
|
#include <stdlib.h>
|
2010-03-28 16:56:39 +04:00
|
|
|
#include <libwapcaplet/libwapcaplet.h>
|
|
|
|
|
2017-01-21 17:20:55 +03:00
|
|
|
#include "netsurf/inttypes.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "utils/config.h"
|
2014-10-13 18:08:16 +04:00
|
|
|
#include "utils/nsoption.h"
|
|
|
|
#include "utils/corestrings.h"
|
|
|
|
#include "utils/log.h"
|
2018-08-13 18:50:17 +03:00
|
|
|
#include "utils/string.h"
|
2014-10-13 18:08:16 +04:00
|
|
|
#include "utils/utf8.h"
|
|
|
|
#include "utils/messages.h"
|
2011-05-17 01:16:44 +04:00
|
|
|
#include "content/content_factory.h"
|
2014-06-19 21:27:24 +04:00
|
|
|
#include "content/fetchers.h"
|
2010-04-12 00:21:13 +04:00
|
|
|
#include "content/hlcache.h"
|
2011-09-04 10:28:09 +04:00
|
|
|
#include "content/mimesniff.h"
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "content/urldb.h"
|
2016-06-06 16:47:27 +03:00
|
|
|
#include "css/css.h"
|
|
|
|
#include "image/image.h"
|
|
|
|
#include "image/image_cache.h"
|
2014-10-13 18:08:16 +04:00
|
|
|
#include "javascript/js.h"
|
2018-05-10 13:34:26 +03:00
|
|
|
#include "html/html.h"
|
|
|
|
#include "text/textplain.h"
|
2014-10-13 18:08:16 +04:00
|
|
|
|
2016-05-30 19:32:57 +03:00
|
|
|
#include "netsurf/browser_window.h"
|
2014-01-10 18:32:29 +04:00
|
|
|
#include "desktop/system_colour.h"
|
2011-01-20 16:51:41 +03:00
|
|
|
#include "desktop/searchweb.h"
|
2016-05-30 13:23:32 +03:00
|
|
|
#include "netsurf/misc.h"
|
2014-10-16 12:48:09 +04:00
|
|
|
#include "desktop/gui_internal.h"
|
2016-05-30 13:51:10 +03:00
|
|
|
#include "netsurf/netsurf.h"
|
2002-09-11 18:24:02 +04:00
|
|
|
|
2011-09-07 13:15:33 +04:00
|
|
|
/** speculative pre-conversion small image size
|
|
|
|
*
|
|
|
|
* Experimenting by visiting every page from default page in order and
|
|
|
|
* then netsurf homepage
|
|
|
|
*
|
|
|
|
* 0 : Cache hit/miss/speculative miss/fail 604/147/ 0/0 (80%/19%/ 0%/ 0%)
|
|
|
|
* 2048 : Cache hit/miss/speculative miss/fail 622/119/ 17/0 (82%/15%/ 2%/ 0%)
|
|
|
|
* 4096 : Cache hit/miss/speculative miss/fail 656/109/ 25/0 (83%/13%/ 3%/ 0%)
|
|
|
|
* 8192 : Cache hit/miss/speculative miss/fail 648/104/ 40/0 (81%/13%/ 5%/ 0%)
|
|
|
|
* ALL : Cache hit/miss/speculative miss/fail 775/ 0/161/0 (82%/ 0%/17%/ 0%)
|
|
|
|
*/
|
|
|
|
#define SPECULATE_SMALL 4096
|
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
/** the time between image cache clean runs in ms. */
|
2011-09-07 13:15:33 +04:00
|
|
|
#define IMAGE_CACHE_CLEAN_TIME (10 * 1000)
|
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
/** default time between content cache cleans. */
|
2011-09-10 04:55:39 +04:00
|
|
|
#define HL_CACHE_CLEAN_TIME (2 * IMAGE_CACHE_CLEAN_TIME)
|
2011-09-08 16:04:57 +04:00
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
/** ensure there is a minimal amount of memory for source objetcs and
|
|
|
|
* decoded bitmaps.
|
|
|
|
*/
|
|
|
|
#define MINIMUM_MEMORY_CACHE_SIZE (2 * 1024 * 1024)
|
|
|
|
|
2014-11-28 22:17:42 +03:00
|
|
|
/** default minimum object time before object is pushed to backing store. (s) */
|
|
|
|
#define LLCACHE_STORE_MIN_LIFETIME (60 * 30)
|
|
|
|
|
|
|
|
/** default minimum bandwidth for backing store writeout. (byte/s) */
|
|
|
|
#define LLCACHE_STORE_MIN_BANDWIDTH (128 * 1024)
|
|
|
|
|
|
|
|
/** default maximum bandwidth for backing store writeout. (byte/s) */
|
|
|
|
#define LLCACHE_STORE_MAX_BANDWIDTH (1024 * 1024)
|
|
|
|
|
|
|
|
/** default time quantum with which to calculate bandwidth (ms) */
|
|
|
|
#define LLCACHE_STORE_TIME_QUANTUM (100)
|
|
|
|
|
2010-04-28 02:14:52 +04:00
|
|
|
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
|
|
|
|
{
|
2019-05-06 15:04:01 +03:00
|
|
|
NSLOG(netsurf, WARNING, "[%3u] %.*s", str->refcnt,
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
(int)lwc_string_length(str), lwc_string_data(str));
|
2010-04-28 02:14:52 +04:00
|
|
|
}
|
|
|
|
|
2018-08-13 18:50:17 +03:00
|
|
|
/**
|
|
|
|
* Build a "username:password" from components.
|
|
|
|
*
|
|
|
|
* \param[in] username The username component.
|
|
|
|
* \param[in] password The password component.
|
|
|
|
* \param[out] userpass_out Returns combined string on success.
|
|
|
|
* Owned by caller.
|
|
|
|
* \return NSERROR_OK, or appropriate error code.
|
|
|
|
*/
|
|
|
|
static nserror netsurf__build_userpass(
|
|
|
|
const char *username,
|
|
|
|
const char *password,
|
|
|
|
char **userpass_out)
|
|
|
|
{
|
|
|
|
char *userpass;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
len = strlen(username) + 1 + strlen(password) + 1;
|
|
|
|
|
|
|
|
userpass = malloc(len);
|
|
|
|
if (userpass == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(userpass, len, "%s:%s", username, password);
|
|
|
|
|
|
|
|
*userpass_out = userpass;
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unpack a "username:password" to components.
|
|
|
|
*
|
|
|
|
* \param[in] userpass The input string to split.
|
|
|
|
* \param[in] username_out Returns username on success. Owned by caller.
|
|
|
|
* \param[out] password_out Returns password on success. Owned by caller.
|
|
|
|
* \return NSERROR_OK, or appropriate error code.
|
|
|
|
*/
|
|
|
|
static nserror netsurf__unpack_userpass(
|
|
|
|
const char *userpass,
|
|
|
|
char **username_out,
|
|
|
|
char **password_out)
|
|
|
|
{
|
|
|
|
const char *tmp;
|
|
|
|
char *username;
|
|
|
|
char *password;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
if (userpass == NULL) {
|
|
|
|
username = malloc(1);
|
|
|
|
password = malloc(1);
|
|
|
|
if (username == NULL || password == NULL) {
|
2018-08-15 13:11:54 +03:00
|
|
|
free(username);
|
|
|
|
free(password);
|
2018-08-13 18:50:17 +03:00
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
username[0] = '\0';
|
|
|
|
password[0] = '\0';
|
|
|
|
|
|
|
|
*username_out = username;
|
|
|
|
*password_out = password;
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = strchr(userpass, ':');
|
|
|
|
if (tmp == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
} else {
|
|
|
|
size_t len2;
|
|
|
|
len = tmp - userpass;
|
|
|
|
len2 = strlen(++tmp);
|
|
|
|
|
|
|
|
username = malloc(len + 1);
|
|
|
|
password = malloc(len2 + 1);
|
|
|
|
if (username == NULL || password == NULL) {
|
2018-08-15 13:11:54 +03:00
|
|
|
free(username);
|
|
|
|
free(password);
|
2018-08-13 18:50:17 +03:00
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
memcpy(username, userpass, len);
|
|
|
|
username[len] = '\0';
|
|
|
|
memcpy(password, tmp, len2 + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
*username_out = username;
|
|
|
|
*password_out = password;
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contect for login callbacks to front ends.
|
|
|
|
*/
|
|
|
|
struct auth_data {
|
|
|
|
char *realm;
|
|
|
|
nsurl *url;
|
|
|
|
|
|
|
|
llcache_query_response cb;
|
|
|
|
void *pw;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback function passed to front ends for handling logins.
|
|
|
|
*
|
|
|
|
* \param[in] username The username.
|
|
|
|
* \param[in] password The password.
|
|
|
|
* \param[in] cbpw Our context.
|
|
|
|
* \return NSERROR_OK, or appropriate error code.
|
|
|
|
*/
|
|
|
|
static nserror netsurf__handle_login_response(
|
|
|
|
const char *username,
|
|
|
|
const char *password,
|
|
|
|
void *cbpw)
|
|
|
|
{
|
|
|
|
struct auth_data *ctx = cbpw;
|
|
|
|
bool proceed = false;
|
|
|
|
nserror err;
|
|
|
|
|
|
|
|
if (username != NULL && password != NULL) {
|
|
|
|
char *userpass;
|
|
|
|
|
|
|
|
err = netsurf__build_userpass(username, password, &userpass);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
urldb_set_auth_details(ctx->url, ctx->realm, userpass);
|
|
|
|
free(userpass);
|
|
|
|
proceed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = ctx->cb(proceed, ctx->pw);
|
|
|
|
nsurl_unref(ctx->url);
|
|
|
|
free(ctx->realm);
|
|
|
|
free(ctx);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper for getting front end to handle logins.
|
|
|
|
*
|
|
|
|
* \param[in] query Query descriptor
|
|
|
|
* \param[in] pw Private data
|
|
|
|
* \param[in] cb Continuation callback
|
|
|
|
* \param[in] cbpw Private data for continuation
|
|
|
|
* \return NSERROR_OK, or appropriate error code.
|
|
|
|
*/
|
|
|
|
static nserror netsurf__handle_login(const llcache_query *query,
|
|
|
|
void *pw, llcache_query_response cb, void *cbpw)
|
|
|
|
{
|
|
|
|
struct auth_data *ctx;
|
|
|
|
char *username;
|
|
|
|
char *password;
|
|
|
|
nserror err;
|
|
|
|
|
|
|
|
NSLOG(llcache, INFO, "HTTP Auth for: %s: %s",
|
|
|
|
query->data.auth.realm, nsurl_access(query->url));
|
|
|
|
|
|
|
|
ctx = malloc(sizeof(*ctx));
|
|
|
|
if (ctx == NULL) {
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->realm = strdup(query->data.auth.realm);
|
|
|
|
if (ctx->realm == NULL) {
|
|
|
|
free(ctx);
|
|
|
|
return NSERROR_NOMEM;
|
|
|
|
}
|
|
|
|
ctx->url = nsurl_ref(query->url);
|
|
|
|
ctx->cb = cb;
|
|
|
|
ctx->pw = cbpw;
|
|
|
|
|
|
|
|
err = netsurf__unpack_userpass(
|
|
|
|
urldb_get_auth_details(ctx->url, ctx->realm),
|
|
|
|
&username, &password);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
nsurl_unref(ctx->url);
|
|
|
|
free(ctx->realm);
|
|
|
|
free(ctx);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = guit->misc->login(ctx->url, ctx->realm, username, password,
|
|
|
|
netsurf__handle_login_response, ctx);
|
|
|
|
free(username);
|
|
|
|
free(password);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
ctx->cb(false, ctx->pw);
|
|
|
|
nsurl_unref(ctx->url);
|
|
|
|
free(ctx->realm);
|
|
|
|
free(ctx);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2010-04-15 03:03:49 +04:00
|
|
|
/**
|
|
|
|
* Dispatch a low-level cache query to the frontend
|
|
|
|
*
|
|
|
|
* \param query Query descriptor
|
|
|
|
* \param pw Private data
|
|
|
|
* \param cb Continuation callback
|
|
|
|
* \param cbpw Private data for continuation
|
|
|
|
* \return NSERROR_OK
|
|
|
|
*/
|
|
|
|
static nserror netsurf_llcache_query_handler(const llcache_query *query,
|
|
|
|
void *pw, llcache_query_response cb, void *cbpw)
|
|
|
|
{
|
2016-07-31 03:24:57 +03:00
|
|
|
nserror res = NSERROR_OK;
|
|
|
|
|
2010-04-15 03:03:49 +04:00
|
|
|
switch (query->type) {
|
|
|
|
case LLCACHE_QUERY_AUTH:
|
2018-08-13 18:50:17 +03:00
|
|
|
res = netsurf__handle_login(query, pw, cb, cbpw);
|
2010-04-15 03:03:49 +04:00
|
|
|
break;
|
2016-07-31 03:24:57 +03:00
|
|
|
|
2010-04-15 03:03:49 +04:00
|
|
|
case LLCACHE_QUERY_REDIRECT:
|
|
|
|
/** \todo Need redirect query dialog */
|
|
|
|
/* For now, do nothing, as this query type isn't emitted yet */
|
|
|
|
break;
|
2016-07-31 03:24:57 +03:00
|
|
|
|
2010-04-15 03:03:49 +04:00
|
|
|
case LLCACHE_QUERY_SSL:
|
2016-07-31 03:24:57 +03:00
|
|
|
res = guit->misc->cert_verify(query->url, query->data.ssl.certs,
|
2010-04-15 03:03:49 +04:00
|
|
|
query->data.ssl.num, cb, cbpw);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-07-31 03:24:57 +03:00
|
|
|
return res;
|
2010-04-15 03:03:49 +04:00
|
|
|
}
|
|
|
|
|
2016-05-30 13:51:10 +03:00
|
|
|
/* exported interface documented in netsurf/netsurf.h */
|
2015-06-19 18:29:42 +03:00
|
|
|
nserror netsurf_init(const char *store_path)
|
2002-09-11 18:24:02 +04:00
|
|
|
{
|
2014-03-22 18:54:51 +04:00
|
|
|
nserror ret;
|
2011-09-08 16:04:57 +04:00
|
|
|
struct hlcache_parameters hlcache_parameters = {
|
|
|
|
.bg_clean_time = HL_CACHE_CLEAN_TIME,
|
2014-03-22 18:54:51 +04:00
|
|
|
.llcache = {
|
|
|
|
.cb = netsurf_llcache_query_handler,
|
2014-11-28 22:17:42 +03:00
|
|
|
.minimum_lifetime = LLCACHE_STORE_MIN_LIFETIME,
|
|
|
|
.minimum_bandwidth = LLCACHE_STORE_MIN_BANDWIDTH,
|
|
|
|
.maximum_bandwidth = LLCACHE_STORE_MAX_BANDWIDTH,
|
|
|
|
.time_quantum = LLCACHE_STORE_TIME_QUANTUM,
|
2014-03-22 18:54:51 +04:00
|
|
|
}
|
2011-09-08 16:04:57 +04:00
|
|
|
};
|
2011-09-07 13:15:33 +04:00
|
|
|
struct image_cache_parameters image_cache_parameters = {
|
|
|
|
.bg_clean_time = IMAGE_CACHE_CLEAN_TIME,
|
|
|
|
.speculative_small = SPECULATE_SMALL
|
|
|
|
};
|
2011-09-10 04:55:39 +04:00
|
|
|
|
2010-01-31 03:36:02 +03:00
|
|
|
#ifdef HAVE_SIGPIPE
|
2007-10-31 18:39:55 +03:00
|
|
|
/* Ignore SIGPIPE - this is necessary as OpenSSL can generate these
|
|
|
|
* and the default action is to terminate the app. There's no easy
|
|
|
|
* way of determining the cause of the SIGPIPE (other than using
|
|
|
|
* sigaction() and some mechanism for getting the file descriptor
|
|
|
|
* out of libcurl). However, we expect nothing else to generate a
|
2013-05-23 12:29:00 +04:00
|
|
|
* SIGPIPE, anyway, so may as well just ignore them all.
|
|
|
|
*/
|
2007-10-31 18:39:55 +03:00
|
|
|
signal(SIGPIPE, SIG_IGN);
|
2010-01-31 03:36:02 +03:00
|
|
|
#endif
|
2007-10-31 18:39:55 +03:00
|
|
|
|
2012-07-22 18:48:55 +04:00
|
|
|
/* corestrings init */
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = corestrings_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2012-07-22 18:48:55 +04:00
|
|
|
|
2011-09-10 04:55:39 +04:00
|
|
|
/* set up cache limits based on the memory cache size option */
|
2014-03-22 18:54:51 +04:00
|
|
|
hlcache_parameters.llcache.limit = nsoption_int(memory_cache_size);
|
2011-09-10 04:55:39 +04:00
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
if (hlcache_parameters.llcache.limit < MINIMUM_MEMORY_CACHE_SIZE) {
|
|
|
|
hlcache_parameters.llcache.limit = MINIMUM_MEMORY_CACHE_SIZE;
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO,
|
|
|
|
"Setting minimum memory cache size %"PRIsizet,
|
|
|
|
hlcache_parameters.llcache.limit);
|
2011-09-10 04:55:39 +04:00
|
|
|
}
|
|
|
|
|
2015-11-11 00:51:54 +03:00
|
|
|
/* Set up the max attempts made to fetch a timing out resource */
|
|
|
|
hlcache_parameters.llcache.fetch_attempts = nsoption_uint(max_retried_fetches);
|
|
|
|
|
2011-09-10 04:55:39 +04:00
|
|
|
/* image cache is 25% of total memory cache size */
|
2014-03-22 18:54:51 +04:00
|
|
|
image_cache_parameters.limit = (hlcache_parameters.llcache.limit * 25) / 100;
|
2011-09-10 04:55:39 +04:00
|
|
|
|
2013-05-27 03:32:08 +04:00
|
|
|
/* image cache hysteresis is 20% of the image cache size */
|
2011-09-10 04:55:39 +04:00
|
|
|
image_cache_parameters.hysteresis = (image_cache_parameters.limit * 20) / 100;
|
|
|
|
|
|
|
|
/* account for image cache use from total */
|
2014-03-22 18:54:51 +04:00
|
|
|
hlcache_parameters.llcache.limit -= image_cache_parameters.limit;
|
|
|
|
|
|
|
|
/* set backing store target limit */
|
2014-06-09 16:10:56 +04:00
|
|
|
hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size);
|
2014-03-22 18:54:51 +04:00
|
|
|
|
|
|
|
/* set backing store hysterissi to 20% */
|
|
|
|
hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;;
|
|
|
|
|
|
|
|
/* set the path to the backing store */
|
2014-03-23 15:33:32 +04:00
|
|
|
hlcache_parameters.llcache.store.path = store_path;
|
2011-09-10 04:55:39 +04:00
|
|
|
|
2011-09-07 13:15:33 +04:00
|
|
|
/* image handler bitmap cache */
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = image_cache_init(&image_cache_parameters);
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-09-07 13:15:33 +04:00
|
|
|
|
|
|
|
/* content handler initialisation */
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = nscss_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = html_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = image_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = textplain_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-05-07 00:40:09 +04:00
|
|
|
|
2016-09-30 00:37:10 +03:00
|
|
|
setlocale(LC_ALL, "");
|
2010-03-30 00:03:44 +04:00
|
|
|
|
2014-01-19 22:17:32 +04:00
|
|
|
/* initialise the fetchers */
|
2014-06-19 21:27:24 +04:00
|
|
|
ret = fetcher_init();
|
2014-03-22 18:54:51 +04:00
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-03-13 21:26:46 +03:00
|
|
|
|
|
|
|
/* Initialise the hlcache and allow it to init the llcache for us */
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = hlcache_initialise(&hlcache_parameters);
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2010-03-30 00:03:44 +04:00
|
|
|
|
2011-01-30 16:40:47 +03:00
|
|
|
/* Initialize system colours */
|
2014-03-22 18:54:51 +04:00
|
|
|
ret = ns_system_colour_init();
|
|
|
|
if (ret != NSERROR_OK)
|
|
|
|
return ret;
|
2011-01-30 16:40:47 +03:00
|
|
|
|
2012-01-02 01:42:38 +04:00
|
|
|
js_initialise();
|
|
|
|
|
2014-03-22 18:54:51 +04:00
|
|
|
return NSERROR_OK;
|
2002-11-03 12:39:53 +03:00
|
|
|
}
|
|
|
|
|
2010-03-28 16:56:39 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
/**
|
|
|
|
* Clean up components used by gui NetSurf.
|
|
|
|
*/
|
2002-10-15 14:41:12 +04:00
|
|
|
|
2003-11-06 22:41:41 +03:00
|
|
|
void netsurf_exit(void)
|
|
|
|
{
|
2011-03-13 23:20:31 +03:00
|
|
|
hlcache_stop();
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Closing GUI");
|
2016-04-16 00:50:28 +03:00
|
|
|
guit->misc->quit();
|
2012-06-30 00:37:32 +04:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Finalising JavaScript");
|
2012-06-30 00:37:32 +04:00
|
|
|
js_finalise();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Finalising Web Search");
|
2014-05-25 03:57:48 +04:00
|
|
|
search_web_finalise();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Finalising high-level cache");
|
2010-12-16 03:03:57 +03:00
|
|
|
hlcache_finalise();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Closing fetches");
|
2014-06-19 21:27:24 +04:00
|
|
|
fetcher_quit();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
2011-09-07 13:15:33 +04:00
|
|
|
/* dump any remaining cache entries */
|
|
|
|
image_cache_fini();
|
|
|
|
|
2011-09-16 02:47:50 +04:00
|
|
|
/* Clean up after content handlers */
|
2011-05-17 01:16:44 +04:00
|
|
|
content_factory_fini();
|
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Closing utf8");
|
2005-07-11 22:10:10 +04:00
|
|
|
utf8_finalise();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Destroying URLdb");
|
2006-12-09 01:38:46 +03:00
|
|
|
urldb_destroy();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Destroying System colours");
|
2014-01-10 18:32:29 +04:00
|
|
|
ns_system_colour_finalize();
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Destroying Messages");
|
2016-12-11 19:43:48 +03:00
|
|
|
messages_destroy();
|
|
|
|
|
2012-07-22 18:48:55 +04:00
|
|
|
corestrings_fini();
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Remaining lwc strings:");
|
2010-04-28 02:14:52 +04:00
|
|
|
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
|
2011-01-30 16:40:47 +03:00
|
|
|
|
Use coccinelle to change logging macro calls in c files
for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done
@@ expression E; @@
-LOG(E);
+NSLOG(netsurf, INFO, E);
@@ expression E, E1; @@
-LOG(E, E1);
+NSLOG(netsurf, INFO, E, E1);
@@ expression E, E1, E2; @@
-LOG(E, E1, E2);
+NSLOG(netsurf, INFO, E, E1, E2);
@@ expression E, E1, E2, E3; @@
-LOG(E, E1, E2, E3);
+NSLOG(netsurf, INFO, E, E1, E2, E3);
@@ expression E, E1, E2, E3, E4; @@
-LOG(E, E1, E2, E3, E4);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4);
@@ expression E, E1, E2, E3, E4, E5; @@
-LOG(E, E1, E2, E3, E4, E5);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5);
@@ expression E, E1, E2, E3, E4, E5, E6; @@
-LOG(E, E1, E2, E3, E4, E5, E6);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6);
@@ expression E, E1, E2, E3, E4, E5, E6, E7; @@
-LOG(E, E1, E2, E3, E4, E5, E6, E7);
+NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7);
2017-09-06 20:28:12 +03:00
|
|
|
NSLOG(netsurf, INFO, "Exited successfully");
|
2002-09-11 18:24:02 +04:00
|
|
|
}
|