/* This file is part of Mailfromd. -*- c -*- Copyright (C) 2008 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "msg.h" MF_STATE(body) MF_DEFUN(body_string, STRING, POINTER text, NUMBER length) { size_t off; char *s = MF_ALLOC_HEAP(off, length + 1); memcpy(s, text, length); s[length] = 0; MF_RETURN(off); } END /* number current_message() */ MF_STATE(eom) MF_CAPTURE MF_DEFUN(current_message, NUMBER) { mu_stream_t mstr = env_get_stream(env); mu_message_t msg; int rc; rc = bi_get_current_message(env); if (rc < 0) { rc = mu_stream_to_message(mstr, &msg); MF_ASSERT(rc == 0, mfe_failure, "mu_stream_to_message: %s", mu_strerror(rc)); rc = bi_message_register(env, NULL, msg, 1); MF_ASSERT(rc >= 0, mfe_failure, _("No more message slots available")); } MF_RETURN(rc); } END MF_INIT