Commit f3065927 f3065927105f7ebc70e0899583233b9fe9b0fea4 by Sergey Poznyakoff

Use util_get_message()

1 parent 80a47134
......@@ -74,14 +74,10 @@ mail_copy0 (int argc, char **argv, int mark)
{
int status;
status = mailbox_get_message (mbox, mp->msg_part[0], &msg);
status = util_get_message (mbox, mp->msg_part[0], &msg, 1);
if (status)
{
util_error ("can't get message %d: %s",
mp->msg_part[0],
mu_errstring (status));
break;
}
break;
mailbox_append_message (mbx, msg);
message_size (msg, &size);
......
......@@ -59,7 +59,7 @@ display_message (message_t mesg, msgset_t *msgset, void *arg)
struct decode_closure *closure = arg;
int pagelines = util_get_crt ();
if (util_isdeleted (msgset->msg_part[0]))
if (util_isdeleted (mesg))
return 1;
message_lines (mesg, &lines);
......
......@@ -26,7 +26,8 @@ mail_delete0 (void)
{
message_t msg;
attribute_t attr;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
if (util_get_message (mbox, cursor, &msg, 0))
return 1;
message_get_attribute (msg, &attr);
attribute_set_deleted (attr);
......
......@@ -36,9 +36,8 @@ mail_followup (int argc, char **argv)
if (msgset_parse (argc, argv, &msglist))
return 1;
if (mailbox_get_message (mbox, cursor, &msg))
if (util_get_message (mbox, cursor, &msg, 1))
{
util_error ("%d: can't get message", cursor);
msgset_free (msglist);
return 1;
}
......
......@@ -42,10 +42,7 @@ mail_from (int argc, char **argv)
struct tm tm;
mu_timezone tz;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
return 1;
if (util_isdeleted (cursor))
if (util_get_message (mbox, cursor, &msg, 1))
return 1;
message_get_header (msg, &hdr);
......
......@@ -32,11 +32,8 @@ mail_hold (int argc, char **argv)
return util_msglist_command (mail_hold, argc, argv, 1);
else
{
if (mailbox_get_message (mbox, cursor, &msg))
{
util_error("%d: can't get message", cursor);
return 1;
}
if (util_get_message (mbox, cursor, &msg, 0))
return 1;
message_get_attribute (msg, &attr);
attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
......
......@@ -31,11 +31,9 @@ mail_mbox (int argc, char **argv)
return util_msglist_command (mail_mbox, argc, argv, 1);
else
{
if (mailbox_get_message (mbox, cursor, &msg))
{
util_error("%d: can't get message", cursor);
return 1;
}
if (util_get_message (mbox, cursor, &msg, 1))
return 1;
/* Mark the message */
message_get_attribute (msg, &attr);
attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
......
......@@ -46,7 +46,7 @@ mail_pipe (int argc, char **argv)
for (mp = list; mp; mp = mp->next)
{
if (mailbox_get_message (mbox, mp->msg_part[0], &msg) == 0)
if (util_get_message (mbox, mp->msg_part[0], &msg, 1) == 0)
{
message_get_stream (msg, &stream);
off = 0;
......
......@@ -42,10 +42,7 @@ mail_print (int argc, char **argv)
attribute_t attr;
int pagelines = util_get_crt ();
if (mailbox_get_message (mbox, cursor, &mesg) != 0)
return 1;
if (util_isdeleted (cursor))
if (util_get_message (mbox, cursor, &mesg, 1))
return 1;
message_lines (mesg, &lines);
......
......@@ -86,11 +86,9 @@ mail_mbox_commit ()
for (i = 1; i <= total; i++)
{
if (mailbox_get_message (mbox, i, &msg))
{
util_error("%d: can't get message", i);
return 1;
}
if (util_get_message (mbox, i, &msg, 0))
return 1;
message_get_attribute (msg, &attr);
if (!is_user_mbox
......
......@@ -39,11 +39,8 @@ mail_reply (int argc, char **argv)
compose_init (&env);
if (mailbox_get_message (mbox, cursor, &msg))
{
util_error ("%d: can't get message", cursor);
return 1;
}
if (util_get_message (mbox, cursor, &msg, 1))
return 1;
message_get_header (msg, &hdr);
......
......@@ -30,11 +30,9 @@ mail_size (int argc, char **argv)
{
size_t size = 0, lines = 0;
message_t msg;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
{
util_error("Could not read message %d", cursor);
return 1;
}
if (util_get_message (mbox, cursor, &msg, 0))
return 1;
message_size (msg, &size);
message_lines (msg, &lines);
......
......@@ -39,10 +39,7 @@ mail_top (int argc, char **argv)
|| lines < 0)
return 1;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
return 1;
if (util_isdeleted (cursor))
if (util_get_message (mbox, cursor, &msg, 1))
return 1;
message_get_stream (msg, &stream);
......
......@@ -30,11 +30,9 @@ mail_undelete (int argc, char **argv)
{
message_t msg;
attribute_t attr;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
{
util_error("Message %d does not exist", cursor);
return 1;
}
if (util_get_message (mbox, cursor, &msg, 0))
return 1;
message_get_attribute (msg, &attr);
if (attribute_is_deleted (attr))
attribute_unset_deleted (attr);
......
......@@ -101,7 +101,7 @@ parse_headers (FILE *fp, compose_env_t *env)
if (name)
{
header_set_value (header, name, value, 0);
header_set_value (header, name, value[0] ? value : NULL, 0);
free (name);
free (value);
name = value = NULL;
......@@ -452,7 +452,7 @@ var_quote (int argc, char **argv, compose_env_t *env)
size_t n = 0;
char *prefix = "\t";
if (mailbox_get_message (mbox, cursor, &mesg) != 0)
if (util_get_message (mbox, cursor, &mesg, 1))
return 1;
fprintf (stdout, "Interpolating: %d\n", cursor);
......
......@@ -81,7 +81,9 @@ mail_write (int argc, char **argv)
off_t off = 0;
size_t n = 0;
mailbox_get_message (mbox, mp->msg_part[0], &msg);
if (util_get_message (mbox, mp->msg_part[0], &msg, 1))
continue;
message_get_body (msg, &bod);
body_size (bod, &size);
......