HUGE PATCH. This moves all of mime_parser.c and all
[citadel.git] / citadel / modules / fulltext / serv_fulltext.c
index b5753fbf63c95e4e156082f36da568d6d8ea9485..5ba8b5a37c74d21fee67fa7b2885b54ede4ff208 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <limits.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
@@ -39,7 +40,6 @@
 #include "msgbase.h"
 #include "control.h"
 #include "room_ops.h"
-#include "tools.h"
 #include "serv_fulltext.h"
 #include "ft_wordbreaker.h"
 
@@ -219,7 +219,9 @@ void do_fulltext_indexing(void) {
        int i;
        static time_t last_index = 0L;
        static time_t last_progress = 0L;
-
+       time_t run_time = 0L;
+       time_t end_time = 0L;
+       
        /*
         * Don't do this if the site doesn't have it enabled.
         */
@@ -242,17 +244,18 @@ void do_fulltext_indexing(void) {
        if (CitControl.MMfulltext >= CitControl.MMhighest) {
                return;         /* nothing to do! */
        }
-
-       lprintf(CTDL_DEBUG, "do_fulltext_indexing() started\n");
+       
+       run_time = time(NULL);
+       lprintf(CTDL_DEBUG, "do_fulltext_indexing() started (%ld)\n", run_time);
        
        /*
         * If we've switched wordbreaker modules, burn the index and start
         * over.
         */
        begin_critical_section(S_CONTROL);
-       lprintf(CTDL_DEBUG, "wb ver on disk = %d, code ver = %d\n",
-                       CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID);
        if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
+               lprintf(CTDL_DEBUG, "wb ver on disk = %d, code ver = %d\n",
+                       CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID);
                lprintf(CTDL_INFO, "(re)initializing full text index\n");
                cdb_trunc(CDB_FULLTEXT);
                CitControl.MMfulltext = 0L;
@@ -310,6 +313,8 @@ void do_fulltext_indexing(void) {
                ft_num_alloc = 0;
                ft_newmsgs = NULL;
        }
+       end_time = time(NULL);
+       lprintf(CTDL_DEBUG, "do_fulltext_indexing() duration (%ld)\n", end_time - run_time);
 
        /* Save our place so we don't have to do this again */
        ft_flush_cache();
@@ -467,12 +472,24 @@ void initialize_ft_cache(void) {
 }
 
 
+void ft_delete_remove(char *room, long msgnum)
+{
+       if (room) return;
+       
+       /* Remove from fulltext index */
+       if (config.c_enable_fulltext) {
+               ft_index_message(msgnum, 0);
+       }
+}
+
 /*****************************************************************************/
 
 CTDL_MODULE_INIT(fulltext)
 {
        initialize_ft_cache();
        CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
+       CtdlRegisterDeleteHook(ft_delete_remove);
+       CtdlRegisterSearchFuncHook(ft_search, "fulltext");
        CtdlRegisterMaintenanceThread ("indexer", indexer_thread);
 
        /* return our Subversion id for the Log */