From 27562bf838d749e81333fd74349902499ccd3f0a Mon Sep 17 00:00:00 2001 From: James Bursa Date: Fri, 2 Apr 2004 13:51:13 +0000 Subject: [project @ 2004-04-02 13:51:13 by bursa] Implement fetch_can_fetch(). svn path=/import/netsurf/; revision=699 --- content/fetch.c | 30 ++++++++++++++++++++++++++++++ content/fetch.h | 1 + 2 files changed, 31 insertions(+) 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 -- cgit v1.2.3