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
83fd9e40
...
83fd9e40c3c4f6b7bc9556b72152b0ac01773b97
authored
2002-12-29 13:37:43 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Rewritten using new iterator functions.
1 parent
7d408629
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
403 additions
and
403 deletions
mail/delete.c
mail/dp.c
mail/edit.c
mail/eq.c
mail/file.c
mail/from.c
mail/headers.c
mail/hold.c
mail/mbox.c
mail/next.c
mail/previous.c
mail/print.c
mail/reply.c
mail/size.c
mail/summary.c
mail/top.c
mail/undelete.c
mail/var.c
mail/visual.c
mail/z.c
mail/delete.c
View file @
83fd9e4
...
...
@@ -22,47 +22,55 @@
*/
static
int
mail_delete
0
(
void
)
mail_delete
_msg
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
message_t
msg
;
attribute_t
attr
;
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_NODELETED
))
return
1
;
message_get_attribute
(
msg
,
&
attr
);
attribute_set_deleted
(
attr
);
if
(
cursor
==
mspec
->
msg_part
[
0
])
{
/* deleting current message. let the caller know */
*
(
int
*
)
data
=
1
;
}
return
0
;
}
int
mail_delete
(
int
argc
,
char
**
argv
)
{
int
rc
=
0
;
if
(
argc
>
1
)
rc
=
util_msglist_command
(
mail_delete
,
argc
,
argv
,
0
);
else
rc
=
mail_delete0
();
/* Readjust the realcursor to no point to the deleted messages. */
if
(
cursor
==
realcursor
)
int
reset_cursor
=
0
;
int
rc
=
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
mail_delete_msg
,
&
reset_cursor
);
/* Readjust the cursor not to point to the deleted messages. */
if
(
reset_cursor
)
{
unsigned
int
here
=
realcursor
;
do
unsigned
int
here
;
for
(
here
=
cursor
;
here
<=
total
;
here
++
)
{
message_t
msg
=
NULL
;
attribute_t
attr
=
NULL
;
mailbox_get_message
(
mbox
,
realcursor
,
&
msg
);
mailbox_get_message
(
mbox
,
here
,
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
if
(
!
attribute_is_deleted
(
attr
))
break
;
if
(
++
realcursor
>
total
)
realcursor
=
1
;
}
while
(
realcursor
!=
here
);
cursor
=
realcursor
;
if
(
here
>
total
)
for
(
here
=
cursor
;
here
>
0
;
here
--
)
{
message_t
msg
=
NULL
;
attribute_t
attr
=
NULL
;
mailbox_get_message
(
mbox
,
here
,
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
if
(
!
attribute_is_deleted
(
attr
))
break
;
}
cursor
=
here
;
}
if
(
util_getenv
(
NULL
,
"autoprint"
,
Mail_env_boolean
,
0
)
==
0
)
...
...
mail/dp.c
View file @
83fd9e4
...
...
@@ -25,10 +25,7 @@
int
mail_dp
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
util_msglist_command
(
mail_delete
,
argc
,
argv
,
0
);
else
util_do_command
(
"delete"
);
mail_delete
(
argc
,
argv
);
util_do_command
(
"print"
);
return
0
;
}
...
...
mail/edit.c
View file @
83fd9e4
...
...
@@ -21,19 +21,21 @@
* e[dit] [msglist]
*/
static
int
edit0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
char
*
file
=
mu_tempname
(
NULL
);
util_do_command
(
"copy %s"
,
file
);
util_do_command
(
"shell %s %s"
,
getenv
(
"EDITOR"
),
file
);
remove
(
file
);
free
(
file
);
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
int
mail_edit
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_edit
,
argc
,
argv
,
1
);
else
{
char
*
file
=
mu_tempname
(
NULL
);
util_do_command
(
"copy %s"
,
file
);
util_do_command
(
"shell %s %s"
,
getenv
(
"EDITOR"
),
file
);
remove
(
file
);
free
(
file
);
return
0
;
}
return
1
;
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
edit0
,
NULL
);
}
...
...
mail/eq.c
View file @
83fd9e4
...
...
@@ -29,7 +29,7 @@ mail_eq (int argc, char **argv)
switch
(
argc
)
{
case
1
:
fprintf
(
ofile
,
"%d
\n
"
,
real
cursor
);
fprintf
(
ofile
,
"%d
\n
"
,
cursor
);
break
;
case
2
:
...
...
@@ -37,8 +37,8 @@ mail_eq (int argc, char **argv)
{
if
(
list
->
msg_part
[
0
]
<=
total
)
{
realcursor
=
cursor
=
list
->
msg_part
[
0
];
fprintf
(
ofile
,
"%d
\n
"
,
real
cursor
);
cursor
=
list
->
msg_part
[
0
];
fprintf
(
ofile
,
"%d
\n
"
,
cursor
);
}
else
util_error_range
(
list
->
msg_part
[
0
]);
...
...
mail/file.c
View file @
83fd9e4
...
...
@@ -111,7 +111,7 @@ mail_file (int argc, char **argv)
mbox
=
newbox
;
mailbox_messages_count
(
mbox
,
&
total
);
cursor
=
realcursor
=
1
;
cursor
=
1
;
if
(
util_getenv
(
NULL
,
"header"
,
Mail_env_boolean
,
0
)
==
0
)
{
util_do_command
(
"summary"
);
...
...
mail/from.c
View file @
83fd9e4
...
...
@@ -22,19 +22,8 @@
*/
int
mail_from
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_from
,
argc
,
argv
,
0
);
else
return
mail_from0
(
cursor
,
1
);
return
1
;
}
int
mail_from0
(
int
msgno
,
int
verbose
)
mail_from0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
message_t
msg
;
header_t
hdr
=
NULL
;
envelope_t
env
;
attribute_t
attr
;
...
...
@@ -48,10 +37,6 @@ mail_from0 (int msgno, int verbose)
struct
tm
tm
;
mu_timezone
tz
;
if
(
util_get_message
(
mbox
,
msgno
,
&
msg
,
MSG_NODELETED
|
(
verbose
?
0
:
MSG_SILENT
)))
return
1
;
message_get_header
(
msg
,
&
hdr
);
if
(
header_aget_value
(
hdr
,
MU_HEADER_FROM
,
&
from
)
==
0
)
{
...
...
@@ -113,11 +98,19 @@ mail_from0 (int msgno, int verbose)
fromp
=
from
?
from
:
""
;
subjp
=
subj
?
subj
:
fromp
;
fprintf
(
ofile
,
"%c%c%4d %-18.18s %-16.16s %s %.*s
\n
"
,
msgno
==
realcursor
?
'>'
:
' '
,
cflag
,
msgno
,
mspec
->
msg_part
[
0
]
==
cursor
?
'>'
:
' '
,
cflag
,
mspec
->
msg_part
[
0
],
fromp
,
date
,
st
,
(
subjl
<
0
)
?
0
:
subjl
,
subjp
);
free
(
from
);
free
(
subj
);
return
0
;
}
int
mail_from
(
int
argc
,
char
**
argv
)
{
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
mail_from0
,
NULL
);
}
...
...
mail/headers.c
View file @
83fd9e4
...
...
@@ -52,7 +52,7 @@ mail_headers (int argc, char **argv)
low
=
list
->
msg_part
[
0
]
-
(
lines
/
2
);
if
(
low
<
1
)
low
=
1
;
high
=
low
+
lines
;
high
=
low
+
util_screen_lines
()
;
if
((
unsigned
int
)
high
>
total
)
{
high
=
total
;
...
...
@@ -60,8 +60,7 @@ mail_headers (int argc, char **argv)
}
}
for
(;
low
<=
high
;
low
++
)
mail_from0
(
low
,
0
);
util_range_msg
(
low
,
high
,
MSG_NODELETED
|
MSG_SILENT
,
mail_from0
,
NULL
);
msgset_free
(
list
);
return
0
;
...
...
mail/hold.c
View file @
83fd9e4
...
...
@@ -22,21 +22,22 @@
* pre[serve] [msglist]
*/
int
mail_hold
(
int
argc
,
char
**
argv
)
static
int
hold0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
message_t
msg
;
attribute_t
attr
;
if
(
argc
>
1
)
return
util_msglist_command
(
mail_hold
,
argc
,
argv
,
1
);
else
{
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_ALL
))
return
1
;
message_get_attribute
(
msg
,
&
attr
);
attribute_unset_userflag
(
attr
,
MAIL_ATTRIBUTE_MBOXED
);
message_get_attribute
(
msg
,
&
attr
);
attribute_unset_userflag
(
attr
,
MAIL_ATTRIBUTE_MBOXED
);
}
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
int
mail_hold
(
int
argc
,
char
**
argv
)
{
return
util_foreach_msg
(
argc
,
argv
,
MSG_ALL
,
hold0
,
NULL
);
}
...
...
mail/mbox.c
View file @
83fd9e4
...
...
@@ -21,22 +21,21 @@
* mb[ox] [msglist]
*/
int
m
ail_mbox
(
int
argc
,
char
**
argv
)
static
int
m
box0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
message_t
msg
;
attribute_t
attr
;
if
(
argc
>
1
)
return
util_msglist_command
(
mail_mbox
,
argc
,
argv
,
1
);
else
{
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_NODELETED
))
return
1
;
/* Mark the message */
message_get_attribute
(
msg
,
&
attr
);
attribute_set_userflag
(
attr
,
MAIL_ATTRIBUTE_MBOXED
);
}
message_get_attribute
(
msg
,
&
attr
);
attribute_set_userflag
(
attr
,
MAIL_ATTRIBUTE_MBOXED
);
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
int
mail_mbox
(
int
argc
,
char
**
argv
)
{
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
mbox0
,
NULL
);
}
...
...
mail/next.c
View file @
83fd9e4
...
...
@@ -53,7 +53,7 @@ mail_next (int argc, char **argv)
if
(
util_get_message
(
mbox
,
n
,
&
msg
,
MSG_NODELETED
|
MSG_SILENT
))
return
1
;
}
cursor
=
realcursor
=
n
;
cursor
=
n
;
util_do_command
(
"print"
);
return
0
;
}
...
...
mail/previous.c
View file @
83fd9e4
...
...
@@ -53,7 +53,7 @@ mail_previous (int argc, char **argv)
if
(
util_get_message
(
mbox
,
n
,
&
msg
,
MSG_NODELETED
|
MSG_SILENT
))
return
1
;
}
cursor
=
realcursor
=
n
;
cursor
=
n
;
util_do_command
(
"print"
);
return
0
;
}
...
...
mail/print.c
View file @
83fd9e4
...
...
@@ -24,92 +24,94 @@
* T[ype] [msglist]
*/
int
mail_print
(
int
argc
,
char
**
argv
)
static
int
mail_print
_msg
(
msgset_t
*
mspec
,
message_t
mesg
,
void
*
data
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_print
,
argc
,
argv
,
1
);
else
{
message_t
mesg
;
header_t
hdr
;
body_t
body
;
stream_t
stream
;
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
,
lines
=
0
;
FILE
*
out
=
ofile
;
attribute_t
attr
;
int
pagelines
=
util_get_crt
();
header_t
hdr
;
body_t
body
;
stream_t
stream
;
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
,
lines
=
0
;
FILE
*
out
=
ofile
;
attribute_t
attr
;
int
pagelines
=
util_get_crt
();
if
(
util_get_message
(
mbox
,
cursor
,
&
mesg
,
MSG_NODELETED
))
return
1
;
message_lines
(
mesg
,
&
lines
);
message_lines
(
mesg
,
&
lines
);
/* If it is POP or IMAP the lines number is not known, so try
to be smart about it. */
if
(
lines
==
0
)
/* If it is POP or IMAP the lines number is not known, so try
to be smart about it. */
if
(
lines
==
0
)
{
if
(
pagelines
)
{
if
(
pagelines
)
size_t
col
=
(
size_t
)
util_getcols
();
if
(
col
)
{
size_t
col
=
(
size_t
)
util_getcols
();
if
(
col
)
{
size_t
size
=
0
;
message_size
(
mesg
,
&
size
);
lines
=
size
/
col
;
}
size_t
size
=
0
;
message_size
(
mesg
,
&
size
);
lines
=
size
/
col
;
}
}
}
if
(
pagelines
&&
lines
>
pagelines
)
out
=
popen
(
getenv
(
"PAGER"
),
"w"
);
if
(
pagelines
&&
lines
>
pagelines
)
out
=
popen
(
getenv
(
"PAGER"
),
"w"
);
if
(
islower
(
argv
[
0
][
0
]))
{
size_t
i
,
num
=
0
;
char
buf
[
512
];
if
(
*
(
int
*
)
data
)
/* print was called with a lowercase 'p' */
{
size_t
i
,
num
=
0
;
char
buf
[
512
];
message_get_header
(
mesg
,
&
hdr
);
header_get_field_count
(
hdr
,
&
num
);
message_get_header
(
mesg
,
&
hdr
);
header_get_field_count
(
hdr
,
&
num
);
for
(
i
=
1
;
i
<=
num
;
i
++
)
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
header_get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
{
header_get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
{
fprintf
(
out
,
"%s: "
,
buf
);
header_get_field_value
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
fprintf
(
out
,
"%s
\n
"
,
buf
);
}
fprintf
(
out
,
"%s: "
,
buf
);
header_get_field_value
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
fprintf
(
out
,
"%s
\n
"
,
buf
);
}
fprintf
(
out
,
"
\n
"
);
message_get_body
(
mesg
,
&
body
);
body_get_stream
(
body
,
&
stream
);
}
else
message_get_stream
(
mesg
,
&
stream
);
while
(
stream_read
(
stream
,
buffer
,
sizeof
buffer
-
1
,
off
,
&
n
)
==
0
&&
n
!=
0
)
{
if
(
ml_got_interrupt
())
{
util_error
(
_
(
"
\n
Interrupt"
));
break
;
}
buffer
[
n
]
=
'\0'
;
fprintf
(
out
,
"%s"
,
buffer
);
off
+=
n
;
}
if
(
out
!=
ofile
)
pclose
(
out
);
fprintf
(
out
,
"
\n
"
);
message_get_body
(
mesg
,
&
body
);
body_get_stream
(
body
,
&
stream
);
}
else
message_get_stream
(
mesg
,
&
stream
);
while
(
stream_read
(
stream
,
buffer
,
sizeof
buffer
-
1
,
off
,
&
n
)
==
0
&&
n
!=
0
)
{
if
(
ml_got_interrupt
())
{
util_error
(
_
(
"
\n
Interrupt"
));
break
;
}
buffer
[
n
]
=
'\0'
;
fprintf
(
out
,
"%s"
,
buffer
);
off
+=
n
;
}
if
(
out
!=
ofile
)
pclose
(
out
);
message_get_attribute
(
mesg
,
&
attr
);
attribute_set_read
(
attr
);
message_get_attribute
(
mesg
,
&
attr
);
attribute_set_read
(
attr
);
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
return
0
;
}
return
1
;
int
mail_print
(
int
argc
,
char
**
argv
)
{
int
lower
=
islower
(
argv
[
0
][
0
]);
int
rc
=
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
mail_print_msg
,
&
lower
);
return
rc
;
}
...
...
mail/reply.c
View file @
83fd9e4
...
...
@@ -169,85 +169,86 @@ make_references (compose_env_t *env, message_t msg)
*/
int
mail_reply
(
int
argc
,
char
**
argv
)
reply0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_reply
,
argc
,
argv
,
1
);
else
{
message_t
msg
;
header_t
hdr
;
compose_env_t
env
;
int
status
;
char
*
str
;
header_t
hdr
;
compose_env_t
env
;
int
status
;
char
*
str
;
compose_init
(
&
env
);
compose_init
(
&
env
);
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_NODELETED
))
return
1
;
message_get_header
(
msg
,
&
hdr
);
message_get_header
(
msg
,
&
hdr
);
compose_header_set
(
&
env
,
MU_HEADER_TO
,
util_get_sender
(
mspec
->
msg_part
[
0
],
0
),
COMPOSE_SINGLE_LINE
);
compose_header_set
(
&
env
,
MU_HEADER_TO
,
util_get_sender
(
cursor
,
0
),
COMPOSE_SINGLE_LINE
);
if
(
*
(
int
*
)
data
)
/* reply starts with a lowercase */
{
/* Add all recepients of the originate letter */
address_t
addr
=
NULL
;
size_t
i
,
count
=
0
;
char
buf
[
512
];
if
(
islower
(
argv
[
0
][
0
])
)
if
(
header_aget_value
(
hdr
,
MU_HEADER_TO
,
&
str
)
==
0
)
{
/* Add all recepients of the originate letter */
address_t
addr
=
NULL
;
size_t
i
,
count
=
0
;
char
buf
[
512
];
if
(
header_aget_value
(
hdr
,
MU_HEADER_TO
,
&
str
)
==
0
)
{
address_create
(
&
addr
,
str
);
free
(
str
);
address_get_count
(
addr
,
&
count
);
}
/* Make sure we do not include our alternate names */
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
address_get_email
(
addr
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
!
mail_is_my_name
(
buf
))
compose_header_set
(
&
env
,
MU_HEADER_TO
,
buf
,
COMPOSE_SINGLE_LINE
);
}
/* Finally, add any Ccs */
if
(
header_aget_value
(
hdr
,
MU_HEADER_CC
,
&
str
)
==
0
)
compose_header_set
(
&
env
,
MU_HEADER_TO
,
str
,
COMPOSE_SINGLE_LINE
);
address_create
(
&
addr
,
str
);
free
(
str
);
address_get_count
(
addr
,
&
count
);
}
if
(
header_aget_value
(
hdr
,
MU_HEADER_SUBJECT
,
&
str
)
==
0
)
/* Make sure we do not include our alternate names */
for
(
i
=
1
;
i
<=
count
;
i
++
)
{
char
*
p
=
NULL
;
if
(
strncasecmp
(
str
,
"Re:"
,
3
))
util_strcat
(
&
p
,
"Re: "
);
util_strcat
(
&
p
,
str
);
free
(
str
);
compose_header_set
(
&
env
,
MU_HEADER_SUBJECT
,
p
,
COMPOSE_REPLACE
);
free
(
p
);
address_get_email
(
addr
,
i
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
!
mail_is_my_name
(
buf
))
compose_header_set
(
&
env
,
MU_HEADER_TO
,
buf
,
COMPOSE_SINGLE_LINE
);
}
else
compose_header_set
(
&
env
,
MU_HEADER_SUBJECT
,
""
,
COMPOSE_REPLACE
);
fprintf
(
ofile
,
"To: %s
\n
"
,
compose_header_get
(
&
env
,
MU_HEADER_TO
,
""
));
str
=
compose_header_get
(
&
env
,
MU_HEADER_CC
,
NULL
);
if
(
str
)
fprintf
(
ofile
,
"Cc: %s
\n
"
,
str
);
fprintf
(
ofile
,
"Subject: %s
\n\n
"
,
compose_header_get
(
&
env
,
MU_HEADER_SUBJECT
,
""
));
make_in_reply_to
(
&
env
,
msg
);
make_references
(
&
env
,
msg
);
status
=
mail_send0
(
&
env
,
0
);
compose_destroy
(
&
env
);
return
status
;
/* Finally, add any Ccs */
if
(
header_aget_value
(
hdr
,
MU_HEADER_CC
,
&
str
)
==
0
)
compose_header_set
(
&
env
,
MU_HEADER_TO
,
str
,
COMPOSE_SINGLE_LINE
);
}
return
1
;
if
(
header_aget_value
(
hdr
,
MU_HEADER_SUBJECT
,
&
str
)
==
0
)
{
char
*
p
=
NULL
;
if
(
strncasecmp
(
str
,
"Re:"
,
3
))
util_strcat
(
&
p
,
"Re: "
);
util_strcat
(
&
p
,
str
);
free
(
str
);
compose_header_set
(
&
env
,
MU_HEADER_SUBJECT
,
p
,
COMPOSE_REPLACE
);
free
(
p
);
}
else
compose_header_set
(
&
env
,
MU_HEADER_SUBJECT
,
""
,
COMPOSE_REPLACE
);
fprintf
(
ofile
,
"To: %s
\n
"
,
compose_header_get
(
&
env
,
MU_HEADER_TO
,
""
));
str
=
compose_header_get
(
&
env
,
MU_HEADER_CC
,
NULL
);
if
(
str
)
fprintf
(
ofile
,
"Cc: %s
\n
"
,
str
);
fprintf
(
ofile
,
"Subject: %s
\n\n
"
,
compose_header_get
(
&
env
,
MU_HEADER_SUBJECT
,
""
));
make_in_reply_to
(
&
env
,
msg
);
make_references
(
&
env
,
msg
);
status
=
mail_send0
(
&
env
,
0
);
compose_destroy
(
&
env
);
cursor
=
mspec
->
msg_part
[
0
];
return
status
;
}
int
mail_reply
(
int
argc
,
char
**
argv
)
{
int
lower
=
islower
(
argv
[
0
][
0
]);
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
reply0
,
&
lower
);
}
...
...
mail/size.c
View file @
83fd9e4
...
...
@@ -21,25 +21,24 @@
* si[ze] [msglist]
*/
static
int
size0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
size_t
size
=
0
,
lines
=
0
;
message_size
(
msg
,
&
size
);
message_lines
(
msg
,
&
lines
);
fprintf
(
ofile
,
"%c%2d %3d/%-5d
\n
"
,
mspec
->
msg_part
[
0
]
==
cursor
?
'>'
:
' '
,
mspec
->
msg_part
[
0
],
lines
,
size
);
return
0
;
}
int
mail_size
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
util_msglist_command
(
mail_size
,
argc
,
argv
,
0
);
else
{
size_t
size
=
0
,
lines
=
0
;
message_t
msg
;
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_ALL
))
return
1
;
message_size
(
msg
,
&
size
);
message_lines
(
msg
,
&
lines
);
fprintf
(
ofile
,
"%c%2d %3d/%-5d
\n
"
,
cursor
==
realcursor
?
'>'
:
' '
,
cursor
,
lines
,
size
);
return
0
;
}
return
1
;
return
util_foreach_msg
(
argc
,
argv
,
MSG_ALL
,
size0
,
NULL
);
}
...
...
mail/summary.c
View file @
83fd9e4
...
...
@@ -19,7 +19,7 @@
/* Simple summary dysplaying a blurb on the name of the
mailbox and how many new:deleted:read messages.
The side effect is that is set the cursor/
real
cursor
The side effect is that is set the cursor/cursor
to the newest or read message number. */
int
mail_summary
(
int
argc
,
char
**
argv
)
...
...
@@ -73,7 +73,7 @@ mail_summary (int argc, char **argv)
printf
(
"
\n
"
);
/* Set the cursor. */
cursor
=
realcursor
=
(
first_new
==
0
)
?
((
first_unread
==
0
)
?
1
:
first_unread
)
:
first_new
;
cursor
=
(
first_new
==
0
)
?
((
first_unread
==
0
)
?
1
:
first_unread
)
:
first_new
;
return
0
;
}
...
...
mail/top.c
View file @
83fd9e4
...
...
@@ -21,36 +21,34 @@
* to[p] [msglist]
*/
int
mail_top
(
int
argc
,
char
**
argv
)
static
int
top0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_top
,
argc
,
argv
,
1
);
else
stream_t
stream
;
char
buf
[
512
];
size_t
n
;
off_t
off
;
int
lines
;
if
(
util_getenv
(
&
lines
,
"toplines"
,
Mail_env_number
,
1
)
||
lines
<
0
)
return
1
;
message_get_stream
(
msg
,
&
stream
);
for
(
n
=
0
,
off
=
0
;
lines
>
0
;
lines
--
,
off
+=
n
)
{
message_t
msg
;
stream_t
stream
;
char
buf
[
512
];
size_t
n
;
off_t
off
;
int
lines
;
if
(
util_getenv
(
&
lines
,
"toplines"
,
Mail_env_number
,
1
)
||
lines
<
0
)
return
1
;
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_NODELETED
))
return
1
;
message_get_stream
(
msg
,
&
stream
);
for
(
n
=
0
,
off
=
0
;
lines
>
0
;
lines
--
,
off
+=
n
)
{
int
status
=
stream_readline
(
stream
,
buf
,
sizeof
(
buf
),
off
,
&
n
);
if
(
status
!=
0
||
n
==
0
)
break
;
fprintf
(
ofile
,
"%s"
,
buf
);
}
return
0
;
int
status
=
stream_readline
(
stream
,
buf
,
sizeof
(
buf
),
off
,
&
n
);
if
(
status
!=
0
||
n
==
0
)
break
;
fprintf
(
ofile
,
"%s"
,
buf
);
}
return
1
;
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
int
mail_top
(
int
argc
,
char
**
argv
)
{
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
top0
,
NULL
);
}
...
...
mail/undelete.c
View file @
83fd9e4
...
...
@@ -21,22 +21,19 @@
* u[ndelete] [msglist]
*/
static
int
undelete0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
attribute_t
attr
;
message_get_attribute
(
msg
,
&
attr
);
attribute_unset_deleted
(
attr
);
return
0
;
}
int
mail_undelete
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_undelete
,
argc
,
argv
,
1
);
else
{
message_t
msg
;
attribute_t
attr
;
if
(
util_get_message
(
mbox
,
cursor
,
&
msg
,
MSG_ALL
))
return
1
;
message_get_attribute
(
msg
,
&
attr
);
if
(
attribute_is_deleted
(
attr
))
attribute_unset_deleted
(
attr
);
return
0
;
}
return
1
;
return
util_foreach_msg
(
argc
,
argv
,
MSG_ALL
,
undelete0
,
NULL
);
}
...
...
mail/var.c
View file @
83fd9e4
...
...
@@ -436,80 +436,80 @@ var_insert (int argc, char **argv, compose_env_t *send_env)
/* ~m[mesg-list] */
/* ~M[mesg-list] */
int
var_quote
(
int
argc
,
char
**
argv
,
compose_env_t
*
env
)
quote0
(
msgset_t
*
mspec
,
message_t
mesg
,
void
*
data
)
{
if
(
argc
>
1
)
return
util_msglist_esccmd
(
var_quote
,
argc
,
argv
,
env
,
0
);
else
{
message_t
mesg
;
header_t
hdr
;
body_t
body
;
stream_t
stream
;
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
;
char
*
prefix
=
"
\t
"
;
header_t
hdr
;
body_t
body
;
stream_t
stream
;
char
buffer
[
512
];
off_t
off
=
0
;
size_t
n
=
0
;
char
*
prefix
=
"
\t
"
;
fprintf
(
stdout
,
_
(
"Interpolating: %d
\n
"
),
mspec
->
msg_part
[
0
]);
if
(
util_get_message
(
mbox
,
cursor
,
&
mesg
,
MSG_NODELETED
))
return
1
;
util_getenv
(
&
prefix
,
"indentprefix"
,
Mail_env_string
,
0
);
fprintf
(
stdout
,
_
(
"Interpolating: %d
\n
"
),
cursor
);
if
(
*
(
int
*
)
data
)
{
size_t
i
,
num
=
0
;
char
buf
[
512
];
util_getenv
(
&
prefix
,
"indentprefix"
,
Mail_env_string
,
0
);
message_get_header
(
mesg
,
&
hdr
);
header_get_field_count
(
hdr
,
&
num
);
if
(
islower
(
argv
[
0
][
0
])
)
for
(
i
=
1
;
i
<=
num
;
i
++
)
{
size_t
i
,
num
=
0
;
char
buf
[
512
];
message_get_header
(
mesg
,
&
hdr
);
header_get_field_count
(
hdr
,
&
num
);
for
(
i
=
1
;
i
<=
num
;
i
++
)
header_get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
{
header_get_field_name
(
hdr
,
i
,
buf
,
sizeof
buf
,
NULL
);
if
(
mail_header_is_visible
(
buf
))
char
*
value
;
fprintf
(
ofile
,
"%s%s: "
,
prefix
,
buf
);
if
(
header_aget_value
(
hdr
,
buf
,
&
value
)
==
0
)
{
char
*
value
;
int
i
;
char
*
p
,
*
s
;
f
printf
(
ofile
,
"%s%s: "
,
prefix
,
buf
)
;
if
(
header_aget_value
(
hdr
,
buf
,
&
value
)
==
0
)
f
or
(
i
=
0
,
p
=
strtok_r
(
value
,
"
\n
"
,
&
s
);
p
;
p
=
strtok_r
(
NULL
,
"
\n
"
,
&
s
),
i
++
)
{
int
i
;
char
*
p
,
*
s
;
for
(
i
=
0
,
p
=
strtok_r
(
value
,
"
\n
"
,
&
s
);
p
;
p
=
strtok_r
(
NULL
,
"
\n
"
,
&
s
),
i
++
)
{
if
(
i
)
fprintf
(
ofile
,
"%s"
,
prefix
);
fprintf
(
ofile
,
"%s
\n
"
,
p
);
}
free
(
value
);
if
(
i
)
fprintf
(
ofile
,
"%s"
,
prefix
);
fprintf
(
ofile
,
"%s
\n
"
,
p
);
}
free
(
value
);
}
}
fprintf
(
ofile
,
"%s
\n
"
,
prefix
);
message_get_body
(
mesg
,
&
body
);
body_get_stream
(
body
,
&
stream
);
}
else
message_get_stream
(
mesg
,
&
stream
);
fprintf
(
ofile
,
"%s
\n
"
,
prefix
);
message_get_body
(
mesg
,
&
body
);
body_get_stream
(
body
,
&
stream
);
}
else
message_get_stream
(
mesg
,
&
stream
);
while
(
stream_readline
(
stream
,
buffer
,
sizeof
buffer
-
1
,
off
,
&
n
)
==
0
&&
n
!=
0
)
{
buffer
[
n
]
=
'\0'
;
fprintf
(
ofile
,
"%s%s"
,
prefix
,
buffer
);
off
+=
n
;
}
var_continue
();
while
(
stream_readline
(
stream
,
buffer
,
sizeof
buffer
-
1
,
off
,
&
n
)
==
0
&&
n
!=
0
)
{
buffer
[
n
]
=
'\0'
;
fprintf
(
ofile
,
"%s%s"
,
prefix
,
buffer
);
off
+=
n
;
}
return
0
;
}
int
var_quote
(
int
argc
,
char
**
argv
,
compose_env_t
*
env
)
{
int
lower
=
islower
(
argv
[
0
][
0
]);
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
|
MSG_SILENT
,
quote0
,
&
lower
);
var_continue
();
return
0
;
}
/* ~p */
int
var_type_input
(
int
argc
,
char
**
argv
,
compose_env_t
*
env
)
...
...
mail/visual.c
View file @
83fd9e4
...
...
@@ -21,29 +21,30 @@
* v[isual] [msglist]
*/
static
int
visual0
(
msgset_t
*
mspec
,
message_t
msg
,
void
*
data
)
{
attribute_t
attr
=
NULL
;
char
*
file
=
mu_tempname
(
NULL
);
util_do_command
(
"copy %s"
,
file
);
util_do_command
(
"shell %s %s"
,
getenv
(
"VISUAL"
),
file
);
remove
(
file
);
free
(
file
);
/* Mark as read */
message_get_attribute
(
msg
,
&
attr
);
attribute_set_read
(
attr
);
cursor
=
mspec
->
msg_part
[
0
];
return
0
;
}
int
mail_visual
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
return
util_msglist_command
(
mail_visual
,
argc
,
argv
,
1
);
else
{
message_t
msg
=
NULL
;
attribute_t
attr
=
NULL
;
char
*
file
=
mu_tempname
(
NULL
);
util_do_command
(
"copy %s"
,
file
);
util_do_command
(
"shell %s %s"
,
getenv
(
"VISUAL"
),
file
);
remove
(
file
);
free
(
file
);
/* Mark as read */
mailbox_get_message
(
mbox
,
cursor
,
&
msg
);
message_get_attribute
(
msg
,
&
attr
);
attribute_set_read
(
attr
);
return
0
;
}
return
1
;
return
util_foreach_msg
(
argc
,
argv
,
MSG_NODELETED
,
visual0
,
NULL
);
}
...
...
mail/z.c
View file @
83fd9e4
...
...
@@ -31,7 +31,8 @@
*/
static
int
z_parse_args
(
int
argc
,
char
**
argv
,
unsigned
int
*
return_count
,
int
*
return_dir
)
z_parse_args
(
int
argc
,
char
**
argv
,
unsigned
int
*
return_count
,
int
*
return_dir
)
{
int
count
=
1
;
int
mul
=
1
;
...
...
@@ -109,38 +110,40 @@ mail_z (int argc, char **argv)
unsigned
int
pagelines
=
util_screen_lines
();
unsigned
int
count
;
int
dir
;
int
crs
;
if
(
z_parse_args
(
argc
,
argv
,
&
count
,
&
dir
))
return
1
;
nlines
=
pagelines
;
count
*=
pagelines
;
crs
=
cursor
;
switch
(
dir
)
{
case
D_BWD
:
if
(
c
ursor
<
nlines
)
if
(
c
rs
<
nlines
)
{
fprintf
(
stdout
,
_
(
"On first screenful of messages
\n
"
));
return
0
;
}
if
(
c
ursor
<
count
)
c
ursor
=
1
;
if
(
c
rs
<
count
)
c
rs
=
1
;
else
c
ursor
-=
count
;
c
rs
-=
count
;
break
;
case
D_FWD
:
if
(
c
ursor
+
pagelines
>
total
)
if
(
c
rs
+
pagelines
>
total
)
{
fprintf
(
stdout
,
_
(
"On last screenful of messages
\n
"
));
return
0
;
}
c
ursor
+=
count
;
c
rs
+=
count
;
if
(
c
ursor
+
nlines
>
total
)
nlines
=
total
-
c
ursor
+
1
;
if
(
c
rs
+
nlines
>
total
)
nlines
=
total
-
c
rs
+
1
;
if
(
nlines
<=
0
)
{
...
...
@@ -156,43 +159,43 @@ mail_z (int argc, char **argv)
of the last message. This behaviour is used on startup
when displaying the summary and the headers, new messages
are last but we want to display a screenful with the
real c
ursor
set by summary() to the new message. */
real c
rs
set by summary() to the new message. */
/* Find the start of the last screen page. */
int
lastpage
=
total
-
pagelines
+
1
;
if
(
lastpage
<=
0
)
lastpage
=
1
;
if
(
c
ursor
>
(
unsigned
int
)
lastpage
)
if
(
c
rs
>
(
unsigned
int
)
lastpage
)
{
realcursor
=
cursor
;
cursor
=
lastpage
;
if
(
cursor
+
nlines
>
total
)
nlines
=
total
-
cursor
+
1
;
for
(
i
=
0
;
i
<
nlines
;
i
++
)
{
mail_from0
(
cursor
,
0
);
cursor
++
;
}
cursor
=
realcursor
;
crs
=
lastpage
;
if
(
crs
+
nlines
>
total
)
nlines
=
total
-
crs
;
util_range_msg
(
crs
,
crs
+
nlines
,
MSG_NODELETED
|
MSG_SILENT
,
mail_from0
,
NULL
);
return
1
;
}
else
if
(
crs
+
nlines
>
total
)
nlines
=
total
-
crs
+
1
;
}
break
;
}
realcursor
=
cursor
;
cursor
=
crs
;
for
(
i
=
0
;
i
<
nlines
&&
cursor
<=
total
;
)
i
=
0
;
do
{
if
(
mail_from0
(
cursor
,
0
)
==
0
)
i
++
;
cursor
++
;
int
cnt
=
util_range_msg
(
crs
,
crs
+
nlines
-
1
,
MSG_NODELETED
|
MSG_SILENT
,
mail_from0
,
NULL
);
if
(
cnt
==
0
)
break
;
i
+=
cnt
;
crs
+=
nlines
;
}
cursor
=
realcursor
;
while
(
i
<
nlines
&&
crs
<=
total
);
return
1
;
}
...
...
Please
register
or
sign in
to post a comment