;;; -*-Scheme-*-
;;;
-;;; $Id: imap-response.scm,v 1.25 2000/05/23 17:39:48 cph Exp $
+;;; $Id: imap-response.scm,v 1.26 2000/05/28 15:16:51 cph Exp $
;;;
;;; Copyright (c) 2000 Massachusetts Institute of Technology
;;;
(read-list port
(lambda (port)
(let ((x (intern (read-fetch-keyword port))))
- (list x
- (case x
- ((ENVELOPE)
- (discard-known-char #\space port)
- (read-generic port))
- ((FLAGS)
- (read-flags-response port))
- ((INTERNALDATE)
- (discard-known-char #\space port)
- (parse-date-time (read-quoted port)))
- ((RFC822 RFC822.HEADER RFC822.TEXT)
- (discard-known-char #\space port)
- (read-nstring port))
- ((RFC822.SIZE)
- (discard-known-char #\space port)
- (read-number port))
- ((BODY)
- (if (char=? #\[ (peek-char-no-eof port))
- (let ((section
- (parse-section (read-bracketed-string port))))
- (discard-known-char #\space port)
- (cons section
- (if (char=? #\< (peek-char-no-eof port))
- (begin
- (discard-char port)
- (let ((n (read-number port)))
- (discard-known-char #\> port)
- (discard-known-char #\space port)
- (list n (read-nstring port))))
- (list (read-nstring port)))))
- (begin
- (discard-known-char #\space port)
- (read-generic port))))
- ((BODYSTRUCTURE)
- (discard-known-char #\space port)
- (read-generic port))
- ((UID)
- (discard-known-char #\space port)
- (read-nz-number port))
- (else
- (error "Illegal fetch keyword:" x))))))))
+ (if (and (eq? 'BODY x)
+ (char=? #\[ (peek-char-no-eof port)))
+ (let ((section
+ (parse-section (read-bracketed-string port))))
+ (discard-known-char #\space port)
+ (let ((origin
+ (and (char=? #\< (peek-char-no-eof port))
+ (begin
+ (discard-char port)
+ (let ((n (read-number port)))
+ (discard-known-char #\> port)
+ (discard-known-char #\space port)
+ n)))))
+ (list x section origin (read-nstring port))))
+ (begin
+ (discard-known-char #\space port)
+ (list x
+ (case x
+ ((ENVELOPE BODY BODYSTRUCTURE)
+ (read-generic port))
+ ((FLAGS)
+ (read-list port read-flag))
+ ((INTERNALDATE)
+ (parse-date-time (read-quoted port)))
+ ((RFC822 RFC822.HEADER RFC822.TEXT)
+ (read-nstring port))
+ ((RFC822.SIZE)
+ (read-number port))
+ ((UID)
+ (read-nz-number port))
+ (else
+ (error "Illegal fetch keyword:" x))))))))))
(define (parse-section string)
(let ((pv (parse-string imap:parse:section string)))
-$Id: imap-response.txt,v 1.4 2000/05/27 14:42:09 cph Exp $
+$Id: imap-response.txt,v 1.5 2000/05/28 15:16:47 cph Exp $
Notes on IMAP server responses
| (RFC822.HEADER <string-or-false>)
| (RFC822.TEXT <string-or-false>)
| (RFC822.SIZE <nonnegative-exact-integer>)
+ | (BODY <section> <number-or-false> <string-or-false>)
| (BODY <body>)
- | (BODY (<section> <string-or-false>))
- | (BODY (<section> <nonnegative-exact-integer> <string-or-false>))
| (BODYSTRUCTURE <body>)
| (UID <positive-exact-integer>)
| (#f #f #f #f) ;end of group
<body> ;too complicated to describe
+
+<string-or-false>
+ = <string>
+ | #F
+
+<number-or-false
+ = <nonnegative-exact-integer>
+ | #F
\f
Notes about handling responses: