Commit d2dcf178 d2dcf178894696fa4e592226715f264de775f295 by Alain Magloire

Corrected mbox-explode.c

1 parent 8ddbdeb8
2001-06-09 Alain Magloire
* examples/mbox-explode.c: message_save_attachment, should take
the part. Continue if the message does have a Date or Subject field.
* mailbox/mapfile_stream.c (_mapfile_open): Identation.
2001-06-09 Alain Magloire
* mailbox/tcp.c (_tcp_get_fd): Buglet, comparing fd against EINVAL
instead of -1.
......@@ -72,7 +79,7 @@
* examples/mbox-dates.c: example of using the date-time parser, it
prints all the dates in a mailbox that it can't parse.
* examples/Makefile: makes the mbox-* examples.
2001-06-01 Alain Magloire
* mailbox/mbx_pop.c (pop_writeline): if buffer is NULL noop.
......
......@@ -21,9 +21,11 @@ main(int argc, char **argv)
mailbox_t mbox;
size_t i;
size_t count = 0;
char *mailbox_name = "+dbuild.details";
char *mailbox_name;
int status;
mailbox_name = (argc > 1) ? argv[0] : "+dbuild.details";
/* Register the desire formats. */
{
list_t bookie;
......@@ -63,17 +65,22 @@ main(int argc, char **argv)
if (
(status = mailbox_get_message (mbox, i, &msg)) != 0 ||
(status = message_get_header (msg, &hdr)) != 0 ||
(status = header_get_value (
hdr, MU_HEADER_SUBJECT, subj, sizeof (subj), &len)) != 0 ||
(status = header_get_value (
hdr, MU_HEADER_DATE, date, sizeof (date), &len)) != 0
)
(status = message_get_header (msg, &hdr)) != 0)
{
fprintf (stderr, "msg %d : %s\n", i, strerror(status));
exit(2);
}
if (
(status = header_get_value (
hdr, MU_HEADER_SUBJECT, subj, sizeof (subj), &len)) != 0 ||
(status = header_get_value (
hdr, MU_HEADER_DATE, date, sizeof (date), &len)) != 0)
{
fprintf (stderr, "msg %d : No Subject|Date\n", i);
continue;
}
if (strcasecmp(subj, "WTLS 1.0 Daily Build-details") == 0)
{
const char* s = date;
......@@ -88,8 +95,8 @@ main(int argc, char **argv)
exit(1);
}
printf ("Processing for: year %d month %d day %d\n",
tm.tm_year + 1900, tm.tm_mon, tm.tm_mday);
printf ("%d Processing for: year %d month %d day %d\n",
i, tm.tm_year + 1900, tm.tm_mon, tm.tm_mday);
snprintf(dir, sizeof(dir), "%d.%02d.%02d",
tm.tm_year + 1900, tm.tm_mon, tm.tm_mday);
......@@ -142,7 +149,7 @@ main(int argc, char **argv)
snprintf(path, sizeof(path), "%s/%s", dir, fname);
printf(" filename %s\n", path);
if((status = message_save_attachment(msg, path, NULL))) {
if((status = message_save_attachment(part, path, NULL))) {
fprintf (stderr, "save attachment failed: %s\n", strerror(status));
break;
}
......
......@@ -279,7 +279,7 @@ _mapfile_open (stream_t stream, const char *filename, int port, int flags)
mfs->fd = -1;
}
/* Map the flags to the system equivalent */
if (flags & MU_STREAM_WRITE && flags & MU_STREAM_READ)
if ((flags & MU_STREAM_WRITE) && (flags & MU_STREAM_READ))
return EINVAL;
else if (flags & MU_STREAM_WRITE)
{
......