From 91d9721e1459680919a057886cc7ab7792b2bef4 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 7 Oct 2009 21:12:52 +0000 Subject: [PATCH] * New MSGS subcommand 'EUID' to fetch msgnum of a message by EUID ... similar to the EUID command --- citadel/file_ops.c | 9 ++++++--- citadel/msgbase.c | 32 ++++++++++++++++++++++++++++++-- citadel/msgbase.h | 3 ++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 8fcc068bf..165fd281f 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -163,6 +163,7 @@ void cmd_movf(char *cmdbuf) char buf[PATH_MAX]; int a; struct ctdlroom qrbuf; + int rv = 0; extract_token(filename, cmdbuf, 0, '|', sizeof filename); extract_token(newroom, cmdbuf, 1, '|', sizeof newroom); @@ -216,7 +217,7 @@ void cmd_movf(char *cmdbuf) snprintf(buf, sizeof buf, "cat ./files/%s/filedir |grep \"%s\" >>./files/%s/filedir", CC->room.QRdirname, filename, qrbuf.QRdirname); - system(buf); + rv = system(buf); cprintf("%d File '%s' has been moved.\n", CIT_OK, filename); } @@ -307,6 +308,7 @@ void cmd_oimg(char *cmdbuf) char which_user[USERNAME_SIZE]; int which_floor; int a; + int rv; extract_token(filename, cmdbuf, 0, '|', sizeof filename); @@ -363,7 +365,7 @@ void cmd_oimg(char *cmdbuf) ERROR + FILE_NOT_FOUND, pathname, strerror(errno)); return; } - fread(&MimeTestBuf[0], 1, 32, CC->download_fp); + rv = fread(&MimeTestBuf[0], 1, 32, CC->download_fp); rewind (CC->download_fp); OpenCmdResult(pathname, GuessMimeType(&MimeTestBuf[0], 32)); } @@ -650,6 +652,7 @@ void cmd_writ(char *cmdbuf) { int bytes; char *buf; + int rv; unbuffer_output(); @@ -669,7 +672,7 @@ void cmd_writ(char *cmdbuf) cprintf("%d %d\n", SEND_BINARY, bytes); buf = malloc(bytes + 1); client_read(buf, bytes); - fwrite(buf, bytes, 1, CC->upload_fp); + rv = fwrite(buf, bytes, 1, CC->upload_fp); free(buf); } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 7b4873cee..9563223d6 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -562,7 +562,9 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums, * API function to perform an operation for each qualifying message in the * current room. (Returns the number of messages processed.) */ -int CtdlForEachMessage(int mode, long ref, char *search_string, +int CtdlForEachMessage(int mode, + long ref, + char *search_string, char *content_type, struct CtdlMessage *compare, void (*CallBack) (long, void *), @@ -654,6 +656,30 @@ int CtdlForEachMessage(int mode, long ref, char *search_string, } } + /* If an EUID was specified, throw away all messages except the correct one. */ + if (mode == MSGS_EUID) { + long correct_msgnum; + int found_match = 0; + + if ((num_msgs > 0) && (search_string) ) { + correct_msgnum = locate_message_by_euid(search_string, &CC->room); + if ( (num_msgs > 0) && (correct_msgnum >= 0L) ) { + for (i=0; i