#include <limits.h>
#include "citadel.h"
#include "server.h"
-#include "sysdep_decls.h"
#include "citserver.h"
#include "support.h"
#include "config.h"
-#include "serv_extensions.h"
#include "database.h"
#include "msgbase.h"
#include "control.h"
#include "ft_wordbreaker.h"
+#include "ctdl_module.h"
+
+
+
long ft_newhighest = 0L;
long *ft_newmsgs = NULL;
int ft_num_msgs = 0;
else {
lprintf(CTDL_ALERT, "Invalid token %d !!\n", tok);
}
-
- /* FIXME do we need to unlock the file here? */
}
free(tokens);
void ft_index_room(struct ctdlroom *qrbuf, void *data)
{
getroom(&CC->room, qrbuf->QRname);
- CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, ft_index_msg, NULL);
+ CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, ft_index_msg, NULL);
}
* 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_INFO, "(re)initializing full text index\n");
cdb_trunc(CDB_FULLTEXT);
CitControl.MMfulltext = 0L;
put_control();
}
+ end_critical_section(S_CONTROL);
/*
* Now go through each room and find messages to index.
/* Here it is ... do each message! */
for (i=0; i<ft_num_msgs; ++i) {
- if ((time(NULL) - last_progress) > 10) {
+ if (time(NULL) != last_progress) {
lprintf(CTDL_DEBUG,
"Indexed %d of %d messages (%d%%)\n",
i, ft_num_msgs,
/* Save our place so we don't have to do this again */
ft_flush_cache();
+ begin_critical_section(S_CONTROL);
CitControl.MMfulltext = ft_newhighest;
CitControl.fulltext_wordbreaker = FT_WORDBREAKER_ID;
put_control();
+ end_critical_section(S_CONTROL);
last_index = time(NULL);
lprintf(CTDL_DEBUG, "do_fulltext_indexing() finished\n");
/*
- * Tentative form of a search command
+ * This search command is for diagnostic purposes and may be removed or replaced.
*/
void cmd_srch(char *argbuf) {
int num_msgs = 0;
if (!config.c_enable_fulltext) {
cprintf("%d Full text index is not enabled on this server.\n",
ERROR + CMD_NOT_SUPPORTED);
+ return;
}
extract_token(search_string, argbuf, 0, '|', sizeof search_string);
/*****************************************************************************/
-char *serv_fulltext_init(void)
+CTDL_MODULE_INIT(fulltext)
{
initialize_ft_cache();
CtdlRegisterProtoHook(cmd_srch, "SRCH", "Full text search");
+
+ /* return our Subversion id for the Log */
return "$Id$";
}