* please see the file GPL in the top level source directory.
*/
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/rx.h>
+#include "lib-lib.h"
rx_t *rx_compile(const char *s, int flags)
{
return -1;
}
+
+int rx_sanitize_string(char *dst, ssize_t n, const char *src)
+{
+ while (*src) {
+ if (n <= 1)
+ break;
+
+ /* these characters must be escaped in regular expressions */
+ if (strchr("^.[$()|*+?{\\", *src)) {
+ if (n <= 2)
+ break;
+
+ *dst++ = '\\';
+ n--;
+ }
+
+ *dst++ = *src++;
+ n--;
+ }
+
+ *dst = '\0';
+
+ return *src ? -1 : 0;
+}