netsurf: branch vince/prstllcache updated. release/3.0-1163-g54e8803
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/54e880371f5eb09c8f1b3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/54e880371f5eb09c8f1b36e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/54e880371f5eb09c8f1b36eaa...
The branch, vince/prstllcache has been updated
via 54e880371f5eb09c8f1b36eaae4f2543253a0bd3 (commit)
via 79a8239ae14b4b0a47612a095d4eb0c9a8de340c (commit)
from 29d6e84b0c7dbf18fb0546bfce2e4e796542cb0a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=54e880371f5eb09c8f1...
commit 54e880371f5eb09c8f1b36eaae4f2543253a0bd3
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
correctly terminate sha1 b64 encoding
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 36bab2f..7c6f961 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -125,7 +125,7 @@ b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
if (b64u == NULL) {
return NULL;
}
- b64u[28] = 0;
+ b64u[27] = 0;
LOG(("b64u len:%d from %d with \"%s\"", b64ulen, NSSHA1_DIGEST_SIZE + 1, b64u));
fname_len = strlen(storestate->params.path) + 31;
fname = calloc(1, fname_len);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=79a8239ae14b4b0a476...
commit 79a8239ae14b4b0a47612a095d4eb0c9a8de340c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
fix sha1 implementation to not corrupt the input data
diff --git a/test/sha1.c b/test/sha1.c
index abfc25b..be31836 100644
--- a/test/sha1.c
+++ b/test/sha1.c
@@ -27,6 +27,11 @@ struct {
{ 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55,
0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }
},
+ {
+ "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ { 0x29, 0xb0, 0xe7, 0x87, 0x82, 0x71, 0x64, 0x5f, 0xff, 0xb7,
+ 0xee, 0xc7, 0xdb, 0x4a, 0x74, 0x73, 0xa1, 0xc0, 0x0b, 0xc1 }
+ },
{ NULL, {0} },
};
diff --git a/utils/sha1.c b/utils/sha1.c
index 882f2b9..e59c8ed 100644
--- a/utils/sha1.c
+++ b/utils/sha1.c
@@ -122,13 +122,16 @@ struct nssha1_ctx {
static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
{
uint32_t a, b, c, d, e;
+
typedef union {
uint8_t c[64];
uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
- block = (CHAR64LONG16*)buffer;
+ static uint8_t workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
/* Copy context->state[] to working vars */
a = state[0];
-----------------------------------------------------------------------
Summary of changes:
gtk/llcache.c | 2 +-
test/sha1.c | 5 +++++
utils/sha1.c | 5 ++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 36bab2f..7c6f961 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -125,7 +125,7 @@ b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
if (b64u == NULL) {
return NULL;
}
- b64u[28] = 0;
+ b64u[27] = 0;
LOG(("b64u len:%d from %d with \"%s\"", b64ulen, NSSHA1_DIGEST_SIZE + 1, b64u));
fname_len = strlen(storestate->params.path) + 31;
fname = calloc(1, fname_len);
diff --git a/test/sha1.c b/test/sha1.c
index abfc25b..be31836 100644
--- a/test/sha1.c
+++ b/test/sha1.c
@@ -27,6 +27,11 @@ struct {
{ 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55,
0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }
},
+ {
+ "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
+ { 0x29, 0xb0, 0xe7, 0x87, 0x82, 0x71, 0x64, 0x5f, 0xff, 0xb7,
+ 0xee, 0xc7, 0xdb, 0x4a, 0x74, 0x73, 0xa1, 0xc0, 0x0b, 0xc1 }
+ },
{ NULL, {0} },
};
diff --git a/utils/sha1.c b/utils/sha1.c
index 882f2b9..e59c8ed 100644
--- a/utils/sha1.c
+++ b/utils/sha1.c
@@ -122,13 +122,16 @@ struct nssha1_ctx {
static void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64])
{
uint32_t a, b, c, d, e;
+
typedef union {
uint8_t c[64];
uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
- block = (CHAR64LONG16*)buffer;
+ static uint8_t workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
/* Copy context->state[] to working vars */
a = state[0];
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1161-g29d6e84
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/29d6e84b0c7dbf18fb054...
...commit http://git.netsurf-browser.org/netsurf.git/commit/29d6e84b0c7dbf18fb0546b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/29d6e84b0c7dbf18fb0546bfc...
The branch, vince/prstllcache has been updated
via 29d6e84b0c7dbf18fb0546bfce2e4e796542cb0a (commit)
from 3366b449a0e072f4e526e7221196dd46fda70689 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=29d6e84b0c7dbf18fb0...
commit 29d6e84b0c7dbf18fb0546bfce2e4e796542cb0a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
only try and cache http and https urls
diff --git a/content/llcache.c b/content/llcache.c
index 68e4b01..e2ef166 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1579,23 +1579,44 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
nserror error;
llcache_object *obj;
nsurl *defragmented_url;
+ bool uncachable = false;
LLCACHE_LOG(("Retrieve %s (%x, %s, %p)", nsurl_access(url), flags,
referer==NULL?"":nsurl_access(referer), post));
- /**
- * Caching Rules:
- *
- * 1) Forced fetches are never cached
- * 2) POST requests are never cached
- */
/* Get rid of any url fragment */
error = nsurl_defragment(url, &defragmented_url);
if (error != NSERROR_OK)
return error;
- if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
+ /* determine if content is cachable */
+ if ((flags & LLCACHE_RETRIEVE_FORCE_FETCH) != 0) {
+ /* Forced fetches are never cached */
+ uncachable = true;
+ } else if (post != NULL) {
+ /* POST requests are never cached */
+ uncachable = true;
+ } else {
+ /* only http and https schemes are cached */
+ lwc_string *scheme;
+ bool match;
+
+ scheme = nsurl_get_component(defragmented_url, NSURL_SCHEME);
+
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_http,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_https,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ uncachable = true;
+ }
+ }
+ }
+
+
+ if (uncachable) {
/* Create new object */
error = llcache_object_new(defragmented_url, &obj);
if (error != NSERROR_OK) {
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 35 ++++++++++++++++++++++++++++-------
1 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 68e4b01..e2ef166 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1579,23 +1579,44 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
nserror error;
llcache_object *obj;
nsurl *defragmented_url;
+ bool uncachable = false;
LLCACHE_LOG(("Retrieve %s (%x, %s, %p)", nsurl_access(url), flags,
referer==NULL?"":nsurl_access(referer), post));
- /**
- * Caching Rules:
- *
- * 1) Forced fetches are never cached
- * 2) POST requests are never cached
- */
/* Get rid of any url fragment */
error = nsurl_defragment(url, &defragmented_url);
if (error != NSERROR_OK)
return error;
- if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
+ /* determine if content is cachable */
+ if ((flags & LLCACHE_RETRIEVE_FORCE_FETCH) != 0) {
+ /* Forced fetches are never cached */
+ uncachable = true;
+ } else if (post != NULL) {
+ /* POST requests are never cached */
+ uncachable = true;
+ } else {
+ /* only http and https schemes are cached */
+ lwc_string *scheme;
+ bool match;
+
+ scheme = nsurl_get_component(defragmented_url, NSURL_SCHEME);
+
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_http,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ if (lwc_string_caseless_isequal(scheme, corestring_lwc_https,
+ &match) == lwc_error_ok &&
+ (match == false)) {
+ uncachable = true;
+ }
+ }
+ }
+
+
+ if (uncachable) {
/* Create new object */
error = llcache_object_new(defragmented_url, &obj);
if (error != NSERROR_OK) {
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1160-g3366b44
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/3366b449a0e072f4e526e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/3366b449a0e072f4e526e72...
...tree http://git.netsurf-browser.org/netsurf.git/tree/3366b449a0e072f4e526e7221...
The branch, vince/prstllcache has been updated
via 3366b449a0e072f4e526e7221196dd46fda70689 (commit)
via 4b9e820eb1d86d7ca8c86a8b704718b06e71c0dc (commit)
from cde16b57cc0335347baa294e8bc305da6b556304 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3366b449a0e072f4e52...
commit 3366b449a0e072f4e526e7221196dd46fda70689
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
remove unecessary caching of if a url has a query element
diff --git a/content/llcache.c b/content/llcache.c
index e0dd69f..68e4b01 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -174,7 +174,6 @@ struct llcache_object {
llcache_object *next; /**< Next in list */
nsurl *url; /**< Post-redirect URL for object */
- bool has_query; /**< URL has a query segment */
/** \todo We need a generic dynamic buffer object */
uint8_t *source_data; /**< Source data for object */
@@ -1579,7 +1578,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
{
nserror error;
llcache_object *obj;
- bool has_query;
nsurl *defragmented_url;
LLCACHE_LOG(("Retrieve %s (%x, %s, %p)", nsurl_access(url), flags,
@@ -1592,9 +1590,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
* 2) POST requests are never cached
*/
- /* Look for a query segment */
- has_query = nsurl_has_component(url, NSURL_QUERY);
-
/* Get rid of any url fragment */
error = nsurl_defragment(url, &defragmented_url);
if (error != NSERROR_OK)
@@ -1630,8 +1625,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
/* Returned object is already in the cached list */
}
- obj->has_query = has_query;
-
LLCACHE_LOG(("Retrieved %p", obj));
*result = obj;
@@ -2295,7 +2288,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
long http_code = fetch_http_code(object->fetch.fetch);
if ((http_code != 200 && http_code != 203) ||
- (object->has_query &&
+ (nsurl_has_component(object->url, NSURL_QUERY) &&
(object->cache.max_age == INVALID_AGE &&
object->cache.expires == 0))) {
/* Invalidate cache control data */
@@ -2715,8 +2708,6 @@ llcache_object_snapshot(llcache_object *object, llcache_object **snapshot)
if (error != NSERROR_OK)
return error;
- newobj->has_query = object->has_query;
-
newobj->source_alloc = newobj->source_len = object->source_len;
if (object->source_len > 0) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4b9e820eb1d86d7ca8c...
commit 4b9e820eb1d86d7ca8c86a8b704718b06e71c0dc
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fix dumb const bug
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 481b666..c99b0d3 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1913,8 +1913,9 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
/* check for source url having no fragment already */
if (url->components.fragment == NULL) {
- url->count++;
- *no_frag = url;
+ *no_frag = (nsurl *)url;
+
+ (*no_frag)->count++;
return NSERROR_OK;
}
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 11 +----------
utils/nsurl.c | 5 +++--
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index e0dd69f..68e4b01 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -174,7 +174,6 @@ struct llcache_object {
llcache_object *next; /**< Next in list */
nsurl *url; /**< Post-redirect URL for object */
- bool has_query; /**< URL has a query segment */
/** \todo We need a generic dynamic buffer object */
uint8_t *source_data; /**< Source data for object */
@@ -1579,7 +1578,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
{
nserror error;
llcache_object *obj;
- bool has_query;
nsurl *defragmented_url;
LLCACHE_LOG(("Retrieve %s (%x, %s, %p)", nsurl_access(url), flags,
@@ -1592,9 +1590,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
* 2) POST requests are never cached
*/
- /* Look for a query segment */
- has_query = nsurl_has_component(url, NSURL_QUERY);
-
/* Get rid of any url fragment */
error = nsurl_defragment(url, &defragmented_url);
if (error != NSERROR_OK)
@@ -1630,8 +1625,6 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
/* Returned object is already in the cached list */
}
- obj->has_query = has_query;
-
LLCACHE_LOG(("Retrieved %p", obj));
*result = obj;
@@ -2295,7 +2288,7 @@ static void llcache_fetch_callback(const fetch_msg *msg, void *p)
long http_code = fetch_http_code(object->fetch.fetch);
if ((http_code != 200 && http_code != 203) ||
- (object->has_query &&
+ (nsurl_has_component(object->url, NSURL_QUERY) &&
(object->cache.max_age == INVALID_AGE &&
object->cache.expires == 0))) {
/* Invalidate cache control data */
@@ -2715,8 +2708,6 @@ llcache_object_snapshot(llcache_object *object, llcache_object **snapshot)
if (error != NSERROR_OK)
return error;
- newobj->has_query = object->has_query;
-
newobj->source_alloc = newobj->source_len = object->source_len;
if (object->source_len > 0) {
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 481b666..c99b0d3 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1913,8 +1913,9 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
/* check for source url having no fragment already */
if (url->components.fragment == NULL) {
- url->count++;
- *no_frag = url;
+ *no_frag = (nsurl *)url;
+
+ (*no_frag)->count++;
return NSERROR_OK;
}
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1158-gcde16b5
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/cde16b57cc0335347baa2...
...commit http://git.netsurf-browser.org/netsurf.git/commit/cde16b57cc0335347baa294...
...tree http://git.netsurf-browser.org/netsurf.git/tree/cde16b57cc0335347baa294e8...
The branch, vince/prstllcache has been updated
via cde16b57cc0335347baa294e8bc305da6b556304 (commit)
from 35e021cbcfd3f77c109c3f4763358509f3524e4b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cde16b57cc0335347ba...
commit cde16b57cc0335347baa294e8bc305da6b556304
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
make nsurl_defragment() API more obvious and remove duplicated parameter checking
diff --git a/content/llcache.c b/content/llcache.c
index f69b7ab..e0dd69f 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1596,13 +1596,9 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
has_query = nsurl_has_component(url, NSURL_QUERY);
/* Get rid of any url fragment */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- error = nsurl_defragment(url, &defragmented_url);
- if (error != NSERROR_OK)
- return error;
- } else {
- defragmented_url = nsurl_ref(url);
- }
+ error = nsurl_defragment(url, &defragmented_url);
+ if (error != NSERROR_OK)
+ return error;
if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
/* Create new object */
diff --git a/content/urldb.c b/content/urldb.c
index f55a1c2..1e17ac5 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1806,14 +1806,9 @@ struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
free(path_query);
if (d && !d->url) {
- /* Insert URL */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- nserror err = nsurl_defragment(url, &d->url);
- if (err != NSERROR_OK)
- return NULL;
- } else {
- d->url = nsurl_ref(url);
- }
+ /* Insert defragmented URL */
+ if (nsurl_defragment(url, &d->url) != NSERROR_OK)
+ return NULL;
}
return d;
@@ -2728,12 +2723,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
assert(url && header);
/* Get defragmented URL, as 'urlt' */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- if (nsurl_defragment(url, &urlt) != NSERROR_OK)
- return NULL;
- } else {
- urlt = nsurl_ref(url);
- }
+ if (nsurl_defragment(url, &urlt) != NSERROR_OK)
+ return NULL;
scheme = nsurl_get_component(url, NSURL_SCHEME);
if (scheme == NULL) {
diff --git a/utils/nsurl.c b/utils/nsurl.c
index ae0c482..481b666 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1911,6 +1911,14 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
size_t length;
char *pos;
+ /* check for source url having no fragment already */
+ if (url->components.fragment == NULL) {
+ url->count++;
+ *no_frag = url;
+
+ return NSERROR_OK;
+ }
+
/* Find the change in length from url to new_url */
length = url->length;
if (url->components.fragment != NULL) {
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 10 +++-------
content/urldb.c | 19 +++++--------------
utils/nsurl.c | 8 ++++++++
3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index f69b7ab..e0dd69f 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -1596,13 +1596,9 @@ static nserror llcache_object_retrieve(nsurl *url, uint32_t flags,
has_query = nsurl_has_component(url, NSURL_QUERY);
/* Get rid of any url fragment */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- error = nsurl_defragment(url, &defragmented_url);
- if (error != NSERROR_OK)
- return error;
- } else {
- defragmented_url = nsurl_ref(url);
- }
+ error = nsurl_defragment(url, &defragmented_url);
+ if (error != NSERROR_OK)
+ return error;
if (flags & LLCACHE_RETRIEVE_FORCE_FETCH || post != NULL) {
/* Create new object */
diff --git a/content/urldb.c b/content/urldb.c
index f55a1c2..1e17ac5 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1806,14 +1806,9 @@ struct path_data *urldb_add_path(lwc_string *scheme, unsigned int port,
free(path_query);
if (d && !d->url) {
- /* Insert URL */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- nserror err = nsurl_defragment(url, &d->url);
- if (err != NSERROR_OK)
- return NULL;
- } else {
- d->url = nsurl_ref(url);
- }
+ /* Insert defragmented URL */
+ if (nsurl_defragment(url, &d->url) != NSERROR_OK)
+ return NULL;
}
return d;
@@ -2728,12 +2723,8 @@ bool urldb_set_cookie(const char *header, nsurl *url, nsurl *referer)
assert(url && header);
/* Get defragmented URL, as 'urlt' */
- if (nsurl_has_component(url, NSURL_FRAGMENT)) {
- if (nsurl_defragment(url, &urlt) != NSERROR_OK)
- return NULL;
- } else {
- urlt = nsurl_ref(url);
- }
+ if (nsurl_defragment(url, &urlt) != NSERROR_OK)
+ return NULL;
scheme = nsurl_get_component(url, NSURL_SCHEME);
if (scheme == NULL) {
diff --git a/utils/nsurl.c b/utils/nsurl.c
index ae0c482..481b666 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -1911,6 +1911,14 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
size_t length;
char *pos;
+ /* check for source url having no fragment already */
+ if (url->components.fragment == NULL) {
+ url->count++;
+ *no_frag = url;
+
+ return NSERROR_OK;
+ }
+
/* Find the change in length from url to new_url */
length = url->length;
if (url->components.fragment != NULL) {
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1157-g35e021c
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/35e021cbcfd3f77c109c3...
...commit http://git.netsurf-browser.org/netsurf.git/commit/35e021cbcfd3f77c109c3f4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/35e021cbcfd3f77c109c3f476...
The branch, vince/prstllcache has been updated
via 35e021cbcfd3f77c109c3f4763358509f3524e4b (commit)
from 14ba9ded1d692add1a092bd2e446d5340674cde8 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=35e021cbcfd3f77c109...
commit 35e021cbcfd3f77c109c3f4763358509f3524e4b
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
fixup sha hashing
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 29ae6c1..1f5bc59 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -127,7 +127,7 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
.llcache = {
.cb = netsurf_llcache_query_handler,
.store = {
- .hashsize = 23,
+ .hashsize = 160,
}
}
};
diff --git a/gtk/llcache.c b/gtk/llcache.c
index f735d79..36bab2f 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -28,6 +28,7 @@
#include "utils/nsurl.h"
#include "utils/log.h"
#include "utils/utils.h"
+#include "utils/sha1.h"
#include "desktop/gui.h"
#include "content/llcache_private.h"
@@ -98,18 +99,58 @@ base64url_encode(const char *data,
/**
* create filename from url and flags
*
- * filename from 160bit sha1 and a bit from the from flags base64 encoded
+ * This uses 160bit sha1 and a bit from the from flags which is then
+ * base64 encoded. This yeilds a 28 character base64 encoded string
+ * (168 bits is minimum byte representation of 161 bits) where the
+ * last character can be discarded (27*6 is 162 bits)
*/
static char *
b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
{
- return NULL;
+ uint8_t hash[NSSHA1_DIGEST_SIZE + 1];
+ int fname_len;
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+
+ NSSHA1((uint8_t *)nsurl_access(url), nsurl_length(url), hash);
+
+ if ((flags & LLCACHE_STORE_META) != 0) {
+ hash[NSSHA1_DIGEST_SIZE] = 0xff;
+ } else {
+ hash[NSSHA1_DIGEST_SIZE] = 0;
+ }
+
+ b64u = base64url_encode((char *)hash, NSSHA1_DIGEST_SIZE + 1, &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+ b64u[28] = 0;
+ LOG(("b64u len:%d from %d with \"%s\"", b64ulen, NSSHA1_DIGEST_SIZE + 1, b64u));
+ fname_len = strlen(storestate->params.path) + 31;
+ fname = calloc(1, fname_len);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ snprintf(fname,
+ fname_len,
+ "%s/%c%c/%s",
+ storestate->params.path,
+ b64u[0], b64u[1], b64u + 2 );
+ free(b64u);
+
+ return fname;
}
/**
- * create filename from url and flags
+ * Create filename from url and flags
*
- * hashing 23bits from the url hash and one bit from the flags base64 encoded
+ * This uses 17bits from the fnv url hash and one bit from the
+ * flags. Yeilding data in 3 bytes which is base64 encoded, the fourth
+ * character (last 6 bits) of the base 64 encoding is not used as it is
+ * empty.
*/
static char *
b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
@@ -125,10 +166,10 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
hashp = (char *)&hash;
- hashp[2] = hashp[2] & 0xfe;
+ hashp[2] = hashp[2] & 0x80;
if ((flags & LLCACHE_STORE_META) != 0) {
- hashp[2] = hashp[2] | 1;
+ hashp[2] = hashp[2] | 0x40;
}
b64u = base64url_encode(hashp, 3, &b64ulen);
@@ -136,7 +177,7 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
return NULL;
}
- fname_len = strlen(storestate->params.path) + b64ulen + 5;
+ fname_len = strlen(storestate->params.path) + 7;
fname = calloc(1, fname_len);
if (fname == NULL) {
free(b64u);
@@ -145,9 +186,9 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
snprintf(fname,
fname_len,
- "%s/%c/%c/%c/%c",
+ "%s/%c/%c/%c",
storestate->params.path,
- b64u[0], b64u[1], b64u[2], b64u[3]);
+ b64u[0], b64u[1], b64u[2]);
free(b64u);
return fname;
-----------------------------------------------------------------------
Summary of changes:
desktop/netsurf.c | 2 +-
gtk/llcache.c | 59 ++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index 29ae6c1..1f5bc59 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -127,7 +127,7 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
.llcache = {
.cb = netsurf_llcache_query_handler,
.store = {
- .hashsize = 23,
+ .hashsize = 160,
}
}
};
diff --git a/gtk/llcache.c b/gtk/llcache.c
index f735d79..36bab2f 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -28,6 +28,7 @@
#include "utils/nsurl.h"
#include "utils/log.h"
#include "utils/utils.h"
+#include "utils/sha1.h"
#include "desktop/gui.h"
#include "content/llcache_private.h"
@@ -98,18 +99,58 @@ base64url_encode(const char *data,
/**
* create filename from url and flags
*
- * filename from 160bit sha1 and a bit from the from flags base64 encoded
+ * This uses 160bit sha1 and a bit from the from flags which is then
+ * base64 encoded. This yeilds a 28 character base64 encoded string
+ * (168 bits is minimum byte representation of 161 bits) where the
+ * last character can be discarded (27*6 is 162 bits)
*/
static char *
b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
{
- return NULL;
+ uint8_t hash[NSSHA1_DIGEST_SIZE + 1];
+ int fname_len;
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+
+ NSSHA1((uint8_t *)nsurl_access(url), nsurl_length(url), hash);
+
+ if ((flags & LLCACHE_STORE_META) != 0) {
+ hash[NSSHA1_DIGEST_SIZE] = 0xff;
+ } else {
+ hash[NSSHA1_DIGEST_SIZE] = 0;
+ }
+
+ b64u = base64url_encode((char *)hash, NSSHA1_DIGEST_SIZE + 1, &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+ b64u[28] = 0;
+ LOG(("b64u len:%d from %d with \"%s\"", b64ulen, NSSHA1_DIGEST_SIZE + 1, b64u));
+ fname_len = strlen(storestate->params.path) + 31;
+ fname = calloc(1, fname_len);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ snprintf(fname,
+ fname_len,
+ "%s/%c%c/%s",
+ storestate->params.path,
+ b64u[0], b64u[1], b64u + 2 );
+ free(b64u);
+
+ return fname;
}
/**
- * create filename from url and flags
+ * Create filename from url and flags
*
- * hashing 23bits from the url hash and one bit from the flags base64 encoded
+ * This uses 17bits from the fnv url hash and one bit from the
+ * flags. Yeilding data in 3 bytes which is base64 encoded, the fourth
+ * character (last 6 bits) of the base 64 encoding is not used as it is
+ * empty.
*/
static char *
b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
@@ -125,10 +166,10 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
hashp = (char *)&hash;
- hashp[2] = hashp[2] & 0xfe;
+ hashp[2] = hashp[2] & 0x80;
if ((flags & LLCACHE_STORE_META) != 0) {
- hashp[2] = hashp[2] | 1;
+ hashp[2] = hashp[2] | 0x40;
}
b64u = base64url_encode(hashp, 3, &b64ulen);
@@ -136,7 +177,7 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
return NULL;
}
- fname_len = strlen(storestate->params.path) + b64ulen + 5;
+ fname_len = strlen(storestate->params.path) + 7;
fname = calloc(1, fname_len);
if (fname == NULL) {
free(b64u);
@@ -145,9 +186,9 @@ b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
snprintf(fname,
fname_len,
- "%s/%c/%c/%c/%c",
+ "%s/%c/%c/%c",
storestate->params.path,
- b64u[0], b64u[1], b64u[2], b64u[3]);
+ b64u[0], b64u[1], b64u[2]);
free(b64u);
return fname;
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1156-g14ba9de
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/14ba9ded1d692add1a092...
...commit http://git.netsurf-browser.org/netsurf.git/commit/14ba9ded1d692add1a092bd...
...tree http://git.netsurf-browser.org/netsurf.git/tree/14ba9ded1d692add1a092bd2e...
The branch, vince/prstllcache has been updated
via 14ba9ded1d692add1a092bd2e446d5340674cde8 (commit)
from 05353864f59bbb7874b4b5cc16e32160c7035acf (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=14ba9ded1d692add1a0...
commit 14ba9ded1d692add1a092bd2e446d5340674cde8
Author: Vincent Sanders <vince(a)netsurf-browser.org>
Commit: Vincent Sanders <vince(a)netsurf-browser.org>
ensure path to cache files exists
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 7b91cd4..f735d79 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -103,6 +103,7 @@ base64url_encode(const char *data,
static char *
b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
{
+ return NULL;
}
/**
@@ -247,6 +248,64 @@ finalise(void)
return NSERROR_OK;
}
+/* ensure that all directory elements needed to store a filename exist */
+static nserror mkfilepath(const char *fname)
+{
+ char *dname;
+ char *sep;
+ struct stat sb;
+
+ dname = strdup(fname);
+
+ sep = strrchr(dname, '/');
+ if (sep == NULL) {
+ /* no directory separator path is just filename so its ok */
+ free(dname);
+ return NSERROR_OK;
+ }
+
+ *sep = 0; /* null terminate directory path */
+
+ if (stat(dname, &sb) == 0) {
+ free(dname);
+ if (S_ISDIR(sb.st_mode)) {
+ /* path to file exists and is a directory */
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_FOUND;
+ }
+ *sep = '/'; /* restore separator */
+
+ sep = dname;
+ while (*sep == '/') {
+ sep++;
+ }
+ while ((sep = strchr(sep, '/')) != NULL) {
+ *sep = 0;
+ if (stat(dname, &sb) != 0) {
+ if (mkdir(dname, 0700) != 0) {
+ /* could not create path element */
+ free(dname);
+ return NSERROR_NOT_FOUND;
+ }
+ } else {
+ if (! S_ISDIR(sb.st_mode)) {
+ /* path element not a directory */
+ free(dname);
+ return NSERROR_NOT_FOUND;
+ }
+ }
+ *sep = '/'; /* restore separator */
+ /* skip directory separators */
+ while (*sep == '/') {
+ sep++;
+ }
+ }
+
+ free(dname);
+ return NSERROR_OK;
+}
+
/**
* Place a source object and its metadata in the backing store.
*
@@ -264,6 +323,7 @@ store(nsurl *url,
{
char *fname;
FILE *file;
+ nserror ret;
LOG(("Writing object for url:%s", nsurl_access(url)));
fname = storestate->store_fname(url, flags);
@@ -271,6 +331,14 @@ store(nsurl *url,
return NSERROR_NOMEM;
}
+ /* ensure path to file is usable */
+ ret = mkfilepath(fname);
+ if (ret != NSERROR_OK) {
+ LOG(("file path \"%s\" could not be created", fname));
+ free(fname);
+ return ret;
+ }
+
LOG(("Opening data file %s", fname));
file = fopen(fname, "wb");
free(fname);
-----------------------------------------------------------------------
Summary of changes:
gtk/llcache.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 7b91cd4..f735d79 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -103,6 +103,7 @@ base64url_encode(const char *data,
static char *
b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
{
+ return NULL;
}
/**
@@ -247,6 +248,64 @@ finalise(void)
return NSERROR_OK;
}
+/* ensure that all directory elements needed to store a filename exist */
+static nserror mkfilepath(const char *fname)
+{
+ char *dname;
+ char *sep;
+ struct stat sb;
+
+ dname = strdup(fname);
+
+ sep = strrchr(dname, '/');
+ if (sep == NULL) {
+ /* no directory separator path is just filename so its ok */
+ free(dname);
+ return NSERROR_OK;
+ }
+
+ *sep = 0; /* null terminate directory path */
+
+ if (stat(dname, &sb) == 0) {
+ free(dname);
+ if (S_ISDIR(sb.st_mode)) {
+ /* path to file exists and is a directory */
+ return NSERROR_OK;
+ }
+ return NSERROR_NOT_FOUND;
+ }
+ *sep = '/'; /* restore separator */
+
+ sep = dname;
+ while (*sep == '/') {
+ sep++;
+ }
+ while ((sep = strchr(sep, '/')) != NULL) {
+ *sep = 0;
+ if (stat(dname, &sb) != 0) {
+ if (mkdir(dname, 0700) != 0) {
+ /* could not create path element */
+ free(dname);
+ return NSERROR_NOT_FOUND;
+ }
+ } else {
+ if (! S_ISDIR(sb.st_mode)) {
+ /* path element not a directory */
+ free(dname);
+ return NSERROR_NOT_FOUND;
+ }
+ }
+ *sep = '/'; /* restore separator */
+ /* skip directory separators */
+ while (*sep == '/') {
+ sep++;
+ }
+ }
+
+ free(dname);
+ return NSERROR_OK;
+}
+
/**
* Place a source object and its metadata in the backing store.
*
@@ -264,6 +323,7 @@ store(nsurl *url,
{
char *fname;
FILE *file;
+ nserror ret;
LOG(("Writing object for url:%s", nsurl_access(url)));
fname = storestate->store_fname(url, flags);
@@ -271,6 +331,14 @@ store(nsurl *url,
return NSERROR_NOMEM;
}
+ /* ensure path to file is usable */
+ ret = mkfilepath(fname);
+ if (ret != NSERROR_OK) {
+ LOG(("file path \"%s\" could not be created", fname));
+ free(fname);
+ return ret;
+ }
+
LOG(("Opening data file %s", fname));
file = fopen(fname, "wb");
free(fname);
--
NetSurf Browser
8 years, 11 months
netsurf: branch vince/prstllcache updated. release/3.0-1155-g0535386
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/05353864f59bbb7874b4b...
...commit http://git.netsurf-browser.org/netsurf.git/commit/05353864f59bbb7874b4b5c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/05353864f59bbb7874b4b5cc1...
The branch, vince/prstllcache has been updated
via 05353864f59bbb7874b4b5cc16e32160c7035acf (commit)
from b498375e044f596dde651bb22a1677bb93a92149 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=05353864f59bbb7874b...
commit 05353864f59bbb7874b4b5cc16e32160c7035acf
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
improve gtk backing store
diff --git a/content/llcache.c b/content/llcache.c
index 36e3bb9..f69b7ab 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2207,7 +2207,7 @@ static void llcache_persist(void *p)
{
nserror ret;
size_t size_written;
- size_t total_written;
+ size_t total_written = 0;
struct llcache_object **lst;
int lst_count;
int idx;
diff --git a/content/llcache.h b/content/llcache.h
index 854f54f..e562083 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -165,9 +165,11 @@ struct llcache_store_parameters {
size_t limit; /**< The backing store upper bound target size */
size_t hysteresis; /**< The hysteresis around the target size */
- /** length of hash to use for filename mapping. 0 indicates
- * use no hash. 23 is a reasonable compromise for RISC OS. 160
- * uses sha1 in a manner similar to git.
+ /** number of bits to use for hash in filename mapping.
+ *
+ * 0 indicates use no hash. (variable length filenames)
+ * 23 is a reasonable compromise for RISC OS.
+ * 160 uses sha1 in a manner similar to git.
*/
int hashsize;
};
diff --git a/content/llcache_private.h b/content/llcache_private.h
index a946249..38a2e15 100644
--- a/content/llcache_private.h
+++ b/content/llcache_private.h
@@ -83,10 +83,13 @@ struct gui_llcache_table {
uint8_t **data, size_t *datalen);
/**
- * invalidate a source object from the backing store.
+ * Invalidate a source object from the backing store.
*
* The entry (if present in the backing store) must no longer
* be returned as a result to the fetch or meta operations.
+ *
+ * @param url The url is used as the unique primary key to invalidate.
+ * @return NSERROR_OK on success or error code on faliure.
*/
nserror (*invalidate)(struct nsurl *url);
};
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index a4b4da2..29ae6c1 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -126,6 +126,9 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
.bg_clean_time = HL_CACHE_CLEAN_TIME,
.llcache = {
.cb = netsurf_llcache_query_handler,
+ .store = {
+ .hashsize = 23,
+ }
}
};
struct image_cache_parameters image_cache_parameters = {
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 06067e5..7b91cd4 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -22,6 +22,8 @@
#include <unistd.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "utils/nsurl.h"
#include "utils/log.h"
@@ -31,6 +33,17 @@
#include "gtk/llcache.h"
+struct llcache_store_state {
+ /** parameters controlling the backing store */
+ struct llcache_store_parameters params;
+
+ /** key to filename conversion */
+ char *(*store_fname)(nsurl *url, enum llcache_store_flags flags);
+};
+
+struct llcache_store_state *storestate;
+
+
static uint8_t encoding_table[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
@@ -82,12 +95,108 @@ base64url_encode(const char *data,
return encoded_data;
}
-struct llcache_store_state {
- /** parameters controlling the backing store */
- struct llcache_store_parameters params;
-};
+/**
+ * create filename from url and flags
+ *
+ * filename from 160bit sha1 and a bit from the from flags base64 encoded
+ */
+static char *
+b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
+{
+}
-struct llcache_store_state *storestate;
+/**
+ * create filename from url and flags
+ *
+ * hashing 23bits from the url hash and one bit from the flags base64 encoded
+ */
+static char *
+b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
+{
+ uint32_t hash;
+ char *hashp;
+ int fname_len;
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+
+ hash = nsurl_hash(url);
+
+ hashp = (char *)&hash;
+
+ hashp[2] = hashp[2] & 0xfe;
+
+ if ((flags & LLCACHE_STORE_META) != 0) {
+ hashp[2] = hashp[2] | 1;
+ }
+
+ b64u = base64url_encode(hashp, 3, &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+
+ fname_len = strlen(storestate->params.path) + b64ulen + 5;
+ fname = calloc(1, fname_len);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ snprintf(fname,
+ fname_len,
+ "%s/%c/%c/%c/%c",
+ storestate->params.path,
+ b64u[0], b64u[1], b64u[2], b64u[3]);
+ free(b64u);
+
+ return fname;
+}
+
+/**
+ * create filename from url and flags
+ *
+ * no hashing, just base64 encode the url
+ */
+static char *
+b64_store_fname(nsurl *url, enum llcache_store_flags flags)
+{
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+ char sep;
+
+ b64u = base64url_encode(nsurl_access(url),
+ strlen(nsurl_access(url)),
+ &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+
+ fname = malloc(strlen(storestate->params.path) +
+ SLEN("/x") + b64ulen + 1);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ if ((flags & LLCACHE_STORE_META) == 0) {
+ sep ='d';
+ } else {
+ sep ='i';
+ }
+
+ snprintf(fname,
+ (strlen(storestate->params.path) + SLEN("/x") + b64ulen + 1),
+ "%s/%s%c",
+ storestate->params.path,
+ b64u,
+ sep);
+ free(b64u);
+
+ return fname;
+}
+
+/* backing store implementation */
/**
* Initialise the backing store.
@@ -98,9 +207,11 @@ struct llcache_store_state *storestate;
static nserror
initialise(const struct llcache_store_parameters *parameters)
{
+ /* check backing store is not already initialised */
if (storestate != NULL) {
return NSERROR_INIT_FAILED;
}
+
storestate = calloc(1, sizeof(struct llcache_store_state));
if (storestate == NULL) {
return NSERROR_NOMEM;
@@ -110,6 +221,14 @@ initialise(const struct llcache_store_parameters *parameters)
parameters,
sizeof(struct llcache_store_parameters));
+ if (storestate->params.hashsize == 0) {
+ storestate->store_fname = b64_store_fname;
+ } else if (storestate->params.hashsize < 32) {
+ storestate->store_fname = b64_store_fname_fnv;
+ } else {
+ storestate->store_fname = b64_store_fname_sha1;
+ }
+
return NSERROR_OK;
}
@@ -128,41 +247,6 @@ finalise(void)
return NSERROR_OK;
}
-static char *store_name(nsurl *url, enum llcache_store_flags flags)
-{
- char *fname;
- uint8_t *b64u;
- size_t b64ulen;
- char sep;
-
- if ((flags & LLCACHE_STORE_META) == 0) {
- sep ='d';
- } else {
- sep ='i';
- }
-
- switch (storestate->params.hashsize) {
- default:
- /* no hashing, just base64 encode the url */
- b64u = base64url_encode(nsurl_access(url),
- strlen(nsurl_access(url)),
- &b64ulen);
-
- fname = malloc(strlen(storestate->params.path) +
- SLEN("/x/") + b64ulen + 1);
-
- snprintf(fname,
- (strlen(storestate->params.path) +
- SLEN("/x/") + b64ulen + 1),
- "%s/%c/%s",
- storestate->params.path,
- sep,
- b64u);
- free(b64u);
- }
- return fname;
-}
-
/**
* Place a source object and its metadata in the backing store.
*
@@ -182,7 +266,10 @@ store(nsurl *url,
FILE *file;
LOG(("Writing object for url:%s", nsurl_access(url)));
- fname = store_name(url, flags);
+ fname = storestate->store_fname(url, flags);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
LOG(("Opening data file %s", fname));
file = fopen(fname, "wb");
@@ -228,7 +315,10 @@ fetch(nsurl *url,
LOG(("retriving cache file for url:%s", nsurl_access(url)));
- fname = store_name(url, *flags);
+ fname = storestate->store_fname(url, *flags);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
LOG(("Opening file %s",fname));
@@ -273,15 +363,30 @@ fetch(nsurl *url,
}
+/**
+ * Invalidate a source object from the backing store.
+ *
+ * The entry (if present in the backing store) must no longer
+ * be returned as a result to the fetch or meta operations.
+ *
+ * @param url The url is used as the unique primary key to invalidate.
+ * @return NSERROR_OK on success or error code on faliure.
+ */
static nserror
invalidate(nsurl *url)
{
char *fname;
- fname = store_name(url, LLCACHE_STORE_META);
+ fname = storestate->store_fname(url, LLCACHE_STORE_META);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
unlink(fname);
free(fname);
- fname = store_name(url, LLCACHE_STORE_NONE);
+ fname = storestate->store_fname(url, LLCACHE_STORE_NONE);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
unlink(fname);
free(fname);
-----------------------------------------------------------------------
Summary of changes:
content/llcache.c | 2 +-
content/llcache.h | 8 +-
content/llcache_private.h | 5 +-
desktop/netsurf.c | 3 +
gtk/llcache.c | 193 ++++++++++++++++++++++++++++++++++----------
5 files changed, 162 insertions(+), 49 deletions(-)
diff --git a/content/llcache.c b/content/llcache.c
index 36e3bb9..f69b7ab 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -2207,7 +2207,7 @@ static void llcache_persist(void *p)
{
nserror ret;
size_t size_written;
- size_t total_written;
+ size_t total_written = 0;
struct llcache_object **lst;
int lst_count;
int idx;
diff --git a/content/llcache.h b/content/llcache.h
index 854f54f..e562083 100644
--- a/content/llcache.h
+++ b/content/llcache.h
@@ -165,9 +165,11 @@ struct llcache_store_parameters {
size_t limit; /**< The backing store upper bound target size */
size_t hysteresis; /**< The hysteresis around the target size */
- /** length of hash to use for filename mapping. 0 indicates
- * use no hash. 23 is a reasonable compromise for RISC OS. 160
- * uses sha1 in a manner similar to git.
+ /** number of bits to use for hash in filename mapping.
+ *
+ * 0 indicates use no hash. (variable length filenames)
+ * 23 is a reasonable compromise for RISC OS.
+ * 160 uses sha1 in a manner similar to git.
*/
int hashsize;
};
diff --git a/content/llcache_private.h b/content/llcache_private.h
index a946249..38a2e15 100644
--- a/content/llcache_private.h
+++ b/content/llcache_private.h
@@ -83,10 +83,13 @@ struct gui_llcache_table {
uint8_t **data, size_t *datalen);
/**
- * invalidate a source object from the backing store.
+ * Invalidate a source object from the backing store.
*
* The entry (if present in the backing store) must no longer
* be returned as a result to the fetch or meta operations.
+ *
+ * @param url The url is used as the unique primary key to invalidate.
+ * @return NSERROR_OK on success or error code on faliure.
*/
nserror (*invalidate)(struct nsurl *url);
};
diff --git a/desktop/netsurf.c b/desktop/netsurf.c
index a4b4da2..29ae6c1 100644
--- a/desktop/netsurf.c
+++ b/desktop/netsurf.c
@@ -126,6 +126,9 @@ nserror netsurf_init(const char *messages, struct gui_table *gt)
.bg_clean_time = HL_CACHE_CLEAN_TIME,
.llcache = {
.cb = netsurf_llcache_query_handler,
+ .store = {
+ .hashsize = 23,
+ }
}
};
struct image_cache_parameters image_cache_parameters = {
diff --git a/gtk/llcache.c b/gtk/llcache.c
index 06067e5..7b91cd4 100644
--- a/gtk/llcache.c
+++ b/gtk/llcache.c
@@ -22,6 +22,8 @@
#include <unistd.h>
#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "utils/nsurl.h"
#include "utils/log.h"
@@ -31,6 +33,17 @@
#include "gtk/llcache.h"
+struct llcache_store_state {
+ /** parameters controlling the backing store */
+ struct llcache_store_parameters params;
+
+ /** key to filename conversion */
+ char *(*store_fname)(nsurl *url, enum llcache_store_flags flags);
+};
+
+struct llcache_store_state *storestate;
+
+
static uint8_t encoding_table[] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
@@ -82,12 +95,108 @@ base64url_encode(const char *data,
return encoded_data;
}
-struct llcache_store_state {
- /** parameters controlling the backing store */
- struct llcache_store_parameters params;
-};
+/**
+ * create filename from url and flags
+ *
+ * filename from 160bit sha1 and a bit from the from flags base64 encoded
+ */
+static char *
+b64_store_fname_sha1(nsurl *url, enum llcache_store_flags flags)
+{
+}
-struct llcache_store_state *storestate;
+/**
+ * create filename from url and flags
+ *
+ * hashing 23bits from the url hash and one bit from the flags base64 encoded
+ */
+static char *
+b64_store_fname_fnv(nsurl *url, enum llcache_store_flags flags)
+{
+ uint32_t hash;
+ char *hashp;
+ int fname_len;
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+
+ hash = nsurl_hash(url);
+
+ hashp = (char *)&hash;
+
+ hashp[2] = hashp[2] & 0xfe;
+
+ if ((flags & LLCACHE_STORE_META) != 0) {
+ hashp[2] = hashp[2] | 1;
+ }
+
+ b64u = base64url_encode(hashp, 3, &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+
+ fname_len = strlen(storestate->params.path) + b64ulen + 5;
+ fname = calloc(1, fname_len);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ snprintf(fname,
+ fname_len,
+ "%s/%c/%c/%c/%c",
+ storestate->params.path,
+ b64u[0], b64u[1], b64u[2], b64u[3]);
+ free(b64u);
+
+ return fname;
+}
+
+/**
+ * create filename from url and flags
+ *
+ * no hashing, just base64 encode the url
+ */
+static char *
+b64_store_fname(nsurl *url, enum llcache_store_flags flags)
+{
+ char *fname;
+ uint8_t *b64u;
+ size_t b64ulen;
+ char sep;
+
+ b64u = base64url_encode(nsurl_access(url),
+ strlen(nsurl_access(url)),
+ &b64ulen);
+ if (b64u == NULL) {
+ return NULL;
+ }
+
+ fname = malloc(strlen(storestate->params.path) +
+ SLEN("/x") + b64ulen + 1);
+ if (fname == NULL) {
+ free(b64u);
+ return NULL;
+ }
+
+ if ((flags & LLCACHE_STORE_META) == 0) {
+ sep ='d';
+ } else {
+ sep ='i';
+ }
+
+ snprintf(fname,
+ (strlen(storestate->params.path) + SLEN("/x") + b64ulen + 1),
+ "%s/%s%c",
+ storestate->params.path,
+ b64u,
+ sep);
+ free(b64u);
+
+ return fname;
+}
+
+/* backing store implementation */
/**
* Initialise the backing store.
@@ -98,9 +207,11 @@ struct llcache_store_state *storestate;
static nserror
initialise(const struct llcache_store_parameters *parameters)
{
+ /* check backing store is not already initialised */
if (storestate != NULL) {
return NSERROR_INIT_FAILED;
}
+
storestate = calloc(1, sizeof(struct llcache_store_state));
if (storestate == NULL) {
return NSERROR_NOMEM;
@@ -110,6 +221,14 @@ initialise(const struct llcache_store_parameters *parameters)
parameters,
sizeof(struct llcache_store_parameters));
+ if (storestate->params.hashsize == 0) {
+ storestate->store_fname = b64_store_fname;
+ } else if (storestate->params.hashsize < 32) {
+ storestate->store_fname = b64_store_fname_fnv;
+ } else {
+ storestate->store_fname = b64_store_fname_sha1;
+ }
+
return NSERROR_OK;
}
@@ -128,41 +247,6 @@ finalise(void)
return NSERROR_OK;
}
-static char *store_name(nsurl *url, enum llcache_store_flags flags)
-{
- char *fname;
- uint8_t *b64u;
- size_t b64ulen;
- char sep;
-
- if ((flags & LLCACHE_STORE_META) == 0) {
- sep ='d';
- } else {
- sep ='i';
- }
-
- switch (storestate->params.hashsize) {
- default:
- /* no hashing, just base64 encode the url */
- b64u = base64url_encode(nsurl_access(url),
- strlen(nsurl_access(url)),
- &b64ulen);
-
- fname = malloc(strlen(storestate->params.path) +
- SLEN("/x/") + b64ulen + 1);
-
- snprintf(fname,
- (strlen(storestate->params.path) +
- SLEN("/x/") + b64ulen + 1),
- "%s/%c/%s",
- storestate->params.path,
- sep,
- b64u);
- free(b64u);
- }
- return fname;
-}
-
/**
* Place a source object and its metadata in the backing store.
*
@@ -182,7 +266,10 @@ store(nsurl *url,
FILE *file;
LOG(("Writing object for url:%s", nsurl_access(url)));
- fname = store_name(url, flags);
+ fname = storestate->store_fname(url, flags);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
LOG(("Opening data file %s", fname));
file = fopen(fname, "wb");
@@ -228,7 +315,10 @@ fetch(nsurl *url,
LOG(("retriving cache file for url:%s", nsurl_access(url)));
- fname = store_name(url, *flags);
+ fname = storestate->store_fname(url, *flags);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
LOG(("Opening file %s",fname));
@@ -273,15 +363,30 @@ fetch(nsurl *url,
}
+/**
+ * Invalidate a source object from the backing store.
+ *
+ * The entry (if present in the backing store) must no longer
+ * be returned as a result to the fetch or meta operations.
+ *
+ * @param url The url is used as the unique primary key to invalidate.
+ * @return NSERROR_OK on success or error code on faliure.
+ */
static nserror
invalidate(nsurl *url)
{
char *fname;
- fname = store_name(url, LLCACHE_STORE_META);
+ fname = storestate->store_fname(url, LLCACHE_STORE_META);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
unlink(fname);
free(fname);
- fname = store_name(url, LLCACHE_STORE_NONE);
+ fname = storestate->store_fname(url, LLCACHE_STORE_NONE);
+ if (fname == NULL) {
+ return NSERROR_NOMEM;
+ }
unlink(fname);
free(fname);
--
NetSurf Browser
8 years, 11 months
netsurf: branch master updated. release/3.0-1137-gfb9b171
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/fb9b171e325488dc9792e...
...commit http://git.netsurf-browser.org/netsurf.git/commit/fb9b171e325488dc9792ee0...
...tree http://git.netsurf-browser.org/netsurf.git/tree/fb9b171e325488dc9792ee0f3...
The branch, master has been updated
via fb9b171e325488dc9792ee0f3062f15d8ec597ee (commit)
from 6a558b293298fe1267c53ee4f6c42f8889ef581b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fb9b171e325488dc979...
commit fb9b171e325488dc9792ee0f3062f15d8ec597ee
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Disable the dither option if we're running on a screen which doesn't use it.
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index d3f7130..b969eb8 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -406,6 +406,7 @@ void ami_gui_opts_open(void)
BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE, proxybypassdisabled = FALSE;
BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE;
BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE;
+ BOOL ditherdisable = TRUE;
BOOL download_notify_disabled = FALSE;
BOOL ptr_disable = FALSE;
char animspeed[10];
@@ -446,6 +447,9 @@ void ami_gui_opts_open(void)
screenmodeid = strtoul(nsoption_charp(screen_modeid),NULL,0);
}
+ if(ami_plot_screen_is_palettemapped() == true)
+ ditherdisable = FALSE;
+
if(nsoption_bool(http_proxy) == true)
{
proxytype = nsoption_int(http_proxy_auth) + 1;
@@ -907,6 +911,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_DITHERQ] = ChooserObject,
GA_ID, GID_OPTS_DITHERQ,
GA_RelVerify, TRUE,
+ GA_Disabled, ditherdisable,
CHOOSER_PopUp, TRUE,
CHOOSER_LabelArray, ditheropts,
CHOOSER_Selected, nsoption_int(dither_quality),
diff --git a/resources/FatMessages b/resources/FatMessages
index ff5a761..74f03e4 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -5681,11 +5681,11 @@ de.all.ScaleQuality:Skalieren hoher Qualität
fr.all.ScaleQuality:Higher quality scaling
it.all.ScaleQuality:Massima qualità di visualizzazione
nl.all.ScaleQuality:Higher quality scaling
-en.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-de.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-fr.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-it.ami.DitherQuality:Qualità dither (<= solo modi a 8-bit)
-nl.ami.DitherQuality:Dither quality (<= 8-bit modes only)
+en.ami.DitherQuality:Dither quality
+de.ami.DitherQuality:Dither quality
+fr.ami.DitherQuality:Dither quality
+it.ami.DitherQuality:Qualità dither
+nl.ami.DitherQuality:Dither quality
en.ami.Low:Low
de.ami.Low:Low
fr.ami.Low:Low
-----------------------------------------------------------------------
Summary of changes:
amiga/gui_options.c | 5 +++++
resources/FatMessages | 10 +++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/amiga/gui_options.c b/amiga/gui_options.c
index d3f7130..b969eb8 100755
--- a/amiga/gui_options.c
+++ b/amiga/gui_options.c
@@ -406,6 +406,7 @@ void ami_gui_opts_open(void)
BOOL proxyhostdisabled = TRUE, proxyauthdisabled = TRUE, proxybypassdisabled = FALSE;
BOOL disableanims, animspeeddisabled = FALSE, acceptlangdisabled = FALSE;
BOOL scaleselected = nsoption_bool(scale_quality), scaledisabled = FALSE;
+ BOOL ditherdisable = TRUE;
BOOL download_notify_disabled = FALSE;
BOOL ptr_disable = FALSE;
char animspeed[10];
@@ -446,6 +447,9 @@ void ami_gui_opts_open(void)
screenmodeid = strtoul(nsoption_charp(screen_modeid),NULL,0);
}
+ if(ami_plot_screen_is_palettemapped() == true)
+ ditherdisable = FALSE;
+
if(nsoption_bool(http_proxy) == true)
{
proxytype = nsoption_int(http_proxy_auth) + 1;
@@ -907,6 +911,7 @@ void ami_gui_opts_open(void)
LAYOUT_AddChild, gow->objects[GID_OPTS_DITHERQ] = ChooserObject,
GA_ID, GID_OPTS_DITHERQ,
GA_RelVerify, TRUE,
+ GA_Disabled, ditherdisable,
CHOOSER_PopUp, TRUE,
CHOOSER_LabelArray, ditheropts,
CHOOSER_Selected, nsoption_int(dither_quality),
diff --git a/resources/FatMessages b/resources/FatMessages
index ff5a761..74f03e4 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -5681,11 +5681,11 @@ de.all.ScaleQuality:Skalieren hoher Qualität
fr.all.ScaleQuality:Higher quality scaling
it.all.ScaleQuality:Massima qualità di visualizzazione
nl.all.ScaleQuality:Higher quality scaling
-en.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-de.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-fr.ami.DitherQuality:Dither quality (<= 8-bit modes only)
-it.ami.DitherQuality:Qualità dither (<= solo modi a 8-bit)
-nl.ami.DitherQuality:Dither quality (<= 8-bit modes only)
+en.ami.DitherQuality:Dither quality
+de.ami.DitherQuality:Dither quality
+fr.ami.DitherQuality:Dither quality
+it.ami.DitherQuality:Qualità dither
+nl.ami.DitherQuality:Dither quality
en.ami.Low:Low
de.ami.Low:Low
fr.ami.Low:Low
--
NetSurf Browser
8 years, 11 months