Merge branch 'maint'
[paraslash.git] / string.c
index 5479e5b4fb43f6f0bac87e6cfba42ec011f30beb..bb63120184c79b44270a4ae1ba671e6dd74de5e1 100644 (file)
--- a/string.c
+++ b/string.c
@@ -6,14 +6,14 @@
 
 /** \file string.c Memory allocation and string handling functions. */
 
-#include "para.h"
-#include "string.h"
-
 #include <sys/time.h> /* gettimeofday */
 #include <pwd.h>
 #include <sys/utsname.h> /* uname() */
 #include <string.h>
+#include <regex.h>
 
+#include "para.h"
+#include "string.h"
 #include "error.h"
 
 /**
@@ -735,3 +735,19 @@ err:
        free(argv);
        return ret;
 }
+
+int para_regcomp(regex_t *preg, const char *regex, int cflags)
+{
+       char *buf;
+       size_t size;
+       int ret = regcomp(preg, regex, cflags);
+
+       if (ret == 0)
+               return 1;
+       size = regerror(ret, preg, NULL, 0);
+       buf = para_malloc(size);
+       regerror(ret, preg, buf, size);
+       PARA_ERROR_LOG("%s\n", buf);
+       free(buf);
+       return -E_REGEX;
+}