151 |
int f_changecur = 0; |
int f_changecur = 0; |
152 |
char *buffer; |
char *buffer; |
153 |
mh_format_t format; |
mh_format_t format; |
154 |
|
int rc; |
155 |
|
|
156 |
mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, |
mh_argp_parse (argc, argv, options, mh_option, args_doc, doc, |
157 |
opt_handler, NULL, NULL); |
opt_handler, NULL, NULL); |
165 |
/* Select and open input mailbox */ |
/* Select and open input mailbox */ |
166 |
if (input_file == NULL) |
if (input_file == NULL) |
167 |
{ |
{ |
168 |
if (mailbox_create_default (&input, NULL) != 0) |
if ((rc = mailbox_create_default (&input, NULL)) != 0) |
169 |
{ |
{ |
170 |
mh_error ("Can not create default mailbox", strerror (errno)); |
mh_error ("Can not create default mailbox", |
171 |
|
mu_errstring (rc)); |
172 |
exit (1); |
exit (1); |
173 |
} |
} |
174 |
f_truncate = 1; |
f_truncate = 1; |
175 |
f_changecur = 1; |
f_changecur = 1; |
176 |
} |
} |
177 |
else if (mailbox_create_default (&input, input_file) != 0) |
else if ((rc = mailbox_create_default (&input, input_file)) != 0) |
178 |
{ |
{ |
179 |
mh_error ("Can not create mailbox %s: %s", input_file, strerror (errno)); |
mh_error ("Can not create mailbox %s: %s", |
180 |
|
input_file, mu_errstring (rc)); |
181 |
exit (1); |
exit (1); |
182 |
} |
} |
183 |
|
|
184 |
if (mailbox_open (input, MU_STREAM_RDWR) != 0) |
if ((rc = mailbox_open (input, MU_STREAM_RDWR)) != 0) |
185 |
{ |
{ |
186 |
url_t url; |
url_t url; |
187 |
mailbox_get_url (input, &url); |
mailbox_get_url (input, &url); |
188 |
mh_error ("Can not open mailbox %s: %s", url_to_string (url), |
mh_error ("Can not open mailbox %s: %s", |
189 |
strerror (errno)); |
url_to_string (url), |
190 |
|
mu_errstring (errno)); |
191 |
exit (1); |
exit (1); |
192 |
} |
} |
193 |
|
|
194 |
if (mailbox_messages_count (input, &total) != 0) |
if ((rc = mailbox_messages_count (input, &total)) != 0) |
195 |
{ |
{ |
196 |
mh_error ("Can not read input mailbox"); |
mh_error ("Can not read input mailbox: %s", mu_errstring (errno)); |
197 |
exit (1); |
exit (1); |
198 |
} |
} |
199 |
|
|
200 |
output = mh_open_folder (append_folder, 1); |
output = mh_open_folder (append_folder, 1); |
201 |
if (mailbox_messages_count (output, &lastmsg) != 0) |
if ((rc = mailbox_messages_count (output, &lastmsg)) != 0) |
202 |
{ |
{ |
203 |
mh_error ("Can not read output mailbox"); |
mh_error ("Can not read output mailbox: %s", |
204 |
|
mu_errstring (errno)); |
205 |
exit (1); |
exit (1); |
206 |
} |
} |
207 |
|
|
221 |
{ |
{ |
222 |
message_t imsg; |
message_t imsg; |
223 |
|
|
224 |
if (mailbox_get_message (input, n, &imsg)) |
if ((rc = mailbox_get_message (input, n, &imsg)) != 0) |
225 |
{ |
{ |
226 |
mh_error ("%d: can't get message: %s", n, strerror (errno)); |
mh_error ("%d: can't get message: %s", |
227 |
|
n, mu_errstring (errno)); |
228 |
continue; |
continue; |
229 |
} |
} |
230 |
|
|
231 |
if (mailbox_append_message (output, imsg)) |
if ((rc = mailbox_append_message (output, imsg)) != 0) |
232 |
{ |
{ |
233 |
mh_error ("%d: error appending message: %s", |
mh_error ("%d: error appending message: %s", |
234 |
n, strerror (errno)); |
n, mu_errstring (errno)); |
235 |
continue; |
continue; |
236 |
} |
} |
237 |
|
|