Disambiguate the "section" form of the BODY response from the
authorChris Hanson <org/chris-hanson/cph>
Sun, 28 May 2000 15:16:51 +0000 (15:16 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sun, 28 May 2000 15:16:51 +0000 (15:16 +0000)
"bodystructure" form.

v7/src/imail/imap-response.scm
v7/src/imail/imap-response.txt

index 6f469900bdc8b0cc835baa26280575f3ce86090d..f1693fa6b91008c8a18249f3ede28987fb1c2a38 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-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)))
index 8656bebb80242a021b38dc8309905e80b74bc762..aee3233776dfa1474d658d55d8112a00fde178e4 100644 (file)
@@ -1,4 +1,4 @@
-$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
 
@@ -259,9 +259,8 @@ 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>)
 
@@ -295,6 +294,14 @@ Notes on IMAP server responses
        | (#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: