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
5c470f14
...
5c470f1488e05c87bdaef2936eb74670d49ee5ab
authored
2001-06-25 08:11:39 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implemented Write. Fixed memory leaks.
1 parent
2400d34e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
28 deletions
mail/write.c
mail/write.c
View file @
5c470f1
...
...
@@ -45,44 +45,27 @@ mail_write (int argc, char **argv)
if
(
isupper
(
argv
[
0
][
0
]))
sender
=
1
;
else
if
(
argc
>=
2
)
filename
=
argv
[
--
argc
]
;
filename
=
strdup
(
argv
[
--
argc
])
;
else
{
filename
=
strdup
(
"mbox"
);
}
filename
=
strdup
(
"mbox"
);
num
=
util_expand_msglist
(
argc
,
argv
,
&
msglist
);
if
(
sender
)
{
mailbox_get_message
(
mbox
,
num
>
0
?
msglist
[
0
]
:
cursor
,
0
);
/* get from */
/* filename = login name part */
filename
=
util_get_sender
(
msglist
[
0
],
1
);
if
(
!
filename
)
{
free
(
msglist
);
return
1
;
}
}
output
=
fopen
(
filename
,
"a"
);
if
(
num
>
0
)
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
mailbox_get_message
(
mbox
,
msglist
[
i
],
&
msg
);
message_get_body
(
msg
,
&
bod
);
body_get_stream
(
bod
,
&
stream
);
/* should there be a separator? */
while
(
stream_read
(
stream
,
buffer
,
sizeof
(
buffer
)
-
1
,
off
,
&
n
)
==
0
&&
n
!=
0
)
{
buffer
[
n
]
=
'\0'
;
fprintf
(
output
,
"%s"
,
buffer
);
off
+=
n
;
}
/* mark as saved */
}
}
else
for
(
i
=
0
;
i
<
num
;
i
++
)
{
mailbox_get_message
(
mbox
,
cursor
,
&
msg
);
mailbox_get_message
(
mbox
,
msglist
[
i
]
,
&
msg
);
message_get_body
(
msg
,
&
bod
);
body_get_stream
(
bod
,
&
stream
);
/* should there be a separator? */
...
...
@@ -93,7 +76,7 @@ mail_write (int argc, char **argv)
fprintf
(
output
,
"%s"
,
buffer
);
off
+=
n
;
}
/* mark as save */
/* mark as save
d
*/
}
fclose
(
output
);
...
...
Please
register
or
sign in
to post a comment