X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Feuidindex.c;h=8533caabf85a6099e7ed32463341265b27691b36;hb=c71df26b9d35c07eb9c1322a7e83caa86337ad82;hp=7e5c735d06a2e267d2fd4f1a1bf2b039d8987284;hpb=655de5af64c89584fbdd0110a27053a9f3bfd138;p=citadel.git diff --git a/citadel/euidindex.c b/citadel/euidindex.c index 7e5c735d0..8533caabf 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -1,5 +1,15 @@ -/* +/* * Index messages by EUID per room. + * + * Copyright (c) 1987-2019 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, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include "sysdep.h" @@ -23,8 +33,6 @@ * */ - - /* * Return nonzero if the supplied room is one which should have * an EUID index. @@ -40,6 +48,7 @@ int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) { case VIEW_TASKS: return(1); case VIEW_NOTES: return(1); case VIEW_WIKI: return(1); + case VIEW_WIKIMD: return(1); case VIEW_BLOG: return(1); } @@ -47,10 +56,6 @@ int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) { } - - - - /* * Locate a message in a given room with a given euid, and return * its message number. @@ -59,13 +64,14 @@ long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf) { return CtdlLocateMessageByEuid (euid, qrbuf); } + long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) { char *key; int key_len; struct cdbdata *cdb_euid; long msgnum = (-1L); - syslog(LOG_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname); + syslog(LOG_DEBUG, "euidindex: searching for EUID <%s> in <%s>", euid, qrbuf->QRname); key_len = strlen(euid) + sizeof(long) + 1; key = malloc(key_len); @@ -85,7 +91,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) { memcpy(&msgnum, cdb_euid->ptr, sizeof(long)); cdb_free(cdb_euid); } - syslog(LOG_DEBUG, "returning msgnum = %ld\n", msgnum); + syslog(LOG_DEBUG, "euidindex: returning msgnum = %ld", msgnum); return(msgnum); } @@ -100,7 +106,7 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) { char *data; int data_len; - syslog(LOG_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname); + syslog(LOG_DEBUG, "euidindex: indexing message #%ld <%s> in <%s>", msgnum, euid, qrbuf->QRname); key_len = strlen(euid) + sizeof(long) + 1; key = malloc(key_len); @@ -119,14 +125,13 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) { } - /* * Called by rebuild_euid_index_for_room() to index one message. */ void rebuild_euid_index_for_msg(long msgnum, void *userdata) { struct CtdlMessage *msg = NULL; - msg = CtdlFetchMessage(msgnum, 0); + msg = CtdlFetchMessage(msgnum, 0, 1); if (msg == NULL) return; if (!CM_IsEmpty(msg, eExclusiveID)) { index_message_by_euid(msg->cm_fields[eExclusiveID], &CC->room, msgnum); @@ -159,9 +164,9 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) { if (CtdlGetRoom(&qr, rplist->name) == 0) { if (DoesThisRoomNeedEuidIndexing(&qr)) { syslog(LOG_DEBUG, - "Rebuilding EUID index for <%s>\n", + "euidindex: rebuilding EUID index for <%s>", rplist->name); - CtdlUserGoto(rplist->name, 0, 0, NULL, NULL); + CtdlUserGoto(rplist->name, 0, 0, NULL, NULL, NULL, NULL); CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, rebuild_euid_index_for_msg, NULL); } @@ -183,7 +188,6 @@ void rebuild_euid_index(void) { } - /* * Server command to fetch a message number given an euid. */ @@ -221,6 +225,7 @@ void cmd_euid(char *cmdbuf) { cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND); } + CTDL_MODULE_INIT(euidindex) { if (!threading) {