move file_ops to modules/ctdlsrv/serv_file.c
[citadel.git] / citadel / euidindex.c
index c7499d832f35ccf700d427c8a35c274f380b8997..85d9ccbf5875df83d45b531d5006b2ba69eaa9f6 100644 (file)
@@ -1,8 +1,5 @@
 /*
- * $Id$
- *
  * Index messages by EUID per room.
- *
  */
 
 #include "sysdep.h"
@@ -39,7 +36,6 @@
 #include "citserver.h"
 #include "room_ops.h"
 #include "user_ops.h"
-#include "file_ops.h"
 #include "config.h"
 #include "control.h"
 #include "euidindex.h"
@@ -72,10 +68,12 @@ int DoesThisRoomNeedEuidIndexing(struct ctdlroom *qrbuf) {
                case VIEW_BBS:          return(0);
                case VIEW_MAILBOX:      return(0);
                case VIEW_ADDRESSBOOK:  return(1);
+               case VIEW_DRAFTS:       return(0);
                case VIEW_CALENDAR:     return(1);
                case VIEW_TASKS:        return(1);
                case VIEW_NOTES:        return(1);
                case VIEW_WIKI:         return(1);
+               case VIEW_BLOG:         return(1);
        }
        
        return(0);
@@ -100,7 +98,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
        struct cdbdata *cdb_euid;
        long msgnum = (-1L);
 
-       CtdlLogPrintf(CTDL_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Searching for EUID <%s> in <%s>\n", euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -120,7 +118,7 @@ long CtdlLocateMessageByEuid(char *euid, struct ctdlroom *qrbuf) {
                memcpy(&msgnum, cdb_euid->ptr, sizeof(long));
                cdb_free(cdb_euid);
        }
-       CtdlLogPrintf(CTDL_DEBUG, "returning msgnum = %ld\n", msgnum);
+       syslog(LOG_DEBUG, "returning msgnum = %ld\n", msgnum);
        return(msgnum);
 }
 
@@ -135,7 +133,7 @@ void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
        char *data;
        int data_len;
 
-       CtdlLogPrintf(CTDL_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
+       syslog(LOG_DEBUG, "Indexing message #%ld <%s> in <%s>\n", msgnum, euid, qrbuf->QRname);
 
        key_len = strlen(euid) + sizeof(long) + 1;
        key = malloc(key_len);
@@ -163,10 +161,10 @@ void rebuild_euid_index_for_msg(long msgnum, void *userdata) {
 
        msg = CtdlFetchMessage(msgnum, 0);
        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);
 }
 
 
@@ -193,7 +191,7 @@ void rebuild_euid_index_for_room(struct ctdlroom *qrbuf, void *data) {
        while (rplist != NULL) {
                if (CtdlGetRoom(&qr, rplist->name) == 0) {
                        if (DoesThisRoomNeedEuidIndexing(&qr)) {
-                               CtdlLogPrintf(CTDL_DEBUG,
+                               syslog(LOG_DEBUG,
                                        "Rebuilding EUID index for <%s>\n",
                                        rplist->name);
                                CtdlUserGoto(rplist->name, 0, 0, NULL, NULL);
@@ -230,10 +228,10 @@ void cmd_euid(char *cmdbuf) {
         int num_msgs = 0;
        int i;
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
        extract_token(euid, cmdbuf, 0, '|', sizeof euid);
-       msgnum = locate_message_by_euid(euid, &CC->room);
+       msgnum = CtdlLocateMessageByEuid(euid, &CC->room);
        if (msgnum <= 0L) {
                cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND);
                return;
@@ -259,8 +257,8 @@ void cmd_euid(char *cmdbuf) {
 CTDL_MODULE_INIT(euidindex)
 {
        if (!threading) {
-               CtdlRegisterProtoHook(cmd_euid, "EUID", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_euid, "EUID", "Perform operations on Extended IDs for messages");
        }
        /* return our Subversion id for the Log */
-       return "$Id$";
+       return "euidindex";
 }