summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-09-07 13:39:07 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2010-09-07 13:39:07 +0300
commit8e227e9b65a9e74450a81d200a99d5539f0ab93f (patch)
treecff9d42de51567e028557fec4eadcad7f4a02d64
parent1cb4b8d7631f3a7a675510ddf3332bc28ddc5d2d (diff)
downloadmailutils-8e227e9b65a9e74450a81d200a99d5539f0ab93f.tar.gz
mailutils-8e227e9b65a9e74450a81d200a99d5539f0ab93f.tar.bz2
imap4d: fetch body with a nonempty section spec returns section body without headers.
* imap4d/fetch.c (fetch_function_closure) <section_tag>: New member. (_frt_body_text): Output ffc->section_tag after the secion part by default. (_frt_header, _frt_mime): Remove. (_frt_header0): Rewrite as a general-purpose _frt_header function. (parse_section_text): Set _frt_header as a driver function and set section_tag accordingly, instead of selecting _frt_header/_frt_mime. Set section_tag when selecting _frt_body_text. (parse_section): Default to _frt_body_text and fall back to _frt_body only when an empty section specifier is given. * imap4d/testsuite/imap4d/fetch.exp: Update accordingly.
-rw-r--r--imap4d/fetch.c39
-rw-r--r--imap4d/testsuite/imap4d/fetch.exp7
2 files changed, 16 insertions, 30 deletions
diff --git a/imap4d/fetch.c b/imap4d/fetch.c
index c84fc6d6d..ef7d6ce8e 100644
--- a/imap4d/fetch.c
+++ b/imap4d/fetch.c
@@ -49,6 +49,7 @@ struct fetch_function_closure
{
fetch_function_t fun; /* Handler function */
const char *name; /* Response tag */
+ const char *section_tag;
size_t *section_part; /* Section-part */
size_t nset; /* Number of elements in section_part */
int peek;
@@ -906,7 +907,7 @@ _frt_body_text (struct fetch_function_closure *ffc,
if (ffc->name)
util_send ("%s", ffc->name);
else
- fetch_send_section_part (ffc, "TEXT", 1);
+ fetch_send_section_part (ffc, ffc->section_tag, 1);
msg = fetch_get_part (ffc, frt);
if (!msg)
{
@@ -935,9 +936,8 @@ _frt_size (struct fetch_function_closure *ffc,
}
static int
-_frt_header0 (struct fetch_function_closure *ffc,
- struct fetch_runtime_closure *frt,
- const char *suffix)
+_frt_header (struct fetch_function_closure *ffc,
+ struct fetch_runtime_closure *frt)
{
mu_message_t msg;
mu_header_t header = NULL;
@@ -946,9 +946,9 @@ _frt_header0 (struct fetch_function_closure *ffc,
set_seen (ffc, frt);
if (ffc->name)
- util_send ("%s", ffc->name);
+ util_send ("%s", ffc->name);
else
- fetch_send_section_part (ffc, suffix, 1);
+ fetch_send_section_part (ffc, ffc->section_tag, 1);
msg = fetch_get_part (ffc, frt);
if (!msg)
@@ -964,20 +964,6 @@ _frt_header0 (struct fetch_function_closure *ffc,
}
static int
-_frt_header (struct fetch_function_closure *ffc,
- struct fetch_runtime_closure *frt)
-{
- return _frt_header0 (ffc, frt, "HEADER");
-}
-
-static int
-_frt_mime (struct fetch_function_closure *ffc,
- struct fetch_runtime_closure *frt)
-{
- return _frt_header0 (ffc, frt, "MIME");
-}
-
-static int
_send_header_name (void *item, void *data)
{
int *pf = data;
@@ -1291,17 +1277,22 @@ parse_section_text (imap4d_parsebuf_t p, struct fetch_function_closure *ffc,
parse_header_list (p, ffc);
}
else
- ffc->fun = _frt_header;
+ {
+ ffc->fun = _frt_header;
+ ffc->section_tag = "HEADER";
+ }
}
else if (mu_c_strcasecmp (p->token, "TEXT") == 0)
{
imap4d_parsebuf_next (p, 1);
ffc->fun = _frt_body_text;
+ ffc->section_tag = "TEXT";
}
else if (allow_mime && mu_c_strcasecmp (p->token, "MIME") == 0)
{
imap4d_parsebuf_next (p, 1);
- ffc->fun = _frt_mime;
+ ffc->fun = _frt_header;
+ ffc->section_tag = "MIME";
}
else
return 1;
@@ -1375,12 +1366,12 @@ parse_section (imap4d_parsebuf_t p, struct fetch_function_closure *ffc)
return 1;
ffc_init (ffc);
ffc->name = NULL;
- ffc->fun = _frt_body;
+ ffc->fun = _frt_body_text;
imap4d_parsebuf_next (p, 1);
if (parse_section_text (p, ffc, 0))
{
if (p->token[0] == ']')
- /* OK */;
+ ffc->fun = _frt_body;
else if (mu_isdigit (p->token[0]))
{
parse_section_part (p, ffc);
diff --git a/imap4d/testsuite/imap4d/fetch.exp b/imap4d/testsuite/imap4d/fetch.exp
index bc3aabf1a..e61f3b51b 100644
--- a/imap4d/testsuite/imap4d/fetch.exp
+++ b/imap4d/testsuite/imap4d/fetch.exp
@@ -330,13 +330,8 @@ imap4d_test "FETCH 3 BODY\[1.MIME\]"\
"OK"
imap4d_test "FETCH 4 BODY\[2.2.1\]"\
-"4 FETCH (FLAGS (\\Seen) BODY\[2.2.1\] {680}"\
+"4 FETCH (FLAGS (\\Seen) BODY\[2.2.1\] {490}"\
-literal\
-"Content-Type: application/octet-stream; name=\"msg.23\""\
-"Content-ID: <5122.1026510654.6@Mirddin.farlep.net>"\
-"Content-Description: Father William Part III"\
-"Content-Transfer-Encoding: base64"\
-""\
"YFlvdSBhcmUgb2xkLCcgc2FpZCB0aGUgeW91dGgsIGBhbmQgeW91ciBqYXdzIGFyZSB0b28gd2Vh"\
"awpGb3IgYW55dGhpbmcgdG91Z2hlciB0aGFuIHN1ZXQ7CllldCB5b3UgZmluaXNoZWQgdGhlIGdv"\
"b3NlLCB3aXRoIHRoZSBib25lcyBhbmQgdGhlIGJlYWstLQpQcmF5IGhvdyBkaWQgeW91IG1hbmFn"\

Return to:

Send suggestions and report system problems to the System administrator.