summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-09-09 21:45:59 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-09-09 21:45:59 +0000
commit2077918805c175ecefeb25dd38f78d2d5b3a3ca2 (patch)
tree73fd0d27d042d97aa9fe67032697bd21f8deee9a /utils
parentb9773d34bb523d3bac09f328900e60b02feea97b (diff)
downloadnetsurf-2077918805c175ecefeb25dd38f78d2d5b3a3ca2.tar.gz
netsurf-2077918805c175ecefeb25dd38f78d2d5b3a3ca2.tar.bz2
Merge branches/vince/netsurf-file-fetcher to trunk
r=jmb svn path=/trunk/netsurf/; revision=10750
Diffstat (limited to 'utils')
-rw-r--r--utils/config.h16
-rw-r--r--utils/url.c25
-rw-r--r--utils/url.h1
3 files changed, 42 insertions, 0 deletions
diff --git a/utils/config.h b/utils/config.h
index 4a4fa069c..f618102a2 100644
--- a/utils/config.h
+++ b/utils/config.h
@@ -20,6 +20,7 @@
#define _NETSURF_UTILS_CONFIG_H_
#include <stddef.h>
+#include <dirent.h>
/* Try to detect which features the target OS supports */
@@ -37,6 +38,21 @@ char *strndup(const char *s, size_t n);
char *strcasestr(const char *haystack, const char *needle);
#endif
+/* fdopendir is actually present on most unix systems but unless
+ * _POSIX_C_SOURCE is set to 2008 it is not declared in the system
+ * headers. It is unavailable on RISC OS which requires fallback code
+ */
+#if (_POSIX_C_SOURCE - 0) >= 200809L
+#define HAVE_FDOPENDIR
+#else
+#if defined(riscos)
+#undef HAVE_FDOPENDIR
+#else
+#define HAVE_FDOPENDIR
+DIR *fdopendir(int fd);
+#endif
+#endif
+
/* For some reason, UnixLib defines this unconditionally.
* Assume we're using UnixLib if building for RISC OS. */
#if (defined(_GNU_SOURCE) || defined(riscos))
diff --git a/utils/url.c b/utils/url.c
index 5cb7305e8..cd731c97c 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -902,6 +902,31 @@ no_path:
return URL_FUNC_FAILED;
}
+/**
+ * Convert an escaped string to plain.
+ * \param result unescaped string owned by caller must be freed with free()
+ * \return URL_FUNC_OK on success
+ */
+url_func_result url_unescape(const char *str, char **result)
+{
+ char *curlstr;
+ char *retstr;
+
+ curlstr = curl_unescape(str, 0);
+ if (curlstr == NULL) {
+ return URL_FUNC_NOMEM;
+ }
+
+ retstr = strdup(curlstr);
+ curl_free(curlstr);
+
+ if (retstr == NULL) {
+ return URL_FUNC_NOMEM;
+ }
+
+ *result = retstr;
+ return URL_FUNC_OK;
+}
/**
* Escape a string suitable for inclusion in an URL.
diff --git a/utils/url.h b/utils/url.h
index e0e18fb17..8b5da77f2 100644
--- a/utils/url.h
+++ b/utils/url.h
@@ -53,6 +53,7 @@ url_func_result url_nice(const char *url, char **result,
bool remove_extensions);
url_func_result url_escape(const char *unescaped, size_t toskip,
bool sptoplus, const char *escexceptions, char **result);
+url_func_result url_unescape(const char *str, char **result);
url_func_result url_canonical_root(const char *url, char **result);
url_func_result url_parent(const char *url, char **result);
url_func_result url_plq(const char *url, char **result);