Add hashes of message id and references to msgs commands with headers
authorArt Cancro <ajc@citadel.org>
Wed, 4 Jan 2017 04:16:49 +0000 (23:16 -0500)
committerArt Cancro <ajc@citadel.org>
Wed, 4 Jan 2017 04:16:49 +0000 (23:16 -0500)
citadel/citadel.h
citadel/modules/ctdlproto/serv_messages.c

index 19c159ca2e42f6463c3636622442d865fc439939..a21b32e6f66ca0141183ec38f13c1bc928ad78ae 100644 (file)
@@ -45,7 +45,7 @@ extern "C" {
  * usually more strict because you're not really supposed to dump/load and
  * upgrade at the same time.
  */
-#define REV_LEVEL      903             /* This version */
+#define REV_LEVEL      904             /* This version */
 #define REV_MIN                591             /* Oldest compatible database */
 #define EXPORT_REV_MIN 760             /* Oldest compatible export files */
 #define LIBCITADEL_MIN 903             /* Minimum required version of libcitadel */
index a6ebdc4e14cc392bff78a1fd2658e8f41f753a9c..dc221d66d61158b0afd7749615624937b9907bec 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * represent messages to the citadel clients
  *
- * Copyright (c) 1987-2015 by the citadel.org team
+ * Copyright (c) 1987-2017 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.
@@ -43,18 +43,33 @@ void headers_listing(long msgnum, void *userdata)
 
        msg = CtdlFetchMessage(msgnum, 0, 1);
        if (msg == NULL) {
-               cprintf("%ld|0|||||\n", msgnum);
+               cprintf("%ld|0|||||||\n", msgnum);
                return;
        }
 
-       cprintf("%ld|%s|%s|%s|%s|%s|\n",
+       // output all fields except the references hash
+       cprintf("%ld|%s|%s|%s|%s|%s|%d|",
                msgnum,
                (!CM_IsEmpty(msg, eTimestamp) ? msg->cm_fields[eTimestamp] : "0"),
                (!CM_IsEmpty(msg, eAuthor) ? msg->cm_fields[eAuthor] : ""),
                (!CM_IsEmpty(msg, eNodeName) ? msg->cm_fields[eNodeName] : ""),
                (!CM_IsEmpty(msg, erFc822Addr) ? msg->cm_fields[erFc822Addr] : ""),
-               (!CM_IsEmpty(msg, eMsgSubject) ? msg->cm_fields[eMsgSubject] : "")
+               (!CM_IsEmpty(msg, eMsgSubject) ? msg->cm_fields[eMsgSubject] : ""),
+               (!CM_IsEmpty(msg, emessageId) ? HashLittle(msg->cm_fields[emessageId],strlen(msg->cm_fields[emessageId])) : 0)
        );
+
+       // output the references hash (yes it's ok that we're trashing the source buffer by doing this)
+       if (!CM_IsEmpty(msg, eWeferences)) {
+               char *token;
+               char *rest = msg->cm_fields[eWeferences];
+               char *prev = rest;
+               while((token = strtok_r(rest, "|", &rest))) {
+                       cprintf("%d%s", HashLittle(token,rest-prev-(*rest==0?0:1)), (*rest==0?"":","));
+                       prev = rest;
+               }
+       }
+
+       cprintf("|\n");
        CM_Free(msg);
 }