From fe70c6e60a5e6c2428bb5bd97b02d32de7b17570 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 6 Oct 2005 19:16:31 +0000 Subject: [PATCH] * Added the EUID command to search for a message by EUID --- citadel/ChangeLog | 4 +++- citadel/citserver.c | 5 +++++ citadel/euidindex.c | 22 ++++++++++++++++++++++ citadel/euidindex.h | 2 ++ citadel/techdoc/protocol.txt | 19 +++++++++++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 2d8143442..383dbe8c3 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 655.24 2005/10/06 19:16:31 ajc +* Added the EUID command to search for a message by EUID + Revision 655.23 2005/10/06 17:14:41 ajc * newinstall.sh: prefer curl over wget @@ -7208,4 +7211,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index a42fd0882..4e8e90143 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -58,6 +58,7 @@ #include "policy.h" #include "control.h" #include "tools.h" +#include "euidindex.h" #ifndef HAVE_SNPRINTF #include "snprintf.h" @@ -1038,6 +1039,10 @@ void do_command_loop(void) { cmd_rdir(); } + else if (!strncasecmp(cmdbuf,"EUID",4)) { + cmd_euid(&cmdbuf[5]); + } + else if (!strncasecmp(cmdbuf,"MSG0",4)) { cmd_msg0(&cmdbuf[5]); } diff --git a/citadel/euidindex.c b/citadel/euidindex.c index ef2cb2780..cada83ac7 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -181,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); + } +} diff --git a/citadel/euidindex.h b/citadel/euidindex.h index d50ce16b0..0072d525e 100644 --- a/citadel/euidindex.h +++ b/citadel/euidindex.h @@ -8,3 +8,5 @@ long locate_message_by_euid(char *euid, struct ctdlroom *qrbuf); void index_message_by_euid(char *euid, struct ctdlroom *qrbuf, long msgnum); void rebuild_euid_index(void); +void cmd_euid(char *cmdbuf); + diff --git a/citadel/techdoc/protocol.txt b/citadel/techdoc/protocol.txt index 9b6c11bcb..cc17b6388 100644 --- a/citadel/techdoc/protocol.txt +++ b/citadel/techdoc/protocol.txt @@ -2215,6 +2215,25 @@ only in rooms to which the user does not have access. Again, keep in mind that this is a temporary implementation and is not guaranteed to continue to exist in this form. + + +EUID (get message number using an EUID)} + + Returns the message number, if present, of the message in the current room +which is indexed using the supplied EUID (exclusive message ID). There can be +only one message in a room with any given EUID; if another message arrives +with the same EUID, the existing one is replaced. This makes it possible to +reference things like calendar items using an immutable URL that does not +change even when the message number changes due to an update. + + The format of this command is: EUID + + If successful, EUID returns OK followed by a message number. The message is +*not* guaranteed to exist, because EUID indices are not immediately removed +when a message is deleted. + If no message exists in the current room with the supplied EUID, the command +returns ERROR+MESSAGE_NOT_FOUND. + -- 2.30.2