summaryrefslogtreecommitdiff
path: root/utils/utils.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-12-27 20:15:23 +0000
committerJames Bursa <james@netsurf-browser.org>2003-12-27 20:15:23 +0000
commitce0d5294d5898b6100269bd39d38c0884d5fd4b4 (patch)
tree3a073e5a6d069113c6272f108fcedd668cd186a8 /utils/utils.c
parent01c0332607e1e9646b74add201a6488ce5265844 (diff)
downloadnetsurf-ce0d5294d5898b6100269bd39d38c0884d5fd4b4.tar.gz
netsurf-ce0d5294d5898b6100269bd39d38c0884d5fd4b4.tar.bz2
[project @ 2003-12-27 20:15:22 by bursa]
Use charset from Content-Type header. svn path=/import/netsurf/; revision=460
Diffstat (limited to 'utils/utils.c')
-rw-r--r--utils/utils.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/utils/utils.c b/utils/utils.c
index 2ebdf9e5d..cb331a55f 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -13,6 +13,8 @@
#include <string.h>
#include <sys/stat.h>
#include <uri.h>
+#include <sys/types.h>
+#include <regex.h>
#include "libxml/encoding.h"
#include "libxml/uri.h"
#include "netsurf/utils/log.h"
@@ -256,3 +258,23 @@ bool is_dir(const char *path)
return S_ISDIR(s.st_mode) ? true : false;
}
+
+
+/**
+ * Compile a regular expression, handling errors.
+ *
+ * Parameters as for regcomp(), see man regex.
+ */
+
+void regcomp_wrapper(regex_t *preg, const char *regex, int cflags)
+{
+ char errbuf[200];
+ int r;
+ r = regcomp(preg, regex, cflags);
+ if (r) {
+ regerror(r, preg, errbuf, sizeof errbuf);
+ fprintf(stderr, "Failed to compile regexp '%s'\n", regex);
+ die(errbuf);
+ }
+}
+