X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Feuidindex.c;fp=citadel%2Feuidindex.c;h=8bad12925557f072c6b713397337121624e0e7f5;hb=4b8c94f25a5fc8892bf7d512554513b8d1e52fd7;hp=a1d5ec960c69424968bb80098197cfd1e7079bd8;hpb=2b07e5c6abcbeca7426f4ce054efa455374a74be;p=citadel.git diff --git a/citadel/euidindex.c b/citadel/euidindex.c index a1d5ec960..8bad12925 100644 --- a/citadel/euidindex.c +++ b/citadel/euidindex.c @@ -217,28 +217,16 @@ void rebuild_euid_index(void) { -struct euid_callback { - long msgnum; - int found_it; -}; - -/* - * callback for cmd_euid - */ -void euid_is_msg_in_room(long msgnum, void *userdata) { - struct euid_callback *ec = (struct euid_callback *) userdata; - - if (msgnum == ec->msgnum) ec->found_it = 1; -} - - /* * Server command to fetch a message number given an euid. */ void cmd_euid(char *cmdbuf) { char euid[256]; long msgnum; - struct euid_callback ec; + struct cdbdata *cdbfr; + long *msglist = NULL; + int num_msgs = 0; + int i; if (CtdlAccessCheck(ac_logged_in_or_guest)) return; @@ -249,21 +237,27 @@ void cmd_euid(char *cmdbuf) { return; } - ec.msgnum = msgnum; - ec.found_it = 0; - CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, euid_is_msg_in_room, (void *)&ec); - - if (ec.found_it) { - cprintf("%d %ld\n", CIT_OK, msgnum); - 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); } CTDL_MODULE_INIT(euidindex) { if (!threading) { - CtdlRegisterProtoHook(cmd_euid, "EUID", "Fetch the msgnum associated with an EUID"); + CtdlRegisterProtoHook(cmd_euid, "EUID", "Perform operations on Extended IDs for messages"); } /* return our Subversion id for the Log */ return "euidindex";