* Added a new "with header summary" mode to the MSGS command.
authorArt Cancro <ajc@citadel.org>
Mon, 8 Aug 2005 14:57:20 +0000 (14:57 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 8 Aug 2005 14:57:20 +0000 (14:57 +0000)
citadel/ChangeLog
citadel/citadel.h
citadel/msgbase.c
citadel/techdoc/protocol.txt

index be0b5c10891141e3790114e8833439afa076ab11..ef5d240ef8c5e18bf708a71eb8df45d03bc912e8 100644 (file)
@@ -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 <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 8dc18548261ed4377d07ffc9d99ad5f10ba0f603..ced109b9addd7f4a207e091b29068ec49f7b79cc 100644 (file)
@@ -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 */
 
index 10b2c0fdc25d484d3e3f44569220ab0fbb099056..941af80b4701ee72df29d73e42543e9cabf94feb 100644 (file)
@@ -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");
 }
index a15d74478bff86d5fcce0c313a34853eff798cb7..01c417ee62314054a149c7333bddeff576fc4e07 100644 (file)
@@ -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