]> code.citadel.org Git - citadel.git/blobdiff - citadel/euidindex.c
* Added the EUID command to search for a message by EUID
[citadel.git] / citadel / euidindex.c
index 9a8d5984316da31e9a543abadeb3af9024122fa8..cada83ac7591476a300c2c23feba6cefec0d2948 100644 (file)
 #include "euidindex.h"
 
 /*
- * The structure of an EUID *index* is:
+ * The structure of an euidindex record *key* is:
  *
  * |----room_number----|----------EUID-------------|
  *    (sizeof long)       (actual length of euid)
  *
  *
- * The structure of an EUID *record* is:
+ * The structure of an euidindex record *value* is:
  *
  * |-----msg_number----|----room_number----|----------EUID-------------|
  *    (sizeof long)       (sizeof long)       (actual length of euid)
  *
  */
 
+
+/*
+ * Locate a message in a given room with a given euid, and return
+ * its message number.
+ */
 long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf) {
        char *key;
        int key_len;
@@ -89,6 +94,11 @@ long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf) {
        return(msgnum);
 }
 
+
+/*
+ * Store the euid index for a message, which has presumably just been
+ * stored in this room by the caller.
+ */
 void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum) {
        char *key;
        int key_len;
@@ -171,3 +181,25 @@ void rebuild_euid_index(void) {
        ForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate the room names */
        rebuild_euid_index_for_room(NULL, NULL);        /* now do indexing on them */
 }
+
+
+
+/*
+ * Server command to fetch a message number given an euid.
+ */
+void cmd_euid(char *cmdbuf) {
+       char euid[256];
+       long msgnum;
+
+       if (CtdlAccessCheck(ac_logged_in)) return;
+
+       extract_token(euid, cmdbuf, 0, '|', sizeof euid);
+       msgnum = locate_message_by_euid(euid, &CC->room);
+
+       if (msgnum > 0L) {
+               cprintf("%d %ld\n", CIT_OK, msgnum);
+       }
+       else {
+               cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND);
+       }
+}