From 9c723a5924ef5ef05d56b1addba42dafb3ca5c37 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Wed, 24 Mar 2004 00:07:21 +0000 Subject: [project @ 2004-03-24 00:07:21 by jmb] Add URL rewriting for most URLs. Still TODO: 1) rewriting of @import rules 2) Objects used by embedded html pages NB. This change means that the XML parse tree is kept in memory until the content is freed. svn path=/import/netsurf/; revision=659 --- riscos/save_complete.c | 578 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 557 insertions(+), 21 deletions(-) (limited to 'riscos/save_complete.c') diff --git a/riscos/save_complete.c b/riscos/save_complete.c index fca18e987..4740b2dac 100644 --- a/riscos/save_complete.c +++ b/riscos/save_complete.c @@ -5,8 +5,12 @@ * Copyright 2004 John M Bell */ +#include #include #include /* for __riscosify */ + +#include "libxml/HTMLtree.h" + #include "oslib/osfile.h" #include "netsurf/utils/config.h" #include "netsurf/content/content.h" @@ -16,16 +20,33 @@ #include "netsurf/riscos/gui.h" #include "netsurf/riscos/save_complete.h" #include "netsurf/utils/log.h" +#include "netsurf/utils/url.h" #include "netsurf/utils/utils.h" #ifdef WITH_SAVE_COMPLETE -/** \todo URL rewriting +/** \todo URL rewriting for @import rules * Objects used by embedded html pages * GUI */ -void save_imported_sheets(struct content *c, int parent, int level, char *p, char* fn); +struct url_entry { + char *url; /**< Fully qualified URL, as per url_join output */ + char *par; /**< Base URL of parent object */ + int ptr; /**< Pointer to object's location in memory */ + struct url_entry *next; /**< Next entry in list */ +}; + +static void save_imported_sheets(struct content *c, char *p, char* fn, + struct url_entry *imports); +/*static char *leafname(const char *url); +static int rewrite_stylesheet_urls(const char* sheet, int isize, char* buffer, + int osize, struct url_entry *head);*/ +static int rewrite_document_urls(xmlDoc *doc, struct url_entry *head, char *fname); +static int rewrite_urls(xmlNode *n, struct url_entry *head, char *fname); +static void rewrite_url_data(xmlNode *n, struct url_entry *head, char *fname); +static void rewrite_url_href(xmlNode *n, struct url_entry *head, char *fname); +static void rewrite_url_src(xmlNode *n, struct url_entry *head, char *fname); /* this is temporary. */ const char * const SAVE_PATH = ".savetest."; @@ -36,6 +57,9 @@ void save_complete(struct content *c) { char *fname = 0, *spath; unsigned int i; + struct url_entry urls = {0, 0, 0, 0}; /* sentinel at head */ + struct url_entry *object; + xmlDoc *toSave; if (c->type != CONTENT_HTML) return; @@ -50,17 +74,41 @@ void save_complete(struct content *c) { /* save stylesheets, ignoring the base sheet and