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
2b656925
...
2b656925f6cdddbf0a9c901bd525a3d2965bc723
authored
2001-08-06 17:21:51 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use msgset_parse instead of util_expand_msglist().
1 parent
3d8deee3
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
43 deletions
mail/copy.c
mail/followup.c
mail/headers.c
mail/next.c
mail/pipe.c
mail/previous.c
mail/write.c
mail/copy.c
View file @
2b65692
...
...
@@ -34,8 +34,7 @@ mail_copy0 (int argc, char **argv, int mark)
message_t
msg
;
mailbox_t
mbx
;
char
*
filename
=
NULL
;
int
*
msglist
=
NULL
;
int
num
=
0
,
i
=
0
;
msgset_t
*
msglist
=
NULL
,
*
mp
;
int
sender
=
0
;
size_t
total_size
=
0
,
total_lines
=
0
,
size
;
...
...
@@ -46,13 +45,19 @@ mail_copy0 (int argc, char **argv, int mark)
else
filename
=
strdup
(
"mbox"
);
num
=
util_expand_msglist
(
argc
,
argv
,
&
msglist
);
if
(
msgset_parse
(
argc
,
argv
,
&
msglist
))
{
if
(
filename
)
free
(
filename
);
return
1
;
}
if
(
sender
)
{
filename
=
util_get_sender
(
msglist
[
0
],
1
);
filename
=
util_get_sender
(
msglist
->
msg_part
[
0
],
1
);
if
(
!
filename
)
{
free
(
msglist
);
msgset_
free
(
msglist
);
return
1
;
}
}
...
...
@@ -62,13 +67,13 @@ mail_copy0 (int argc, char **argv, int mark)
{
util_error
(
"can't create mailbox %s"
,
filename
);
free
(
filename
);
free
(
msglist
);
msgset_
free
(
msglist
);
return
1
;
}
for
(
i
=
0
;
i
<
num
;
i
++
)
for
(
mp
=
msglist
;
mp
;
mp
=
mp
->
next
)
{
mailbox_get_message
(
mbox
,
m
sglist
[
i
],
&
msg
);
mailbox_get_message
(
mbox
,
m
p
->
msg_part
[
0
],
&
msg
);
mailbox_append_message
(
mbx
,
msg
);
message_size
(
msg
,
&
size
);
...
...
@@ -90,7 +95,7 @@ mail_copy0 (int argc, char **argv, int mark)
mailbox_destroy
(
&
mbx
);
free
(
filename
);
free
(
msglist
);
msgset_
free
(
msglist
);
return
0
;
}
...
...
mail/followup.c
View file @
2b65692
...
...
@@ -28,18 +28,20 @@ mail_followup (int argc, char **argv)
message_t
msg
;
header_t
hdr
;
char
*
str
;
int
i
,
num
,
*
msglist
;
int
i
;
msgset_t
*
msglist
,
*
mp
;
struct
send_environ
env
;
int
status
;
env
.
to
=
env
.
cc
=
env
.
bcc
=
env
.
subj
=
NULL
;
env
.
outfiles
=
NULL
;
env
.
nfiles
=
0
;
num
=
util_expand_msglist
(
argc
,
argv
,
&
msglist
);
if
(
msgset_parse
(
argc
,
argv
,
&
msglist
))
return
1
;
if
(
mailbox_get_message
(
mbox
,
cursor
,
&
msg
))
{
util_error
(
"%d: can't get message"
,
cursor
);
free
(
msglist
);
msgset_free
(
msglist
);
return
1
;
}
...
...
@@ -55,13 +57,13 @@ mail_followup (int argc, char **argv)
/* Add authors of the subsequent messages to the to list
(or should it be cc?)*/
for
(
i
=
1
;
i
<
num
;
i
++
)
for
(
mp
=
msglist
;
mp
;
mp
=
mp
->
next
)
{
util_strcat
(
&
env
.
to
,
","
);
util_strcat
(
&
env
.
to
,
util_get_sender
(
m
sglist
[
i
],
0
));
util_strcat
(
&
env
.
to
,
util_get_sender
(
m
p
->
msg_part
[
0
],
0
));
}
free
(
msglist
);
msgset_
free
(
msglist
);
fprintf
(
ofile
,
"To: %s
\n
"
,
env
.
to
);
fprintf
(
ofile
,
"Subject: %s
\n\n
"
,
env
.
subj
);
...
...
mail/headers.c
View file @
2b65692
...
...
@@ -29,9 +29,17 @@
int
mail_headers
(
int
argc
,
char
**
argv
)
{
int
low
=
1
,
high
=
total
,
*
list
=
NULL
;
int
low
=
1
,
high
=
total
;
msgset_t
*
list
=
NULL
,
*
mp
;
int
lines
=
util_screen_lines
();
int
num
=
util_expand_msglist
(
argc
,
argv
,
&
list
);
int
num
;
if
(
msgset_parse
(
argc
,
argv
,
&
list
))
return
1
;
num
=
0
;
for
(
mp
=
list
;
mp
;
mp
=
mp
->
next
)
num
++
;
lines
=
(
lines
/
num
)
-
2
;
if
(
lines
<
0
)
...
...
@@ -39,7 +47,7 @@ mail_headers (int argc, char **argv)
if
(
lines
<
total
)
{
low
=
list
[
0
]
-
(
lines
/
2
);
low
=
list
->
msg_part
[
0
]
-
(
lines
/
2
);
if
(
low
<
1
)
low
=
1
;
high
=
low
+
lines
;
...
...
@@ -52,6 +60,6 @@ mail_headers (int argc, char **argv)
util_do_command
(
"from %d-%d"
,
low
,
high
);
free
(
list
);
msgset_
free
(
list
);
return
0
;
}
...
...
mail/next.c
View file @
2b65692
...
...
@@ -33,11 +33,11 @@ mail_next (int argc, char **argv)
}
else
{
in
t
*
list
=
NULL
;
util_expand_msglist
(
argc
,
argv
,
&
list
);
cursor
=
list
[
0
];
msgset_
t
*
list
=
NULL
;
msgset_parse
(
argc
,
argv
,
&
list
);
cursor
=
list
->
msg_part
[
0
];
realcursor
=
cursor
;
free
(
list
);
msgset_
free
(
list
);
return
0
;
}
return
1
;
...
...
mail/pipe.c
View file @
2b65692
...
...
@@ -29,11 +29,10 @@ mail_pipe (int argc, char **argv)
stream_t
stream
;
char
*
cmd
;
FILE
*
pipe
;
int
*
list
,
num
=
0
;
msgset_t
*
list
,
*
mp
;
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
;
int
i
;
if
(
argc
>
1
)
cmd
=
argv
[
--
argc
];
...
...
@@ -42,12 +41,14 @@ mail_pipe (int argc, char **argv)
else
return
1
;
if
(
msgset_parse
(
argc
,
argv
,
&
list
))
return
1
;
pipe
=
popen
(
cmd
,
"w"
);
num
=
util_expand_msglist
(
argc
,
argv
,
&
list
);
for
(
i
=
0
;
i
<
num
;
i
++
)
for
(
mp
=
list
;
mp
;
mp
=
mp
->
next
)
{
if
(
mailbox_get_message
(
mbox
,
list
[
i
],
&
msg
)
==
0
)
if
(
mailbox_get_message
(
mbox
,
mp
->
msg_part
[
0
],
&
msg
)
==
0
)
{
message_get_stream
(
msg
,
&
stream
);
off
=
0
;
...
...
@@ -58,12 +59,12 @@ mail_pipe (int argc, char **argv)
fprintf
(
pipe
,
"%s"
,
buffer
);
off
+=
n
;
}
if
((
util_find_env
(
"page"
))
->
set
&&
i
<
num
-
1
)
if
((
util_find_env
(
"page"
))
->
set
&&
mp
->
next
)
fprintf
(
pipe
,
"
\f\n
"
);
}
}
free
(
list
);
msgset_
free
(
list
);
pclose
(
pipe
);
return
0
;
}
...
...
mail/previous.c
View file @
2b65692
...
...
@@ -33,11 +33,12 @@ mail_previous (int argc, char **argv)
}
else
{
int
*
list
=
NULL
;
util_expand_msglist
(
argc
,
argv
,
&
list
);
cursor
=
list
[
0
];
msgset_t
*
list
=
NULL
;
if
(
msgset_parse
(
argc
,
argv
,
&
list
))
return
1
;
cursor
=
list
->
msg_part
[
0
];
realcursor
=
cursor
;
free
(
list
);
msgset_
free
(
list
);
return
0
;
}
return
1
;
...
...
mail/write.c
View file @
2b65692
...
...
@@ -34,8 +34,7 @@ mail_write (int argc, char **argv)
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
;
int
*
msglist
=
NULL
;
int
num
=
0
,
i
=
0
;
msgset_t
*
msglist
=
NULL
,
*
mp
;
int
sender
=
0
;
size_t
total_size
=
0
,
total_lines
=
0
,
size
;
...
...
@@ -48,14 +47,19 @@ mail_write (int argc, char **argv)
else
filename
=
strdup
(
"mbox"
);
num
=
util_expand_msglist
(
argc
,
argv
,
&
msglist
);
if
(
msgset_parse
(
argc
,
argv
,
&
msglist
))
{
if
(
filename
)
free
(
filename
);
return
1
;
}
if
(
sender
)
{
filename
=
util_get_sender
(
msglist
[
0
],
1
);
filename
=
util_get_sender
(
msglist
->
msg_part
[
0
],
1
);
if
(
!
filename
)
{
free
(
msglist
);
msgset_
free
(
msglist
);
return
1
;
}
}
...
...
@@ -66,15 +70,15 @@ mail_write (int argc, char **argv)
util_error
(
"can't open %s: %s"
,
filename
,
strerror
(
errno
));
free
(
filename
);
fclose
(
output
);
free
(
msglist
);
msgset_
free
(
msglist
);
return
1
;
}
for
(
i
=
0
;
i
<
num
;
i
++
)
for
(
mp
=
msglist
;
mp
;
mp
=
mp
->
next
)
{
attribute_t
attr
;
mailbox_get_message
(
mbox
,
m
sglist
[
i
],
&
msg
);
mailbox_get_message
(
mbox
,
m
p
->
msg_part
[
0
],
&
msg
);
message_get_body
(
msg
,
&
bod
);
body_size
(
bod
,
&
size
);
...
...
@@ -102,6 +106,6 @@ mail_write (int argc, char **argv)
free
(
filename
);
fclose
(
output
);
free
(
msglist
);
msgset_
free
(
msglist
);
return
0
;
}
...
...
Please
register
or
sign in
to post a comment