summaryrefslogtreecommitdiff
path: root/content/fetchers
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-09-26 21:07:19 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-09-26 21:07:19 +0000
commitc94271edf591226f9a5de88ac59719c4b5290a1b (patch)
tree176856c99c8a1a6eb859df6509df0b44376b6041 /content/fetchers
parent393b1afd4f09db7205c5e232c0c477ad3bb1ea32 (diff)
downloadnetsurf-c94271edf591226f9a5de88ac59719c4b5290a1b.tar.gz
netsurf-c94271edf591226f9a5de88ac59719c4b5290a1b.tar.bz2
Fetchers register with an lwc_string, rather than a string.
svn path=/trunk/netsurf/; revision=12891
Diffstat (limited to 'content/fetchers')
-rw-r--r--content/fetchers/about.c18
-rw-r--r--content/fetchers/curl.c55
-rw-r--r--content/fetchers/data.c21
-rw-r--r--content/fetchers/file.c17
-rw-r--r--content/fetchers/resource.c18
5 files changed, 92 insertions, 37 deletions
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 59461ee9f..2a5475d97 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -39,6 +39,8 @@
#include <limits.h>
#include <stdarg.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "utils/config.h"
#include "content/dirlist.h"
#include "content/fetch.h"
@@ -486,13 +488,13 @@ fetch_about_config_handler_aborted:
/** callback to initialise the about fetcher. */
-static bool fetch_about_initialise(const char *scheme)
+static bool fetch_about_initialise(lwc_string *scheme)
{
return true;
}
/** callback to initialise the about fetcher. */
-static void fetch_about_finalise(const char *scheme)
+static void fetch_about_finalise(lwc_string *scheme)
{
}
@@ -561,7 +563,7 @@ static void fetch_about_abort(void *ctx)
/** callback to poll for additional about fetch contents */
-static void fetch_about_poll(const char *scheme)
+static void fetch_about_poll(lwc_string *scheme)
{
struct fetch_about_context *c, *next;
@@ -603,7 +605,15 @@ static void fetch_about_poll(const char *scheme)
void fetch_about_register(void)
{
- fetch_add_fetcher("about",
+ lwc_string *scheme;
+
+ if (lwc_intern_string("about", SLEN("about"),
+ &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"about\").");
+ }
+
+ fetch_add_fetcher(scheme,
fetch_about_initialise,
fetch_about_setup,
fetch_about_start,
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 6fedda539..eb74fd7b6 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -37,6 +37,8 @@
#include <time.h>
#include <sys/stat.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "utils/config.h"
#include <openssl/ssl.h>
#include "content/fetch.h"
@@ -105,8 +107,8 @@ static bool curl_with_openssl;
static char fetch_error_buffer[CURL_ERROR_SIZE]; /**< Error buffer for cURL. */
static char fetch_proxy_userpwd[100]; /**< Proxy authentication details. */
-static bool fetch_curl_initialise(const char *scheme);
-static void fetch_curl_finalise(const char *scheme);
+static bool fetch_curl_initialise(lwc_string *scheme);
+static void fetch_curl_finalise(lwc_string *scheme);
static void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
const struct fetch_multipart_data *post_multipart,
@@ -122,7 +124,7 @@ static CURLcode fetch_curl_sslctxfun(CURL *curl_handle, void *_sslctx,
static void fetch_curl_abort(void *vf);
static void fetch_curl_stop(struct curl_fetch_info *f);
static void fetch_curl_free(void *f);
-static void fetch_curl_poll(const char *scheme_ignored);
+static void fetch_curl_poll(lwc_string *scheme_ignored);
static void fetch_curl_done(CURL *curl_handle, CURLcode result);
static int fetch_curl_progress(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow);
@@ -155,6 +157,7 @@ void fetch_curl_register(void)
CURLcode code;
curl_version_info_data *data;
int i;
+ lwc_string *scheme;
LOG(("curl_version %s", curl_version()));
@@ -224,19 +227,33 @@ void fetch_curl_register(void)
data = curl_version_info(CURLVERSION_NOW);
for (i = 0; data->protocols[i]; i++) {
- /* Ignore non-http(s) protocols */
- if (strcmp(data->protocols[i], "http") != 0 &&
- strcmp(data->protocols[i], "https") != 0)
+ if (strcmp(data->protocols[i], "http") == 0) {
+ if (lwc_intern_string("http", SLEN("http"),
+ &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"http\").");
+ }
+
+ } else if (strcmp(data->protocols[i], "https") == 0) {
+ if (lwc_intern_string("https", SLEN("https"),
+ &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"https\").");
+ }
+
+ } else {
+ /* Ignore non-http(s) protocols */
continue;
+ }
- if (!fetch_add_fetcher(data->protocols[i],
- fetch_curl_initialise,
- fetch_curl_setup,
- fetch_curl_start,
- fetch_curl_abort,
- fetch_curl_free,
- fetch_curl_poll,
- fetch_curl_finalise)) {
+ if (!fetch_add_fetcher(scheme,
+ fetch_curl_initialise,
+ fetch_curl_setup,
+ fetch_curl_start,
+ fetch_curl_abort,
+ fetch_curl_free,
+ fetch_curl_poll,
+ fetch_curl_finalise)) {
LOG(("Unable to register cURL fetcher for %s",
data->protocols[i]));
}
@@ -253,9 +270,9 @@ curl_easy_setopt_failed:
* Initialise a cURL fetcher.
*/
-bool fetch_curl_initialise(const char *scheme)
+bool fetch_curl_initialise(lwc_string *scheme)
{
- LOG(("Initialise cURL fetcher for %s", scheme));
+ LOG(("Initialise cURL fetcher for %s", lwc_string_data(scheme)));
curl_fetchers_registered++;
return true; /* Always succeeds */
}
@@ -265,10 +282,10 @@ bool fetch_curl_initialise(const char *scheme)
* Finalise a cURL fetcher
*/
-void fetch_curl_finalise(const char *scheme)
+void fetch_curl_finalise(lwc_string *scheme)
{
curl_fetchers_registered--;
- LOG(("Finalise cURL fetcher %s", scheme));
+ LOG(("Finalise cURL fetcher %s", lwc_string_data(scheme)));
if (curl_fetchers_registered == 0) {
CURLMcode codem;
/* All the fetchers have been finalised. */
@@ -716,7 +733,7 @@ void fetch_curl_free(void *vf)
* Must be called regularly to make progress on fetches.
*/
-void fetch_curl_poll(const char *scheme_ignored)
+void fetch_curl_poll(lwc_string *scheme_ignored)
{
int running, queue;
CURLMcode codem;
diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 5abe2d6dd..d9d7f768a 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -27,6 +27,8 @@
#include <curl/curl.h> /* for URL unescaping functions */
+#include <libwapcaplet/libwapcaplet.h>
+
#include "utils/config.h"
#include "content/fetch.h"
#include "content/fetchers/data.h"
@@ -58,18 +60,18 @@ static struct fetch_data_context *ring = NULL;
static CURL *curl;
-static bool fetch_data_initialise(const char *scheme)
+static bool fetch_data_initialise(lwc_string *scheme)
{
- LOG(("fetch_data_initialise called for %s", scheme));
+ LOG(("fetch_data_initialise called for %s", lwc_string_data(scheme)));
if ( (curl = curl_easy_init()) == NULL)
return false;
else
return true;
}
-static void fetch_data_finalise(const char *scheme)
+static void fetch_data_finalise(lwc_string *scheme)
{
- LOG(("fetch_data_finalise called for %s", scheme));
+ LOG(("fetch_data_finalise called for %s", lwc_string_data(scheme)));
curl_easy_cleanup(curl);
}
@@ -226,7 +228,7 @@ static bool fetch_data_process(struct fetch_data_context *c)
return true;
}
-static void fetch_data_poll(const char *scheme)
+static void fetch_data_poll(lwc_string *scheme)
{
struct fetch_data_context *c, *next;
@@ -306,7 +308,14 @@ static void fetch_data_poll(const char *scheme)
void fetch_data_register(void)
{
- fetch_add_fetcher("data",
+ lwc_string *scheme;
+
+ if (lwc_intern_string("data", SLEN("data"), &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"data\").");
+ }
+
+ fetch_add_fetcher(scheme,
fetch_data_initialise,
fetch_data_setup,
fetch_data_start,
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index 164fa5fd9..cc41e8c54 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -34,6 +34,8 @@
#include <limits.h>
#include <stdarg.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "utils/config.h"
#include "content/dirlist.h"
#include "content/fetch.h"
@@ -98,13 +100,13 @@ static bool fetch_file_send_header(struct fetch_file_context *ctx,
}
/** callback to initialise the file fetcher. */
-static bool fetch_file_initialise(const char *scheme)
+static bool fetch_file_initialise(lwc_string *scheme)
{
return true;
}
/** callback to initialise the file fetcher. */
-static void fetch_file_finalise(const char *scheme)
+static void fetch_file_finalise(lwc_string *scheme)
{
}
@@ -589,7 +591,7 @@ static void fetch_file_process(struct fetch_file_context *ctx)
}
/** callback to poll for additional file fetch contents */
-static void fetch_file_poll(const char *scheme)
+static void fetch_file_poll(lwc_string *scheme)
{
struct fetch_file_context *c, *next;
@@ -631,7 +633,14 @@ static void fetch_file_poll(const char *scheme)
void fetch_file_register(void)
{
- fetch_add_fetcher("file",
+ lwc_string *scheme;
+
+ if (lwc_intern_string("file", SLEN("file"), &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"file\").");
+ }
+
+ fetch_add_fetcher(scheme,
fetch_file_initialise,
fetch_file_setup,
fetch_file_start,
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index b0aac9067..27194ef06 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -34,6 +34,8 @@
#include <limits.h>
#include <stdarg.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "utils/config.h"
#include "content/dirlist.h"
#include "content/fetch.h"
@@ -149,13 +151,13 @@ fetch_resource_notfound_handler_aborted:
/** callback to initialise the resource fetcher. */
-static bool fetch_resource_initialise(const char *scheme)
+static bool fetch_resource_initialise(lwc_string *scheme)
{
return true;
}
/** callback to initialise the resource fetcher. */
-static void fetch_resource_finalise(const char *scheme)
+static void fetch_resource_finalise(lwc_string *scheme)
{
}
@@ -225,7 +227,7 @@ static void fetch_resource_abort(void *ctx)
/** callback to poll for additional resource fetch contents */
-static void fetch_resource_poll(const char *scheme)
+static void fetch_resource_poll(lwc_string *scheme)
{
struct fetch_resource_context *c, *next;
@@ -267,7 +269,15 @@ static void fetch_resource_poll(const char *scheme)
void fetch_resource_register(void)
{
- fetch_add_fetcher("resource",
+ lwc_string *scheme;
+
+ if (lwc_intern_string("resource", SLEN("resource"),
+ &scheme) != lwc_error_ok) {
+ die("Failed to initialise the fetch module "
+ "(couldn't intern \"resource\").");
+ }
+
+ fetch_add_fetcher(scheme,
fetch_resource_initialise,
fetch_resource_setup,
fetch_resource_start,