$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
/*
* 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
* 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 */
}
-
+/*
+ * Back end for the MSGS command: output message number only.
+ */
void simple_listing(long msgnum, void *userdata)
{
cprintf("%ld\n", msgnum);
+/*
+ * 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.
*/
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, " ");
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");
}
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