moar syslog
[citadel.git] / citadel / euidindex.c
index 8bad12925557f072c6b713397337121624e0e7f5..95c7c77a792fe05b885f685a5048cf19696fb525 100644 (file)
@@ -3,45 +3,11 @@
  */
 
 #include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
 #include <stdio.h>
-#include <fcntl.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-
-#include <ctype.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <sys/stat.h>
 #include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "database.h"
-#include "msgbase.h"
-#include "support.h"
-#include "sysdep_decls.h"
+
 #include "citserver.h"
 #include "room_ops.h"
-#include "user_ops.h"
-#include "file_ops.h"
-#include "config.h"
-#include "control.h"
-#include "euidindex.h"
-
-#include "ctdl_module.h"
 
 /*
  * The structure of an euidindex record *key* is:
@@ -74,6 +40,8 @@ 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);
        }
        
        return(0);
@@ -98,7 +66,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
        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);
@@ -118,7 +86,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);
 }
 
@@ -133,7 +101,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: ndexing message #%ld <%s> in <%s>", msgnum, euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -159,12 +127,12 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
 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 (msg->cm_fields['E'] != NULL) {
-               index_message_by_euid(msg->cm_fields['E'], &CC->room, msgnum);
+       if (!CM_IsEmpty(msg, eExclusiveID)) {
+               index_message_by_euid(msg->cm_fields[eExclusiveID], &CC->room, msgnum);
        }
-       CtdlFreeMessage(msg);
+       CM_Free(msg);
 }
 
 
@@ -192,9 +160,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);
                        }