From f5a0093a881603269bb24aca976374ddc7725bec Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Mon, 5 Apr 2004 21:54:22 +0000 Subject: [project @ 2004-04-05 21:54:22 by jmb] Implement outstanding functionality svn path=/import/netsurf/; revision=722 --- riscos/save_complete.c | 164 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 51 deletions(-) (limited to 'riscos') diff --git a/riscos/save_complete.c b/riscos/save_complete.c index ac2df75a4..1bc47221f 100644 --- a/riscos/save_complete.c +++ b/riscos/save_complete.c @@ -29,11 +29,6 @@ #ifdef WITH_SAVE_COMPLETE -/** \todo URL rewriting for @import rules - * Objects used by embedded html pages - * GUI - */ - regex_t save_complete_import_re; /** An entry in save_complete_list. */ @@ -42,18 +37,17 @@ struct save_complete_entry { int ptr; /**< Pointer to object's location in memory */ struct save_complete_entry *next; /**< Next entry in list */ }; -/** List of urls seen and saved so far. */ -static struct save_complete_entry *save_complete_list; - -static void save_imported_sheets(struct content *c, const char *path); -static char * rewrite_stylesheet_urls(const char *source, unsigned int size, +static void save_complete_internal(struct content *c, const char *path, + bool index); +static void save_imported_sheets(struct save_complete_entry **save_complete_list, struct content *c, const char *path); +static char * rewrite_stylesheet_urls(struct save_complete_entry *save_complete_list, const char *source, unsigned int size, int *osize, const char *base); -static int rewrite_document_urls(xmlDoc *doc, const char *base); -static int rewrite_urls(xmlNode *n, const char *base); -static void rewrite_url(xmlNode *n, const char *attr, const char *base); -static void save_complete_add_url(const char *url, int id); -static int save_complete_find_url(const char *url); +static int rewrite_document_urls(struct save_complete_entry *save_complete_list, xmlDoc *doc, const char *base); +static int rewrite_urls(struct save_complete_entry *save_complete_list, xmlNode *n, const char *base); +static void rewrite_url(struct save_complete_entry *save_complete_list, xmlNode *n, const char *attr, const char *base); +static void save_complete_add_url(struct save_complete_entry **save_complete_list, const char *url, int id); +static int save_complete_find_url(struct save_complete_entry *save_complete_list, const char *url); /** @@ -64,18 +58,34 @@ static int save_complete_find_url(const char *url); */ void save_complete(struct content *c, const char *path) +{ + save_complete_internal(c, path, true); +} + +/** + * Save an HTML page with all dependencies, recursing through imported pages. + * + * \param save_complete_list head of list of URLs + * \param c CONTENT_HTML to save + * \param path directory to save to (must exist) + */ + +void save_complete_internal(struct content *c, const char *path, bool index) { char spath[256]; unsigned int i; htmlParserCtxtPtr toSave; + /** List of urls seen and saved so far. One per HTML document */ + struct save_complete_entry *save_complete_list; + if (c->type != CONTENT_HTML) return; save_complete_list = 0; - /* save stylesheets, ignoring the base sheet and