diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2001-08-05 13:51:09 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2001-08-05 13:51:09 +0000 |
commit | 3f27d4608bfa174db525376a54bb53d17d2b87b5 (patch) | |
tree | 8c42112dd5b727eca10b07eb2f1a2cfe2672afeb /libmu_scm | |
parent | df69c3f00f93523c59952ccb97fa1bc7a59b56c3 (diff) | |
download | mailutils-3f27d4608bfa174db525376a54bb53d17d2b87b5.tar.gz mailutils-3f27d4608bfa174db525376a54bb53d17d2b87b5.tar.bz2 |
Added mu-message-get-port.
mu-message-set-header: don't bail out if third argument is boolean,
to allow for constructs like:
(mu-message-set-header
m1 "From"
(mu-message-get-header m2 "To"))
Diffstat (limited to 'libmu_scm')
-rw-r--r-- | libmu_scm/mu_message.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c index 90f63bb4c..5f4cd3652 100644 --- a/libmu_scm/mu_message.c +++ b/libmu_scm/mu_message.c @@ -211,6 +211,10 @@ SCM_DEFINE (mu_message_set_header, "mu-message-set-header", 3, 1, 0, msg = mu_scm_message_get (MESG); SCM_ASSERT (SCM_NIMP (HEADER) && SCM_STRINGP (HEADER), HEADER, SCM_ARG2, FUNC_NAME); + + if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE)) + return SCM_UNSPECIFIED; + SCM_ASSERT (SCM_NIMP (VALUE) && SCM_STRINGP (VALUE), VALUE, SCM_ARG2, FUNC_NAME); if (!SCM_UNBNDP (REPLACE)) @@ -621,6 +625,47 @@ SCM_DEFINE (mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, } #undef FUNC_NAME +SCM_DEFINE (mu_message_get_port, "mu-message-get-port", 2, 1, 0, + (SCM MESG, SCM MODE, SCM FULL), + "Returns a port associated with the given MESG. MODE is a string\n" + "defining operation mode of the stream. It may contain any of the\n" + "two characters: \"r\" for reading, \"w\" for writing.\n" + "If optional FULL argument specified, it should be a boolean value.\n" + "If it is #t then the returned port will allow access to any\n" + "part of the message (including headers). If it is #f then the port\n" + "accesses only the message body (the default).\n") +#define FUNC_NAME s_mu_message_get_port +{ + message_t msg; + stream_t stream = NULL; + + SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); + SCM_ASSERT (SCM_NIMP (MODE) && SCM_STRINGP (MODE), + MODE, SCM_ARG2, FUNC_NAME); + + msg = mu_scm_message_get (MESG); + + if (!SCM_UNBNDP (FULL)) + { + SCM_ASSERT (SCM_IMP (FULL) && SCM_BOOLP (FULL), + FULL, SCM_ARG3, FUNC_NAME); + if (FULL == SCM_BOOL_T && message_get_stream (msg, &stream)) + return SCM_BOOL_F; + } + + if (!stream) + { + body_t body = NULL; + + if (message_get_body (msg, &body) + || body_get_stream (body, &stream)) + return SCM_BOOL_F; + } + + return mu_port_make_from_stream (MESG, stream, + scm_mode_bits (SCM_CHARS (MODE))); +} +#undef FUNC_NAME SCM_DEFINE (mu_message_get_body, "mu-message-get-body", 1, 0, 0, |