diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2006-09-02 15:52:41 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2006-09-02 15:52:41 +0000 |
commit | 74fa727509874983884a35b44b646be034b1fd69 (patch) | |
tree | 1daf083961efd039e318c7a1157b6aa2a83b9d54 /content | |
parent | b51f807fe326f6d9aec0600cbf526f96db7577d0 (diff) | |
download | netsurf-74fa727509874983884a35b44b646be034b1fd69.tar.gz netsurf-74fa727509874983884a35b44b646be034b1fd69.tar.bz2 |
Experimental new frames code.
svn path=/trunk/netsurf/; revision=2906
Diffstat (limited to 'content')
-rw-r--r-- | content/content.c | 2 | ||||
-rw-r--r-- | content/urldb.c | 61 | ||||
-rw-r--r-- | content/urldb.h | 5 |
3 files changed, 67 insertions, 1 deletions
diff --git a/content/content.c b/content/content.c index 68c90a7f0..6b8d7b9fe 100644 --- a/content/content.c +++ b/content/content.c @@ -816,7 +816,6 @@ void content_destroy(struct content *c) if (c->type < HANDLER_MAP_COUNT && handler_map[c->type].destroy) handler_map[c->type].destroy(c); - talloc_free(c); } @@ -855,6 +854,7 @@ void content_quit(void) while (content_list && progress) { progress = false; for (c = content_list; c; c = next) { + assert(c->next != c); next = c->next; if (c->user_list->next && diff --git a/content/urldb.c b/content/urldb.c index f498f106e..1e51d45db 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -81,6 +81,7 @@ #include <curl/curl.h> #include "netsurf/image/bitmap.h" +#include "netsurf/content/content.h" #include "netsurf/content/urldb.h" #include "netsurf/desktop/cookies.h" #include "netsurf/desktop/options.h" @@ -89,6 +90,7 @@ #include "netsurf/riscos/bitmap.h" #endif #include "netsurf/utils/log.h" +#include "netsurf/utils/filename.h" #include "netsurf/utils/url.h" #include "netsurf/utils/utils.h" @@ -117,6 +119,10 @@ struct auth_data { * username:password */ }; +struct cache_internal_data { + char filename[12]; /**< Cached filename, or first byte 0 for none */ +}; + struct url_internal_data { char *title; /**< Resource title */ unsigned int visits; /**< Visit count */ @@ -135,6 +141,7 @@ struct path_data { struct bitmap *thumb; /**< Thumbnail image of resource */ struct url_internal_data urld; /**< URL data for resource */ + struct cache_internal_data cache; /**< Cache data for resource */ struct auth_data auth; /**< Authentication data for resource */ struct cookie_internal_data *cookies; /**< Cookies associated with resource */ @@ -3361,6 +3368,60 @@ void urldb_save_cookie_paths(FILE *fp, struct path_data *parent) } +/** + * Sets the content data associated with a particular URL + * + * \param url the URL to associate content with + * \param content the content to associate + * \return true on success, false otherwise + */ +bool urldb_set_cache_data(const char *url, const struct content *content) { + struct path_data *p; + char *filename; + + assert(url && content); + + p = urldb_find_url(url); + if (!p) + return false; + + /* new filename needed */ + if (p->cache.filename[0] == 0) { + filename = filename_request(); + if (!filename) + return false; + sprintf(p->cache.filename, filename); + } + + /* todo: save content, set cache data etc */ + return true; +} + + +/** + * Gets a file:// URL for the cached data associated with a URL + * + * \param url the URL to get the associated content for + * \return a local URL allocated on heap, or NULL + */ +char *urldb_get_cache_data(const char *url) { + struct path_data *p; + + assert(url); + + p = urldb_find_url(url); + if (!p) + return NULL; + + /* no file cache */ + if (p->cache.filename[0] == 0) + return NULL; + + /* todo: handle cache expiry etc */ + return filename_as_url(p->cache.filename); +} + + #ifdef TEST_URLDB int option_expire_url = 0; diff --git a/content/urldb.h b/content/urldb.h index 20d97ebca..aa8ec7742 100644 --- a/content/urldb.h +++ b/content/urldb.h @@ -14,6 +14,7 @@ #include <stdbool.h> #include <time.h> +#include "netsurf/content/content.h" #include "netsurf/content/content_type.h" typedef enum { @@ -100,4 +101,8 @@ void urldb_delete_cookie(const char *domain, const char *path, const char *name) void urldb_load_cookies(const char *filename); void urldb_save_cookies(const char *filename); +/* Cache */ +bool urldb_set_cache_data(const char *url, const struct content *content); +char *urldb_get_cache_data(const char *url); + #endif |