Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4e28d683
...
4e28d683d6ea3a57e4acf907164196cc44c6a5c3
authored
2001-08-03 02:40:03 +0000
by
Sam Roberts
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Don't mkdir unless the mailbox can be opened, and better cleanup on error
detection.
1 parent
a013b372
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
examples/mbox-explode.c
examples/mbox-explode.c
View file @
4e28d68
...
...
@@ -32,16 +32,12 @@ main (int argc, char **argv)
mbox_name
=
argv
[
1
];
dir_name
=
argv
[
2
];
if
(
mkdir
(
dir_name
,
0777
)
!=
0
)
{
fprintf
(
stderr
,
"mkdir(%s) failed: %s
\n
"
,
dir_name
,
strerror
(
errno
));
exit
(
1
);
}
/* Register the desire formats. */
{
list_t
bookie
;
registrar_get_list
(
&
bookie
);
list_append
(
bookie
,
path_record
);
list_append
(
bookie
,
imap_record
);
}
if
((
status
=
mailbox_create_default
(
&
mbox
,
mbox_name
))
!=
0
)
...
...
@@ -64,6 +60,13 @@ main (int argc, char **argv)
}
mailbox_messages_count
(
mbox
,
&
count
);
if
(
mkdir
(
dir_name
,
0777
)
!=
0
)
{
fprintf
(
stderr
,
"mkdir(%s) failed: %s
\n
"
,
dir_name
,
strerror
(
errno
));
mailbox_close
(
mbox
);
exit
(
1
);
}
for
(
msgno
=
1
;
msgno
<=
count
;
++
msgno
)
{
message_t
msg
=
0
;
...
...
@@ -74,12 +77,14 @@ main (int argc, char **argv)
{
fprintf
(
stderr
,
"msg %d: get message failed: %s
\n
"
,
msgno
,
strerror
(
status
));
exit
(
2
);
mailbox_close
(
mbox
);
exit
(
1
);
}
if
((
status
=
message_get_num_parts
(
msg
,
&
nparts
)))
{
fprintf
(
stderr
,
"msg %d: get num parts failed: %s
\n
"
,
msgno
,
strerror
(
status
));
mailbox_close
(
mbox
);
exit
(
1
);
}
printf
(
"msg %03d: %02d parts
\n
"
,
msgno
,
nparts
);
...
...
@@ -97,6 +102,7 @@ main (int argc, char **argv)
{
fprintf
(
stderr
,
"msg %d: get part %d failed: %s
\n
"
,
msgno
,
partno
,
strerror
(
status
));
mailbox_close
(
mbox
);
exit
(
1
);
}
if
((
status
=
message_save_attachment
(
part
,
path
,
0
)))
...
...
Please
register
or
sign in
to post a comment