summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-04-02 13:51:13 +0000
committerJames Bursa <james@netsurf-browser.org>2004-04-02 13:51:13 +0000
commit27562bf838d749e81333fd74349902499ccd3f0a (patch)
treeff6200b79701d1908f48a678f61e401e0e228deb
parent9454b8bca10f2ac8e224b9d60d71355b36194555 (diff)
downloadnetsurf-27562bf838d749e81333fd74349902499ccd3f0a.tar.gz
netsurf-27562bf838d749e81333fd74349902499ccd3f0a.tar.bz2
[project @ 2004-04-02 13:51:13 by bursa]
Implement fetch_can_fetch(). svn path=/import/netsurf/; revision=699
-rw-r--r--content/fetch.c30
-rw-r--r--content/fetch.h1
2 files changed, 31 insertions, 0 deletions
diff --git a/content/fetch.c b/content/fetch.c
index 5f6f0015c..bc6b8acc2 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -772,6 +772,36 @@ struct curl_httppost *fetch_post_convert(struct form_successful_control *control
}
#endif
+
+/**
+ * Check if a URL's scheme can be fetched.
+ *
+ * \param url URL to check
+ * \return true if the scheme is supported
+ */
+
+bool fetch_can_fetch(const char *url)
+{
+ unsigned int i;
+ const char *semi;
+ unsigned int len;
+ curl_version_info_data *data;
+
+ semi = strchr(url, ':');
+ if (!semi)
+ return false;
+ len = semi - url;
+
+ data = curl_version_info(CURLVERSION_NOW);
+
+ for (i = 0; data->protocols[i]; i++)
+ if (strlen(data->protocols[i]) == len &&
+ strncasecmp(url, data->protocols[i], len) == 0)
+ return true;
+ return false;
+}
+
+
/**
* testing framework
*/
diff --git a/content/fetch.h b/content/fetch.h
index e5dfff6a3..f906b4bd4 100644
--- a/content/fetch.h
+++ b/content/fetch.h
@@ -51,5 +51,6 @@ void fetch_poll(void);
void fetch_quit(void);
const char *fetch_filetype(const char *unix_path);
char *fetch_mimetype(const char *ro_path);
+bool fetch_can_fetch(const char *url);
#endif