r3336 tlsa - in /trunk/netsurfweb: download/index.de download/index.en index.de
by netsurf@semichrome.net
Author: tlsa
Date: Sun Jun 10 20:31:47 2007
New Revision: 3336
URL: http://svn.semichrome.net?rev=3D3336&view=3Drev
Log:
Updated German homepage and new German download page. Thanks to Sebastian B=
arthel.
Added:
trunk/netsurfweb/download/index.de
Modified:
trunk/netsurfweb/download/index.en
trunk/netsurfweb/index.de
Added: trunk/netsurfweb/download/index.de
URL: http://svn.semichrome.net/trunk/netsurfweb/download/index.de?rev=3D333=
6&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurfweb/download/index.de (added)
+++ trunk/netsurfweb/download/index.de Sun Jun 10 20:31:47 2007
@@ -1,0 +1,72 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<title>NetSurf | Download</title>
+<link rel=3D"stylesheet" type=3D"text/css" href=3D"/netsurf.css">
+</head>
+
+<body>
+<p class=3D"banner"><a href=3D"/"><img src=3D"/netsurf.png" alt=3D"NetSurf=
: Web Browser for RISC OS"></a></p>
+<p class=3D"languages">Deutsch =C2=B7 <a href=3D"index.en">English</a></p>
+
+<h1>Download NetSurf</h1>
+
+<p id=3D"newtonetsurf"><strong>Neu bei NetSurf?</strong> Lade
+<span class=3D"highlight">NetSurf</span> von hier herunter und lies die <a
+href=3D"/info#GettingStartedInstallation">Installationsanweisungen</a>.</p>
+
+<table class=3D"download">
+<tr><th class=3D"highlight"><a href=3D"netsurf-1.0.zip"><img src=3D"/build=
s/netsurf.png"
+alt=3D""><br>NetSurf 1.0</a></th>
+<td>2.4M</td>
+<td>17 May 2007</td>
+<td>NetSurf Browser f=C3=BCr RISC OS, Vollversion.
+<strong>Empfohlen f=C3=BCr die Mehrzahl der Nutzer.</strong></td>
+</tr>
+
+<tr><th><a href=3D"netsurf-1.0-src.tar.gz"><img src=3D"/builds/netsurf.png=
" alt=3D""><br>NetSurf 1.0 Quellcode</a></th>
+<td>946kB</td>
+<td>17 May 2007</td>
+<td>NetSurf Quellcode, geeignet zum Erstellen des Browsers unter RISC OS o=
der Linux/GTK.</td>
+</tr>
+
+<!--tr><th><a href=3D"unetsurf.zip"><img src=3D"unetsurf.png" alt=3D""><br=
>Small NetSurf</a></th>
+<td>SIZE_UNETSURF</td>
+<td>DATE_UNETSURF</td>
+<td>Small NetSurf browser for RISC OS. This has support for http: and file=
: only (no https:). It is more suitable for machines with small amounts of =
RAM (8MB or less).</td>
+</tr-->
+</table>
+
+<!--p>A <a href=3D"http://www.riscpkg.org/">RiscPkg</a> package of NetSurf=
is
+available. To use it, add the line <code>pkg
+http://www.netsurf-browser.org/builds/riscpkg/packages</code> to
+<code>Choices:RiscPkg.Sources</code>. See the RiscPkg documentation for mo=
re
+information.</p-->
+
+<h2>Zus=C3=A4tzlich wird ben=C3=B6tigt :</h2>
+
+<p>NetSurf verwendet verschiedene Zusatzprogramme. Diese m=C3=BCssen auf d=
em System vorhanden sein, um NetSurf zu starten.</p>
+
+<ul>
+<li>WindowManager 3.80 oder h=C3=B6her. Dieser ist ab RISC OS 4 Systembest=
andteil. Nutzer von RISC OS 3 sollten die <a href=3D"http://acorn.riscos.co=
m/riscos/releases/UniBoot/">Universal Boot Sequence</a> installieren.</li>
+</ul>
+
+<p>Die folgenden Module werden mit NetSurf 'mitgeliefert' :</p>
+
+<ul>
+<li><a href=3D"http://sudden.recoil.org/others/">AcornURI</a> v1.04, Chris=
tian Ludlam.</li>
+<li><a href=3D"/iconv/">Iconv</a> v0.08, John-Mark Bell.</li>
+<li><a href=3D"http://www.riscos.info/downloads/gccsdk/sharedunixlib/syste=
m.zip">SharedUnixLibrary</a> v1.10, GCCSDK Team.</li>
+<li><a href=3D"http://www.tinct.net/tinct.asp">Tinct</a> v0.13, Richard Wi=
lson.</li>
+</ul>
+
+<p><strong>Optional:</strong> Eine <a href=3D"http://www.beebware.com/soft=
ware/mappings/">MimeMap Datei</a> sollte heruntergeladen und installiert we=
rden, sofern noch keine auf dem System installiert ist und/oder NetSurf ein=
e entsprechende Fehlermeldung ausgibt.</p>
+
+<div class=3D"footer">
+<p class=3D"breadcrumbs"><a href=3D"/">NetSurf</a> =C2=BB Download</p>
+<p class=3D"sourceforge"><a href=3D"http://sourceforge.net/"><img src=3D"h=
ttp://sourceforge.net/sflogo.php?group_id=3D51719&type=3D1" alt=3D"Sour=
ceForge.net"></a></p>
+</div>
+
+</body>
+</html>
Modified: trunk/netsurfweb/download/index.en
URL: http://svn.semichrome.net/trunk/netsurfweb/download/index.en?rev=3D333=
6&r1=3D3335&r2=3D3336&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurfweb/download/index.en (original)
+++ trunk/netsurfweb/download/index.en Sun Jun 10 20:31:47 2007
@@ -8,7 +8,7 @@
=
<body>
<p class=3D"banner"><a href=3D"/"><img src=3D"/netsurf.png" alt=3D"NetSurf=
: Web Browser for RISC OS"></a></p>
-<!--p class=3D"languages">English</p-->
+<p class=3D"languages"><a href=3D"index.de">Deutsch</a> =C2=B7 English</p>
=
<h1>Download NetSurf</h1>
=
Modified: trunk/netsurfweb/index.de
URL: http://svn.semichrome.net/trunk/netsurfweb/index.de?rev=3D3336&r1=3D33=
35&r2=3D3336&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurfweb/index.de (original)
+++ trunk/netsurfweb/index.de Sun Jun 10 20:31:47 2007
@@ -2,7 +2,7 @@
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
-<title>NetSurf | Open Source Web Browser f=C3=BCr RISC OS</title>
+<title>NetSurf | Open Source Web-Browser f=C3=BCr RISC OS</title>
<link rel=3D"stylesheet" type=3D"text/css" href=3D"netsurf.css">
</head>
=
@@ -16,8 +16,8 @@
=
<p>NetSurf ist ein Open-Source Web-Browser f=C3=BCr RISC OS und wird unter=
der <a href=3D"licence">GPL</a> lizensiert. Ziel dieses Projektes ist es, =
die Standards HTML 4 und CSS auf der RISC OS Plattform zur Verf=C3=BCg=
ung zu stellen. NetSurf ist ein schlankes, schnelles und einfach zu bediene=
ndes Programm.</p>
=
-<p>The latest release is 1.0.<strong>
-<a href=3D"download/">Download NetSurf 1.0 for RISC OS</a>.</strong></p>
+<p>Die aktuelle Programmversion ist Version 1.0 .<strong>
+<a href=3D"download/">Downloaden von NetSurf 1.0 f=C3=BCr RISC OS</a>.</st=
rong></p>
=
<p>NetSurf befindet sich in stetiger Entwicklung auch wenn bisher noch kei=
ne Vollversion ver=C3=B6ffentlicht wurde. Testversionen stehen zum <a href=
=3D"builds/">Download</a> bereit. Diese werden automatisch aller 15 Minuten=
aus dem Quellcode auf <a href=3D"http://source.netsurf-browser.org/trunk/n=
etsurf/">Subversion</a> erzeugt.</p>
=
@@ -51,7 +51,7 @@
=
<dl>
<dt><a href=3D"download/">Download</a></dt>
-<dd>Get NetSurf 1.0</dd>
+<dd>NetSurf 1.0 herunterladen</dd>
=
<dt><a href=3D"docs">Dokumentation</a></dt>
<dd>Allgemeine Informationen und Handbuch</dd>
15 years, 7 months
r3335 jmb - /trunk/netsurf/render/html.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Jun 10 20:30:37 2007
New Revision: 3335
URL: http://svn.semichrome.net?rev=3D3335&view=3Drev
Log:
Fix UTF-16LE BOM detection _again_
Modified:
trunk/netsurf/render/html.c
Modified: trunk/netsurf/render/html.c
URL: http://svn.semichrome.net/trunk/netsurf/render/html.c?rev=3D3335&r1=3D=
3334&r2=3D3335&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Sun Jun 10 20:30:37 2007
@@ -355,7 +355,7 @@
*data +=3D 2;
*size -=3D 2;
return "UTF-16BE";
- } else if (d[0] =3D=3D 0xfe && d[1] =3D=3D 0xff) { /* BOM ff fe */
+ } else if (d[0] =3D=3D 0xff && d[1] =3D=3D 0xfe) { /* BOM ff fe */
*data +=3D 2;
*size -=3D 2;
return "UTF-16LE";
15 years, 7 months
r3334 dsilvers - /trunk/netsurf/utils/useragent.c
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 19:13:59 2007
New Revision: 3334
URL: http://svn.semichrome.net?rev=3D3334&view=3Drev
Log:
Reflow useragent.c to be 8 char indent. Also rename build_user_agent to use=
r_agent_build_string so that all useragent.c starts user_agent_*
Modified:
trunk/netsurf/utils/useragent.c
Modified: trunk/netsurf/utils/useragent.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/useragent.c?rev=3D3334&r=
1=3D3333&r2=3D3334&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/utils/useragent.c (original)
+++ trunk/netsurf/utils/useragent.c Sun Jun 10 19:13:59 2007
@@ -23,46 +23,46 @@
* user agent in HTTP requests.
*/
static void
-build_user_agent(void)
+user_agent_build_string(void)
{
- struct utsname un;
- const char *sysname =3D "Unknown";
- const char *machine =3D "Unknown";
- char *ua_string;
- int len;
+ struct utsname un;
+ const char *sysname =3D "Unknown";
+ const char *machine =3D "Unknown";
+ char *ua_string;
+ int len;
=
- if (uname(&un) =3D=3D 0) {
- sysname =3D un.sysname;
- machine =3D un.machine;
- }
+ if (uname(&un) =3D=3D 0) {
+ sysname =3D un.sysname;
+ machine =3D un.machine;
+ }
=
- len =3D snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING,
+ len =3D snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING,
+ netsurf_version_major,
+ netsurf_version_minor,
+ sysname,
+ machine);
+ ua_string =3D malloc(len + 1);
+ if (!ua_string) {
+ /** \todo this needs handling better */
+ return;
+ }
+ snprintf(ua_string, len + 1,
+ NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
sysname,
machine);
- ua_string =3D malloc(len + 1);
- if (!ua_string) {
- /** \todo this needs handling better */
- return;
- }
- snprintf(ua_string, len + 1,
- NETSURF_UA_FORMAT_STRING,
- netsurf_version_major,
- netsurf_version_minor,
- sysname,
- machine);
=
- core_user_agent_string =3D ua_string;
+ core_user_agent_string =3D ua_string;
=
- LOG(("Built user agent \"%s\"", core_user_agent_string));
+ LOG(("Built user agent \"%s\"", core_user_agent_string));
}
=
/* This is a function so that later we can override it trivially */
const char *
user_agent_string(void)
{
- if (core_user_agent_string =3D=3D NULL)
- build_user_agent();
- return core_user_agent_string;
+ if (core_user_agent_string =3D=3D NULL)
+ user_agent_build_string();
+ return core_user_agent_string;
}
15 years, 7 months
r3333 dsilvers - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 19:12:30 2007
New Revision: 3333
URL: http://svn.semichrome.net?rev=3D3333&view=3Drev
Log:
Add debug about ring sizes. Ensure we dispatch queued jobs when a job is fr=
eed.
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3D3333&r1=
=3D3332&r2=3D3333&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Jun 10 19:12:30 2007
@@ -384,6 +384,8 @@
}
}
fetch_active =3D (all_active > 0);
+ LOG(("Fetch ring is now %d elements.", all_active));
+ LOG(("Queue ring is now %d elements.", all_queued));
}
=
/**
@@ -509,6 +511,8 @@
void
fetch_can_be_freed(struct fetch *fetch)
{
+ int all_active, all_queued;
+ =
/* Go ahead and free the fetch properly now */
LOG(("Fetch %p, fetcher %p can be freed", fetch, fetch->fetcher_ha=
ndle));
=
@@ -518,9 +522,17 @@
RING_REMOVE(queue_ring, fetch);
}
=
- fetch_active =3D (fetch_ring !=3D NULL);
+ RING_GETSIZE(struct fetch, fetch_ring, all_active);
+ RING_GETSIZE(struct fetch, queue_ring, all_queued);
=
+ fetch_active =3D (all_active > 0);
+ =
+ LOG(("Fetch ring is now %d elements.", all_active));
+ LOG(("Queue ring is now %d elements.", all_queued));
+
fetch_free(fetch);
+ =
+ fetch_dispatch_jobs();
}
=
void
15 years, 7 months
r3332 jmb - in /trunk/netsurf: content/fetch.c content/fetch.h content/fetchers/fetch_curl.c utils/useragent.c
by netsurf@semichrome.net
Author: jmb
Date: Sun Jun 10 19:08:22 2007
New Revision: 3332
URL: http://svn.semichrome.net?rev=3D3332&view=3Drev
Log:
Warning fixes.
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/content/fetchers/fetch_curl.c
trunk/netsurf/utils/useragent.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3D3332&r1=
=3D3331&r2=3D3332&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Jun 10 19:08:22 2007
@@ -255,7 +255,7 @@
fetch->referer =3D 0;
fetch->ops =3D 0;
fetch->fetch_is_active =3D false;
- =
+
if (referer !=3D NULL) {
fetch->referer =3D strdup(referer);
if (fetch->referer =3D=3D NULL)
@@ -276,33 +276,33 @@
}
fetcher =3D fetcher->next_fetcher;
}
- =
+
if (fetch->ops =3D=3D NULL)
goto failed;
- =
+
/* Got a scheme fetcher, try and set up the fetch */
- fetch->fetcher_handle =3D =
+ fetch->fetcher_handle =3D
fetch->ops->setup_fetch(fetch, url, only_2xx, post_urlenc,
post_multipart, verifiable, parent=
_url,
(const char **)headers);
- =
+
if (fetch->fetcher_handle =3D=3D NULL)
goto failed;
- =
+
/* Rah, got it, so ref the fetcher. */
fetch_ref_fetcher(fetch->ops);
- =
+
/* these aren't needed past here */
if (ref1) {
free(ref1);
ref1 =3D 0;
}
- =
+
if (ref2) {
free(ref2);
ref2 =3D 0;
}
- =
+
/* Dump us in the queue and ask the queue to run. */
RING_INSERT(queue_ring, fetch);
fetch_dispatch_jobs();
@@ -446,18 +446,18 @@
const char *semi;
size_t len;
scheme_fetcher *fetcher =3D fetchers;
- =
+
if ((semi =3D strchr(url, ':')) =3D=3D NULL)
return false;
len =3D semi - url;
- =
+
while (fetcher !=3D NULL) {
if (strlen(fetcher->scheme_name) =3D=3D len &&
strncmp(fetcher->scheme_name, url, len) =3D=3D 0)
return true;
fetcher =3D fetcher->next_fetcher;
}
- =
+
return false;
}
=
@@ -498,9 +498,10 @@
}
=
void
-fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsign=
ed long size)
-{
- LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size =
%d",
+fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
+ unsigned long size)
+{
+ LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size =
%lu",
fetch, fetch->fetcher_handle, data, size));
fetch->callback(msg, fetch->p, data, size);
}
@@ -525,7 +526,7 @@
void
fetch_set_http_code(struct fetch *fetch, long http_code)
{
- LOG(("Setting HTTP code to %d", http_code));
+ LOG(("Setting HTTP code to %ld", http_code));
fetch->http_code =3D http_code;
}
=
Modified: trunk/netsurf/content/fetch.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.h?rev=3D3332&r1=
=3D3331&r2=3D3332&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Sun Jun 10 19:08:22 2007
@@ -90,7 +90,7 @@
=
typedef bool (*fetcher_initialise)(const char *);
typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
- bool, const char *, =
+ bool, const char *,
struct form_successful_control *, boo=
l,
const char *, const char **);
typedef bool (*fetcher_start_fetch)(void *);
@@ -108,7 +108,8 @@
fetcher_poll_fetcher poll_fetcher,
fetcher_finalise finaliser);
=
-void fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, u=
nsigned long size);
+void fetch_send_callback(fetch_msg msg, struct fetch *fetch,
+ const void *data, unsigned long size);
void fetch_can_be_freed(struct fetch *fetch);
void fetch_set_http_code(struct fetch *fetch, long http_code);
const char *fetch_get_referer_to_send(struct fetch *fetch);
Modified: trunk/netsurf/content/fetchers/fetch_curl.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetchers/fetch_curl.c?=
rev=3D3332&r1=3D3331&r2=3D3332&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetchers/fetch_curl.c (original)
+++ trunk/netsurf/content/fetchers/fetch_curl.c Sun Jun 10 19:08:22 2007
@@ -162,9 +162,9 @@
fetch =3D malloc(sizeof (*fetch));
if (!fetch)
return 0;
- =
+
fetch->fetch_handle =3D parent_fetch;
- =
+
res =3D url_host(url, &host);
if (res !=3D URL_FUNC_OK) {
/* we only fail memory exhaustion */
@@ -175,7 +175,7 @@
if (!host)
goto failed;
}
- =
+
LOG(("fetch %p, url '%s'", fetch, url));
=
/* construct a new fetch structure */
@@ -255,13 +255,13 @@
/* And add any headers specified by the caller */
for (i =3D 0; headers[i]; i++) {
if (strncasecmp(headers[i], "If-Modified-Since:", 18) =3D=3D 0) {
- char *d =3D headers[i] + 18;
+ const char *d =3D headers[i] + 18;
for (; *d && (*d =3D=3D ' ' || *d =3D=3D '\t'); d++)
/* do nothing */;
fetch->last_modified =3D curl_getdate(d, NULL);
}
else if (strncasecmp(headers[i], "If-None-Match:", 14) =3D=3D 0) {
- char *d =3D headers[i] + 14;
+ const char *d =3D headers[i] + 14;
for (; *d && (*d =3D=3D ' ' || *d =3D=3D '\t' || *d =3D=3D '"');
d++)
/* do nothing */;
@@ -758,7 +758,7 @@
#endif
else if (error)
fetch_send_callback(FETCH_ERROR, f->fetch_handle, fetch_error_buffer, 0);
- =
+
fetch_curl_stop(f);
}
=
@@ -1277,13 +1277,13 @@
/* All the fetchers have been finalised. */
LOG(("All cURL fetchers finalised, closing down cURL"));
CURLMcode codem;
- =
+
curl_easy_cleanup(fetch_blank_curl);
- =
+
codem =3D curl_multi_cleanup(fetch_curl_multi);
if (codem !=3D CURLM_OK)
LOG(("curl_multi_cleanup failed: ignoring"));
- =
+
curl_global_cleanup();
}
}
@@ -1299,7 +1299,7 @@
CURLcode code;
curl_version_info_data *data;
int i;
- =
+
LOG(("curl_version %s", curl_version()));
=
code =3D curl_global_init(CURL_GLOBAL_ALL);
@@ -1318,7 +1318,7 @@
if (!fetch_blank_curl)
die("Failed to initialise the fetch module "
"(curl_easy_init failed).");
- =
+
#undef SETOPT
#define SETOPT(option, value) \
code =3D curl_easy_setopt(fetch_blank_curl, option, value); \
@@ -1344,9 +1344,9 @@
=
if (option_ca_bundle)
SETOPT(CURLOPT_CAINFO, option_ca_bundle);
- =
+
/* cURL initialised okay, register the fetchers */
- =
+
data =3D curl_version_info(CURLVERSION_NOW);
=
for (i =3D 0; data->protocols[i]; i++)
Modified: trunk/netsurf/utils/useragent.c
URL: http://svn.semichrome.net/trunk/netsurf/utils/useragent.c?rev=3D3332&r=
1=3D3331&r2=3D3332&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/utils/useragent.c (original)
+++ trunk/netsurf/utils/useragent.c Sun Jun 10 19:08:22 2007
@@ -8,10 +8,11 @@
=
#include <sys/utsname.h>
#include <stdio.h>
+#include <stdlib.h>
=
-#include "useragent.h"
#include "desktop/netsurf.h"
#include "utils/log.h"
+#include "utils/useragent.h"
=
static const char *core_user_agent_string =3D NULL;
=
@@ -27,25 +28,32 @@
struct utsname un;
const char *sysname =3D "Unknown";
const char *machine =3D "Unknown";
+ char *ua_string;
int len;
- =
+
if (uname(&un) =3D=3D 0) {
sysname =3D un.sysname;
machine =3D un.machine;
}
- =
+
len =3D snprintf(NULL, 0, NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
- un.sysname,
- un.machine);
- core_user_agent_string =3D malloc(len + 1);
- snprintf(core_user_agent_string, len + 1,
+ sysname,
+ machine);
+ ua_string =3D malloc(len + 1);
+ if (!ua_string) {
+ /** \todo this needs handling better */
+ return;
+ }
+ snprintf(ua_string, len + 1,
NETSURF_UA_FORMAT_STRING,
netsurf_version_major,
netsurf_version_minor,
- un.sysname,
- un.machine);
+ sysname,
+ machine);
+
+ core_user_agent_string =3D ua_string;
=
LOG(("Built user agent \"%s\"", core_user_agent_string));
}
15 years, 7 months
r3331 dsilvers - /trunk/netsurf/content/fetch.c
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 18:55:07 2007
New Revision: 3331
URL: http://svn.semichrome.net?rev=3D3331&view=3Drev
Log:
Remove a time consuming LOG(()) and add some whitespace to help me think
Modified:
trunk/netsurf/content/fetch.c
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3D3331&r1=
=3D3330&r2=3D3331&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Jun 10 18:55:07 2007
@@ -427,7 +427,7 @@
if (!fetch_active)
return; /* No point polling, there's no fetch active. */
while (fetcher !=3D NULL) {
- LOG(("Polling fetcher for %s", fetcher->scheme_name));
+ /* LOG(("Polling fetcher for %s", fetcher->scheme_name)); =
*/
fetcher->poll_fetcher(fetcher->scheme_name);
fetcher =3D fetcher->next_fetcher;
}
@@ -510,12 +510,15 @@
{
/* Go ahead and free the fetch properly now */
LOG(("Fetch %p, fetcher %p can be freed", fetch, fetch->fetcher_ha=
ndle));
+ =
if (fetch->fetch_is_active) {
RING_REMOVE(fetch_ring, fetch);
} else {
RING_REMOVE(queue_ring, fetch);
}
+ =
fetch_active =3D (fetch_ring !=3D NULL);
+ =
fetch_free(fetch);
}
=
15 years, 7 months
r3330 dsilvers - in /trunk/netsurf: content/fetch.c content/fetch.h content/fetchers/ gtk/gtk_gui.c makefile utils/ring.h utils/useragent.c utils/useragent.h
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 18:46:44 2007
New Revision: 3330
URL: http://svn.semichrome.net?rev=3D3330&view=3Drev
Log:
Merge scheme switcher branch in.
Added:
trunk/netsurf/content/fetchers/
- copied from r3329, branches/dsilvers/scheme-switcher/content/fetche=
rs/
trunk/netsurf/utils/ring.h
- copied unchanged from r3329, branches/dsilvers/scheme-switcher/util=
s/ring.h
trunk/netsurf/utils/useragent.c
- copied unchanged from r3329, branches/dsilvers/scheme-switcher/util=
s/useragent.c
trunk/netsurf/utils/useragent.h
- copied unchanged from r3329, branches/dsilvers/scheme-switcher/util=
s/useragent.h
Modified:
trunk/netsurf/content/fetch.c
trunk/netsurf/content/fetch.h
trunk/netsurf/gtk/gtk_gui.c
trunk/netsurf/makefile
Modified: trunk/netsurf/content/fetch.c
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.c?rev=3D3330&r1=
=3D3329&r2=3D3330&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.c (original)
+++ trunk/netsurf/content/fetch.c Sun Jun 10 18:46:44 2007
@@ -2,21 +2,18 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2006 Daniel Silverstone <dsilvers(a)digital-scurf.org>
+ * Copyright 2006,2007 Daniel Silverstone <dsilvers(a)digital-scurf.org>
* Copyright 2007 James Bursa <bursa(a)users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson(a)users.sourceforge.net>
*/
=
/** \file
* Fetching of data from a URL (implementation).
- *
- * This implementation uses libcurl's 'multi' interface.
*
* Active fetches are held in the circular linked list ::fetch_ring. There=
may
* be at most ::option_max_fetchers_per_host active requests per Host: hea=
der.
* There may be at most ::option_max_fetchers active requests overall. Ina=
ctive
- * fetchers are stored in the ::queue_ring and there are at most
- * ::option_max_cached_fetch_handles kept in there at any one time.
+ * fetchers are stored in the ::queue_ring waiting for use.
*/
=
#include <assert.h>
@@ -27,16 +24,15 @@
#include <time.h>
#include <sys/select.h>
#include <sys/stat.h>
-#include <sys/utsname.h>
#ifdef riscos
#include <unixlib/local.h>
#endif
-#include <curl/curl.h>
#include "utils/config.h"
#ifdef WITH_SSL
#include <openssl/ssl.h>
#endif
#include "content/fetch.h"
+#include "content/fetchers/fetch_curl.h"
#include "content/urldb.h"
#include "desktop/netsurf.h"
#include "desktop/options.h"
@@ -46,172 +42,107 @@
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
-
+#include "utils/ring.h"
=
bool fetch_active; /**< Fetches in progress, please call fetch_poll(). */
=
-#ifdef WITH_SSL
-/** SSL certificate info */
-struct cert_info {
- X509 *cert; /**< Pointer to certificate */
- long err; /**< OpenSSL error code */
-};
-#endif
+/** Information about a fetcher for a given scheme. */
+typedef struct scheme_fetcher_s {
+ char *scheme_name; /**< The scheme. */
+ fetcher_setup_fetch setup_fetch; /**< Set up a fetch. */
+ fetcher_start_fetch start_fetch; /**< Start a fetch. */
+ fetcher_abort_fetch abort_fetch; /**< Abort a fetch. */
+ fetcher_free_fetch free_fetch; /**< Free a fetch. */
+ fetcher_poll_fetcher poll_fetcher; /**< Poll this fetcher. */
+ fetcher_finalise finaliser; /**< Clean up this fetcher. */
+ int refcount; /**< When zero, clean up the fetcher. */
+ struct scheme_fetcher_s *next_fetcher; /**< Next fetcher in the li=
st. */
+ struct scheme_fetcher_s *prev_fetcher; /**< Prev fetcher in the l=
ist. */
+} scheme_fetcher;
+
+static scheme_fetcher *fetchers =3D NULL;
=
/** Information for a single fetch. */
struct fetch {
- CURL * curl_handle; /**< cURL handle if being fetched, or 0. */
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size);
- /**< Callback function. */
- bool had_headers; /**< Headers have been processed. */
+ fetch_callback callback;/**< Callback function. */
bool abort; /**< Abort requested. */
bool stopped; /**< Download stopped on purpose. */
- bool only_2xx; /**< Only HTTP 2xx responses acceptable. */
- bool verifiable; /**< Transaction is verifiable */
- char *url; /**< URL. */
- char *referer; /**< URL for Referer header. */
+ char *url; /**< URL. */
+ char *referer; /**< Referer URL. */
bool send_referer; /**< Valid to send the referer */
- char *parent_fetch_url; /**< URL of parent fetch (not necessarily
- * the same as the referer) */
void *p; /**< Private data for callback. */
- struct curl_slist *headers; /**< List of request headers. */
char *host; /**< Host part of URL. */
- char *location; /**< Response Location header, or 0. */
- unsigned long content_length; /**< Response Content-Length, or 0. */
long http_code; /**< HTTP response code, or 0. */
- char *cookie_string; /**< Cookie string for this fetch */
- char *realm; /**< HTTP Auth Realm */
- char *post_urlenc; /**< Url encoded POST string, or 0. */
- struct curl_httppost *post_multipart; /**< Multipart post data, or 0. */
- struct cache_data cachedata; /**< Cache control data */
- time_t last_modified; /**< If-Modified-Since time */
- time_t file_etag; /**< ETag for local objects */
-#ifdef WITH_SSL
-#define MAX_CERTS 10
- struct cert_info cert_data[MAX_CERTS]; /**< HTTPS certificate data */
-#endif
+ scheme_fetcher *ops; /**< Fetcher operations for this fetch. NULL =
if not set. */
+ void *fetcher_handle; /**< The handle for the fetcher. */
+ bool fetch_is_active; /**< This fetch is active. */
struct fetch *r_prev; /**< Previous active fetch in ::fetch_ring. */
struct fetch *r_next; /**< Next active fetch in ::fetch_ring. */
};
=
-struct cache_handle {
- CURL *handle; /**< The cached cURL handle */
- char *host; /**< The host for which this handle is cached */
-
- struct cache_handle *r_prev; /**< Previous cached handle in ring. */
- struct cache_handle *r_next; /**< Next cached handle in ring. */
-};
-
-CURLM *fetch_curl_multi; /**< Global cURL multi handle. */
-/** Curl handle with default options set; not used for transfers. */
-static CURL *fetch_blank_curl;
static struct fetch *fetch_ring =3D 0; /**< Ring of active fetches. */
static struct fetch *queue_ring =3D 0; /**< Ring of queued fetches */
-static struct cache_handle *handle_ring =3D 0; /**< Ring of cached handles=
*/
-
-static char fetch_error_buffer[CURL_ERROR_SIZE]; /**< Error buffer for cUR=
L. */
-static char fetch_progress_buffer[256]; /**< Progress buffer for cURL */
-static char fetch_proxy_userpwd[100]; /**< Proxy authentication details. */
-static char fetch_user_agent[100] =3D "NetSurf";
-
-static void fetch_init_user_agent(void);
-static CURLcode fetch_set_options(struct fetch *f);
-#ifdef WITH_SSL
-static CURLcode fetch_sslctxfun(CURL *curl_handle, SSL_CTX *sslctx, void *=
p);
-#endif
+
static void fetch_free(struct fetch *f);
-static void fetch_stop(struct fetch *f);
-static void fetch_done(CURL *curl_handle, CURLcode result);
-static int fetch_curl_progress(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow);
-static size_t fetch_curl_data(void *data, size_t size, size_t nmemb,
- struct fetch *f);
-static size_t fetch_curl_header(char *data, size_t size, size_t nmemb,
- struct fetch *f);
-static bool fetch_process_headers(struct fetch *f);
-static struct curl_httppost *fetch_post_convert(
- struct form_successful_control *control);
-#ifdef WITH_SSL
-static int fetch_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ct=
x);
-static int fetch_cert_verify_callback(X509_STORE_CTX *x509_ctx, void *parm=
);
-#endif
-
-/** Insert the given item into the specified ring.
- * Assumes that the element is zeroed as appropriate.
- */
-#define RING_INSERT(ring,element) \
- /*LOG(("RING_INSERT(%s, %p(%s))", #ring, element, element->host));*/ \
- if (ring) { \
- element->r_next =3D ring; \
- element->r_prev =3D ring->r_prev; \
- ring->r_prev =3D element; \
- element->r_prev->r_next =3D element; \
- } else \
- ring =3D element->r_prev =3D element->r_next =3D element
-
-/** Remove the given element from the specified ring.
- * Will zero the element as needed
- */
-#define RING_REMOVE(ring, element) \
- /*LOG(("RING_REMOVE(%s, %p(%s)", #ring, element, element->host));*/ \
- if (element->r_next !=3D element ) { \
- /* Not the only thing in the ring */ \
- element->r_next->r_prev =3D element->r_prev; \
- element->r_prev->r_next =3D element->r_next; \
- if (ring =3D=3D element) ring =3D element->r_next; \
- } else { \
- /* Only thing in the ring */ \
- ring =3D 0; \
- } \
- element->r_next =3D element->r_prev =3D 0
-
-/** Find the element (by hostname) in the given ring, leave it in the
- * provided element variable
- */
-#define RING_FINDBYHOST(ring, element, hostname) \
- /*LOG(("RING_FINDBYHOST(%s, %s)", #ring, hostname));*/ \
- if (ring) { \
- bool found =3D false; \
- element =3D ring; \
- do { \
- if (strcasecmp(element->host, hostname) =3D=3D 0) { \
- found =3D true; \
- break; \
- } \
- element =3D element->r_next; \
- } while (element !=3D ring); \
- if (!found) element =3D 0; \
- } else element =3D 0
-
-/** Measure the size of a ring and put it in the supplied variable */
-#define RING_GETSIZE(ringtype, ring, sizevar) \
- /*LOG(("RING_GETSIZE(%s)", #ring));*/ \
- if (ring) { \
- ringtype *p =3D ring; \
- sizevar =3D 0; \
- do { \
- sizevar++; \
- p =3D p->r_next; \
- } while (p !=3D ring); \
- } else sizevar =3D 0
-
-/** Count the number of elements in the ring which match the provided host=
name */
-#define RING_COUNTBYHOST(ringtype, ring, sizevar, hostname) \
- /*LOG(("RING_COUNTBYHOST(%s, %s)", #ring, hostname));*/ \
- if (ring) { \
- ringtype *p =3D ring; \
- sizevar =3D 0; \
- do { \
- if (strcasecmp(p->host, hostname) =3D=3D 0) \
- sizevar++; \
- p =3D p->r_next; \
- } while (p !=3D ring); \
- } else sizevar =3D 0
-
-static void fetch_cache_handle(CURL *handle, char *hostname);
static void fetch_dispatch_jobs(void);
=
+#define fetch_ref_fetcher(F) F->refcount++;
+
+static void fetch_unref_fetcher(scheme_fetcher *fetcher)
+{
+ if (--fetcher->refcount =3D=3D 0) {
+ fetcher->finaliser(fetcher->scheme_name);
+ free(fetcher->scheme_name);
+ if (fetcher =3D=3D fetchers) {
+ fetchers =3D fetcher->next_fetcher;
+ if (fetchers)
+ fetchers->prev_fetcher =3D NULL;
+ } else {
+ fetcher->prev_fetcher->next_fetcher =3D fetcher->n=
ext_fetcher;
+ if (fetcher->next_fetcher !=3D NULL)
+ fetcher->next_fetcher->prev_fetcher =3D fe=
tcher->prev_fetcher;
+ }
+ free(fetcher);
+ }
+}
+
+bool
+fetch_add_fetcher(const char *scheme,
+ fetcher_initialise initialiser,
+ fetcher_setup_fetch setup_fetch,
+ fetcher_start_fetch start_fetch,
+ fetcher_abort_fetch abort_fetch,
+ fetcher_free_fetch free_fetch,
+ fetcher_poll_fetcher poll_fetcher,
+ fetcher_finalise finaliser)
+{
+ scheme_fetcher *new_fetcher;
+ if (!initialiser(scheme))
+ return false;
+ new_fetcher =3D malloc(sizeof(scheme_fetcher));
+ if (new_fetcher =3D=3D NULL) {
+ finaliser(scheme);
+ return false;
+ }
+ new_fetcher->scheme_name =3D strdup(scheme);
+ if (new_fetcher->scheme_name =3D=3D NULL) {
+ free(new_fetcher);
+ finaliser(scheme);
+ return false;
+ }
+ new_fetcher->refcount =3D 0;
+ new_fetcher->setup_fetch =3D setup_fetch;
+ new_fetcher->start_fetch =3D start_fetch;
+ new_fetcher->abort_fetch =3D abort_fetch;
+ new_fetcher->free_fetch =3D free_fetch;
+ new_fetcher->poll_fetcher =3D poll_fetcher;
+ new_fetcher->finaliser =3D finaliser;
+ new_fetcher->next_fetcher =3D fetchers;
+ fetchers =3D new_fetcher;
+ fetch_ref_fetcher(new_fetcher);
+ return true;
+}
+
/**
* Initialise the fetcher.
*
@@ -220,86 +151,8 @@
=
void fetch_init(void)
{
- CURLcode code;
-
- LOG(("curl_version %s", curl_version()));
-
- code =3D curl_global_init(CURL_GLOBAL_ALL);
- if (code !=3D CURLE_OK)
- die("Failed to initialise the fetch module "
- "(curl_global_init failed).");
-
- fetch_curl_multi =3D curl_multi_init();
- if (!fetch_curl_multi)
- die("Failed to initialise the fetch module "
- "(curl_multi_init failed).");
-
- fetch_init_user_agent();
-
- /* Create a curl easy handle with the options that are common to all
- fetches. */
- fetch_blank_curl =3D curl_easy_init();
- if (!fetch_blank_curl)
- die("Failed to initialise the fetch module "
- "(curl_easy_init failed).");
-
-#define SETOPT(option, value) \
- code =3D curl_easy_setopt(fetch_blank_curl, option, value); \
- if (code !=3D CURLE_OK) \
- goto curl_easy_setopt_failed;
-
- if (verbose_log) {
- SETOPT(CURLOPT_VERBOSE, 1);
- } else {
- SETOPT(CURLOPT_VERBOSE, 0);
- }
- SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer);
- SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data);
- SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header);
- SETOPT(CURLOPT_PROGRESSFUNCTION, fetch_curl_progress);
- SETOPT(CURLOPT_NOPROGRESS, 0);
- SETOPT(CURLOPT_USERAGENT, fetch_user_agent);
- SETOPT(CURLOPT_ENCODING, "gzip");
- SETOPT(CURLOPT_LOW_SPEED_LIMIT, 1L);
- SETOPT(CURLOPT_LOW_SPEED_TIME, 180L);
- SETOPT(CURLOPT_NOSIGNAL, 1L);
- SETOPT(CURLOPT_CONNECTTIMEOUT, 30L);
-
- if (option_ca_bundle)
- SETOPT(CURLOPT_CAINFO, option_ca_bundle);
-
- return;
-
-curl_easy_setopt_failed:
- die("Failed to initialise the fetch module "
- "(curl_easy_setopt failed).");
-}
-
-
-/**
- * Fill fetch_user_agent with a string suitable for use as a user agent in
- * HTTP requests.
- */
-
-void fetch_init_user_agent(void)
-{
- struct utsname un;
-
- if (uname(&un) !=3D 0) {
- LOG(("uname: %i %s", errno, strerror(errno)));
- die("Failed to initialise the fetch module "
- "(uname failed).");
- }
-
- snprintf(fetch_user_agent, sizeof fetch_user_agent,
- "NetSurf/%d.%d (%s; %s)",
- netsurf_version_major,
- netsurf_version_minor,
- un.sysname,
- un.machine);
- fetch_user_agent[sizeof fetch_user_agent - 1] =3D 0;
-
- LOG(("fetch_user_agent \"%s\"", fetch_user_agent));
+ register_curl_fetchers();
+ fetch_active =3D false;
}
=
=
@@ -311,15 +164,14 @@
=
void fetch_quit(void)
{
- CURLMcode codem;
-
- curl_easy_cleanup(fetch_blank_curl);
-
- codem =3D curl_multi_cleanup(fetch_curl_multi);
- if (codem !=3D CURLM_OK)
- LOG(("curl_multi_cleanup failed: ignoring"));
-
- curl_global_cleanup();
+ while (fetchers !=3D NULL) {
+ if (fetchers->refcount !=3D 1) {
+ LOG(("Fetcher for scheme %s still active?!", fetch=
ers->scheme_name));
+ /* We shouldn't do this, but... */
+ fetchers->refcount =3D 1;
+ }
+ fetch_unref_fetcher(fetchers);
+ }
}
=
=
@@ -341,23 +193,19 @@
* data contains an error message. FETCH_REDIRECT may replace the FETCH_TY=
PE,
* FETCH_DATA, FETCH_FINISHED sequence if the server sends a replacement U=
RL.
*
- * Some private data can be passed as the last parameter to fetch_start, a=
nd
- * callbacks will contain this.
*/
=
struct fetch * fetch_start(const char *url, const char *referer,
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size),
- void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
- bool verifiable, const char *parent_url, char *headers[])
+ fetch_callback callback,
+ void *p, bool only_2xx, const char *post_urlenc,
+ struct form_successful_control *post_multipart,
+ bool verifiable, const char *parent_url, char *=
headers[])
{
char *host;
struct fetch *fetch;
- struct curl_slist *slist;
url_func_result res;
char *ref1 =3D 0, *ref2 =3D 0;
- int i;
+ scheme_fetcher *fetcher =3D fetchers;
=
fetch =3D malloc(sizeof (*fetch));
if (!fetch)
@@ -395,120 +243,67 @@
LOG(("fetch %p, url '%s'", fetch, url));
=
/* construct a new fetch structure */
- fetch->curl_handle =3D 0;
fetch->callback =3D callback;
- fetch->had_headers =3D false;
fetch->abort =3D false;
fetch->stopped =3D false;
- fetch->only_2xx =3D only_2xx;
- fetch->verifiable =3D verifiable;
fetch->url =3D strdup(url);
- fetch->referer =3D 0;
- fetch->send_referer =3D false;
- /* only send the referer if the schemes match */
- if (referer) {
- fetch->referer =3D strdup(referer);
+ fetch->p =3D p;
+ fetch->host =3D host;
+ fetch->http_code =3D 0;
+ fetch->r_prev =3D 0;
+ fetch->r_next =3D 0;
+ fetch->referer =3D 0;
+ fetch->ops =3D 0;
+ fetch->fetch_is_active =3D false;
+ =
+ if (referer !=3D NULL) {
+ fetch->referer =3D strdup(referer);
+ if (fetch->referer =3D=3D NULL)
+ goto failed;
if (option_send_referer && ref1 && ref2 &&
strcasecmp(ref1, ref2) =3D=3D 0)
fetch->send_referer =3D true;
- }
- fetch->parent_fetch_url =3D parent_url ? strdup(parent_url) : 0;
- fetch->p =3D p;
- fetch->headers =3D 0;
- fetch->host =3D host;
- fetch->location =3D 0;
- fetch->content_length =3D 0;
- fetch->http_code =3D 0;
- fetch->cookie_string =3D 0;
- fetch->realm =3D 0;
- fetch->post_urlenc =3D 0;
- fetch->post_multipart =3D 0;
- if (post_urlenc)
- fetch->post_urlenc =3D strdup(post_urlenc);
- else if (post_multipart)
- fetch->post_multipart =3D fetch_post_convert(post_multipart);
- fetch->cachedata.req_time =3D time(0);
- fetch->cachedata.res_time =3D 0;
- fetch->cachedata.date =3D 0;
- fetch->cachedata.expires =3D 0;
- fetch->cachedata.age =3D INVALID_AGE;
- fetch->cachedata.max_age =3D INVALID_AGE;
- fetch->cachedata.no_cache =3D false;
- fetch->cachedata.etag =3D 0;
- fetch->cachedata.last_modified =3D 0;
- fetch->last_modified =3D 0;
- fetch->file_etag =3D 0;
-#ifdef WITH_SSL
- memset(fetch->cert_data, 0, sizeof(fetch->cert_data));
-#endif
- fetch->r_prev =3D 0;
- fetch->r_next =3D 0;
-
- if (!fetch->url || (referer && !fetch->referer) ||
- (parent_url && !fetch->parent_fetch_url) ||
- (post_urlenc && !fetch->post_urlenc) ||
- (post_multipart && !fetch->post_multipart))
+ }
+
+ if (!fetch->url)
goto failed;
=
+ /* Pick the scheme ops */
+ while (fetcher) {
+ if (strcmp(fetcher->scheme_name, ref1) =3D=3D 0) {
+ fetch->ops =3D fetcher;
+ break;
+ }
+ fetcher =3D fetcher->next_fetcher;
+ }
+ =
+ if (fetch->ops =3D=3D NULL)
+ goto failed;
+ =
+ /* Got a scheme fetcher, try and set up the fetch */
+ fetch->fetcher_handle =3D =
+ fetch->ops->setup_fetch(fetch, url, only_2xx, post_urlenc,
+ post_multipart, verifiable, parent=
_url,
+ (const char **)headers);
+ =
+ if (fetch->fetcher_handle =3D=3D NULL)
+ goto failed;
+ =
+ /* Rah, got it, so ref the fetcher. */
+ fetch_ref_fetcher(fetch->ops);
+ =
/* these aren't needed past here */
if (ref1) {
free(ref1);
ref1 =3D 0;
}
- if (ref2) {
- free(ref2);
- ref2 =3D 0;
- }
-
-#define APPEND(list, value) \
- slist =3D curl_slist_append(list, value); \
- if (!slist) \
- goto failed; \
- list =3D slist;
-
- /* remove curl default headers */
- APPEND(fetch->headers, "Accept:");
- APPEND(fetch->headers, "Pragma:");
-
- /* when doing a POST libcurl sends Expect: 100-continue" by default
- * which fails with lighttpd, so disable it (see bug 1429054) */
- APPEND(fetch->headers, "Expect:");
-
- if (option_accept_language) {
- char s[80];
- snprintf(s, sizeof s, "Accept-Language: %s, *;q=3D0.1",
- option_accept_language);
- s[sizeof s - 1] =3D 0;
- APPEND(fetch->headers, s);
- }
-
- if (option_accept_charset) {
- char s[80];
- snprintf(s, sizeof s, "Accept-Charset: %s, *;q=3D0.1",
- option_accept_charset);
- s[sizeof s - 1] =3D 0;
- APPEND(fetch->headers, s);
- }
-
- /* And add any headers specified by the caller */
- for (i =3D 0; headers[i]; i++) {
- if (strncasecmp(headers[i], "If-Modified-Since:", 18) =3D=3D 0) {
- char *d =3D headers[i] + 18;
- for (; *d && (*d =3D=3D ' ' || *d =3D=3D '\t'); d++)
- /* do nothing */;
- fetch->last_modified =3D curl_getdate(d, NULL);
- }
- else if (strncasecmp(headers[i], "If-None-Match:", 14) =3D=3D 0) {
- char *d =3D headers[i] + 14;
- for (; *d && (*d =3D=3D ' ' || *d =3D=3D '\t' || *d =3D=3D '"');
- d++)
- /* do nothing */;
- fetch->file_etag =3D atoi(d);
- }
- APPEND(fetch->headers, headers[i]);
- }
-
- /* Dump us in the queue and ask the queue to run. */
+ =
+ if (ref2) {
+ free(ref2);
+ ref2 =3D 0;
+ }
+ =
+ /* Dump us in the queue and ask the queue to run. */
RING_INSERT(queue_ring, fetch);
fetch_dispatch_jobs();
return fetch;
@@ -517,78 +312,27 @@
free(host);
if (ref1)
free(ref1);
- if (ref2)
- free(ref2);
free(fetch->url);
- free(fetch->parent_fetch_url);
- free(fetch->referer);
- free(fetch->post_urlenc);
- if (fetch->post_multipart)
- curl_formfree(fetch->post_multipart);
- curl_slist_free_all(fetch->headers);
- free(fetch);
+ if (fetch->referer)
+ free(fetch->referer);
+ free(fetch);
return 0;
}
=
/**
- * Initiate a fetch from the queue.
- *
- * Called with a fetch structure and a CURL handle to be used to fetch the=
content.
- *
- * This will return whether or not the fetch was successfully initiated.
- */
-static bool fetch_initiate_fetch(struct fetch *fetch, CURL *handle)
-{
- CURLcode code;
- CURLMcode codem;
-
- fetch->curl_handle =3D handle;
-
- /* Initialise the handle */
- code =3D fetch_set_options(fetch);
- if (code !=3D CURLE_OK) {
- fetch->curl_handle =3D 0;
- return false;
- }
-
- /* add to the global curl multi handle */
- codem =3D curl_multi_add_handle(fetch_curl_multi, fetch->curl_handle);
- assert(codem =3D=3D CURLM_OK || codem =3D=3D CURLM_CALL_MULTI_PERFORM);
-
- fetch_active =3D true;
- return true;
-}
-
-/**
- * Find a CURL handle to use to dispatch a job
- */
-static CURL *fetch_get_handle(char *host)
-{
- struct cache_handle *h;
- CURL *ret;
- RING_FINDBYHOST(handle_ring, h, host);
- if (h) {
- ret =3D h->handle;
- free(h->host);
- RING_REMOVE(handle_ring, h);
- free(h);
- } else {
- ret =3D curl_easy_duphandle(fetch_blank_curl);
- }
- return ret;
-}
-
-/**
* Dispatch a single job
*/
static bool fetch_dispatch_job(struct fetch *fetch)
{
RING_REMOVE(queue_ring, fetch);
- if (!fetch_initiate_fetch(fetch, fetch_get_handle(fetch->host))) {
+ LOG(("Attempting to start fetch %p, fetcher %p, url %s", fetch,
+ fetch->fetcher_handle, fetch->url));
+ if (!fetch->ops->start_fetch(fetch->fetcher_handle)) {
RING_INSERT(queue_ring, fetch); /* Put it back on the end of the queue */
return false;
} else {
RING_INSERT(fetch_ring, fetch);
+ fetch->fetch_is_active =3D true;
return true;
}
}
@@ -639,151 +383,8 @@
break;
}
}
-}
-
-/**
- * Cache a CURL handle for the provided host (if wanted)
- *
- */
-static void fetch_cache_handle(CURL *handle, char *host)
-{
- struct cache_handle *h =3D 0;
- int c;
- RING_FINDBYHOST(handle_ring, h, host);
- if (h) {
- /* Already have a handle cached for this hostname */
- curl_easy_cleanup(handle);
- return;
- }
- /* We do not have a handle cached, first up determine if the cache is ful=
l */
- RING_GETSIZE(struct cache_handle, handle_ring, c);
- if (c >=3D option_max_cached_fetch_handles) {
- /* Cache is full, so, we rotate the ring by one and replace the
- * oldest handle with this one. We do this without freeing/allocating
- * memory (except the hostname) and without removing the entry from the
- * ring and then re-inserting it, in order to be as efficient as we can.
- */
- h =3D handle_ring;
- handle_ring =3D h->r_next;
- curl_easy_cleanup(h->handle);
- h->handle =3D handle;
- free(h->host);
- h->host =3D strdup(host);
- return;
- }
- /* The table isn't full yet, so make a shiny new handle to add to the rin=
g */
- h =3D (struct cache_handle*)malloc(sizeof(struct cache_handle));
- h->handle =3D handle;
- h->host =3D strdup(host);
- RING_INSERT(handle_ring, h);
-}
-
-/**
- * Set options specific for a fetch.
- */
-
-CURLcode fetch_set_options(struct fetch *f)
-{
- CURLcode code;
- const char *auth;
-
-#undef SETOPT
-#define SETOPT(option, value) { \
- code =3D curl_easy_setopt(f->curl_handle, option, value); \
- if (code !=3D CURLE_OK) \
- return code; \
- }
-
- SETOPT(CURLOPT_URL, f->url);
- SETOPT(CURLOPT_PRIVATE, f);
- SETOPT(CURLOPT_WRITEDATA, f);
- SETOPT(CURLOPT_WRITEHEADER, f);
- SETOPT(CURLOPT_PROGRESSDATA, f);
- SETOPT(CURLOPT_REFERER, f->send_referer ? f->referer : 0);
- SETOPT(CURLOPT_HTTPHEADER, f->headers);
- if (f->post_urlenc) {
- SETOPT(CURLOPT_HTTPPOST, 0);
- SETOPT(CURLOPT_HTTPGET, 0L);
- SETOPT(CURLOPT_POSTFIELDS, f->post_urlenc);
- } else if (f->post_multipart) {
- SETOPT(CURLOPT_POSTFIELDS, 0);
- SETOPT(CURLOPT_HTTPGET, 0L);
- SETOPT(CURLOPT_HTTPPOST, f->post_multipart);
- } else {
- SETOPT(CURLOPT_POSTFIELDS, 0);
- SETOPT(CURLOPT_HTTPPOST, 0);
- SETOPT(CURLOPT_HTTPGET, 1L);
- }
-
- f->cookie_string =3D urldb_get_cookie(f->url);
- if (f->cookie_string) {
- SETOPT(CURLOPT_COOKIE, f->cookie_string);
- } else {
- SETOPT(CURLOPT_COOKIE, 0);
- }
-
-#ifdef WITH_AUTH
- if ((auth =3D urldb_get_auth_details(f->url)) !=3D NULL) {
- SETOPT(CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- SETOPT(CURLOPT_USERPWD, auth);
- } else {
-#endif
- SETOPT(CURLOPT_USERPWD, 0);
-#ifdef WITH_AUTH
- }
-#endif
- if (option_http_proxy && option_http_proxy_host) {
- SETOPT(CURLOPT_PROXY, option_http_proxy_host);
- SETOPT(CURLOPT_PROXYPORT, (long) option_http_proxy_port);
- if (option_http_proxy_auth !=3D OPTION_HTTP_PROXY_AUTH_NONE) {
- SETOPT(CURLOPT_PROXYAUTH,
- option_http_proxy_auth =3D=3D
- OPTION_HTTP_PROXY_AUTH_BASIC ?
- (long) CURLAUTH_BASIC :
- (long) CURLAUTH_NTLM);
- snprintf(fetch_proxy_userpwd,
- sizeof fetch_proxy_userpwd,
- "%s:%s",
- option_http_proxy_auth_user,
- option_http_proxy_auth_pass);
- SETOPT(CURLOPT_PROXYUSERPWD, fetch_proxy_userpwd);
- }
- }
-
-#ifdef WITH_SSL
- if (urldb_get_cert_permissions(f->url)) {
- /* Disable certificate verification */
- SETOPT(CURLOPT_SSL_VERIFYPEER, 0L);
- SETOPT(CURLOPT_SSL_VERIFYHOST, 0L);
- SETOPT(CURLOPT_SSL_CTX_FUNCTION, 0);
- SETOPT(CURLOPT_SSL_CTX_DATA, 0);
- } else {
- /* do verification */
- SETOPT(CURLOPT_SSL_VERIFYPEER, 1L);
- SETOPT(CURLOPT_SSL_VERIFYHOST, 2L);
- SETOPT(CURLOPT_SSL_CTX_FUNCTION, fetch_sslctxfun);
- SETOPT(CURLOPT_SSL_CTX_DATA, f);
- }
-#endif
-
- return CURLE_OK;
-}
-
-
-#ifdef WITH_SSL
-/**
- * cURL SSL setup callback
- */
-
-CURLcode fetch_sslctxfun(CURL *curl_handle, SSL_CTX *sslctx, void *parm)
-{
- SSL_CTX_set_verify(sslctx, SSL_VERIFY_PEER, fetch_verify_callback);
- SSL_CTX_set_cert_verify_callback(sslctx, fetch_cert_verify_callback,
- parm);
- return CURLE_OK;
-}
-#endif
-
+ fetch_active =3D (all_active > 0);
+}
=
/**
* Abort a fetch.
@@ -792,49 +393,8 @@
void fetch_abort(struct fetch *f)
{
assert(f);
- LOG(("fetch %p, url '%s'", f, f->url));
- if (f->curl_handle) {
- f->abort =3D true;
- } else {
- RING_REMOVE(queue_ring, f);
- fetch_free(f);
- }
-}
-
-
-/**
- * Clean up the provided fetch object and free it.
- *
- * Will prod the queue afterwards to allow pending requests to be initiate=
d.
- */
-
-void fetch_stop(struct fetch *f)
-{
- CURLMcode codem;
-
- assert(f);
- LOG(("fetch %p, url '%s'", f, f->url));
-
- if (f->curl_handle) {
- /* remove from curl multi handle */
- codem =3D curl_multi_remove_handle(fetch_curl_multi,
- f->curl_handle);
- assert(codem =3D=3D CURLM_OK);
- /* Put this curl handle into the cache if wanted. */
- fetch_cache_handle(f->curl_handle, f->host);
- f->curl_handle =3D 0;
- /* Remove this from the active set of fetches (if it's still there) */
- RING_REMOVE(fetch_ring, f);
- } else {
- /* Remove this from the queued set of fetches (if it's still there) */
- RING_REMOVE(queue_ring, f);
- }
-
- fetch_free(f);
- if (!fetch_ring && !queue_ring)
- fetch_active =3D false;
- else if (queue_ring)
- fetch_dispatch_jobs();
+ LOG(("fetch %p, fetcher %p, url '%s'", f, f->fetcher_handle, f->url));
+ f->ops->abort_fetch(f->fetcher_handle);
}
=
=
@@ -844,34 +404,13 @@
=
void fetch_free(struct fetch *f)
{
-#ifdef WITH_SSL
- int i;
-#endif
-
- if (f->curl_handle)
- curl_easy_cleanup(f->curl_handle);
+ LOG(("Freeing fetch %p, fetcher %p", f, f->fetcher_handle));
+ f->ops->free_fetch(f->fetcher_handle);
+ fetch_unref_fetcher(f->ops);
free(f->url);
free(f->host);
- free(f->parent_fetch_url);
- free(f->referer);
- free(f->location);
- free(f->cookie_string);
- free(f->realm);
- if (f->headers)
- curl_slist_free_all(f->headers);
- free(f->post_urlenc);
- if (f->post_multipart)
- curl_formfree(f->post_multipart);
- free(f->cachedata.etag);
-
-#ifdef WITH_SSL
- for (i =3D 0; i < MAX_CERTS && f->cert_data[i].cert; i++) {
- f->cert_data[i].cert->references--;
- if (f->cert_data[i].cert->references =3D=3D 0)
- X509_free(f->cert_data[i].cert);
- }
-#endif
-
+ if (f->referer)
+ free(f->referer);
free(f);
}
=
@@ -884,639 +423,14 @@
=
void fetch_poll(void)
{
- int running, queue;
- CURLMcode codem;
- CURLMsg *curl_msg;
-
- /* do any possible work on the current fetches */
- do {
- codem =3D curl_multi_perform(fetch_curl_multi, &running);
- assert(codem =3D=3D CURLM_OK || codem =3D=3D CURLM_CALL_MULTI_PERFORM);
- } while (codem =3D=3D CURLM_CALL_MULTI_PERFORM);
-
- /* process curl results */
- curl_msg =3D curl_multi_info_read(fetch_curl_multi, &queue);
- while (curl_msg) {
- switch (curl_msg->msg) {
- case CURLMSG_DONE:
- fetch_done(curl_msg->easy_handle,
- curl_msg->data.result);
- break;
- default:
- break;
- }
- curl_msg =3D curl_multi_info_read(fetch_curl_multi, &queue);
- }
-}
-
-
-/**
- * Handle a completed fetch (CURLMSG_DONE from curl_multi_info_read()).
- *
- * \param curl_handle curl easy handle of fetch
- */
-
-void fetch_done(CURL *curl_handle, CURLcode result)
-{
- bool finished =3D false;
- bool error =3D false;
-#ifdef WITH_SSL
- bool cert =3D false;
-#endif
- bool abort;
- struct fetch *f;
- void *p;
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size);
- CURLcode code;
- struct cache_data cachedata;
-#ifdef WITH_SSL
- struct cert_info certs[MAX_CERTS];
- memset(certs, 0, sizeof(certs));
-#endif
-
- /* find the structure associated with this fetch */
- code =3D curl_easy_getinfo(curl_handle, CURLINFO_PRIVATE, &f);
- assert(code =3D=3D CURLE_OK);
-
- abort =3D f->abort;
- callback =3D f->callback;
- p =3D f->p;
-
- if (!abort && result =3D=3D CURLE_OK) {
- /* fetch completed normally */
- if (f->stopped ||
- (!f->had_headers &&
- fetch_process_headers(f)))
- ; /* redirect with no body or similar */
- else
- finished =3D true;
- } else if (result =3D=3D CURLE_PARTIAL_FILE) {
- /* CURLE_PARTIAL_FILE occurs if the received body of a
- * response is smaller than that specified in the
- * Content-Length header. */
- if (!f->had_headers && fetch_process_headers(f))
- ; /* redirect with partial body, or similar */
- else
- error =3D true;
- } else if (result =3D=3D CURLE_WRITE_ERROR && f->stopped)
- /* CURLE_WRITE_ERROR occurs when fetch_curl_data
- * returns 0, which we use to abort intentionally */
- ;
-#ifdef WITH_SSL
- else if (result =3D=3D CURLE_SSL_PEER_CERTIFICATE ||
- result =3D=3D CURLE_SSL_CACERT) {
- memcpy(certs, f->cert_data, sizeof(certs));
- memset(f->cert_data, 0, sizeof(f->cert_data));
- cert =3D true;
- }
-#endif
- else
- error =3D true;
-
- /* If finished, acquire cache info to pass to callback */
- if (finished) {
- memcpy(&cachedata, &f->cachedata, sizeof(struct cache_data));
- f->cachedata.etag =3D 0;
- }
-
- /* clean up fetch and start any queued fetch for this host */
- fetch_stop(f);
-
- /* postponed until after stop so that queue fetches are started */
- if (abort)
- ; /* fetch was aborted: no callback */
- else if (finished) {
- callback(FETCH_FINISHED, p, &cachedata, 0);
- free(cachedata.etag);
- }
-#ifdef WITH_SSL
- else if (cert) {
- int i;
- BIO *mem;
- BUF_MEM *buf;
- struct ssl_cert_info ssl_certs[MAX_CERTS];
-
- for (i =3D 0; i < MAX_CERTS && certs[i].cert; i++) {
- ssl_certs[i].version =3D
- X509_get_version(certs[i].cert);
-
- mem =3D BIO_new(BIO_s_mem());
- ASN1_TIME_print(mem,
- X509_get_notBefore(certs[i].cert));
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- snprintf(ssl_certs[i].not_before,
- min(sizeof ssl_certs[i].not_before,
- (unsigned) buf->length + 1),
- "%s", buf->data);
- BUF_MEM_free(buf);
-
- mem =3D BIO_new(BIO_s_mem());
- ASN1_TIME_print(mem,
- X509_get_notAfter(certs[i].cert));
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- snprintf(ssl_certs[i].not_after,
- min(sizeof ssl_certs[i].not_after,
- (unsigned) buf->length + 1),
- "%s", buf->data);
- BUF_MEM_free(buf);
-
- ssl_certs[i].sig_type =3D
- X509_get_signature_type(certs[i].cert);
- ssl_certs[i].serial =3D
- ASN1_INTEGER_get(
- X509_get_serialNumber(certs[i].cert));
- mem =3D BIO_new(BIO_s_mem());
- X509_NAME_print_ex(mem,
- X509_get_issuer_name(certs[i].cert),
- 0, XN_FLAG_SEP_CPLUS_SPC |
- XN_FLAG_DN_REV | XN_FLAG_FN_NONE);
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- snprintf(ssl_certs[i].issuer,
- min(sizeof ssl_certs[i].issuer,
- (unsigned) buf->length + 1),
- "%s", buf->data);
- BUF_MEM_free(buf);
-
- mem =3D BIO_new(BIO_s_mem());
- X509_NAME_print_ex(mem,
- X509_get_subject_name(certs[i].cert),
- 0, XN_FLAG_SEP_CPLUS_SPC |
- XN_FLAG_DN_REV | XN_FLAG_FN_NONE);
- BIO_get_mem_ptr(mem, &buf);
- (void) BIO_set_close(mem, BIO_NOCLOSE);
- BIO_free(mem);
- snprintf(ssl_certs[i].subject,
- min(sizeof ssl_certs[i].subject,
- (unsigned) buf->length + 1),
- "%s", buf->data);
- BUF_MEM_free(buf);
-
- ssl_certs[i].cert_type =3D
- X509_certificate_type(certs[i].cert,
- X509_get_pubkey(certs[i].cert));
-
- /* and clean up */
- certs[i].cert->references--;
- if (certs[i].cert->references =3D=3D 0)
- X509_free(certs[i].cert);
- }
-
- callback(FETCH_CERT_ERR, p, &ssl_certs, i);
-
- }
-#endif
- else if (error)
- callback(FETCH_ERROR, p, fetch_error_buffer, 0);
-}
-
-
-/**
- * Callback function for fetch progress.
- */
-
-int fetch_curl_progress(void *clientp, double dltotal, double dlnow,
- double ultotal, double ulnow)
-{
- struct fetch *f =3D (struct fetch *) clientp;
- double percent;
-
- if (f->abort)
- return 0;
-
- if (dltotal > 0) {
- percent =3D dlnow * 100.0f / dltotal;
- snprintf(fetch_progress_buffer, 255,
- messages_get("Progress"),
- human_friendly_bytesize(dlnow),
- human_friendly_bytesize(dltotal));
- f->callback(FETCH_PROGRESS, f->p, fetch_progress_buffer,
- (unsigned long) percent);
- } else {
- snprintf(fetch_progress_buffer, 255,
- messages_get("ProgressU"),
- human_friendly_bytesize(dlnow));
- f->callback(FETCH_PROGRESS, f->p, fetch_progress_buffer, 0);
- }
-
- return 0;
-}
-
-
-/**
- * Callback function for cURL.
- */
-
-size_t fetch_curl_data(void *data, size_t size, size_t nmemb,
- struct fetch *f)
-{
- CURLcode code;
-
- /* ensure we only have to get this information once */
- if (!f->http_code)
- {
- code =3D curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
- &f->http_code);
- assert(code =3D=3D CURLE_OK);
- }
-
- /* ignore body if this is a 401 reply by skipping it and reset
- the HTTP response code to enable follow up fetches */
- if (f->http_code =3D=3D 401)
- {
- f->http_code =3D 0;
- return size * nmemb;
- }
-
- /*LOG(("fetch %p, size %lu", f, size * nmemb));*/
-
- if (f->abort || (!f->had_headers && fetch_process_headers(f))) {
- f->stopped =3D true;
- return 0;
- }
-
- /* send data to the caller */
- /*LOG(("FETCH_DATA"));*/
- f->callback(FETCH_DATA, f->p, data, size * nmemb);
-
- if (f->abort) {
- f->stopped =3D true;
- return 0;
- }
-
- return size * nmemb;
-}
-
-
-/**
- * Callback function for headers.
- */
-
-size_t fetch_curl_header(char *data, size_t size, size_t nmemb,
- struct fetch *f)
-{
- int i;
- size *=3D nmemb;
-
-#define SKIP_ST(o) for (i =3D (o); i < (int) size && (data[i] =3D=3D ' ' |=
| data[i] =3D=3D '\t'); i++)
-
- /* Set fetch response time if not already set */
- if (f->cachedata.res_time =3D=3D 0)
- f->cachedata.res_time =3D time(0);
-
- if (12 < size && strncasecmp(data, "Location:", 9) =3D=3D 0) {
- /* extract Location header */
- free(f->location);
- f->location =3D malloc(size);
- if (!f->location) {
- LOG(("malloc failed"));
- return size;
- }
- SKIP_ST(9);
- strncpy(f->location, data + i, size - i);
- f->location[size - i] =3D '\0';
- for (i =3D size - i - 1; i >=3D 0 &&
- (f->location[i] =3D=3D ' ' ||
- f->location[i] =3D=3D '\t' ||
- f->location[i] =3D=3D '\r' ||
- f->location[i] =3D=3D '\n'); i--)
- f->location[i] =3D '\0';
- } else if (15 < size && strncasecmp(data, "Content-Length:", 15) =3D=3D 0=
) {
- /* extract Content-Length header */
- SKIP_ST(15);
- if (i < (int)size && '0' <=3D data[i] && data[i] <=3D '9')
- f->content_length =3D atol(data + i);
-#ifdef WITH_AUTH
- } else if (17 < size && strncasecmp(data, "WWW-Authenticate:", 17) =3D=3D=
0) {
- /* extract the first Realm from WWW-Authenticate header */
- free(f->realm);
- f->realm =3D malloc(size);
- if (!f->realm) {
- LOG(("malloc failed"));
- return size;
- }
- SKIP_ST(17);
-
- while (i < (int) size - 5 &&
- strncasecmp(data + i, "realm", 5))
- i++;
- while (i < (int) size - 1 && data[++i] !=3D '"')
- /* */;
- i++;
-
- if (i < (int) size) {
- strncpy(f->realm, data + i, size - i);
- f->realm[size - i] =3D '\0';
- for (i =3D size - i - 1; i >=3D 0 &&
- (f->realm[i] =3D=3D ' ' ||
- f->realm[i] =3D=3D '"' ||
- f->realm[i] =3D=3D '\t' ||
- f->realm[i] =3D=3D '\r' ||
- f->realm[i] =3D=3D '\n'); --i)
- f->realm[i] =3D '\0';
- }
-#endif
- } else if (5 < size && strncasecmp(data, "Date:", 5) =3D=3D 0) {
- /* extract Date header */
- SKIP_ST(5);
- if (i < (int) size)
- f->cachedata.date =3D curl_getdate(&data[i], NULL);
- } else if (4 < size && strncasecmp(data, "Age:", 4) =3D=3D 0) {
- /* extract Age header */
- SKIP_ST(4);
- if (i < (int) size && '0' <=3D data[i] && data[i] <=3D '9')
- f->cachedata.age =3D atoi(data + i);
- } else if (8 < size && strncasecmp(data, "Expires:", 8) =3D=3D 0) {
- /* extract Expires header */
- SKIP_ST(8);
- if (i < (int) size)
- f->cachedata.expires =3D curl_getdate(&data[i], NULL);
- } else if (14 < size && strncasecmp(data, "Cache-Control:", 14) =3D=3D 0)=
{
- /* extract and parse Cache-Control header */
- int comma;
- SKIP_ST(14);
-
- while (i < (int) size) {
- for (comma =3D i; comma < (int) size; comma++)
- if (data[comma] =3D=3D ',')
- break;
-
- SKIP_ST(i);
-
- if (8 < comma - i && (strncasecmp(data + i, "no-cache", 8) =3D=3D 0 || =
strncasecmp(data + i, "no-store", 8) =3D=3D 0))
- /* When we get a disk cache we should
- * distinguish between these two */
- f->cachedata.no_cache =3D true;
- else if (7 < comma - i && strncasecmp(data + i, "max-age", 7) =3D=3D 0)=
{
- for (; i < comma; i++)
- if (data[i] =3D=3D '=3D')
- break;
- SKIP_ST(i+1);
- if (i < comma)
- f->cachedata.max_age =3D
- atoi(data + i);
- }
-
- i =3D comma + 1;
- }
- } else if (5 < size && strncasecmp(data, "ETag:", 5) =3D=3D 0) {
- /* extract ETag header */
- free(f->cachedata.etag);
- f->cachedata.etag =3D malloc(size);
- if (!f->cachedata.etag) {
- LOG(("malloc failed"));
- return size;
- }
- SKIP_ST(5);
- strncpy(f->cachedata.etag, data + i, size - i);
- f->cachedata.etag[size - i] =3D '\0';
- for (i =3D size - i - 1; i >=3D 0 &&
- (f->cachedata.etag[i] =3D=3D ' ' ||
- f->cachedata.etag[i] =3D=3D '\t' ||
- f->cachedata.etag[i] =3D=3D '\r' ||
- f->cachedata.etag[i] =3D=3D '\n'); --i)
- f->cachedata.etag[i] =3D '\0';
- } else if (14 < size && strncasecmp(data, "Last-Modified:", 14) =3D=3D 0)=
{
- /* extract Last-Modified header */
- SKIP_ST(14);
- if (i < (int) size) {
- f->cachedata.last_modified =3D
- curl_getdate(&data[i], NULL);
- }
- } else if (11 < size && strncasecmp(data, "Set-Cookie:", 11) =3D=3D 0) {
- /* extract Set-Cookie header */
- SKIP_ST(11);
-
- /* If the fetch is unverifiable and there's no parent fetch
- * url, err on the side of caution and do not set the
- cookie */
-
- if (f->verifiable || f->parent_fetch_url) {
- /* If the transaction's verifiable, we don't require
- * that the request uri and the parent domain match,
- * so don't pass in the parent in this case. */
- urldb_set_cookie(&data[i], f->url,
- f->verifiable ? 0
- : f->parent_fetch_url);
- }
- }
-
- return size;
-#undef SKIP_ST
-}
-
-
-/**
- * Find the status code and content type and inform the caller.
- *
- * Return true if the fetch is being aborted.
- */
-
-bool fetch_process_headers(struct fetch *f)
-{
- long http_code;
- const char *type;
- CURLcode code;
- struct stat s;
- char *url_path =3D 0;
-
- f->had_headers =3D true;
-
- /* Set fetch response time if not already set */
- if (f->cachedata.res_time =3D=3D 0)
- f->cachedata.res_time =3D time(0);
-
- if (!f->http_code)
- {
- code =3D curl_easy_getinfo(f->curl_handle, CURLINFO_HTTP_CODE,
- &f->http_code);
- assert(code =3D=3D CURLE_OK);
- }
- http_code =3D f->http_code;
- LOG(("HTTP status code %li", http_code));
-
- if (http_code =3D=3D 304 && !f->post_urlenc && !f->post_multipart) {
- /* Not Modified && GET request */
- f->callback(FETCH_NOTMODIFIED, f->p,
- (const char *)&f->cachedata, 0);
- return true;
- }
-
- /* handle HTTP redirects (3xx response codes) */
- if (300 <=3D http_code && http_code < 400 && f->location !=3D 0) {
- LOG(("FETCH_REDIRECT, '%s'", f->location));
- f->callback(FETCH_REDIRECT, f->p, f->location, 0);
- return true;
- }
-
- /* handle HTTP 401 (Authentication errors) */
-#ifdef WITH_AUTH
- if (http_code =3D=3D 401) {
- f->callback(FETCH_AUTH, f->p, f->realm,0);
- return true;
- }
-#endif
-
- /* handle HTTP errors (non 2xx response codes) */
- if (f->only_2xx && strncmp(f->url, "http", 4) =3D=3D 0 &&
- (http_code < 200 || 299 < http_code)) {
- f->callback(FETCH_ERROR, f->p, messages_get("Not2xx"), 0);
- return true;
- }
-
- /* find MIME type from headers or filetype for local files */
- code =3D curl_easy_getinfo(f->curl_handle, CURLINFO_CONTENT_TYPE, &type);
- assert(code =3D=3D CURLE_OK);
-
- if (strncmp(f->url, "file:///", 8) =3D=3D 0)
- url_path =3D curl_unescape(f->url + 7,
- (int) strlen(f->url) - 7);
-
- if (url_path && stat(url_path, &s) =3D=3D 0) {
- /* file: URL and file exists */
- /* create etag */
- free(f->cachedata.etag);
- f->cachedata.etag =3D malloc(13);
- if (f->cachedata.etag)
- sprintf(f->cachedata.etag,
- "\"%10d\"", (int)s.st_mtime);
-
- /* don't set last modified time so as to ensure that local
- * files are revalidated at all times. */
-
- /* If performed a conditional request and unmodified ... */
- if (f->last_modified && f->file_etag &&
- f->last_modified > s.st_mtime &&
- f->file_etag =3D=3D s.st_mtime) {
- f->callback(FETCH_NOTMODIFIED, f->p,
- (const char *)&f->cachedata, 0);
- curl_free(url_path);
- return true;
- }
- }
-
- if (type =3D=3D 0) {
- type =3D "text/plain";
- if (url_path) {
- type =3D fetch_filetype(url_path);
- }
- }
-
- curl_free(url_path);
-
- LOG(("FETCH_TYPE, '%s'", type));
- f->callback(FETCH_TYPE, f->p, type, f->content_length);
- if (f->abort)
- return true;
-
- return false;
-}
-
-
-/**
- * Convert a list of struct ::form_successful_control to a list of
- * struct curl_httppost for libcurl.
- */
-struct curl_httppost *fetch_post_convert(struct form_successful_control *c=
ontrol)
-{
- struct curl_httppost *post =3D 0, *last =3D 0;
- CURLFORMcode code;
-
- for (; control; control =3D control->next) {
- if (control->file) {
- char *leafname =3D 0;
-#ifdef riscos
- char *temp;
- int leaflen;
-
- temp =3D strrchr(control->value, '.');
- if (!temp)
- temp =3D control->value; /* already leafname */
- else
- temp +=3D 1;
-
- leaflen =3D strlen(temp);
-
- leafname =3D malloc(leaflen + 1);
- if (!leafname) {
- LOG(("malloc failed"));
- continue;
- }
- memcpy(leafname, temp, leaflen + 1);
-
- /* and s/\//\./g */
- for (temp =3D leafname; *temp; temp++)
- if (*temp =3D=3D '/')
- *temp =3D '.';
-#else
- leafname =3D strrchr(control->value, '/') ;
- if (!leafname)
- leafname =3D control->value;
- else
- leafname +=3D 1;
-#endif
- /* We have to special case filenames of "", so curl
- * a) actually attempts the fetch and
- * b) doesn't attempt to open the file ""
- */
- if (control->value[0] =3D=3D '\0') {
- /* dummy buffer - needs to be static so
- * pointer's still valid when we go out
- * of scope (not that libcurl should be
- * attempting to access it, of course). */
- static char buf;
-
- code =3D curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_BUFFER, control->value,
- /* needed, as basename("") =3D=3D "." */
- CURLFORM_FILENAME, "",
- CURLFORM_BUFFERPTR, &buf,
- CURLFORM_BUFFERLENGTH, 0,
- CURLFORM_CONTENTTYPE,
- "application/octet-stream",
- CURLFORM_END);
- if (code !=3D CURL_FORMADD_OK)
- LOG(("curl_formadd: %d (%s)",
- code, control->name));
- } else {
- char *mimetype =3D fetch_mimetype(control->value);
- code =3D curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_FILE, control->value,
- CURLFORM_FILENAME, leafname,
- CURLFORM_CONTENTTYPE,
- (mimetype !=3D 0 ? mimetype : "text/plain"),
- CURLFORM_END);
- if (code !=3D CURL_FORMADD_OK)
- LOG(("curl_formadd: %d (%s=3D%s)",
- code, control->name,
- control->value));
- free(mimetype);
- }
-#ifdef riscos
- free(leafname);
-#endif
- }
- else {
- code =3D curl_formadd(&post, &last,
- CURLFORM_COPYNAME, control->name,
- CURLFORM_COPYCONTENTS, control->value,
- CURLFORM_END);
- if (code !=3D CURL_FORMADD_OK)
- LOG(("curl_formadd: %d (%s=3D%s)", code,
- control->name,
- control->value));
- }
- }
-
- return post;
+ scheme_fetcher *fetcher =3D fetchers;
+ if (!fetch_active)
+ return; /* No point polling, there's no fetch active. */
+ while (fetcher !=3D NULL) {
+ LOG(("Polling fetcher for %s", fetcher->scheme_name));
+ fetcher->poll_fetcher(fetcher->scheme_name);
+ fetcher =3D fetcher->next_fetcher;
+ }
}
=
=
@@ -1529,22 +443,21 @@
=
bool fetch_can_fetch(const char *url)
{
- unsigned int i;
const char *semi;
size_t len;
- curl_version_info_data *data;
-
+ scheme_fetcher *fetcher =3D fetchers;
+ =
if ((semi =3D strchr(url, ':')) =3D=3D NULL)
return false;
len =3D semi - url;
-
- data =3D curl_version_info(CURLVERSION_NOW);
-
- for (i =3D 0; data->protocols[i]; i++)
- if (strlen(data->protocols[i]) =3D=3D len &&
- strncasecmp(url, data->protocols[i], len) =3D=3D 0)
- return true;
-
+ =
+ while (fetcher !=3D NULL) {
+ if (strlen(fetcher->scheme_name) =3D=3D len &&
+ strncmp(fetcher->scheme_name, url, len) =3D=3D 0)
+ return true;
+ fetcher =3D fetcher->next_fetcher;
+ }
+ =
return false;
}
=
@@ -1554,9 +467,8 @@
*/
=
void fetch_change_callback(struct fetch *fetch,
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size),
- void *p)
+ fetch_callback callback,
+ void *p)
{
assert(fetch);
fetch->callback =3D callback;
@@ -1585,105 +497,39 @@
return fetch->referer;
}
=
-
-#ifdef WITH_SSL
-/**
- * OpenSSL Certificate verification callback
- * Stores certificate details in fetch struct.
- */
-
-int fetch_verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)
-{
- X509 *cert =3D X509_STORE_CTX_get_current_cert(x509_ctx);
- int depth =3D X509_STORE_CTX_get_error_depth(x509_ctx);
- int err =3D X509_STORE_CTX_get_error(x509_ctx);
- struct fetch *f =3D X509_STORE_CTX_get_app_data(x509_ctx);
-
- /* save the certificate by incrementing the reference count and
- * keeping a pointer */
- if (depth < MAX_CERTS && !f->cert_data[depth].cert) {
- f->cert_data[depth].cert =3D cert;
- f->cert_data[depth].err =3D err;
- cert->references++;
- }
-
- return preverify_ok;
-}
-
-
-/**
- * OpenSSL certificate chain verification callback
- * Verifies certificate chain, setting up context for fetch_verify_callback
- */
-
-int fetch_cert_verify_callback(X509_STORE_CTX *x509_ctx, void *parm)
-{
- int ok;
-
- /* Store fetch struct in context for verify callback */
- ok =3D X509_STORE_CTX_set_app_data(x509_ctx, parm);
-
- /* and verify the certificate chain */
- if (ok)
- ok =3D X509_verify_cert(x509_ctx);
-
- return ok;
-}
-#endif
-
-
-/**
- * testing framework
- */
-
-#ifdef TEST
-#include <unistd.h>
-
-struct test {char *url; struct fetch *f;};
-
-void callback(fetch_msg msg, struct test *t, char *data, unsigned long siz=
e)
-{
- printf("%s: ", t->url);
- switch (msg) {
- case FETCH_TYPE:
- printf("FETCH_TYPE '%s'", data);
- break;
- case FETCH_DATA:
- printf("FETCH_DATA %lu", size);
- break;
- case FETCH_FINISHED:
- printf("FETCH_FINISHED");
- break;
- case FETCH_ERROR:
- printf("FETCH_ERROR '%s'", data);
- break;
- default:
- assert(0);
- }
- printf("\n");
-}
-
-struct test test[] =3D {
- {"http://127.0.0.1/", 0},
- {"http://netsurf.strcprstskrzkrk.co.uk/", 0},
- {"http://www.oxfordstudent.com/", 0},
- {"http://www.google.co.uk/", 0},
- {"http://news.bbc.co.uk/", 0},
- {"http://doesnt.exist/", 0},
- {"blah://blah", 0},
-};
-
-int main(void)
-{
- int i;
- fetch_init();
- for (i =3D 0; i !=3D sizeof(test) / sizeof(test[0]); i++)
- test[i].f =3D fetch_start(test[i].url, 0, callback, &test[i]);
- while (1) {
- fetch_poll();
- sleep(1);
- }
- return 0;
-}
-#endif
-
+void
+fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsign=
ed long size)
+{
+ LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size =
%d",
+ fetch, fetch->fetcher_handle, data, size));
+ fetch->callback(msg, fetch->p, data, size);
+}
+
+void
+fetch_can_be_freed(struct fetch *fetch)
+{
+ /* Go ahead and free the fetch properly now */
+ LOG(("Fetch %p, fetcher %p can be freed", fetch, fetch->fetcher_ha=
ndle));
+ if (fetch->fetch_is_active) {
+ RING_REMOVE(fetch_ring, fetch);
+ } else {
+ RING_REMOVE(queue_ring, fetch);
+ }
+ fetch_active =3D (fetch_ring !=3D NULL);
+ fetch_free(fetch);
+}
+
+void
+fetch_set_http_code(struct fetch *fetch, long http_code)
+{
+ LOG(("Setting HTTP code to %d", http_code));
+ fetch->http_code =3D http_code;
+}
+
+const char *
+fetch_get_referer_to_send(struct fetch *fetch)
+{
+ if (fetch->send_referer)
+ return fetch->referer;
+ return NULL;
+}
Modified: trunk/netsurf/content/fetch.h
URL: http://svn.semichrome.net/trunk/netsurf/content/fetch.h?rev=3D3330&r1=
=3D3329&r2=3D3330&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/content/fetch.h (original)
+++ trunk/netsurf/content/fetch.h Sun Jun 10 18:46:44 2007
@@ -14,7 +14,6 @@
=
#include <stdbool.h>
#include <sys/select.h>
-#include <curl/curl.h>
#include "utils/config.h"
=
typedef enum {
@@ -64,15 +63,17 @@
#endif
=
extern bool fetch_active;
-extern CURLM *fetch_curl_multi;
+
+typedef void (*fetch_callback)(fetch_msg msg, void *p, const void *data,
+ unsigned long size);
+
=
void fetch_init(void);
struct fetch * fetch_start(const char *url, const char *referer,
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size),
- void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
- bool verifiable, const char *parent_url, char *headers[]);
+ fetch_callback callback,
+ void *p, bool only_2xx, const char *post_urlenc,
+ struct form_successful_control *post_multipart,
+ bool verifiable, const char *parent_url, char *=
headers[]);
void fetch_abort(struct fetch *f);
void fetch_poll(void);
void fetch_quit(void);
@@ -80,10 +81,35 @@
char *fetch_mimetype(const char *ro_path);
bool fetch_can_fetch(const char *url);
void fetch_change_callback(struct fetch *fetch,
- void (*callback)(fetch_msg msg, void *p, const void *data,
- unsigned long size),
- void *p);
+ fetch_callback callback,
+ void *p);
long fetch_http_code(struct fetch *fetch);
const char *fetch_get_referer(struct fetch *fetch);
=
+/* API for fetchers themselves */
+
+typedef bool (*fetcher_initialise)(const char *);
+typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
+ bool, const char *, =
+ struct form_successful_control *, boo=
l,
+ const char *, const char **);
+typedef bool (*fetcher_start_fetch)(void *);
+typedef void (*fetcher_abort_fetch)(void *);
+typedef void (*fetcher_free_fetch)(void *);
+typedef void (*fetcher_poll_fetcher)(const char *);
+typedef void (*fetcher_finalise)(const char *);
+
+bool fetch_add_fetcher(const char *scheme,
+ fetcher_initialise initialiser,
+ fetcher_setup_fetch setup_fetch,
+ fetcher_start_fetch start_fetch,
+ fetcher_abort_fetch abort_fetch,
+ fetcher_free_fetch free_fetch,
+ fetcher_poll_fetcher poll_fetcher,
+ fetcher_finalise finaliser);
+
+void fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, u=
nsigned long size);
+void fetch_can_be_freed(struct fetch *fetch);
+void fetch_set_http_code(struct fetch *fetch, long http_code);
+const char *fetch_get_referer_to_send(struct fetch *fetch);
#endif
Modified: trunk/netsurf/gtk/gtk_gui.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_gui.c?rev=3D3330&r1=3D=
3329&r2=3D3330&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/gtk_gui.c (original)
+++ trunk/netsurf/gtk/gtk_gui.c Sun Jun 10 18:46:44 2007
@@ -22,6 +22,7 @@
#include <glade/glade.h>
#include "content/content.h"
#include "content/fetch.h"
+#include "content/fetchers/fetch_curl.h"
#include "content/urldb.h"
#include "desktop/401login.h"
#include "desktop/browser.h"
Modified: trunk/netsurf/makefile
URL: http://svn.semichrome.net/trunk/netsurf/makefile?rev=3D3330&r1=3D3329&=
r2=3D3330&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/makefile (original)
+++ trunk/netsurf/makefile Sun Jun 10 18:46:44 2007
@@ -20,12 +20,13 @@
SYSTEM_CC ?=3D gcc
=
OBJECTS_COMMON =3D content.o fetch.o fetchcache.o urldb.o # content/
+OBJECTS_COMMON +=3D fetch_curl.o # conten=
t/fetchers/
OBJECTS_COMMON +=3D css.o css_enum.o parser.o ruleset.o scanner.o # css/
OBJECTS_COMMON +=3D box.o box_construct.o box_normalise.o directory.o \
form.o html.o html_redraw.o imagemap.o layout.o list.o \
table.o textplain.o # render/
OBJECTS_COMMON +=3D filename.o hashtable.o messages.o talloc.o \
- url.o utf8.o utils.o # utils/
+ url.o utf8.o utils.o useragent.o # utils/
OBJECTS_COMMON +=3D knockout.o options.o tree.o version.o # desktop/
=
OBJECTS_IMAGE =3D bmp.o bmpread.o gif.o gifread.o ico.o jpeg.o \
@@ -110,7 +111,7 @@
include posix.mk
endif
=
-VPATH =3D content:css:desktop:image:render:riscos:riscos/configure:riscos/=
gui:utils:debug:gtk
+VPATH =3D content:content/fetchers:css:desktop:image:render:riscos:riscos/=
configure:riscos/gui:utils:debug:gtk
=
WARNFLAGS =3D -W -Wall -Wundef -Wpointer-arith -Wcast-qual \
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
@@ -131,7 +132,7 @@
-D_BSD_SOURCE \
-DGTK_DISABLE_DEPRECATED \
-D_POSIX_C_SOURCE \
- $(WARNFLAGS) -I. -g -O2 -Wformat=3D2 \
+ $(WARNFLAGS) -I. -g -O0 -Wformat=3D2 \
`pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags`
=
# Stop GCC under Cygwin throwing a fit
@@ -209,7 +210,7 @@
# available), remove */*.[ch] from the line below.
# Under RISC OS, you may require *Set UnixFS$sfix "", if perl gives
# "No such file or directory" errors.
-depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch]
+depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch=
] */*/*.[ch]
@echo "--> modified files $?"
@echo "--> updating dependencies"
@-mkdir -p $(OBJDIR_RISCOS) $(OBJDIR_RISCOS_SMALL) $(OBJDIR_NCOS) $(OBJDI=
R_DEBUG) $(OBJDIR_GTK)
15 years, 7 months
r3329 dsilvers - in /branches/dsilvers/scheme-switcher: content/fetch.c content/fetch.h content/fetchers/fetch_curl.c makefile
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 18:21:33 2007
New Revision: 3329
URL: http://svn.semichrome.net?rev=3D3329&view=3Drev
Log:
Fetchers now behave properly and we're back to the behaviour we had at the =
start
Modified:
branches/dsilvers/scheme-switcher/content/fetch.c
branches/dsilvers/scheme-switcher/content/fetch.h
branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.c
branches/dsilvers/scheme-switcher/makefile
Modified: branches/dsilvers/scheme-switcher/content/fetch.c
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/content/fe=
tch.c?rev=3D3329&r1=3D3328&r2=3D3329&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/content/fetch.c (original)
+++ branches/dsilvers/scheme-switcher/content/fetch.c Sun Jun 10 18:21:33 2=
007
@@ -46,6 +46,22 @@
=
bool fetch_active; /**< Fetches in progress, please call fetch_poll(). */
=
+/** Information about a fetcher for a given scheme. */
+typedef struct scheme_fetcher_s {
+ char *scheme_name; /**< The scheme. */
+ fetcher_setup_fetch setup_fetch; /**< Set up a fetch. */
+ fetcher_start_fetch start_fetch; /**< Start a fetch. */
+ fetcher_abort_fetch abort_fetch; /**< Abort a fetch. */
+ fetcher_free_fetch free_fetch; /**< Free a fetch. */
+ fetcher_poll_fetcher poll_fetcher; /**< Poll this fetcher. */
+ fetcher_finalise finaliser; /**< Clean up this fetcher. */
+ int refcount; /**< When zero, clean up the fetcher. */
+ struct scheme_fetcher_s *next_fetcher; /**< Next fetcher in the li=
st. */
+ struct scheme_fetcher_s *prev_fetcher; /**< Prev fetcher in the l=
ist. */
+} scheme_fetcher;
+
+static scheme_fetcher *fetchers =3D NULL;
+
/** Information for a single fetch. */
struct fetch {
fetch_callback callback;/**< Callback function. */
@@ -57,6 +73,9 @@
void *p; /**< Private data for callback. */
char *host; /**< Host part of URL. */
long http_code; /**< HTTP response code, or 0. */
+ scheme_fetcher *ops; /**< Fetcher operations for this fetch. NULL =
if not set. */
+ void *fetcher_handle; /**< The handle for the fetcher. */
+ bool fetch_is_active; /**< This fetch is active. */
struct fetch *r_prev; /**< Previous active fetch in ::fetch_ring. */
struct fetch *r_next; /**< Next active fetch in ::fetch_ring. */
};
@@ -65,10 +84,65 @@
static struct fetch *queue_ring =3D 0; /**< Ring of queued fetches */
=
static void fetch_free(struct fetch *f);
-static void fetch_stop(struct fetch *f);
-
static void fetch_dispatch_jobs(void);
=
+#define fetch_ref_fetcher(F) F->refcount++;
+
+static void fetch_unref_fetcher(scheme_fetcher *fetcher)
+{
+ if (--fetcher->refcount =3D=3D 0) {
+ fetcher->finaliser(fetcher->scheme_name);
+ free(fetcher->scheme_name);
+ if (fetcher =3D=3D fetchers) {
+ fetchers =3D fetcher->next_fetcher;
+ if (fetchers)
+ fetchers->prev_fetcher =3D NULL;
+ } else {
+ fetcher->prev_fetcher->next_fetcher =3D fetcher->n=
ext_fetcher;
+ if (fetcher->next_fetcher !=3D NULL)
+ fetcher->next_fetcher->prev_fetcher =3D fe=
tcher->prev_fetcher;
+ }
+ free(fetcher);
+ }
+}
+
+bool
+fetch_add_fetcher(const char *scheme,
+ fetcher_initialise initialiser,
+ fetcher_setup_fetch setup_fetch,
+ fetcher_start_fetch start_fetch,
+ fetcher_abort_fetch abort_fetch,
+ fetcher_free_fetch free_fetch,
+ fetcher_poll_fetcher poll_fetcher,
+ fetcher_finalise finaliser)
+{
+ scheme_fetcher *new_fetcher;
+ if (!initialiser(scheme))
+ return false;
+ new_fetcher =3D malloc(sizeof(scheme_fetcher));
+ if (new_fetcher =3D=3D NULL) {
+ finaliser(scheme);
+ return false;
+ }
+ new_fetcher->scheme_name =3D strdup(scheme);
+ if (new_fetcher->scheme_name =3D=3D NULL) {
+ free(new_fetcher);
+ finaliser(scheme);
+ return false;
+ }
+ new_fetcher->refcount =3D 0;
+ new_fetcher->setup_fetch =3D setup_fetch;
+ new_fetcher->start_fetch =3D start_fetch;
+ new_fetcher->abort_fetch =3D abort_fetch;
+ new_fetcher->free_fetch =3D free_fetch;
+ new_fetcher->poll_fetcher =3D poll_fetcher;
+ new_fetcher->finaliser =3D finaliser;
+ new_fetcher->next_fetcher =3D fetchers;
+ fetchers =3D new_fetcher;
+ fetch_ref_fetcher(new_fetcher);
+ return true;
+}
+
/**
* Initialise the fetcher.
*
@@ -78,6 +152,7 @@
void fetch_init(void)
{
register_curl_fetchers();
+ fetch_active =3D false;
}
=
=
@@ -89,6 +164,14 @@
=
void fetch_quit(void)
{
+ while (fetchers !=3D NULL) {
+ if (fetchers->refcount !=3D 1) {
+ LOG(("Fetcher for scheme %s still active?!", fetch=
ers->scheme_name));
+ /* We shouldn't do this, but... */
+ fetchers->refcount =3D 1;
+ }
+ fetch_unref_fetcher(fetchers);
+ }
}
=
=
@@ -122,6 +205,7 @@
struct fetch *fetch;
url_func_result res;
char *ref1 =3D 0, *ref2 =3D 0;
+ scheme_fetcher *fetcher =3D fetchers;
=
fetch =3D malloc(sizeof (*fetch));
if (!fetch)
@@ -169,6 +253,9 @@
fetch->r_prev =3D 0;
fetch->r_next =3D 0;
fetch->referer =3D 0;
+ fetch->ops =3D 0;
+ fetch->fetch_is_active =3D false;
+ =
if (referer !=3D NULL) {
fetch->referer =3D strdup(referer);
if (fetch->referer =3D=3D NULL)
@@ -181,6 +268,30 @@
if (!fetch->url)
goto failed;
=
+ /* Pick the scheme ops */
+ while (fetcher) {
+ if (strcmp(fetcher->scheme_name, ref1) =3D=3D 0) {
+ fetch->ops =3D fetcher;
+ break;
+ }
+ fetcher =3D fetcher->next_fetcher;
+ }
+ =
+ if (fetch->ops =3D=3D NULL)
+ goto failed;
+ =
+ /* Got a scheme fetcher, try and set up the fetch */
+ fetch->fetcher_handle =3D =
+ fetch->ops->setup_fetch(fetch, url, only_2xx, post_urlenc,
+ post_multipart, verifiable, parent=
_url,
+ (const char **)headers);
+ =
+ if (fetch->fetcher_handle =3D=3D NULL)
+ goto failed;
+ =
+ /* Rah, got it, so ref the fetcher. */
+ fetch_ref_fetcher(fetch->ops);
+ =
/* these aren't needed past here */
if (ref1) {
free(ref1);
@@ -213,16 +324,17 @@
*/
static bool fetch_dispatch_job(struct fetch *fetch)
{
- /*
RING_REMOVE(queue_ring, fetch);
- if (!fetch_initiate_fetch(fetch, fetch_get_handle(fetch->host))) {
- RING_INSERT(queue_ring, fetch); /* Put it back on the end of the queue *=
/
+ LOG(("Attempting to start fetch %p, fetcher %p, url %s", fetch,
+ fetch->fetcher_handle, fetch->url));
+ if (!fetch->ops->start_fetch(fetch->fetcher_handle)) {
+ RING_INSERT(queue_ring, fetch); /* Put it back on the end of the queue */
return false;
} else {
RING_INSERT(fetch_ring, fetch);
+ fetch->fetch_is_active =3D true;
return true;
}
-*/
}
=
/**
@@ -271,6 +383,7 @@
break;
}
}
+ fetch_active =3D (all_active > 0);
}
=
/**
@@ -280,42 +393,8 @@
void fetch_abort(struct fetch *f)
{
assert(f);
- LOG(("fetch %p, url '%s'", f, f->url));
- /*
- if (f->curl_handle) {
- f->abort =3D true;
- } else {
- RING_REMOVE(queue_ring, f);
- fetch_free(f);
- }
- */
-}
-
-
-/**
- * Clean up the provided fetch object and free it.
- *
- * Will prod the queue afterwards to allow pending requests to be initiate=
d.
- */
-
-void fetch_stop(struct fetch *f)
-{
- assert(f);
- LOG(("fetch %p, url '%s'", f, f->url));
-
-// if (f->curl_handle) {
- /* Remove this from the active set of fetches (if it's still there) */
- RING_REMOVE(fetch_ring, f);
-// } else {
- /* Remove this from the queued set of fetches (if it's still there) */
- RING_REMOVE(queue_ring, f);
-// }
-
- fetch_free(f);
- if (!fetch_ring && !queue_ring)
- fetch_active =3D false;
- else if (queue_ring)
- fetch_dispatch_jobs();
+ LOG(("fetch %p, fetcher %p, url '%s'", f, f->fetcher_handle, f->url));
+ f->ops->abort_fetch(f->fetcher_handle);
}
=
=
@@ -325,6 +404,9 @@
=
void fetch_free(struct fetch *f)
{
+ LOG(("Freeing fetch %p, fetcher %p", f, f->fetcher_handle));
+ f->ops->free_fetch(f->fetcher_handle);
+ fetch_unref_fetcher(f->ops);
free(f->url);
free(f->host);
if (f->referer)
@@ -341,6 +423,14 @@
=
void fetch_poll(void)
{
+ scheme_fetcher *fetcher =3D fetchers;
+ if (!fetch_active)
+ return; /* No point polling, there's no fetch active. */
+ while (fetcher !=3D NULL) {
+ LOG(("Polling fetcher for %s", fetcher->scheme_name));
+ fetcher->poll_fetcher(fetcher->scheme_name);
+ fetcher =3D fetcher->next_fetcher;
+ }
}
=
=
@@ -355,11 +445,19 @@
{
const char *semi;
size_t len;
-
+ scheme_fetcher *fetcher =3D fetchers;
+ =
if ((semi =3D strchr(url, ':')) =3D=3D NULL)
return false;
len =3D semi - url;
-
+ =
+ while (fetcher !=3D NULL) {
+ if (strlen(fetcher->scheme_name) =3D=3D len &&
+ strncmp(fetcher->scheme_name, url, len) =3D=3D 0)
+ return true;
+ fetcher =3D fetcher->next_fetcher;
+ }
+ =
return false;
}
=
@@ -402,6 +500,8 @@
void
fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsign=
ed long size)
{
+ LOG(("Fetcher sending callback. Fetch %p, fetcher %p data %p size =
%d",
+ fetch, fetch->fetcher_handle, data, size));
fetch->callback(msg, fetch->p, data, size);
}
=
@@ -409,11 +509,20 @@
fetch_can_be_freed(struct fetch *fetch)
{
/* Go ahead and free the fetch properly now */
+ LOG(("Fetch %p, fetcher %p can be freed", fetch, fetch->fetcher_ha=
ndle));
+ if (fetch->fetch_is_active) {
+ RING_REMOVE(fetch_ring, fetch);
+ } else {
+ RING_REMOVE(queue_ring, fetch);
+ }
+ fetch_active =3D (fetch_ring !=3D NULL);
+ fetch_free(fetch);
}
=
void
fetch_set_http_code(struct fetch *fetch, long http_code)
{
+ LOG(("Setting HTTP code to %d", http_code));
fetch->http_code =3D http_code;
}
=
Modified: branches/dsilvers/scheme-switcher/content/fetch.h
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/content/fe=
tch.h?rev=3D3329&r1=3D3328&r2=3D3329&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/content/fetch.h (original)
+++ branches/dsilvers/scheme-switcher/content/fetch.h Sun Jun 10 18:21:33 2=
007
@@ -96,7 +96,7 @@
typedef bool (*fetcher_start_fetch)(void *);
typedef void (*fetcher_abort_fetch)(void *);
typedef void (*fetcher_free_fetch)(void *);
-typedef void (*fetcher_poll_fetch)(const char *);
+typedef void (*fetcher_poll_fetcher)(const char *);
typedef void (*fetcher_finalise)(const char *);
=
bool fetch_add_fetcher(const char *scheme,
@@ -105,7 +105,7 @@
fetcher_start_fetch start_fetch,
fetcher_abort_fetch abort_fetch,
fetcher_free_fetch free_fetch,
- fetcher_poll_fetch poll_fetch,
+ fetcher_poll_fetcher poll_fetcher,
fetcher_finalise finaliser);
=
void fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, u=
nsigned long size);
Modified: branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.c
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/content/fe=
tchers/fetch_curl.c?rev=3D3329&r1=3D3328&r2=3D3329&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.c (origin=
al)
+++ branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.c Sun Jun=
10 18:21:33 2007
@@ -309,7 +309,6 @@
codem =3D curl_multi_add_handle(fetch_curl_multi, fetch->curl_handle);
assert(codem =3D=3D CURLM_OK || codem =3D=3D CURLM_CALL_MULTI_PERFORM);
=
- fetch_active =3D true;
return true;
}
=
@@ -668,9 +667,6 @@
f->cachedata.etag =3D 0;
}
=
- /* clean up fetch and start any queued fetch for this host */
- fetch_curl_stop(f);
-
/* postponed until after stop so that queue fetches are started */
if (abort)
; /* fetch was aborted: no callback */
@@ -762,6 +758,8 @@
#endif
else if (error)
fetch_send_callback(FETCH_ERROR, f->fetch_handle, fetch_error_buffer, 0);
+ =
+ fetch_curl_stop(f);
}
=
=
Modified: branches/dsilvers/scheme-switcher/makefile
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/makefile?r=
ev=3D3329&r1=3D3328&r2=3D3329&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/makefile (original)
+++ branches/dsilvers/scheme-switcher/makefile Sun Jun 10 18:21:33 2007
@@ -132,7 +132,7 @@
-D_BSD_SOURCE \
-DGTK_DISABLE_DEPRECATED \
-D_POSIX_C_SOURCE \
- $(WARNFLAGS) -I. -g -O2 -Wformat=3D2 \
+ $(WARNFLAGS) -I. -g -O0 -Wformat=3D2 \
`pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags`
=
# Stop GCC under Cygwin throwing a fit
15 years, 7 months
r3328 rjek - /trunk/netsurf/gtk/gtk_window.c
by netsurf@semichrome.net
Author: rjek
Date: Sun Jun 10 17:23:59 2007
New Revision: 3328
URL: http://svn.semichrome.net?rev=3D3328&view=3Drev
Log:
Don't bother resizing/repositioning frames when the core asks us to if it w=
ould result in no difference. Hopefully this fixes nsgtk consuming all ava=
ilable CPU on sites like news.bbc.co.uk
Modified:
trunk/netsurf/gtk/gtk_window.c
Modified: trunk/netsurf/gtk/gtk_window.c
URL: http://svn.semichrome.net/trunk/netsurf/gtk/gtk_window.c?rev=3D3328&r1=
=3D3327&r2=3D3328&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/netsurf/gtk/gtk_window.c (original)
+++ trunk/netsurf/gtk/gtk_window.c Sun Jun 10 17:23:59 2007
@@ -245,8 +245,22 @@
assert(w);
assert(f);
LOG(("%s: %d,%d %dx%d", g->bw->name, x0, y0, x1-x0+2, y1-y0+2));
- gtk_fixed_move(f, w, x0, y0);
- gtk_widget_set_size_request(w, x1 - x0 + 2, y1 - y0 + 2);
+ =
+ /* if the window has not changed position or size, do not bother
+ * moving/resising it.
+ */
+
+ LOG((" current: %d,%d %dx%d",
+ w->allocation.x, w->allocation.y,
+ w->allocation.width, w->allocation.height));
+
+ if (w->allocation.x !=3D x0 || w->allocation.y !=3D y0 ||
+ w->allocation.width !=3D x1 - x0 + 2 ||
+ w->allocation.height !=3D y1 - y0 + 2) {
+ LOG((" frame has moved/resized."));
+ gtk_fixed_move(f, w, x0, y0);
+ gtk_widget_set_size_request(w, x1 - x0 + 2, y1 - y0 + 2);
+ }
}
=
gboolean nsgtk_window_expose_event(GtkWidget *widget,
15 years, 7 months
r3327 dsilvers - in /branches/dsilvers/scheme-switcher: content/fetch.c content/fetchers/fetch_curl.h makefile utils/useragent.c
by netsurf@semichrome.net
Author: dsilvers
Date: Sun Jun 10 16:54:43 2007
New Revision: 3327
URL: http://svn.semichrome.net?rev=3D3327&view=3Drev
Log:
More cleanups, and add missing header
Added:
branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.h
Modified:
branches/dsilvers/scheme-switcher/content/fetch.c
branches/dsilvers/scheme-switcher/makefile
branches/dsilvers/scheme-switcher/utils/useragent.c
Modified: branches/dsilvers/scheme-switcher/content/fetch.c
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/content/fe=
tch.c?rev=3D3327&r1=3D3326&r2=3D3327&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/content/fetch.c (original)
+++ branches/dsilvers/scheme-switcher/content/fetch.c Sun Jun 10 16:54:43 2=
007
@@ -24,7 +24,6 @@
#include <time.h>
#include <sys/select.h>
#include <sys/stat.h>
-#include <sys/utsname.h>
#ifdef riscos
#include <unixlib/local.h>
#endif
@@ -400,58 +399,28 @@
return fetch->referer;
}
=
-/**
- * testing framework
- */
-
-#ifdef TEST
-#include <unistd.h>
-
-struct test {char *url; struct fetch *f;};
-
-void callback(fetch_msg msg, struct test *t, char *data, unsigned long siz=
e)
-{
- printf("%s: ", t->url);
- switch (msg) {
- case FETCH_TYPE:
- printf("FETCH_TYPE '%s'", data);
- break;
- case FETCH_DATA:
- printf("FETCH_DATA %lu", size);
- break;
- case FETCH_FINISHED:
- printf("FETCH_FINISHED");
- break;
- case FETCH_ERROR:
- printf("FETCH_ERROR '%s'", data);
- break;
- default:
- assert(0);
- }
- printf("\n");
-}
-
-struct test test[] =3D {
- {"http://127.0.0.1/", 0},
- {"http://netsurf.strcprstskrzkrk.co.uk/", 0},
- {"http://www.oxfordstudent.com/", 0},
- {"http://www.google.co.uk/", 0},
- {"http://news.bbc.co.uk/", 0},
- {"http://doesnt.exist/", 0},
- {"blah://blah", 0},
-};
-
-int main(void)
-{
- int i;
- fetch_init();
- for (i =3D 0; i !=3D sizeof(test) / sizeof(test[0]); i++)
- test[i].f =3D fetch_start(test[i].url, 0, callback, &test[i]);
- while (1) {
- fetch_poll();
- sleep(1);
- }
- return 0;
-}
-#endif
-
+void
+fetch_send_callback(fetch_msg msg, struct fetch *fetch, void *data, unsign=
ed long size)
+{
+ fetch->callback(msg, fetch->p, data, size);
+}
+
+void
+fetch_can_be_freed(struct fetch *fetch)
+{
+ /* Go ahead and free the fetch properly now */
+}
+
+void
+fetch_set_http_code(struct fetch *fetch, long http_code)
+{
+ fetch->http_code =3D http_code;
+}
+
+const char *
+fetch_get_referer_to_send(struct fetch *fetch)
+{
+ if (fetch->send_referer)
+ return fetch->referer;
+ return NULL;
+}
Added: branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.h
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/content/fe=
tchers/fetch_curl.h?rev=3D3327&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.h (added)
+++ branches/dsilvers/scheme-switcher/content/fetchers/fetch_curl.h Sun Jun=
10 16:54:43 2007
@@ -1,0 +1,22 @@
+/*
+ * This file is part of NetSurf, http://netsurf-browser.org/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2007 Daniel Silverstone <dsilvers(a)digital-scurf.org>
+ */
+
+/** \file
+ * Fetching of data from a URL (Registration).
+ */
+
+#ifndef NETSURF_CONTENT_FETCHERS_FETCH_CURL_H
+#define NETSURF_CONTENT_FETCHERS_FETCH_CURL_H
+
+#include <curl/curl.h>
+
+void register_curl_fetchers(void);
+
+/** Global cURL multi handle. */
+extern CURLM *fetch_curl_multi;
+
+#endif
Modified: branches/dsilvers/scheme-switcher/makefile
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/makefile?r=
ev=3D3327&r1=3D3326&r2=3D3327&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/makefile (original)
+++ branches/dsilvers/scheme-switcher/makefile Sun Jun 10 16:54:43 2007
@@ -26,7 +26,7 @@
form.o html.o html_redraw.o imagemap.o layout.o list.o \
table.o textplain.o # render/
OBJECTS_COMMON +=3D filename.o hashtable.o messages.o talloc.o \
- url.o utf8.o utils.o # utils/
+ url.o utf8.o utils.o useragent.o # utils/
OBJECTS_COMMON +=3D knockout.o options.o tree.o version.o # desktop/
=
OBJECTS_IMAGE =3D bmp.o bmpread.o gif.o gifread.o ico.o jpeg.o \
@@ -210,7 +210,7 @@
# available), remove */*.[ch] from the line below.
# Under RISC OS, you may require *Set UnixFS$sfix "", if perl gives
# "No such file or directory" errors.
-depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch]
+depend: css/css_enum.c css/parser.c css/scanner.c utils/translit.c */*.[ch=
] */*/*.[ch]
@echo "--> modified files $?"
@echo "--> updating dependencies"
@-mkdir -p $(OBJDIR_RISCOS) $(OBJDIR_RISCOS_SMALL) $(OBJDIR_NCOS) $(OBJDI=
R_DEBUG) $(OBJDIR_GTK)
Modified: branches/dsilvers/scheme-switcher/utils/useragent.c
URL: http://svn.semichrome.net/branches/dsilvers/scheme-switcher/utils/user=
agent.c?rev=3D3327&r1=3D3326&r2=3D3327&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/dsilvers/scheme-switcher/utils/useragent.c (original)
+++ branches/dsilvers/scheme-switcher/utils/useragent.c Sun Jun 10 16:54:43=
2007
@@ -5,6 +5,13 @@
* Copyright 2007 Daniel Silverstone <dsilvers(a)digital-scurf.org>
* Copyright 2007 Rob Kendrick <rjek(a)netsurf-browser.org>
*/
+
+#include <sys/utsname.h>
+#include <stdio.h>
+
+#include "useragent.h"
+#include "desktop/netsurf.h"
+#include "utils/log.h"
=
static const char *core_user_agent_string =3D NULL;
=
@@ -40,7 +47,7 @@
un.sysname,
un.machine);
=
- LOG(("fetch_user_agent \"%s\"", fetch_user_agent));
+ LOG(("Built user agent \"%s\"", core_user_agent_string));
}
=
/* This is a function so that later we can override it trivially */
15 years, 7 months