mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 12:36:51 +03:00
[project @ 2004-06-21 15:49:59 by bursa]
Remove obsolete files and some dead code. svn path=/import/netsurf/; revision=989
This commit is contained in:
parent
86206259fe
commit
1fa1786d83
315
content/cache.c
315
content/cache.c
@ -1,315 +0,0 @@
|
||||
/*
|
||||
* 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 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Caching of converted contents (implementation).
|
||||
*
|
||||
* The current implementation is a memory cache only. The content structures
|
||||
* are stored in two linked lists.
|
||||
* - inuse_list contains non-freeable contents
|
||||
* - unused_list contains freeable contents
|
||||
*
|
||||
* The cache has a suggested maximum size. If the sum of the size attribute of
|
||||
* the contents exceeds the maximum, contents from the freeable list are
|
||||
* destroyed until the size drops below the maximum, if possible. Freeing is
|
||||
* attempted only when cache_put is used.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "netsurf/content/cache.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
|
||||
#ifndef TEST
|
||||
#include "netsurf/content/content.h"
|
||||
#else
|
||||
#include <unistd.h>
|
||||
struct content {
|
||||
char *url;
|
||||
struct cache_entry *cache;
|
||||
unsigned long size;
|
||||
};
|
||||
void content_destroy(struct content *c);
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* internal structures and declarations
|
||||
*/
|
||||
|
||||
static void cache_shrink(void);
|
||||
static unsigned long cache_size(void);
|
||||
|
||||
struct cache_entry {
|
||||
struct content *content;
|
||||
struct cache_entry *next, *prev;
|
||||
};
|
||||
|
||||
/* doubly-linked lists using a sentinel */
|
||||
/* TODO: replace with a structure which can be searched faster */
|
||||
/* unused list is ordered from most recently to least recently used */
|
||||
static struct cache_entry inuse_list_sentinel = {0, &inuse_list_sentinel, &inuse_list_sentinel};
|
||||
static struct cache_entry unused_list_sentinel = {0, &unused_list_sentinel, &unused_list_sentinel};
|
||||
static struct cache_entry *inuse_list = &inuse_list_sentinel;
|
||||
static struct cache_entry *unused_list = &unused_list_sentinel;
|
||||
|
||||
/** Suggested maximum size of cache (bytes). */
|
||||
static unsigned long max_size = 1024*1024; /* TODO: make this configurable */
|
||||
|
||||
|
||||
/**
|
||||
* Initialise the cache manager.
|
||||
*
|
||||
* Must be called before using any other cache functions.
|
||||
*
|
||||
* Currently does nothing.
|
||||
*/
|
||||
|
||||
void cache_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Terminate the cache manager.
|
||||
*
|
||||
* Must be called before the program exits.
|
||||
*
|
||||
* Currently does nothing.
|
||||
*/
|
||||
|
||||
void cache_quit(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a content from the memory cache or disc cache.
|
||||
*
|
||||
* Returns the content and sets it to non-freeable on success. Returns 0 if
|
||||
* the URL is not present in the cache.
|
||||
*/
|
||||
|
||||
struct content * cache_get(const char * const url)
|
||||
{
|
||||
struct cache_entry *e;
|
||||
LOG(("url %s", url));
|
||||
|
||||
/* search inuse_list first */
|
||||
for (e = inuse_list->next; e != inuse_list && strcmp(e->content->url, url) != 0; e = e->next)
|
||||
;
|
||||
if (e != inuse_list) {
|
||||
LOG(("'%s' in inuse_list, content %p", url, e->content));
|
||||
return e->content;
|
||||
}
|
||||
|
||||
LOG(("not in inuse_list"));
|
||||
|
||||
/* search unused_list if not found */
|
||||
for (e = unused_list->next; e != unused_list && strcmp(e->content->url, url) != 0; e = e->next)
|
||||
;
|
||||
if (e != unused_list) {
|
||||
LOG(("'%s' in unused_list, content %p", url, e->content));
|
||||
/* move to inuse_list */
|
||||
e->prev->next = e->next;
|
||||
e->next->prev = e->prev;
|
||||
e->prev = inuse_list->prev;
|
||||
e->next = inuse_list;
|
||||
inuse_list->prev->next = e;
|
||||
inuse_list->prev = e;
|
||||
return e->content;
|
||||
}
|
||||
|
||||
LOG(("'%s' not in cache", url));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a content to the memory cache.
|
||||
*
|
||||
* The content is set to non-freeable.
|
||||
*/
|
||||
|
||||
void cache_put(struct content * content)
|
||||
{
|
||||
struct cache_entry * e;
|
||||
LOG(("content %p, url '%s', size %lu", content, content->url, content->size));
|
||||
|
||||
cache_shrink();
|
||||
|
||||
/* add the new content to the inuse_list */
|
||||
e = xcalloc(1, sizeof(struct cache_entry));
|
||||
e->content = content;
|
||||
e->prev = inuse_list->prev;
|
||||
e->next = inuse_list;
|
||||
inuse_list->prev->next = e;
|
||||
inuse_list->prev = e;
|
||||
content->cache = e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inform cache that the content has no users.
|
||||
*
|
||||
* The content is set to freeable, and may be destroyed in the future.
|
||||
*/
|
||||
|
||||
void cache_freeable(struct content * content)
|
||||
{
|
||||
struct cache_entry * e = content->cache;
|
||||
|
||||
assert(e != 0);
|
||||
LOG(("content %p, url '%s'", content, content->url));
|
||||
|
||||
/* move to unused_list */
|
||||
e->prev->next = e->next;
|
||||
e->next->prev = e->prev;
|
||||
e->prev = unused_list;
|
||||
e->next = unused_list->next;
|
||||
unused_list->next->prev = e;
|
||||
unused_list->next = e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a content from the cache immediately.
|
||||
*
|
||||
* Informs the cache that a content is about to be destroyed, and must be
|
||||
* removed from the cache. This should be called when an error occurs when
|
||||
* loading an url and the content is destroyed. The content must be
|
||||
* non-freeable.
|
||||
*/
|
||||
|
||||
void cache_destroy(struct content * content)
|
||||
{
|
||||
struct cache_entry * e = content->cache;
|
||||
e->prev->next = e->next;
|
||||
e->next->prev = e->prev;
|
||||
xfree(e);
|
||||
content->cache = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to reduce cache size below max_size.
|
||||
*/
|
||||
|
||||
void cache_shrink(void)
|
||||
{
|
||||
struct cache_entry * e;
|
||||
unsigned long size = cache_size();
|
||||
|
||||
/* clear old data from the usused_list until the size drops below max_size */
|
||||
while (max_size < size && unused_list->next != unused_list) {
|
||||
e = unused_list->prev;
|
||||
LOG(("size %lu, removing %p '%s'", size, e->content, e->content->url));
|
||||
/* TODO: move to disc cache */
|
||||
size -= e->content->size;
|
||||
e->content->cache = 0;
|
||||
content_destroy(e->content);
|
||||
unused_list->prev = e->prev;
|
||||
e->prev->next = unused_list;
|
||||
xfree(e);
|
||||
}
|
||||
LOG(("size %lu", size));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return current size of the cache.
|
||||
*/
|
||||
|
||||
unsigned long cache_size(void)
|
||||
{
|
||||
struct cache_entry * e;
|
||||
unsigned long size = 0;
|
||||
for (e = inuse_list->next; e != inuse_list; e = e->next)
|
||||
size += e->content->size;
|
||||
for (e = unused_list->next; e != unused_list; e = e->next)
|
||||
size += e->content->size;
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dump contents of cache.
|
||||
*/
|
||||
|
||||
void cache_dump(void) {
|
||||
struct cache_entry * e;
|
||||
LOG(("size %lu", cache_size()));
|
||||
LOG(("inuse_list:"));
|
||||
for (e = inuse_list->next; e != inuse_list; e = e->next)
|
||||
LOG((" content %p, size %lu, url '%s'", e->content,
|
||||
e->content->size, e->content->url));
|
||||
LOG(("unused_list (time now %lu):", time(0)));
|
||||
for (e = unused_list->next; e != unused_list; e = e->next)
|
||||
LOG((" content %p, size %lu, url '%s'", e->content,
|
||||
e->content->size, e->content->url));
|
||||
LOG(("end"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testing framework
|
||||
*/
|
||||
|
||||
#ifdef TEST
|
||||
struct content test[] = {
|
||||
{"aaa", 0, 200 * 1024},
|
||||
{"bbb", 0, 100 * 1024},
|
||||
{"ccc", 0, 400 * 1024},
|
||||
{"ddd", 0, 600 * 1024},
|
||||
{"eee", 0, 300 * 1024},
|
||||
{"fff", 0, 500 * 1024},
|
||||
};
|
||||
|
||||
#define TEST_COUNT (sizeof(test) / sizeof(test[0]))
|
||||
|
||||
unsigned int test_state[TEST_COUNT];
|
||||
|
||||
void content_destroy(struct content *c)
|
||||
{
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i;
|
||||
struct content *c;
|
||||
for (i = 0; i != TEST_COUNT; i++)
|
||||
test_state[i] = 0;
|
||||
|
||||
cache_init();
|
||||
|
||||
for (i = 0; i != 100; i++) {
|
||||
int x = rand() % TEST_COUNT;
|
||||
switch (rand() % 2) {
|
||||
case 0:
|
||||
c = cache_get(test[x].url);
|
||||
if (c == 0) {
|
||||
assert(test_state[x] == 0);
|
||||
cache_put(&test[x]);
|
||||
} else
|
||||
assert(c == &test[x]);
|
||||
test_state[x]++;
|
||||
break;
|
||||
case 1:
|
||||
if (test_state[x] != 0) {
|
||||
cache_free(&test[x]);
|
||||
test_state[x]--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
cache_dump();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* Caching of converted contents (interface).
|
||||
*
|
||||
* The cache contains a ::content structure for each url. If a structure is not
|
||||
* in state CONTENT_STATUS_DONE, then loading and converting must be actively
|
||||
* in progress, so that when a not done content is retrieved no action needs
|
||||
* to be taken to load it.
|
||||
*
|
||||
* Each content in the cache is either freeable or non-freeable. If an entry
|
||||
* is freeable, the cache may destroy it through content_destroy() at any time.
|
||||
*
|
||||
* The cache uses the cache element of struct content.
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_DESKTOP_CACHE_H_
|
||||
#define _NETSURF_DESKTOP_CACHE_H_
|
||||
|
||||
struct content;
|
||||
struct cache_entry;
|
||||
|
||||
void cache_init(void);
|
||||
void cache_quit(void);
|
||||
struct content * cache_get(const char * const url);
|
||||
void cache_put(struct content * content);
|
||||
void cache_freeable(struct content * content);
|
||||
void cache_destroy(struct content * content);
|
||||
void cache_dump(void);
|
||||
|
||||
#endif
|
299
riscos/about.c
299
riscos/about.c
@ -1,299 +0,0 @@
|
||||
/*
|
||||
* 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 2003,4 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* About page creation.
|
||||
* Dynamically creates the about page, scanning for available plugin information.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unixlib/local.h> /* for __unixify */
|
||||
#include "oslib/fileswitch.h"
|
||||
#include "oslib/osargs.h"
|
||||
#include "oslib/osfile.h"
|
||||
#include "oslib/osfind.h"
|
||||
#include "oslib/osfscontrol.h"
|
||||
#include "oslib/osgbpb.h"
|
||||
#include "netsurf/utils/config.h"
|
||||
#include "netsurf/desktop/browser.h"
|
||||
#include "netsurf/desktop/netsurf.h"
|
||||
#include "netsurf/utils/log.h"
|
||||
#include "netsurf/utils/messages.h"
|
||||
#include "netsurf/utils/utils.h"
|
||||
|
||||
#ifdef WITH_ABOUT
|
||||
|
||||
static const char *pabouthdr = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/transitional.dtd\"><html><head><title>%s</title></head><body bgcolor=\"#f3f3ff\"><!-- About header --><table border=\"0\" width=\"100%%\" bgcolor=\"#94adff\" cellspacing=\"2\"><tr><td><a href=\"http://netsurf.sf.net\"><img src=\"file:///%%3CNetSurf$Dir%%3E/About/nslogo\" alt=\"Netsurf logo\"></a><td><table bgcolor=\"#94adff\" border=\"0\"><tr><td> <tr><td align=\"center\"><h2>NetSurf %s</h2><tr><td align=\"center\"><h5>Copyright © 2002, 2003 NetSurf Developers.</h5><tr><td> </table></table><hr>"; /**< About page header */
|
||||
static const char *pabtplghd = "<!-- Plugin information --><strong><i>The following plugins are installed on your system:</i></strong><br> <br><table border=\"0\" cellspacing=\"2\" width=\"100%\">"; /**< Plugin table header */
|
||||
static const char *paboutpl1 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>"; /**< Plugin entry without image */
|
||||
static const char *paboutpl2 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font><br><img src=\"%s\" alt=\"%s\"></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>";/**< Plugin entry with image (filename=nn) */
|
||||
static const char *paboutpl3 = "<tr valign=\"top\"><td width=\"30%%\"><font size=\"2\"><strong>%s</strong></font><br><img src=\"%s\" alt=\"%s\" width=\"%d\" height=\"%d\"></td><td width=\"70%%\"><font size=\"2\">%s</font></td></tr><tr><td colspan=\"2\" bgcolor=\"#dddddd\" height=\"1\"></td></tr>"; /**< Plugin entry with image (filename=nnwwwwhhhh) */
|
||||
static const char *pabtplgft = "</table>"; /**< Plugin table footer */
|
||||
static const char *paboutftr = "</div></body></html>"; /**< Page footer */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the browser about page.
|
||||
*
|
||||
* \param url requested url (about:...)
|
||||
* \param callback content callback function, for content_add_user()
|
||||
* \param p1 user parameter for callback
|
||||
* \param p2 user parameter for callback
|
||||
* \param width available width
|
||||
* \param height available height
|
||||
* \return a new content containing the about page
|
||||
*/
|
||||
|
||||
struct content *about_create(const char *url,
|
||||
void (*callback)(content_msg msg, struct content *c, void *p1,
|
||||
void *p2, const char *error),
|
||||
void *p1, void *p2, unsigned long width, unsigned long height)
|
||||
{
|
||||
struct content *c = 0;
|
||||
FILE *fp;
|
||||
char *buf, *val, var[20], *ptype, *pdetails, *fname, *furl;
|
||||
int i, nofiles, j, w, h, size;
|
||||
fileswitch_object_type fot;
|
||||
os_error *e;
|
||||
const char *params[] = { 0 };
|
||||
|
||||
c = content_create(url);
|
||||
c->width = width;
|
||||
c->height = height;
|
||||
content_add_user(c, callback, p1, p2);
|
||||
content_set_type(c, CONTENT_HTML, "text/html", params);
|
||||
|
||||
/* Page header */
|
||||
buf = xcalloc(strlen(pabouthdr) + 50, sizeof(char));
|
||||
snprintf(buf, strlen(pabouthdr) + 50, pabouthdr, "About NetSurf",
|
||||
netsurf_version);
|
||||
content_process_data(c, buf, strlen(buf));
|
||||
free(buf);
|
||||
|
||||
/* browser details */
|
||||
buf = load("<NetSurf$Dir>.About.About");
|
||||
content_process_data(c, buf, strlen(buf));
|
||||
free(buf);
|
||||
|
||||
/* plugin header */
|
||||
content_process_data(c, pabtplghd, strlen(pabtplghd));
|
||||
|
||||
/* plugins registered */
|
||||
for (i=0; i!=4096; i++) {
|
||||
sprintf(var, "Plugin$About_%3.3x", i);
|
||||
|
||||
if ((val = getenv(var)) != 0) {
|
||||
/* Plugin Name */
|
||||
sprintf(var, "Plugin$Type_%3.3x", i);
|
||||
ptype = getenv(var);
|
||||
|
||||
buf = xcalloc(strlen(val) + 20, sizeof(char));
|
||||
/* count files which match <Plugin$About_i>.About* */
|
||||
sprintf(buf, "%s.About*", val);
|
||||
xosfscontrol_count(buf,0,0,0,0,0,0,&nofiles);
|
||||
|
||||
for (j=0; j!=nofiles; j++) {
|
||||
/* get plugin details */
|
||||
if (j == 0) {
|
||||
sprintf(buf, "%s.About", val);
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "%s.About%2.2d", val, j);
|
||||
}
|
||||
e = xosfile_read_stamped_no_path(buf,&fot,0,0,&size,0,0);
|
||||
|
||||
/* If only one file, name can be "About" or "About00" */
|
||||
if(e || (j == 0 && (int)fot != 1)) {
|
||||
sprintf(buf, "%s.About%2.2d", val, j);
|
||||
e = xosfile_read_stamped_no_path(buf,&fot,0,0,&size,0,0);
|
||||
}
|
||||
/* ok, no file found. try again */
|
||||
if(e || (int)fot != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* read contents of file */
|
||||
fp = fopen(buf, "r");
|
||||
pdetails = xcalloc((unsigned int)size + 10, sizeof(char));
|
||||
fread(pdetails, sizeof(char), (unsigned int)size, fp);
|
||||
fclose(fp);
|
||||
|
||||
/* now see if there's an image to display */
|
||||
sprintf(buf, "%s.%2.2d", val, j);
|
||||
LOG(("buf: %s", buf));
|
||||
e = xosfile_read_stamped_no_path(buf,&fot,0,0,0,0,0);
|
||||
|
||||
if(e || (int)fot != 1) {
|
||||
sprintf(buf, "%s.%2.2d*", val, j);
|
||||
LOG(("buf: %s", buf));
|
||||
e = xosfile_read_stamped_no_path(buf,&fot,0,0,0,0,0);
|
||||
|
||||
if(e || (int)fot != 1) {
|
||||
/* Type 1: no image file */
|
||||
furl = xcalloc(strlen(paboutpl1) + strlen(ptype) + strlen(pdetails) + 10, sizeof(char));
|
||||
sprintf(furl, paboutpl1, ptype, pdetails);
|
||||
LOG(("furl: %s", furl));
|
||||
content_process_data(c, furl, strlen(furl));
|
||||
xfree(pdetails);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
void *name;
|
||||
|
||||
/* Type 3: image file with name xxwwwwhhhh */
|
||||
/* get actual file name */
|
||||
sprintf(var, "%2.2d*", j);
|
||||
LOG(("var: %s", var));
|
||||
|
||||
name = (void*)xcalloc((unsigned int)20, sizeof(char));
|
||||
|
||||
e = xosgbpb_dir_entries(val, (osgbpb_string_list*)name,
|
||||
1, 0, 255, var, NULL, NULL);
|
||||
if (e) {
|
||||
LOG(("%s", e->errmess));
|
||||
xfree(name);
|
||||
xfree(pdetails);
|
||||
continue;
|
||||
}
|
||||
LOG(("fname: %s", (char*)name));
|
||||
sprintf(buf, "%s.%s", val, (char*)name);
|
||||
furl = xcalloc(strlen(buf) + 20, sizeof(char));
|
||||
|
||||
/* grab leafname and get width and height */
|
||||
h = atoi((char*)name+6);
|
||||
((char*)name)[6] = 0;
|
||||
w = atoi((char*)name+2);
|
||||
|
||||
xfree(name);
|
||||
|
||||
/* convert to URL */
|
||||
__unixify(buf, 0, furl, strlen(buf)+20, 0);
|
||||
sprintf(buf, "file://%s", furl);
|
||||
xfree(furl);
|
||||
|
||||
LOG(("furl: %s", buf));
|
||||
furl = xcalloc(strlen(paboutpl3) + strlen(ptype) + strlen(buf) +
|
||||
strlen(pdetails) + 10, sizeof(char));
|
||||
sprintf(furl, paboutpl3, ptype, buf, ptype, w, h, pdetails);
|
||||
content_process_data(c, furl, strlen(furl));
|
||||
xfree(pdetails);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Type 2: image file with name xx */
|
||||
/* convert RO path to url */
|
||||
fname = xcalloc(strlen(buf) + 10, sizeof(char));
|
||||
furl = xcalloc(strlen(buf) + 10, sizeof(char));
|
||||
__unixify(buf, 0, furl, strlen(buf) + 10, 0);
|
||||
sprintf(fname, "file://%s", furl);
|
||||
xfree(furl);
|
||||
|
||||
furl = xcalloc(strlen(paboutpl2) + strlen(ptype) + strlen(fname) + strlen(pdetails) + 10, sizeof(char));
|
||||
sprintf(furl, paboutpl2, ptype, fname, ptype, pdetails);
|
||||
content_process_data(c, furl, strlen(furl));
|
||||
xfree(fname);
|
||||
xfree(pdetails);
|
||||
}
|
||||
}
|
||||
if (buf != 0) {
|
||||
xfree(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* plugin footer */
|
||||
content_process_data(c, pabtplgft, strlen(pabtplgft));
|
||||
|
||||
/* Page footer */
|
||||
content_process_data(c, paboutftr, strlen(paboutftr));
|
||||
|
||||
content_convert(c, c->width, c->height);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#ifdef WITH_COOKIES
|
||||
/**
|
||||
* Creates the cookie list and stores it in <Wimp$ScrapDir>.WWW.Netsurf
|
||||
*/
|
||||
void cookie_create(void) {
|
||||
|
||||
FILE *fp;
|
||||
int len, count=0;
|
||||
char *cookies = 0, *pos;
|
||||
char domain[256], flag[10], path[256], secure[10],
|
||||
exp[50], name[256], val[256];
|
||||
unsigned int expiry;
|
||||
|
||||
fp = fopen(messages_get("cookiefile"), "r");
|
||||
if (!fp) {
|
||||
LOG(("Failed to open cookie jar"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* read file length */
|
||||
fseek(fp, 0, SEEK_END);
|
||||
len = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
cookies = xcalloc((unsigned int)len, sizeof(char));
|
||||
fread(cookies, (unsigned int)len, sizeof(char), fp);
|
||||
fclose(fp);
|
||||
|
||||
xosfile_create_dir("<Wimp$ScrapDir>.WWW", 77);
|
||||
xosfile_create_dir("<Wimp$ScrapDir>.WWW.NetSurf", 77);
|
||||
fp = fopen("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", "w+");
|
||||
if (!fp) {
|
||||
xfree(cookies);
|
||||
LOG(("Failed to create file"));
|
||||
return;
|
||||
}
|
||||
fprintf(fp, pabouthdr, "About NetSurf - Cookies", netsurf_version);
|
||||
fprintf(fp, "<strong><i>The following cookies are stored on your system:</i></strong><div align=\"center\"><table cellspacing=\"2\" cellpadding=\"2\" width=\"100%%\"><strong><thead><td nowrap>Domain:</td><td nowrap>Flag:</td><td nowrap>Path:</td><td nowrap>Secure:</td><td nowrap>Expiration:</td><td nowrap>Name:</td><td nowrap>Value:</td></thead></strong><tbody>");
|
||||
pos = cookies;
|
||||
while (pos != (cookies+len-1)) {
|
||||
if (*pos == '#') {
|
||||
for (; *pos != '\n'; pos++);
|
||||
pos += 1;
|
||||
continue;
|
||||
}
|
||||
sscanf(pos, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", domain, flag, path, secure,
|
||||
exp, name, val);
|
||||
pos += (strlen(domain) + strlen(flag) + strlen(path) + strlen(secure) +
|
||||
strlen(exp) + strlen(name) +strlen(val) + 7);
|
||||
sscanf(exp, "%u", &expiry);
|
||||
fprintf(fp, "<tr%s><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td><td nowrap>%s</td></tr>", (count%2 == 0 ? " bgcolor=\"#ddddee\"" : ""), domain, flag, path, secure,
|
||||
(expiry == 0 ? "Expires on exit" : ctime((time_t*)&expiry)), name, val);
|
||||
count++;
|
||||
}
|
||||
|
||||
fprintf(fp, "</tbody></table></div></body></html>");
|
||||
fclose(fp);
|
||||
xosfile_set_type("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", 0xfaf);
|
||||
xfree(cookies);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Clean up created files
|
||||
*/
|
||||
void about_quit(void) {
|
||||
|
||||
xosfile_delete("<Wimp$ScrapDir>.WWW.NetSurf.About", 0, 0, 0, 0, 0);
|
||||
#ifdef WITH_COOKIES
|
||||
xosfile_delete("<Wimp$ScrapDir>.WWW.NetSurf.Cookies", 0, 0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* 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 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_ABOUT_H_
|
||||
#define _NETSURF_RISCOS_ABOUT_H_
|
||||
|
||||
#include "netsurf/utils/config.h"
|
||||
|
||||
#ifdef WITH_ABOUT
|
||||
void about_create(void);
|
||||
#ifdef WITH_COOKIES
|
||||
void cookie_create(void);
|
||||
#endif
|
||||
void about_quit(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,20 +0,0 @@
|
||||
/*
|
||||
* 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 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
#include "netsurf/utils/config.h"
|
||||
#include "netsurf/riscos/constdata.h"
|
||||
|
||||
#ifdef WITH_ABOUT
|
||||
const char * const ABOUT_URL = "file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/About";
|
||||
#ifdef WITH_COOKIES
|
||||
const char * const COOKIE_URL = "file:///%3CWimp$ScrapDir%3E/WWW/NetSurf/Cookies";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
const char * const THEMES_URL = "http://netsurf.sourceforge.net/themes/";
|
@ -1,24 +0,0 @@
|
||||
/*
|
||||
* 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 2003 Phil Mellor <monkeyson@users.sourceforge.net>
|
||||
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
||||
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef _NETSURF_RISCOS_CONSTDATA_H_
|
||||
#define _NETSURF_RISCOS_CONSTDATA_H_
|
||||
|
||||
#include "netsurf/utils/config.h"
|
||||
|
||||
#ifdef WITH_ABOUT
|
||||
extern const char * const ABOUT_URL;
|
||||
#ifdef WITH_COOKIES
|
||||
extern const char * const COOKIE_URL;
|
||||
#endif
|
||||
#endif
|
||||
extern const char * const GESTURES_URL;
|
||||
extern const char * const THEMES_URL;
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user