NetSurf
|
Save HTML document with dependencies implementation. More...
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <sys/types.h>
#include <dom/dom.h>
#include "utils/config.h"
#include "utils/regex.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/nsurl.h"
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/file.h"
#include "utils/messages.h"
#include "utils/ascii.h"
#include "netsurf/content.h"
#include "content/hlcache.h"
#include "css/css.h"
#include "html/box.h"
#include "html/html_save.h"
#include "html/html.h"
#include "netsurf/misc.h"
#include "desktop/gui_internal.h"
#include "desktop/save_complete.h"
Go to the source code of this file.
Data Structures | |
struct | save_complete_entry |
An entry in save_complete_list. More... | |
struct | save_complete_ctx |
Typedefs | |
typedef struct save_complete_entry | save_complete_entry |
An entry in save_complete_list. More... | |
typedef struct save_complete_ctx | save_complete_ctx |
Enumerations | |
enum | save_complete_event_type { EVENT_ENTER , EVENT_LEAVE } |
Functions | |
static nserror | save_complete_save_html (save_complete_ctx *ctx, hlcache_handle *c, bool index) |
Save an HTML page with all dependencies, recursing through imported pages. More... | |
static nserror | save_complete_save_imported_sheets (save_complete_ctx *ctx, struct nscss_import *imports, uint32_t import_count) |
static void | save_complete_ctx_initialise (save_complete_ctx *ctx, const char *path, save_complete_set_type_cb set_type) |
static void | save_complete_ctx_finalise (save_complete_ctx *ctx) |
static nserror | save_complete_ctx_add_content (save_complete_ctx *ctx, struct hlcache_handle *content) |
static struct hlcache_handle * | save_complete_ctx_find_content (save_complete_ctx *ctx, const nsurl *url) |
find handle to content for url More... | |
static bool | save_complete_ctx_has_content (save_complete_ctx *ctx, struct hlcache_handle *content) |
static nserror | save_complete_save_buffer (save_complete_ctx *ctx, const char *leafname, const uint8_t *data, size_t data_len, lwc_string *mime_type) |
static int | snregexec (regex_t *preg, const char *string, size_t stringlen, size_t nmatch, regmatch_t pmatch[], int eflags) |
perform a posix regexec on a string without a null terminator More... | |
static uint8_t * | save_complete_rewrite_stylesheet_urls (save_complete_ctx *ctx, const uint8_t *source, size_t size, const nsurl *base, size_t *osize) |
Rewrite stylesheet @import rules for save complete. More... | |
static nserror | save_complete_save_stylesheet (save_complete_ctx *ctx, hlcache_handle *css) |
static nserror | save_complete_save_html_stylesheet (save_complete_ctx *ctx, struct html_stylesheet *sheet) |
static nserror | save_complete_save_html_stylesheets (save_complete_ctx *ctx, hlcache_handle *c) |
static nserror | save_complete_save_html_object (save_complete_ctx *ctx, hlcache_handle *obj) |
static nserror | save_complete_save_html_objects (save_complete_ctx *ctx, hlcache_handle *c) |
static bool | save_complete_libdom_treewalk (dom_node *root, bool(*callback)(dom_node *node, save_complete_event_type event_type, void *ctx), void *ctx) |
static bool | save_complete_rewrite_url_value (save_complete_ctx *ctx, const char *value, size_t value_len) |
static bool | save_complete_write_value (save_complete_ctx *ctx, const char *value, size_t value_len) |
static bool | save_complete_handle_attr_value (save_complete_ctx *ctx, dom_string *node_name, dom_string *attr_name, dom_string *attr_value) |
static bool | save_complete_handle_attr (save_complete_ctx *ctx, dom_string *node_name, dom_attr *attr) |
static bool | save_complete_handle_attrs (save_complete_ctx *ctx, dom_string *node_name, dom_namednodemap *attrs) |
static bool | save_complete_handle_element (save_complete_ctx *ctx, dom_node *node, save_complete_event_type event_type) |
static bool | save_complete_node_handler (dom_node *node, save_complete_event_type event_type, void *ctxin) |
static nserror | save_complete_save_html_document (save_complete_ctx *ctx, hlcache_handle *c, bool index) |
static nserror | save_complete_inventory (save_complete_ctx *ctx) |
Create the inventory file listing original URLs. More... | |
static nserror | regcomp_wrapper (regex_t *preg, const char *regex, int cflags) |
Compile a regular expression, handling errors. More... | |
void | save_complete_init (void) |
Initialise save complete module. More... | |
nserror | save_complete_finalise (void) |
Finalise save complete module. More... | |
nserror | save_complete (hlcache_handle *c, const char *path, save_complete_set_type_cb set_type) |
Save an HTML page with all dependencies. More... | |
Variables | |
static regex_t | save_complete_import_re |
Save HTML document with dependencies implementation.
Definition in file save_complete.c.
typedef struct save_complete_ctx save_complete_ctx |
typedef struct save_complete_entry save_complete_entry |
An entry in save_complete_list.
Enumerator | |
---|---|
EVENT_ENTER | |
EVENT_LEAVE |
Definition at line 72 of file save_complete.c.
Compile a regular expression, handling errors.
Parameters as for regcomp(), see man regex.
Definition at line 1273 of file save_complete.c.
References NSERROR_INIT_FAILED, NSERROR_OK, NSLOG, regcomp(), and regerror().
Referenced by save_complete_init().
nserror save_complete | ( | struct hlcache_handle * | c, |
const char * | path, | ||
save_complete_set_type_cb | set_type | ||
) |
Save an HTML page with all dependencies.
c | CONTENT_HTML to save |
path | Native path to directory to save in to (must exist) |
set_type | Callback to set type of a file, or NULL |
Definition at line 1330 of file save_complete.c.
References NSERROR_OK, path(), result, save_complete_ctx_finalise(), save_complete_ctx_initialise(), save_complete_inventory(), and save_complete_save_html().
Referenced by ami_file_save(), menu_save_page(), ro_gui_save_complete(), and savepage_button_clicked_cb().
|
static |
Definition at line 103 of file save_complete.c.
References save_complete_entry::content, save_complete_ctx::list, save_complete_entry::next, NSERROR_NOMEM, and NSERROR_OK.
Referenced by save_complete_save_html_object(), and save_complete_save_stylesheet().
|
static |
Definition at line 91 of file save_complete.c.
References save_complete_ctx::list, and save_complete_entry::next.
Referenced by save_complete().
|
static |
find handle to content for url
ctx | The save context |
url | The url to find content handle for |
Definition at line 128 of file save_complete.c.
References hlcache_entry::content, hlcache_handle::entry, hlcache_handle_get_url(), save_complete_ctx::list, hlcache_entry::next, nsurl_compare(), and NSURL_COMPLETE.
Referenced by save_complete_rewrite_stylesheet_urls(), save_complete_rewrite_url_value(), save_complete_save_html_object(), and save_complete_save_stylesheet().
|
static |
Definition at line 145 of file save_complete.c.
References hlcache_entry::content, hlcache_handle::entry, hlcache_handle_get_content(), save_complete_ctx::list, and hlcache_entry::next.
Referenced by save_complete_save_html().
|
static |
Definition at line 83 of file save_complete.c.
References save_complete_ctx::list, save_complete_ctx::path, path(), and save_complete_ctx::set_type.
Referenced by save_complete().
nserror save_complete_finalise | ( | void | ) |
Finalise save complete module.
Definition at line 1322 of file save_complete.c.
References NSERROR_OK, regfree(), and save_complete_import_re.
Referenced by nsgtk_finalise().
|
static |
Definition at line 786 of file save_complete.c.
References save_complete_ctx::fp, node_name(), and save_complete_handle_attr_value().
Referenced by save_complete_handle_attrs().
|
static |
We only need to consider the following cases:
Attribute: Elements:
1) data object 2) href a, area, link 3) src script, input, frame, iframe, img 4) background any (except those above)
Definition at line 697 of file save_complete.c.
References node_name(), save_complete_rewrite_url_value(), save_complete_write_value(), and SLEN.
Referenced by save_complete_handle_attr().
|
static |
Definition at line 832 of file save_complete.c.
References node_name(), and save_complete_handle_attr().
Referenced by save_complete_handle_element().
|
static |
Definition at line 865 of file save_complete.c.
References save_complete_ctx::base, content_html_object::content, EVENT_ENTER, EVENT_LEAVE, save_complete_ctx::fp, save_complete_ctx::iter_state, save_complete_handle_attrs(), save_complete_rewrite_stylesheet_urls(), and SLEN.
Referenced by save_complete_node_handler().
void save_complete_init | ( | void | ) |
Initialise save complete module.
Definition at line 1289 of file save_complete.c.
References REG_EXTENDED, REG_ICASE, regcomp_wrapper(), and save_complete_import_re.
Referenced by gui_init(), main(), menu_save_page(), and nsgtk_setup().
|
static |
Create the inventory file listing original URLs.
Definition at line 1237 of file save_complete.c.
References save_complete_entry::content, hlcache_handle_get_url(), save_complete_ctx::list, netsurf_mkpath(), save_complete_entry::next, NSERROR_OK, NSERROR_SAVE_FAILED, NSLOG, nsurl_access(), and save_complete_ctx::path.
Referenced by save_complete().
|
static |
Definition at line 540 of file save_complete.c.
References EVENT_ENTER, EVENT_LEAVE, content_html_object::next, and root.
Referenced by save_complete_save_html_document().
|
static |
Definition at line 1017 of file save_complete.c.
References EVENT_ENTER, save_complete_ctx::fp, save_complete_ctx::iter_state, NSERROR_OK, NSLOG, save_complete_handle_element(), text(), type, and utf8_to_html().
Referenced by save_complete_save_html_document().
|
static |
Rewrite stylesheet @import rules for save complete.
ctx | Save complete context. |
source | stylesheet source. |
size | size of source. |
base | url of stylesheet. |
osize | updated with the size of the result. |
Definition at line 234 of file save_complete.c.
References ascii_to_lower(), base, NSERROR_NOMEM, nsurl_join(), nsurl_unref(), regmatch_t::rm_eo, regmatch_t::rm_so, save_complete_ctx_find_content(), save_complete_import_re, SLEN, snregexec(), and strndup().
Referenced by save_complete_handle_element(), and save_complete_save_stylesheet().
|
static |
Definition at line 635 of file save_complete.c.
References save_complete_ctx::base, content_html_object::content, save_complete_ctx::fp, NSERROR_NOMEM, NSERROR_OK, nsurl_access(), nsurl_join(), nsurl_length(), nsurl_unref(), save_complete_ctx_find_content(), and utf8_to_html().
Referenced by save_complete_handle_attr_value().
|
static |
Definition at line 160 of file save_complete.c.
References netsurf_mkpath(), NSERROR_OK, NSERROR_SAVE_FAILED, NSLOG, save_complete_ctx::path, and save_complete_ctx::set_type.
Referenced by save_complete_save_html_object(), and save_complete_save_stylesheet().
|
static |
Save an HTML page with all dependencies, recursing through imported pages.
ctx | Save complete context |
c | Content to save |
index | true to save as "index" |
Definition at line 1205 of file save_complete.c.
References content_get_type(), CONTENT_HTML, NSERROR_INVALID, NSERROR_OK, save_complete_ctx_has_content(), save_complete_save_html_document(), save_complete_save_html_objects(), and save_complete_save_html_stylesheets().
Referenced by save_complete(), and save_complete_save_html_object().
|
static |
Definition at line 1138 of file save_complete.c.
References save_complete_ctx::base, content_get_mime_type(), save_complete_ctx::fp, html_get_base_url(), html_get_document(), save_complete_ctx::iter_state, netsurf_mkpath(), NSERROR_NOMEM, NSERROR_OK, NSERROR_SAVE_FAILED, NSLOG, save_complete_ctx::path, save_complete_libdom_treewalk(), save_complete_node_handler(), and save_complete_ctx::set_type.
Referenced by save_complete_save_html().
|
static |
Definition at line 471 of file save_complete.c.
References content_get_mime_type(), content_get_source_data(), content_get_type(), CONTENT_HTML, CONTENT_NONE, hlcache_handle_get_url(), NSERROR_NOMEM, NSERROR_OK, result, save_complete_ctx_add_content(), save_complete_ctx_find_content(), save_complete_save_buffer(), save_complete_save_html(), and type.
Referenced by save_complete_save_html_objects().
|
static |
Definition at line 517 of file save_complete.c.
References content_html_object::box, content_html_object::content, count(), html_get_objects(), NSERROR_OK, and save_complete_save_html_object().
Referenced by save_complete_save_html().
|
static |
Definition at line 440 of file save_complete.c.
References NSERROR_OK, save_complete_save_stylesheet(), and html_stylesheet::sheet.
Referenced by save_complete_save_html_stylesheets().
|
static |
Definition at line 451 of file save_complete.c.
References count(), html_get_stylesheets(), NSERROR_OK, save_complete_save_html_stylesheet(), and STYLESHEET_START.
Referenced by save_complete_save_html().
|
static |
Definition at line 419 of file save_complete.c.
References nscss_import::c, NSERROR_OK, and save_complete_save_stylesheet().
Referenced by save_complete_save_stylesheet().
|
static |
Definition at line 360 of file save_complete.c.
References content_get_mime_type(), content_get_source_data(), hlcache_handle_get_url(), nscss_get_imports(), NSERROR_NOMEM, NSERROR_OK, result, save_complete_ctx_add_content(), save_complete_ctx_find_content(), save_complete_rewrite_stylesheet_urls(), save_complete_save_buffer(), save_complete_save_imported_sheets(), and type.
Referenced by save_complete_save_html_stylesheet(), and save_complete_save_imported_sheets().
|
static |
Definition at line 680 of file save_complete.c.
References save_complete_ctx::fp, NSERROR_OK, and utf8_to_html().
Referenced by save_complete_handle_attr_value().
|
static |
perform a posix regexec on a string without a null terminator
Definition at line 199 of file save_complete.c.
References regexec().
Referenced by save_complete_rewrite_stylesheet_urls().
|
static |
Definition at line 54 of file save_complete.c.
Referenced by save_complete_finalise(), save_complete_init(), and save_complete_rewrite_stylesheet_urls().