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"))
Showing
1 changed file
with
45 additions
and
0 deletions
... | @@ -211,6 +211,10 @@ SCM_DEFINE (mu_message_set_header, "mu-message-set-header", 3, 1, 0, | ... | @@ -211,6 +211,10 @@ SCM_DEFINE (mu_message_set_header, "mu-message-set-header", 3, 1, 0, |
211 | msg = mu_scm_message_get (MESG); | 211 | msg = mu_scm_message_get (MESG); |
212 | SCM_ASSERT (SCM_NIMP (HEADER) && SCM_STRINGP (HEADER), | 212 | SCM_ASSERT (SCM_NIMP (HEADER) && SCM_STRINGP (HEADER), |
213 | HEADER, SCM_ARG2, FUNC_NAME); | 213 | HEADER, SCM_ARG2, FUNC_NAME); |
214 | |||
215 | if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE)) | ||
216 | return SCM_UNSPECIFIED; | ||
217 | |||
214 | SCM_ASSERT (SCM_NIMP (VALUE) && SCM_STRINGP (VALUE), | 218 | SCM_ASSERT (SCM_NIMP (VALUE) && SCM_STRINGP (VALUE), |
215 | VALUE, SCM_ARG2, FUNC_NAME); | 219 | VALUE, SCM_ARG2, FUNC_NAME); |
216 | if (!SCM_UNBNDP (REPLACE)) | 220 | if (!SCM_UNBNDP (REPLACE)) |
... | @@ -621,6 +625,47 @@ SCM_DEFINE (mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, | ... | @@ -621,6 +625,47 @@ SCM_DEFINE (mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, |
621 | } | 625 | } |
622 | #undef FUNC_NAME | 626 | #undef FUNC_NAME |
623 | 627 | ||
628 | SCM_DEFINE (mu_message_get_port, "mu-message-get-port", 2, 1, 0, | ||
629 | (SCM MESG, SCM MODE, SCM FULL), | ||
630 | "Returns a port associated with the given MESG. MODE is a string\n" | ||
631 | "defining operation mode of the stream. It may contain any of the\n" | ||
632 | "two characters: \"r\" for reading, \"w\" for writing.\n" | ||
633 | "If optional FULL argument specified, it should be a boolean value.\n" | ||
634 | "If it is #t then the returned port will allow access to any\n" | ||
635 | "part of the message (including headers). If it is #f then the port\n" | ||
636 | "accesses only the message body (the default).\n") | ||
637 | #define FUNC_NAME s_mu_message_get_port | ||
638 | { | ||
639 | message_t msg; | ||
640 | stream_t stream = NULL; | ||
641 | |||
642 | SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); | ||
643 | SCM_ASSERT (SCM_NIMP (MODE) && SCM_STRINGP (MODE), | ||
644 | MODE, SCM_ARG2, FUNC_NAME); | ||
645 | |||
646 | msg = mu_scm_message_get (MESG); | ||
647 | |||
648 | if (!SCM_UNBNDP (FULL)) | ||
649 | { | ||
650 | SCM_ASSERT (SCM_IMP (FULL) && SCM_BOOLP (FULL), | ||
651 | FULL, SCM_ARG3, FUNC_NAME); | ||
652 | if (FULL == SCM_BOOL_T && message_get_stream (msg, &stream)) | ||
653 | return SCM_BOOL_F; | ||
654 | } | ||
655 | |||
656 | if (!stream) | ||
657 | { | ||
658 | body_t body = NULL; | ||
659 | |||
660 | if (message_get_body (msg, &body) | ||
661 | || body_get_stream (body, &stream)) | ||
662 | return SCM_BOOL_F; | ||
663 | } | ||
664 | |||
665 | return mu_port_make_from_stream (MESG, stream, | ||
666 | scm_mode_bits (SCM_CHARS (MODE))); | ||
667 | } | ||
668 | #undef FUNC_NAME | ||
624 | 669 | ||
625 | 670 | ||
626 | SCM_DEFINE (mu_message_get_body, "mu-message-get-body", 1, 0, 0, | 671 | SCM_DEFINE (mu_message_get_body, "mu-message-get-body", 1, 0, 0, | ... | ... |
-
Please register or sign in to post a comment