From cb3c0982d624946545cdb8ee49d29a2a0232f980 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Mon, 8 Aug 2005 14:57:20 +0000 Subject: [PATCH] * Added a new "with header summary" mode to the MSGS command. --- citadel/ChangeLog | 4 +++- citadel/citadel.h | 4 ++-- citadel/msgbase.c | 43 ++++++++++++++++++++++++++++++++---- citadel/techdoc/protocol.txt | 29 ++++++++++++++---------- 4 files changed, 61 insertions(+), 19 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index be0b5c108..ef5d240ef 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 654.3 2005/08/08 14:57:19 ajc +* Added a new "with header summary" mode to the MSGS command. + Revision 654.2 2005/08/08 14:28:41 ajc * CtdlForEachMessage() -- avoid scanning v_seen sequence set for each message during a MSGS_ALL fetch, because the results don't matter. @@ -6998,4 +7001,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citadel.h b/citadel/citadel.h index 8dc185482..ced109b9a 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -33,7 +33,7 @@ extern "C" { /* * Text description of this software */ -#define CITADEL "Citadel 6.54" +#define CITADEL "Citadel 6.55" /* * REV_LEVEL is the current version number (multiplied by 100 to avoid having @@ -45,7 +45,7 @@ extern "C" { * usually more strict because you're not really supposed to dump/load and * upgrade at the same time. */ -#define REV_LEVEL 654 /* This version */ +#define REV_LEVEL 655 /* This version */ #define REV_MIN 591 /* Oldest compatible database */ #define EXPORT_REV_MIN 652 /* Oldest compatible export files */ diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 10b2c0fdc..941af80b4 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -260,7 +260,9 @@ void get_mm(void) } - +/* + * Back end for the MSGS command: output message number only. + */ void simple_listing(long msgnum, void *userdata) { cprintf("%ld\n", msgnum); @@ -268,6 +270,32 @@ void simple_listing(long msgnum, void *userdata) +/* + * Back end for the MSGS command: output header summary. + */ +void headers_listing(long msgnum, void *userdata) +{ + struct CtdlMessage *msg; + + msg = CtdlFetchMessage(msgnum, 0); + if (msg < 0L) { + cprintf("%ld|0|||||\n", msgnum); + return; + } + + cprintf("%ld|%s|%s|%s|%s|%s|\n", + msgnum, + (msg->cm_fields['T'] ? msg->cm_fields['T'] : "0"), + (msg->cm_fields['A'] ? msg->cm_fields['A'] : ""), + (msg->cm_fields['N'] ? msg->cm_fields['N'] : ""), + (msg->cm_fields['F'] ? msg->cm_fields['F'] : ""), + (msg->cm_fields['U'] ? msg->cm_fields['U'] : "") + ); + CtdlFreeMessage(msg); +} + + + /* Determine if a given message matches the fields in a message template. * Return 0 for a successful match. */ @@ -625,10 +653,12 @@ void cmd_msgs(char *cmdbuf) int i; int with_template = 0; struct CtdlMessage *template = NULL; + int with_headers = 0; extract_token(which, cmdbuf, 0, '|', sizeof which); cm_ref = extract_int(cmdbuf, 1); with_template = extract_int(cmdbuf, 2); + with_headers = extract_int(cmdbuf, 3); mode = MSGS_ALL; strcat(which, " "); @@ -668,11 +698,16 @@ void cmd_msgs(char *cmdbuf) buffer_output(); } else { - cprintf("%d Message list...\n", LISTING_FOLLOWS); + cprintf("%d \n", LISTING_FOLLOWS); } - CtdlForEachMessage(mode, cm_ref, - NULL, template, simple_listing, NULL); + CtdlForEachMessage(mode, + cm_ref, + NULL, + template, + (with_headers ? headers_listing : simple_listing), + NULL + ); if (template != NULL) CtdlFreeMessage(template); cprintf("000\n"); } diff --git a/citadel/techdoc/protocol.txt b/citadel/techdoc/protocol.txt index a15d74478..01c417ee6 100644 --- a/citadel/techdoc/protocol.txt +++ b/citadel/techdoc/protocol.txt @@ -450,18 +450,23 @@ restrictions, though. which the client may request. This command may be passed a single parameter: either "all", "old", or "new" to request all messages, only old messages, or new messages. Or it may be passed two parameters: "last" plus a number, in -which case that many message pointers will be returned, or "first" plus a -number, for the corresponding effect. If no parameters are specified, "all" -is assumed. - - In Citadel 5.00 and above, the client may also specify "gt" plus a number, -to list all messages in the current room with a message number greater than -the one specified. - - The third argument, valid only in Citadel 5.60 and above, may be either -0 or 1. If it is 1, this command behaves differently: before a listing is -returned, the client must transmit a list of fields to search for. The field -headers are listed below in the writeup for the "MSG0" command. +which case that many message pointers will be returned; "first" plus a +number, for the corresponding effect; or "gt" plus a number, to list all +messages in the current room with a message number greater than the one +specified. If no parameters are specified, "all" is assumed. + + The third argument, may be either 0 or 1. If it is 1, this command behaves +differently: before a listing is returned, the client must transmit a list +of fields to search for. The field headers are listed below in the writeup +for the "MSG0" command. + + The optional fourth argument may also be either 0 or 1. If it is 1, the +output of this command will include not only a list of message numbers, but +a simple header summary of each message as well. This is somewhat resource +intensive so you shouldn't do this unless you absolutely need all the headers +immediately. The fields which are output (in the usual delimited fashion, of +course) are: message number, timestamp, display name, node name, Internet +email address (if present), subject (if present). This command can return three possible results. ERROR + NOT_LOGGED_IN will be returned if no user is currently logged in. Otherwise, LISTING_FOLLOWS -- 2.39.2