Improved subject simplification by regexp.
[claws.git] / src / string_match.h
index a338894b55c63c53e3f5f1d0298b620efff5716d..86793bd3c2407774d6eb1746d99df8142268e8d7 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Sylpheed -- regexp pattern matching utilities
  * Copyright (C) 2001 Thomas Link, Hiroyuki Yamamoto
+ *                    Modified by Melvin Hadasht.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  */
 
 
-#ifndef __STRING_MATCH_H__
-#define __STRING_MATCH_H__
+#ifndef STRING_MATCH_H__
+#define STRING_MATCH_H__
 
-#include <stdio.h>
+#include <sys/types.h>
 #include <regex.h>
+#include <glib.h>
 
+/* Precompile the preg buffer for the rexp regexp string. See regex man for the
+ * meaning of cflags.  
+ */
 
-/* the size used for regexec in string_remove_match */
-/* this is probably not the most clever way to define this here, though */
-#define STRING_MATCH_MR_SIZE 30
-
-
-/* match a REXP in TXT, return non-zero if found */
-/* for documentation of SIZE, MATCHES, CFLAGS, and EFLAGS see "man regex" */
-/* MATCHES will be updated by regexec */
-int string_match_regexp(char * txt, char * rexp, \
-                       int size, regmatch_t matches[], \
-                       int cflags, int eflags);
-
-/* remove substring matching REXP from TXT. Destructive! */
-/* for documentation of CFLAGS and EFLAGS see "man regex" */
-/* returns -1 = not found; N = next find pos */
-/* if the match is an empty string (e.g. "x\?"), the find position will
-   be increased by 1 */
-int string_remove_match(char * txt, char * rexp, int cflags, int eflags);
-
-/* remove all substrings matching REXP from TXT. Destructive! */
-/* for documentation of CFLAGS and EFLAGS see "man regex" */
-/* returns position of last replacement (i.e. TXT has been modified up
-   to this position, use this as the starting point for further mangling) */
-int string_remove_all_matches(char * txt, char * rexp, int cflags, int eflags);
+int string_match_precompile (gchar *rexp, regex_t *preg, int cflags);
 
+/* remove from txt the substrings matching the regexp in the precompiled preg buffer.  
+ * The result is stored in the preallocated buf buffer which maximal length
+ * is buflen.
+ */
+gchar *string_remove_match(gchar *buf, gint buflen, gchar * txt, regex_t *preg);
 
-#endif
+#endif /* STRING_MATCH_H__ */