summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2016-04-21 21:36:21 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2016-04-21 21:36:21 (GMT)
commit7d9c9dba3610bb14c0de6acb1bdaf9ec49a66f33 (patch)
tree5efbbb0accdce7586dfe518f3ea0c00a6e8a9c43
parent3488e337b64f7444f3021ca98f391d4ded3326e4 (diff)
downloadnetsurf-7d9c9dba3610bb14c0de6acb1bdaf9ec49a66f33.tar.gz
netsurf-7d9c9dba3610bb14c0de6acb1bdaf9ec49a66f33.tar.bz2
Split utils header into string functions and everything else
split out the string handling API from the rest of the utils header and fix up all the fallout.
-rw-r--r--amiga/download.c1
-rwxr-xr-xamiga/misc.c1
-rw-r--r--amiga/theme.c1
-rw-r--r--amiga/tree.c1
-rw-r--r--atari/download.c1
-rw-r--r--atari/file.c1
-rw-r--r--beos/download.cpp1
-rw-r--r--content/fetch.c1
-rw-r--r--content/fetchers/about.c32
-rw-r--r--content/fetchers/curl.c1
-rw-r--r--content/fetchers/data.c26
-rw-r--r--content/fetchers/file.c12
-rw-r--r--content/fetchers/resource.c17
-rw-r--r--framebuffer/fbtk/fbtk.c1
-rw-r--r--gtk/about.c1
-rw-r--r--gtk/download.c1
-rw-r--r--gtk/history.c1
-rw-r--r--gtk/preferences.c1
-rw-r--r--gtk/toolbar.c1
-rw-r--r--gtk/treeview.c1
-rw-r--r--gtk/viewsource.c1
-rw-r--r--gtk/window.c1
-rw-r--r--javascript/fetcher.c27
-rw-r--r--monkey/browser.c1
-rw-r--r--render/box_construct.c13
-rw-r--r--render/html.c1
-rw-r--r--riscos/download.c1
-rw-r--r--riscos/image.c1
-rw-r--r--riscos/textselection.c5
-rw-r--r--riscos/ucstables.c1
-rw-r--r--riscos/url_protocol.c5
-rw-r--r--riscos/window.c1
-rw-r--r--utils/file.c1
-rw-r--r--utils/messages.c1
-rw-r--r--utils/string.h115
-rw-r--r--utils/url.c2
-rw-r--r--utils/utils.c1
-rw-r--r--utils/utils.h85
-rw-r--r--windows/download.c1
-rw-r--r--windows/file.c1
-rw-r--r--windows/schedule.c1
41 files changed, 187 insertions, 182 deletions
diff --git a/amiga/download.c b/amiga/download.c
index fc58bd4..21c21ca 100644
--- a/amiga/download.c
+++ b/amiga/download.c
@@ -47,6 +47,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
+#include "utils/string.h"
#include "desktop/download.h"
#include "desktop/save_complete.h"
#include "desktop/browser.h"
diff --git a/amiga/misc.c b/amiga/misc.c
index ae91bf3..dc87ae9 100755
--- a/amiga/misc.c
+++ b/amiga/misc.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
diff --git a/amiga/theme.c b/amiga/theme.c
index 97b6bab..399a116 100644
--- a/amiga/theme.c
+++ b/amiga/theme.c
@@ -18,6 +18,7 @@
#include "amiga/os3support.h"
+#include <stdlib.h>
#include <string.h>
#include <proto/clicktab.h>
diff --git a/amiga/tree.c b/amiga/tree.c
index fd0a5a6..48b1521 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -18,6 +18,7 @@
#include "amiga/os3support.h"
+#include <stdlib.h>
#include <proto/window.h>
#include <proto/layout.h>
#include <proto/space.h>
diff --git a/atari/download.c b/atari/download.c
index c6f1d68..dad5d1f 100644
--- a/atari/download.c
+++ b/atari/download.c
@@ -29,6 +29,7 @@
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/nsoption.h"
+#include "utils/string.h"
#include "content/urldb.h"
#include "content/fetch.h"
#include "desktop/save_complete.h"
diff --git a/atari/file.c b/atari/file.c
index b6d465f..499edd6 100644
--- a/atari/file.c
+++ b/atari/file.c
@@ -29,6 +29,7 @@
#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/file.h"
+#include "utils/string.h"
/**
* \file
diff --git a/beos/download.cpp b/beos/download.cpp
index 791da35..6145caf 100644
--- a/beos/download.cpp
+++ b/beos/download.cpp
@@ -24,6 +24,7 @@ extern "C" {
#include "desktop/download.h"
#include "desktop/gui_download.h"
#include "utils/utils.h"
+#include "utils/string.h"
}
#include "beos/download.h"
diff --git a/content/fetch.c b/content/fetch.c
index 415ca26..9c2933b 100644
--- a/content/fetch.c
+++ b/content/fetch.c
@@ -31,6 +31,7 @@
* fetches are stored in the ::queue_ring waiting for use.
*/
+#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index cf66a62..605d3a8 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file content/fetchers/about.c
+/**
+ * \file
*
* URL handling for the "about" scheme.
*
@@ -25,39 +26,24 @@
* information from the browser from a known, fixed URL.
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <inttypes.h>
+#include <stdlib.h>
#include <string.h>
-#include <strings.h>
-#include <time.h>
#include <stdio.h>
-#include <limits.h>
#include <stdarg.h>
-#include <libwapcaplet/libwapcaplet.h>
-
#include "testament.h"
+#include "utils/corestrings.h"
+#include "utils/nsoption.h"
+#include "utils/utils.h"
+#include "utils/ring.h"
-#include "utils/config.h"
-#include "utils/dirent.h"
#include "content/fetch.h"
#include "content/fetchers.h"
#include "content/fetchers/about.h"
-#include "content/urldb.h"
-#include "utils/nsoption.h"
-#include "utils/corestrings.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
-#include "utils/ring.h"
+#include "content/content_type.h"
#include "image/image_cache.h"
+
struct fetch_about_context;
typedef bool (*fetch_about_handler)(struct fetch_about_context *);
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index 07b13d5..7b9c5f0 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -51,6 +51,7 @@
#include "utils/ring.h"
#include "utils/useragent.h"
#include "utils/file.h"
+#include "utils/string.h"
#include "desktop/gui_fetch.h"
#include "desktop/gui_internal.h"
diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 6c18911..84d0aa3 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -16,32 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* data: URL handling. See http://tools.ietf.org/html/rfc2397 */
+/**
+ * \file
+ * data scheme handling. See http://tools.ietf.org/html/rfc2397
+ */
-#include <assert.h>
-#include <errno.h>
#include <stdbool.h>
#include <string.h>
-#include <strings.h>
-#include <time.h>
-
-#include <curl/curl.h> /* for URL unescaping functions */
-
+#include <stdlib.h>
+#include <curl/curl.h> /* for URL unescaping functions */
#include <libwapcaplet/libwapcaplet.h>
-#include "utils/config.h"
-#include "content/fetch.h"
-#include "content/fetchers.h"
-#include "content/fetchers/data.h"
-#include "content/urldb.h"
+#include "utils/nsurl.h"
#include "utils/corestrings.h"
-#include "utils/nsoption.h"
#include "utils/log.h"
-#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/ring.h"
#include "utils/base64.h"
+#include "content/fetch.h"
+#include "content/fetchers.h"
+#include "content/fetchers/data.h"
+
struct fetch_data_context {
struct fetch *parent_fetch;
char *url;
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index d13b4d5..2e3411a 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -24,33 +24,26 @@
#include "utils/config.h"
+#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <assert.h>
#include <errno.h>
#include <stdbool.h>
-#include <inttypes.h>
#include <string.h>
-#include <strings.h>
#include <time.h>
#include <stdio.h>
-#include <limits.h>
#include <stdarg.h>
-
#ifdef HAVE_MMAP
#include <sys/mman.h>
#endif
-
#include <libwapcaplet/libwapcaplet.h>
+#include "utils/nsurl.h"
#include "utils/dirent.h"
#include "utils/corestrings.h"
-#include "utils/nsoption.h"
-#include "utils/errors.h"
-#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/ring.h"
@@ -61,7 +54,6 @@
#include "content/dirlist.h"
#include "content/fetch.h"
#include "content/fetchers.h"
-#include "content/urldb.h"
#include "content/fetchers/file.h"
/* Maximum size of read buffer */
diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c
index 2db414d..4dfac5c 100644
--- a/content/fetchers/resource.c
+++ b/content/fetchers/resource.c
@@ -21,27 +21,15 @@
* resource scheme URL handling. Based on the data fetcher by Rob Kendrick
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
+#include <stdlib.h>
#include <stdbool.h>
-#include <inttypes.h>
#include <string.h>
-#include <strings.h>
-#include <time.h>
#include <stdio.h>
-#include <limits.h>
#include <stdarg.h>
-
#include <libwapcaplet/libwapcaplet.h>
-#include "utils/dirent.h"
-#include "utils/errors.h"
+#include "utils/nsurl.h"
#include "utils/corestrings.h"
-#include "utils/nsoption.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/utils.h"
@@ -52,7 +40,6 @@
#include "content/fetch.h"
#include "content/fetchers.h"
#include "content/fetchers/resource.h"
-#include "content/urldb.h"
#define DIRECT_ETAG_VALUE 123456
diff --git a/framebuffer/fbtk/fbtk.c b/framebuffer/fbtk/fbtk.c
index 882e5e5..db1c1f1 100644
--- a/framebuffer/fbtk/fbtk.c
+++ b/framebuffer/fbtk/fbtk.c
@@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <sys/types.h>
#include <assert.h>
#include <stdint.h>
diff --git a/gtk/about.c b/gtk/about.c
index b2f5a52..55df409 100644
--- a/gtk/about.c
+++ b/gtk/about.c
@@ -22,6 +22,7 @@
* Implementation of gtk about dialog.
*/
+#include <stdlib.h>
#include <stdint.h>
#include "utils/utils.h"
diff --git a/gtk/download.c b/gtk/download.c
index 23832de..195f689 100644
--- a/gtk/download.c
+++ b/gtk/download.c
@@ -28,6 +28,7 @@
#include "utils/nsurl.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
+#include "utils/string.h"
#include "desktop/download.h"
#include "desktop/gui_download.h"
diff --git a/gtk/history.c b/gtk/history.c
index db30c5b..2f11042 100644
--- a/gtk/history.c
+++ b/gtk/history.c
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <gtk/gtk.h>
#include "utils/log.h"
diff --git a/gtk/preferences.c b/gtk/preferences.c
index 5e7c3c5..0f38506 100644
--- a/gtk/preferences.c
+++ b/gtk/preferences.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include <string.h>
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index 8012598..cb01e1a 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gtk/gtk.h>
diff --git a/gtk/treeview.c b/gtk/treeview.c
index 2b2e6c7..08f1d9e 100644
--- a/gtk/treeview.c
+++ b/gtk/treeview.c
@@ -21,6 +21,7 @@
* Generic tree handling (implementation).
*/
+#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <limits.h>
diff --git a/gtk/viewsource.c b/gtk/viewsource.c
index 62e5959..554cfbf 100644
--- a/gtk/viewsource.c
+++ b/gtk/viewsource.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <gtk/gtk.h>
#include "utils/utils.h"
diff --git a/gtk/window.c b/gtk/window.c
index c50ed20..14aa34e 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -22,6 +22,7 @@
* Implementation of gtk windowing.
*/
+#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <limits.h>
diff --git a/javascript/fetcher.c b/javascript/fetcher.c
index 5bbe3dd..839df26 100644
--- a/javascript/fetcher.c
+++ b/javascript/fetcher.c
@@ -22,36 +22,17 @@
* This fetcher implements http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#javascript-protocol
*/
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
#include <stdbool.h>
-#include <inttypes.h>
-#include <string.h>
-#include <strings.h>
-#include <time.h>
-#include <stdio.h>
-#include <limits.h>
-#include <stdarg.h>
-
+#include <stdlib.h>
#include <libwapcaplet/libwapcaplet.h>
-#include "utils/config.h"
-#include "utils/errors.h"
+#include "utils/nsurl.h"
#include "utils/corestrings.h"
-#include "utils/nsoption.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/utils.h"
#include "utils/ring.h"
-
#include "content/fetch.h"
#include "content/fetchers.h"
+
#include "javascript/fetcher.h"
-#include "content/urldb.h"
/** Context for an resource fetch */
struct fetch_javascript_context {
@@ -62,7 +43,7 @@ struct fetch_javascript_context {
bool aborted; /**< Flag indicating fetch has been aborted */
bool locked; /**< Flag indicating entry is already entered */
- nsurl *url;
+ nsurl *url; /**< The URL being fetched */
};
static struct fetch_javascript_context *ring = NULL;
diff --git a/monkey/browser.c b/monkey/browser.c
index 2b007fd..85b3c62 100644
--- a/monkey/browser.c
+++ b/monkey/browser.c
@@ -19,6 +19,7 @@
/* Browser-related callbacks */
#include <stdio.h>
+#include <stdlib.h>
#include "utils/utils.h"
#include "utils/ring.h"
diff --git a/render/box_construct.c b/render/box_construct.c
index 23d4120..7e982d7 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -22,7 +22,7 @@
/**
* \file
- * Conversion of XML tree to box tree (implementation).
+ * Implementation of conversion from DOM tree to box tree.
*/
#include <assert.h>
@@ -34,11 +34,6 @@
#include <strings.h>
#include "utils/config.h"
-#include "content/content_protected.h"
-#include "css/css.h"
-#include "css/hints.h"
-#include "css/select.h"
-#include "css/utils.h"
#include "utils/nsoption.h"
#include "utils/corestrings.h"
#include "utils/locale.h"
@@ -46,6 +41,12 @@
#include "utils/messages.h"
#include "utils/talloc.h"
#include "utils/utils.h"
+#include "utils/string.h"
+#include "content/content_protected.h"
+#include "css/css.h"
+#include "css/hints.h"
+#include "css/select.h"
+#include "css/utils.h"
#include "desktop/gui_misc.h"
#include "desktop/gui_internal.h"
diff --git a/render/html.c b/render/html.c
index fb4c05b..c95044f 100644
--- a/render/html.c
+++ b/render/html.c
@@ -39,6 +39,7 @@
#include "utils/talloc.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
+#include "utils/string.h"
#include "content/content_protected.h"
#include "content/fetch.h"
#include "content/hlcache.h"
diff --git a/riscos/download.c b/riscos/download.c
index 851f0ae..cf4f8f4 100644
--- a/riscos/download.c
+++ b/riscos/download.c
@@ -52,6 +52,7 @@
#include "utils/nsurl.h"
#include "utils/utf8.h"
#include "utils/utils.h"
+#include "utils/string.h"
#include "utils/corestrings.h"
#include "desktop/gui_download.h"
#include "desktop/download.h"
diff --git a/riscos/image.c b/riscos/image.c
index 63e65f2..3f23691 100644
--- a/riscos/image.c
+++ b/riscos/image.c
@@ -18,6 +18,7 @@
#include <stdbool.h>
#include <swis.h>
+#include <stdlib.h>
#include <oslib/colourtrans.h>
#include <oslib/osspriteop.h>
diff --git a/riscos/textselection.c b/riscos/textselection.c
index dc852a7..38a33ef 100644
--- a/riscos/textselection.c
+++ b/riscos/textselection.c
@@ -23,8 +23,9 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
-#include "oslib/osfile.h"
-#include "oslib/wimp.h"
+#include <stdlib.h>
+#include <oslib/osfile.h>
+#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/utf8.h"
diff --git a/riscos/ucstables.c b/riscos/ucstables.c
index c881437..7ac685d 100644
--- a/riscos/ucstables.c
+++ b/riscos/ucstables.c
@@ -23,6 +23,7 @@
#include <assert.h>
#include <limits.h>
#include <string.h>
+#include <stdlib.h>
#include <oslib/osbyte.h>
#include <oslib/territory.h>
diff --git a/riscos/url_protocol.c b/riscos/url_protocol.c
index 9fa8882..34c2814 100644
--- a/riscos/url_protocol.c
+++ b/riscos/url_protocol.c
@@ -29,8 +29,9 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
-#include "oslib/inetsuite.h"
-#include "oslib/wimp.h"
+#include <stdlib.h>
+#include <oslib/inetsuite.h>
+#include <oslib/wimp.h>
#include "utils/log.h"
#include "utils/messages.h"
diff --git a/riscos/window.c b/riscos/window.c
index 6145707..acf51c5 100644
--- a/riscos/window.c
+++ b/riscos/window.c
@@ -51,6 +51,7 @@
#include "utils/utf8.h"
#include "utils/utils.h"
#include "utils/messages.h"
+#include "utils/string.h"
#include "content/content.h"
#include "content/hlcache.h"
#include "content/urldb.h"
diff --git a/utils/file.c b/utils/file.c
index 00f8eef..8888110 100644
--- a/utils/file.c
+++ b/utils/file.c
@@ -33,6 +33,7 @@
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/nsurl.h"
+#include "utils/string.h"
#include "utils/file.h"
/**
diff --git a/utils/messages.c b/utils/messages.c
index d652fef..d343cfc 100644
--- a/utils/messages.c
+++ b/utils/messages.c
@@ -25,6 +25,7 @@
* fast access.
*/
+#include <stdlib.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
diff --git a/utils/string.h b/utils/string.h
new file mode 100644
index 0000000..03d8917
--- a/dev/null
+++ b/utils/string.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * \brief Interface to utility string handling.
+ */
+
+#ifndef _NETSURF_UTILS_STRING_H_
+#define _NETSURF_UTILS_STRING_H_
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "utils/errors.h"
+
+
+/**
+ * Replace consecutive whitespace with a single space.
+ *
+ * @todo determine if squash_whitespace utf-8 safe and that it needs to be
+ *
+ * \param s source string
+ * \return heap allocated result, or NULL on memory exhaustion
+ */
+char *squash_whitespace(const char * s);
+
+
+/**
+ * Converts NUL terminated UTF-8 encoded string s containing zero or more
+ * spaces (char 32) or TABs (char 9) to non-breaking spaces
+ * (0xC2 + 0xA0 in UTF-8 encoding).
+ *
+ * Caller needs to free() result. Returns NULL in case of error. No
+ * checking is done on validness of the UTF-8 input string.
+ */
+char *cnv_space2nbsp(const char *s);
+
+
+/**
+ * Create a human readable representation of a size in bytes.
+ *
+ * Does a simple conversion which assumes the user speaks English.
+ * The buffer returned is one of three static ones so may change each
+ * time this call is made. Don't store the buffer for later use.
+ * It's done this way for convenience and to fight possible memory
+ * leaks, it is not necessarily pretty.
+ *
+ * @param bytesize The size in bytes.
+ * @return A human readable string representing the size.
+ */
+char *human_friendly_bytesize(unsigned long bytesize);
+
+
+/**
+ * Generate a string from one or more component elements separated with
+ * a single value.
+ *
+ * This is similar in intent to the perl join function creating a
+ * single delimited string from an array of several.
+ *
+ * @note If a string is allocated it must be freed by the caller.
+ *
+ * @param[in,out] str pointer to string pointer if this is NULL enough
+ * storage will be allocated for the complete path.
+ * @param[in,out] size The size of the space available if \a str not
+ * NULL on input and if not NULL set to the total
+ * output length on output.
+ * @param[in] sep The character to separate the elements with.
+ * @param[in] nelm The number of elements up to a maximum of 16.
+ * @param[in] ap The elements of the path as string pointers.
+ * @return NSERROR_OK and the complete path is written to str or error
+ * code on failure.
+ */
+nserror vsnstrjoin(char **str, size_t *size, char sep, size_t nelm, va_list ap);
+
+
+/**
+ * Generate a string from one or more component elements separated with
+ * a single value.
+ *
+ * This is similar in intent to the Perl join function creating a
+ * single delimited string from an array of several.
+ *
+ * @note If a string is allocated it must be freed by the caller.
+ *
+ * @param[in,out] str pointer to string pointer if this is NULL enough
+ * storage will be allocated for the complete path.
+ * @param[in,out] size The size of the space available if \a str not
+ * NULL on input and if not NULL set to the total
+ * output length on output.
+ * @param[in] sep The character to separate the elements with.
+ * @param[in] nelm The number of elements up to a maximum of 16.
+ * @param[in] ... The elements of the path as string pointers.
+ * @return NSERROR_OK and the complete path is written to str or error
+ * code on failure.
+ */
+nserror snstrjoin(char **str, size_t *size, char sep, size_t nelm, ...);
+
+#endif
diff --git a/utils/url.c b/utils/url.c
index 450d471..1e3ef42 100644
--- a/utils/url.c
+++ b/utils/url.c
@@ -24,11 +24,11 @@
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
#include <curl/curl.h>
#include "utils/config.h"
#include "utils/log.h"
-#include "utils/utils.h"
#include "utils/url.h"
diff --git a/utils/utils.c b/utils/utils.c
index 2a41c8a..1509a6b 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -40,6 +40,7 @@
#include "utils/sys_time.h"
#include "utils/inet.h"
#include "utils/dirent.h"
+#include "utils/string.h"
#include "utils/utils.h"
/* exported interface documented in utils/utils.h */
diff --git a/utils/utils.h b/utils/utils.h
index a436206..d4bad9d 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -28,10 +28,6 @@
#include <inttypes.h>
#include <stdbool.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "utils/errors.h"
/** Rectangle coordinates */
struct rect {
@@ -115,91 +111,10 @@ struct dirent;
/**
- * Replace consecutive whitespace with a single space.
- *
- * @todo determine if squash_whitespace utf-8 safe and that it needs to be
- *
- * \param s source string
- * \return heap allocated result, or NULL on memory exhaustion
- */
-char * squash_whitespace(const char * s);
-
-/**
- * Converts NUL terminated UTF-8 encoded string s containing zero or more
- * spaces (char 32) or TABs (char 9) to non-breaking spaces
- * (0xC2 + 0xA0 in UTF-8 encoding).
- *
- * Caller needs to free() result. Returns NULL in case of error. No
- * checking is done on validness of the UTF-8 input string.
- */
-char *cnv_space2nbsp(const char *s);
-
-/**
* Check if a directory exists.
*/
bool is_dir(const char *path);
-/**
- * Create a human redable representation of a size in bytes.
- *
- * Does a simple conversion which assumes the user speaks English.
- * The buffer returned is one of three static ones so may change each
- * time this call is made. Don't store the buffer for later use.
- * It's done this way for convenience and to fight possible memory
- * leaks, it is not necessarily pretty.
- *
- * @todo This implementation is strange doe sit need
- * reconsidering?
- *
- * @param bytesize The size in bytes.
- * @return A human readable string representing the size.
- */
-char *human_friendly_bytesize(unsigned long bytesize);
-
-
-/**
- * Generate a string from one or more component elemnts separated with
- * a single value.
- *
- * This is similar in intent to the perl join function creating a
- * single delimited string from an array of several.
- *
- * @note If a string is allocated it must be freed by the caller.
- *
- * @param[in,out] str pointer to string pointer if this is NULL enough
- * storage will be allocated for the complete path.
- * @param[in,out] size The size of the space available if \a str not
- * NULL on input and if not NULL set to the total
- * output length on output.
- * @param[in] sep The character to separete the elemnts with.
- * @param[in] nelm The number of elements up to a maximum of 16.
- * @param[in] ap The elements of the path as string pointers.
- * @return NSERROR_OK and the complete path is written to str or error
- * code on faliure.
- */
-nserror vsnstrjoin(char **str, size_t *size, char sep, size_t nelm, va_list ap);
-
-/**
- * Generate a string from one or more component elemnts separated with
- * a single value.
- *
- * This is similar in intent to the perl join function creating a
- * single delimited string from an array of several.
- *
- * @note If a string is allocated it must be freed by the caller.
- *
- * @param[in,out] str pointer to string pointer if this is NULL enough
- * storage will be allocated for the complete path.
- * @param[in,out] size The size of the space available if \a str not
- * NULL on input and if not NULL set to the total
- * output length on output.
- * @param[in] sep The character to separete the elemnts with.
- * @param[in] nelm The number of elements up to a maximum of 16.
- * @param[in] ... The elements of the path as string pointers.
- * @return NSERROR_OK and the complete path is written to str or error
- * code on faliure.
- */
-nserror snstrjoin(char **str, size_t *size, char sep, size_t nelm, ...);
/* Platform specific functions */
void warn_user(const char *warning, const char *detail);
diff --git a/windows/download.c b/windows/download.c
index 110c272..c2cda8f 100644
--- a/windows/download.c
+++ b/windows/download.c
@@ -29,6 +29,7 @@
#include "utils/url.h"
#include "utils/nsurl.h"
#include "utils/utils.h"
+#include "utils/string.h"
#include "content/fetch.h"
#include "desktop/gui_download.h"
#include "desktop/download.h"
diff --git a/windows/file.c b/windows/file.c
index f8372b4..e9eb9ca 100644
--- a/windows/file.c
+++ b/windows/file.c
@@ -34,6 +34,7 @@
#include "utils/corestrings.h"
#include "utils/url.h"
#include "utils/file.h"
+#include "utils/string.h"
#include "desktop/browser.h"
#include "windows/file.h"
diff --git a/windows/schedule.c b/windows/schedule.c
index 249e60e..5366add 100644
--- a/windows/schedule.c
+++ b/windows/schedule.c
@@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdlib.h>
#include <time.h>
#include "utils/sys_time.h"