]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/msgbase.c
Rewrite of the indexer is complete!
[citadel.git] / citadel / server / msgbase.c
index 60e1140cf3b9f05a6c3958b587e85f07c96c1d0c..66a56da97d9eca29cae2e29fef0a3ff07e3e4fcf 100644 (file)
@@ -24,6 +24,7 @@
 #include "euidindex.h"
 #include "msgbase.h"
 #include "journaling.h"
+#include "modules/fulltext/serv_fulltext.h"
 
 struct addresses_to_be_filed *atbf = NULL;
 
@@ -615,11 +616,10 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
        int is_seen = 0;
        long lastold = 0L;
        int printed_lastold = 0;
-       int num_search_msgs = 0;
-       long *search_msgs = NULL;
        regex_t re;
        int need_to_free_re = 0;
        regmatch_t pm;
+       Array *search = NULL;
 
        if ((content_type) && (!IsEmptyStr(content_type))) {
                regcomp(&re, content_type, 0);
@@ -719,18 +719,19 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
                 * NULL means use any search function available.
                 * otherwise replace with a char * to name of search routine
                 */
-               CtdlModuleDoSearch(search_string, "fulltext");
-               //FIXME FOOFOO DO ARRAY
+               search = CtdlFullTextSearch(search_string);
 
-               if (num_search_msgs > 0) {
+               if (array_len(search) > 0) {
        
                        int orig_num_msgs;
 
                        orig_num_msgs = num_msgs;
                        num_msgs = 0;
                        for (i=0; i<orig_num_msgs; ++i) {
-                               for (j=0; j<num_search_msgs; ++j) {
-                                       if (msglist[i] == search_msgs[j]) {
+                               for (j=0; j<array_len(search); ++j) {
+                                       long smsgnum;
+                                       memcpy(&smsgnum, array_get_element_at(search, j), sizeof(long));
+                                       if (msglist[i] == smsgnum) {
                                                msglist[num_msgs++] = msglist[i];
                                        }
                                }
@@ -739,7 +740,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
                else {
                        num_msgs = 0;   /* No messages qualify */
                }
-               if (search_msgs != NULL) free(search_msgs);
+               if (search != NULL) array_free(search);
 
                /* Now that we've purged messages which don't contain the search
                 * string, treat a MSGS_SEARCH just like a MSGS_ALL from this