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/save_complete.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 riscos/save_complete.c (limited to 'riscos/save_complete.c') 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