- cdb_trunc(CDB_EUIDINDEX); /* delete the old indices */
- ForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate the room names */
- rebuild_euid_index_for_room(NULL, NULL); /* now do indexing on them */
+ cdb_trunc(CDB_EUIDINDEX); /* delete the old indices */
+ CtdlForEachRoom(rebuild_euid_index_for_room, NULL); /* enumerate rm names */
+ rebuild_euid_index_for_room(NULL, NULL); /* and index them */
+}
+
+
+/*
+ * Server command to fetch a message number given an euid.
+ */
+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_or_guest)) return;
+
+ extract_token(euid, cmdbuf, 0, '|', sizeof euid);
+ msgnum = CtdlLocateMessageByEuid(euid, &CC->room);
+ 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);
+}
+
+
+CTDL_MODULE_INIT(euidindex)
+{
+ if (!threading) {
+ CtdlRegisterProtoHook(cmd_euid, "EUID", "Perform operations on Extended IDs for messages");
+ }
+ /* return our Subversion id for the Log */
+ return "euidindex";