/*
* This module handles fulltext indexing of the message base.
- * Copyright (c) 2005-2011 by the citadel.org team
+ * Copyright (c) 2005-2015 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
int tok;
struct CtdlMessage *msg = NULL;
- msg = CtdlFetchMessage(msgnum, 1);
+ msg = CtdlFetchMessage(msgnum, 1, 1);
if (msg == NULL) {
syslog(LOG_ERR, "ft_index_message() could not load msg %ld", msgnum);
return;
}
- if (msg->cm_fields[eSuppressIdx] != NULL) {
+ if (!CM_IsEmpty(msg, eSuppressIdx)) {
syslog(LOG_DEBUG, "ft_index_message() excluded msg %ld", msgnum);
- CtdlFreeMessage(msg);
+ CM_Free(msg);
return;
}
*/
CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
CtdlOutputPreLoadedMsg(msg, MT_CITADEL, HEADERS_ALL, 0, 1, 0);
- CtdlFreeMessage(msg);
+ CM_Free(msg);
msgtext = CC->redirect_buffer;
CC->redirect_buffer = NULL;
if (msgtext != NULL) {
*/
void ft_index_msg(long msgnum, void *userdata) {
- if ((msgnum > CitControl.MMfulltext) && (msgnum <= ft_newhighest)) {
+ if ((msgnum > CtdlGetConfigLong("MMfulltext")) && (msgnum <= ft_newhighest)) {
++ft_num_msgs;
if (ft_num_msgs > ft_num_alloc) {
ft_num_alloc += 1024;
/*
* Don't do this if the site doesn't have it enabled.
*/
- if (!config.c_enable_fulltext) {
+ if (!CtdlGetConfigInt("c_enable_fulltext")) {
return;
}
* Check to see whether the fulltext index is up to date; if there
* are no messages to index, don't waste any more time trying.
*/
- if ((CitControl.MMfulltext >= CitControl.MMhighest) && (CitControl.fulltext_wordbreaker == FT_WORDBREAKER_ID)) {
+ if (
+ (CtdlGetConfigLong("MMfulltext") >= CtdlGetConfigLong("MMhighest"))
+ && (CtdlGetConfigInt("MM_fulltext_wordbreaker") == FT_WORDBREAKER_ID)
+ ) {
return; /* nothing to do! */
}
* over.
*/
begin_critical_section(S_CONTROL);
- if (CitControl.fulltext_wordbreaker != FT_WORDBREAKER_ID) {
+ if (CtdlGetConfigInt("MM_fulltext_wordbreaker") != FT_WORDBREAKER_ID) {
syslog(LOG_DEBUG, "wb ver on disk = %d, code ver = %d",
- CitControl.fulltext_wordbreaker, FT_WORDBREAKER_ID
+ CtdlGetConfigInt("MM_fulltext_wordbreaker"), FT_WORDBREAKER_ID
);
syslog(LOG_INFO, "(re)initializing full text index");
cdb_trunc(CDB_FULLTEXT);
- CitControl.MMfulltext = 0L;
- put_control();
+ CtdlSetConfigLong("MMfulltext", 0);
}
end_critical_section(S_CONTROL);
/*
* Now go through each room and find messages to index.
*/
- ft_newhighest = CitControl.MMhighest;
+ ft_newhighest = CtdlGetConfigLong("MMhighest");
CtdlForEachRoom(ft_index_room, NULL); /* load all msg pointers */
if (ft_num_msgs > 0) {
/* 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();
+ CtdlSetConfigLong("MMfulltext", ft_newhighest);
+ CtdlSetConfigInt("MM_fulltext_wordbreaker", FT_WORDBREAKER_ID);
end_critical_section(S_CONTROL);
last_index = time(NULL);
if (CtdlAccessCheck(ac_logged_in)) return;
- if (!config.c_enable_fulltext) {
+ if (!CtdlGetConfigInt("c_enable_fulltext")) {
cprintf("%d Full text index is not enabled on this server.\n",
ERROR + CMD_NOT_SUPPORTED);
return;
if (room) return;
/* Remove from fulltext index */
- if (config.c_enable_fulltext) {
+ if (CtdlGetConfigInt("c_enable_fulltext")) {
ft_index_message(msgnum, 0);
}
}