$Log$
+ Revision 573.28 2000/11/25 06:17:06 ajc
+ * Minor IMAP tweaks. It still doesn't work. :(
+
Revision 573.27 2000/11/23 07:22:21 error
* citadel.spec: update version number
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
-
* Implements the ENVELOPE fetch item
*
* FIXME ... we have to actually do something useful here.
+ *
+ * Note that the imap_strout() function can cleverly output NULL fields as NIL,
+ * so we don't have to check for that condition like we do elsewhere.
*/
void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) {
+ char buf[256];
+ time_t msgdate;
+
+ if (msg->cm_fields['T'] != NULL) {
+ msgdate = atol(msg->cm_fields['T']);
+ }
+ else {
+ msgdate = time(NULL);
+ }
+
+ datestring(buf, msgdate, DATESTRING_IMAP);
+
cprintf("ENVELOPE (");
- cprintf("NIL "); /* date */
- cprintf("NIL "); /* subject */
+
+ /* date */
+ cprintf("\"%s\" ", buf);
+
+ /* subject */
+ imap_strout(msg->cm_fields['U']);
+ cprintf(" ");
+
cprintf("NIL "); /* from */
cprintf("NIL "); /* sender */
cprintf("NIL "); /* reply-to */
cprintf("NIL "); /* cc */
cprintf("NIL "); /* bcc */
cprintf("NIL "); /* in-reply-to */
- cprintf("NIL"); /* message-id */
- cprintf(")\r\n");
+
+ /* message ID */
+ imap_strout(msg->cm_fields['I']);
+
+ cprintf(") ");
}
for (i=0; i<strlen(partial); ++i) {
if (partial[i]=='>') partial[i] = 0;
}
+ if (is_partial == 0) strcpy(partial, "");
lprintf(9, "Partial is %s\n", partial);
tmp = tmpfile();
#include <stdlib.h>
#include <unistd.h>
+#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "citadel.h"
+#include "sysdep_decls.h"
#include "tools.h"
#include "imap_tools.h"
+
+/*
+ * Output a string to the IMAP client, either as a literal or quoted.
+ * (We do a literal if it has any double-quotes or backslashes.)
+ */
+void imap_strout(char *buf) {
+ int i;
+ int is_literal = 0;
+
+ if (buf == NULL) { /* yeah, we handle this */
+ cprintf("NIL");
+ return;
+ }
+
+ for (i=0; i<strlen(buf); ++i) {
+ if ( (buf[i]=='\"') || (buf[i]=='\\') ) is_literal = 1;
+ }
+
+ if (is_literal) {
+ cprintf("{%d}\r\n%s", strlen(buf), buf);
+ }
+
+ else {
+ cprintf("\"%s\"", buf);
+ }
+}
+
+
+
+
+
/*
* Break a command down into tokens, taking into consideration the
* possibility of escaping spaces using quoted tokens