summaryrefslogtreecommitdiff
path: root/utils
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
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')
-rw-r--r--utils/utils.c22
-rw-r--r--utils/utils.h3
2 files changed, 25 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);
+ }
+}
+
diff --git a/utils/utils.h b/utils/utils.h
index 3ca3072af..e3a210352 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -10,6 +10,8 @@
#include <stdbool.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <regex.h>
#include "libxml/encoding.h"
void die(const char * const error);
@@ -27,5 +29,6 @@ char *squash_tolat1(xmlChar *s);
char *url_join(char *rel_url, char *base_url);
char *get_host_from_url(char* url);
bool is_dir(const char *path);
+void regcomp_wrapper(regex_t *preg, const char *regex, int cflags);
#endif