From 6839622183b74914ed0bcb83387fedf6459e2c5c Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Tue, 17 Feb 2004 12:41:38 +0000 Subject: [project @ 2004-02-17 12:41:38 by jmb] Begin save complete support. Fix memory leak when using Select PNG renderer. (commented out lines can probably removed) svn path=/import/netsurf/; revision=556 --- riscos/png.c | 19 ++++-- riscos/save_complete.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ riscos/save_complete.h | 15 +++++ riscos/window.c | 9 ++- 4 files changed, 209 insertions(+), 8 deletions(-) create mode 100644 riscos/save_complete.c create mode 100644 riscos/save_complete.h (limited to 'riscos') diff --git a/riscos/png.c b/riscos/png.c index 8105ebfe7..20597fa57 100644 --- a/riscos/png.c +++ b/riscos/png.c @@ -69,11 +69,11 @@ void nspng_init(void) void nspng_create(struct content *c, const char *params[]) { #ifndef NO_IFC - if (imagefileconvert) { +// if (imagefileconvert) { c->data.other.data = xcalloc(0, 1); c->data.other.length = 0; - return; - } +// return; +// } #endif c->data.png.sprite_area = 0; @@ -97,14 +97,14 @@ void nspng_create(struct content *c, const char *params[]) void nspng_process_data(struct content *c, char *data, unsigned long size) { #ifndef NO_IFC - if (imagefileconvert) { +// if (imagefileconvert) { c->data.png.data = xrealloc(c->data.png.data, c->data.png.length + size); memcpy(c->data.png.data + c->data.png.length, data, size); c->data.png.length += size; - c->size += size; - return; - } +// c->size += size; +// return; +// } #endif if (setjmp(png_jmpbuf(c->data.png.png))) { @@ -366,6 +366,11 @@ void nspng_destroy(struct content *c) { xfree(c->title); xfree(c->data.png.sprite_area); +#ifndef NO_IFC +// if (imagefileconvert) { + xfree(c->data.png.data); +// } +#endif } diff --git a/riscos/save_complete.c b/riscos/save_complete.c new file mode 100644 index 000000000..3b6e3a988 --- /dev/null +++ b/riscos/save_complete.c @@ -0,0 +1,174 @@ +/* + * This file is part of NetSurf, http://netsurf.sourceforge.net/ + * Licensed under the GNU General Public License, + * http://www.opensource.org/licenses/gpl-license + * Copyright 2004 John M Bell + */ + +#include + +#include /* for __riscosify */ + +#include /* possibly just have accessor methods in utils.c */ + +#include "oslib/osfile.h" + +#include "netsurf/utils/config.h" +#include "netsurf/content/content.h" +#include "netsurf/css/css.h" +#include "netsurf/render/form.h" +#include "netsurf/render/layout.h" +#include "netsurf/riscos/save_complete.h" +#include "netsurf/utils/log.h" +#include "netsurf/utils/utils.h" + +/** \todo Save out CSS. */ + +#ifdef WITH_SAVE_COMPLETE + +char* get_filename(char * url); + +/* this is temporary. */ +const char * const SAVE_PATH = ".savetest."; +const char * const OBJ_DIR = "_files"; + +/** \todo this will probably want to take a filename */ +void save_complete(struct content *c) { + + struct box *box; + char *fname = 0, *spath, *ofname; + unsigned int i; + + if (c->type != CONTENT_HTML) { + return; + } + + fname = get_filename(c->data.html.base_url); + + if (!fname) { /* no path -> exit */ + return; + } + + spath = xcalloc(strlen(SAVE_PATH)+strlen(OBJ_DIR)+strlen(fname)+50, + sizeof(char)); + + sprintf(spath, "%s%s%s", SAVE_PATH, fname, OBJ_DIR); + xosfile_create_dir(spath, 77); + + /* save stylesheets, ignoring the base sheet and