Author: mmu_man
Date: Fri Apr 6 10:50:13 2012
New Revision: 13795
URL:
http://source.netsurf-browser.org?rev=13795&view=rev
Log:
Apply and merge r12393 from v2 branch: Add url_gopher_type() which extracts the gopher
item type from the url.
Modified:
branches/mmu_man/netsurf-gopher-support-v3/utils/url.c
branches/mmu_man/netsurf-gopher-support-v3/utils/url.h
Modified: branches/mmu_man/netsurf-gopher-support-v3/utils/url.c
URL:
http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/utils/url.c (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/utils/url.c Fri Apr 6 10:50:13 2012
@@ -671,6 +671,38 @@
}
/**
+ * Extract the gopher document type from an URL
+ *
+ * \param url an absolute URL
+ * \param result pointer to buffer to hold result
+ * \return URL_FUNC_OK on success
+ */
+
+url_func_result url_gopher_type(const char *url, char *result)
+{
+ url_func_result status;
+ struct url_components components;
+
+ assert(url);
+
+ status = url_get_components(url, &components);
+ if (status == URL_FUNC_OK) {
+ if (!components.path) {
+ status = URL_FUNC_FAILED;
+ } else {
+ if (strlen(components.path) < 2)
+ *result = '1';
+ else if (components.path[0] == '/')
+ *result = components.path[1];
+ else
+ status = URL_FUNC_FAILED;
+ }
+ }
+ url_destroy_components(&components);
+ return status;
+}
+
+/**
* Attempt to find a nice filename for a URL.
*
* \param url an absolute URL
Modified: branches/mmu_man/netsurf-gopher-support-v3/utils/url.h
URL:
http://source.netsurf-browser.org/branches/mmu_man/netsurf-gopher-support...
==============================================================================
--- branches/mmu_man/netsurf-gopher-support-v3/utils/url.h (original)
+++ branches/mmu_man/netsurf-gopher-support-v3/utils/url.h Fri Apr 6 10:50:13 2012
@@ -59,6 +59,7 @@
url_func_result url_path(const char *url, char **result);
url_func_result url_leafname(const char *url, char **result);
url_func_result url_fragment(const char *url, char **result);
+url_func_result url_gopher_type(const char *url, char *result);
url_func_result url_compare(const char *url1, const char *url2,
bool nofrag, bool *result);