From f1f384a7cd03094670fbc57398826666e85981af Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 6 Oct 2005 19:47:00 +0000 Subject: [PATCH] * Change to EUID command syntax: returned msg num is now guaranteed to exist. --- citadel/ChangeLog | 5 +++++ citadel/euidindex.c | 29 ++++++++++++++++++++++++----- citadel/techdoc/protocol.txt | 4 +--- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 383dbe8c3..a38867f8a 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 655.25 2005/10/06 19:47:00 ajc +* Change to EUID command syntax: returned msg num is now guaranteed to + exist. + Revision 655.24 2005/10/06 19:16:31 ajc * Added the EUID command to search for a message by EUID @@ -7211,3 +7215,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/euidindex.c b/citadel/euidindex.c index cada83ac7..abab0383e 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -190,16 +190,35 @@ void rebuild_euid_index(void) { void cmd_euid(char *cmdbuf) { char euid[256]; long msgnum; + struct cdbdata *cdbfr; + long *msglist = NULL; + int num_msgs = 0; + int i; 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 { + if (msgnum <= 0L) { cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND); + return; + } + + cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); + if (cdbfr != NULL) { + num_msgs = cdbfr->len / sizeof(long); + msglist = (long *) cdbfr->ptr; + for (i = 0; i < num_msgs; ++i) { + if (msglist[i] == msgnum) { + cdb_free(cdbfr); + cprintf("%d %ld\n", CIT_OK, msgnum); + return; + } + } + cdb_free(cdbfr); } + + cprintf("%d not found\n", ERROR + MESSAGE_NOT_FOUND); } + + diff --git a/citadel/techdoc/protocol.txt b/citadel/techdoc/protocol.txt index cc17b6388..7dfcf4024 100644 --- a/citadel/techdoc/protocol.txt +++ b/citadel/techdoc/protocol.txt @@ -2228,9 +2228,7 @@ 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 successful, EUID returns OK followed by a message number. If no message exists in the current room with the supplied EUID, the command returns ERROR+MESSAGE_NOT_FOUND. -- 2.39.2