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) ...@@ -74,14 +74,10 @@ mail_copy0 (int argc, char **argv, int mark)
74 { 74 {
75 int status; 75 int status;
76 76
77 status = mailbox_get_message (mbox, mp->msg_part[0], &msg); 77 status = util_get_message (mbox, mp->msg_part[0], &msg, 1);
78 if (status) 78 if (status)
79 { 79 break;
80 util_error ("can't get message %d: %s", 80
81 mp->msg_part[0],
82 mu_errstring (status));
83 break;
84 }
85 mailbox_append_message (mbx, msg); 81 mailbox_append_message (mbx, msg);
86 82
87 message_size (msg, &size); 83 message_size (msg, &size);
......
...@@ -59,7 +59,7 @@ display_message (message_t mesg, msgset_t *msgset, void *arg) ...@@ -59,7 +59,7 @@ display_message (message_t mesg, msgset_t *msgset, void *arg)
59 struct decode_closure *closure = arg; 59 struct decode_closure *closure = arg;
60 int pagelines = util_get_crt (); 60 int pagelines = util_get_crt ();
61 61
62 if (util_isdeleted (msgset->msg_part[0])) 62 if (util_isdeleted (mesg))
63 return 1; 63 return 1;
64 64
65 message_lines (mesg, &lines); 65 message_lines (mesg, &lines);
......
...@@ -26,7 +26,8 @@ mail_delete0 (void) ...@@ -26,7 +26,8 @@ mail_delete0 (void)
26 { 26 {
27 message_t msg; 27 message_t msg;
28 attribute_t attr; 28 attribute_t attr;
29 if (mailbox_get_message (mbox, cursor, &msg) != 0) 29
30 if (util_get_message (mbox, cursor, &msg, 0))
30 return 1; 31 return 1;
31 message_get_attribute (msg, &attr); 32 message_get_attribute (msg, &attr);
32 attribute_set_deleted (attr); 33 attribute_set_deleted (attr);
......
...@@ -36,9 +36,8 @@ mail_followup (int argc, char **argv) ...@@ -36,9 +36,8 @@ mail_followup (int argc, char **argv)
36 if (msgset_parse (argc, argv, &msglist)) 36 if (msgset_parse (argc, argv, &msglist))
37 return 1; 37 return 1;
38 38
39 if (mailbox_get_message (mbox, cursor, &msg)) 39 if (util_get_message (mbox, cursor, &msg, 1))
40 { 40 {
41 util_error ("%d: can't get message", cursor);
42 msgset_free (msglist); 41 msgset_free (msglist);
43 return 1; 42 return 1;
44 } 43 }
......
...@@ -42,10 +42,7 @@ mail_from (int argc, char **argv) ...@@ -42,10 +42,7 @@ mail_from (int argc, char **argv)
42 struct tm tm; 42 struct tm tm;
43 mu_timezone tz; 43 mu_timezone tz;
44 44
45 if (mailbox_get_message (mbox, cursor, &msg) != 0) 45 if (util_get_message (mbox, cursor, &msg, 1))
46 return 1;
47
48 if (util_isdeleted (cursor))
49 return 1; 46 return 1;
50 47
51 message_get_header (msg, &hdr); 48 message_get_header (msg, &hdr);
......
...@@ -32,11 +32,8 @@ mail_hold (int argc, char **argv) ...@@ -32,11 +32,8 @@ mail_hold (int argc, char **argv)
32 return util_msglist_command (mail_hold, argc, argv, 1); 32 return util_msglist_command (mail_hold, argc, argv, 1);
33 else 33 else
34 { 34 {
35 if (mailbox_get_message (mbox, cursor, &msg)) 35 if (util_get_message (mbox, cursor, &msg, 0))
36 { 36 return 1;
37 util_error("%d: can't get message", cursor);
38 return 1;
39 }
40 37
41 message_get_attribute (msg, &attr); 38 message_get_attribute (msg, &attr);
42 attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED); 39 attribute_unset_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
......
...@@ -31,11 +31,9 @@ mail_mbox (int argc, char **argv) ...@@ -31,11 +31,9 @@ mail_mbox (int argc, char **argv)
31 return util_msglist_command (mail_mbox, argc, argv, 1); 31 return util_msglist_command (mail_mbox, argc, argv, 1);
32 else 32 else
33 { 33 {
34 if (mailbox_get_message (mbox, cursor, &msg)) 34 if (util_get_message (mbox, cursor, &msg, 1))
35 { 35 return 1;
36 util_error("%d: can't get message", cursor); 36
37 return 1;
38 }
39 /* Mark the message */ 37 /* Mark the message */
40 message_get_attribute (msg, &attr); 38 message_get_attribute (msg, &attr);
41 attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED); 39 attribute_set_userflag (attr, MAIL_ATTRIBUTE_MBOXED);
......
...@@ -46,7 +46,7 @@ mail_pipe (int argc, char **argv) ...@@ -46,7 +46,7 @@ mail_pipe (int argc, char **argv)
46 46
47 for (mp = list; mp; mp = mp->next) 47 for (mp = list; mp; mp = mp->next)
48 { 48 {
49 if (mailbox_get_message (mbox, mp->msg_part[0], &msg) == 0) 49 if (util_get_message (mbox, mp->msg_part[0], &msg, 1) == 0)
50 { 50 {
51 message_get_stream (msg, &stream); 51 message_get_stream (msg, &stream);
52 off = 0; 52 off = 0;
......
...@@ -42,10 +42,7 @@ mail_print (int argc, char **argv) ...@@ -42,10 +42,7 @@ mail_print (int argc, char **argv)
42 attribute_t attr; 42 attribute_t attr;
43 int pagelines = util_get_crt (); 43 int pagelines = util_get_crt ();
44 44
45 if (mailbox_get_message (mbox, cursor, &mesg) != 0) 45 if (util_get_message (mbox, cursor, &mesg, 1))
46 return 1;
47
48 if (util_isdeleted (cursor))
49 return 1; 46 return 1;
50 47
51 message_lines (mesg, &lines); 48 message_lines (mesg, &lines);
......
...@@ -86,11 +86,9 @@ mail_mbox_commit () ...@@ -86,11 +86,9 @@ mail_mbox_commit ()
86 86
87 for (i = 1; i <= total; i++) 87 for (i = 1; i <= total; i++)
88 { 88 {
89 if (mailbox_get_message (mbox, i, &msg)) 89 if (util_get_message (mbox, i, &msg, 0))
90 { 90 return 1;
91 util_error("%d: can't get message", i); 91
92 return 1;
93 }
94 message_get_attribute (msg, &attr); 92 message_get_attribute (msg, &attr);
95 93
96 if (!is_user_mbox 94 if (!is_user_mbox
......
...@@ -39,11 +39,8 @@ mail_reply (int argc, char **argv) ...@@ -39,11 +39,8 @@ mail_reply (int argc, char **argv)
39 39
40 compose_init (&env); 40 compose_init (&env);
41 41
42 if (mailbox_get_message (mbox, cursor, &msg)) 42 if (util_get_message (mbox, cursor, &msg, 1))
43 { 43 return 1;
44 util_error ("%d: can't get message", cursor);
45 return 1;
46 }
47 44
48 message_get_header (msg, &hdr); 45 message_get_header (msg, &hdr);
49 46
......
...@@ -30,11 +30,9 @@ mail_size (int argc, char **argv) ...@@ -30,11 +30,9 @@ mail_size (int argc, char **argv)
30 { 30 {
31 size_t size = 0, lines = 0; 31 size_t size = 0, lines = 0;
32 message_t msg; 32 message_t msg;
33 if (mailbox_get_message (mbox, cursor, &msg) != 0) 33 if (util_get_message (mbox, cursor, &msg, 0))
34 { 34 return 1;
35 util_error("Could not read message %d", cursor); 35
36 return 1;
37 }
38 message_size (msg, &size); 36 message_size (msg, &size);
39 message_lines (msg, &lines); 37 message_lines (msg, &lines);
40 38
......
...@@ -39,10 +39,7 @@ mail_top (int argc, char **argv) ...@@ -39,10 +39,7 @@ mail_top (int argc, char **argv)
39 || lines < 0) 39 || lines < 0)
40 return 1; 40 return 1;
41 41
42 if (mailbox_get_message (mbox, cursor, &msg) != 0) 42 if (util_get_message (mbox, cursor, &msg, 1))
43 return 1;
44
45 if (util_isdeleted (cursor))
46 return 1; 43 return 1;
47 44
48 message_get_stream (msg, &stream); 45 message_get_stream (msg, &stream);
......
...@@ -30,11 +30,9 @@ mail_undelete (int argc, char **argv) ...@@ -30,11 +30,9 @@ mail_undelete (int argc, char **argv)
30 { 30 {
31 message_t msg; 31 message_t msg;
32 attribute_t attr; 32 attribute_t attr;
33 if (mailbox_get_message (mbox, cursor, &msg) != 0) 33 if (util_get_message (mbox, cursor, &msg, 0))
34 { 34 return 1;
35 util_error("Message %d does not exist", cursor); 35
36 return 1;
37 }
38 message_get_attribute (msg, &attr); 36 message_get_attribute (msg, &attr);
39 if (attribute_is_deleted (attr)) 37 if (attribute_is_deleted (attr))
40 attribute_unset_deleted (attr); 38 attribute_unset_deleted (attr);
......
...@@ -101,7 +101,7 @@ parse_headers (FILE *fp, compose_env_t *env) ...@@ -101,7 +101,7 @@ parse_headers (FILE *fp, compose_env_t *env)
101 101
102 if (name) 102 if (name)
103 { 103 {
104 header_set_value (header, name, value, 0); 104 header_set_value (header, name, value[0] ? value : NULL, 0);
105 free (name); 105 free (name);
106 free (value); 106 free (value);
107 name = value = NULL; 107 name = value = NULL;
...@@ -452,7 +452,7 @@ var_quote (int argc, char **argv, compose_env_t *env) ...@@ -452,7 +452,7 @@ var_quote (int argc, char **argv, compose_env_t *env)
452 size_t n = 0; 452 size_t n = 0;
453 char *prefix = "\t"; 453 char *prefix = "\t";
454 454
455 if (mailbox_get_message (mbox, cursor, &mesg) != 0) 455 if (util_get_message (mbox, cursor, &mesg, 1))
456 return 1; 456 return 1;
457 457
458 fprintf (stdout, "Interpolating: %d\n", cursor); 458 fprintf (stdout, "Interpolating: %d\n", cursor);
......
...@@ -81,7 +81,9 @@ mail_write (int argc, char **argv) ...@@ -81,7 +81,9 @@ mail_write (int argc, char **argv)
81 off_t off = 0; 81 off_t off = 0;
82 size_t n = 0; 82 size_t n = 0;
83 83
84 mailbox_get_message (mbox, mp->msg_part[0], &msg); 84 if (util_get_message (mbox, mp->msg_part[0], &msg, 1))
85 continue;
86
85 message_get_body (msg, &bod); 87 message_get_body (msg, &bod);
86 88
87 body_size (bod, &size); 89 body_size (bod, &size);
......