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
e781ed92
...
e781ed92ae27da6e5d400bfa3b4655ebfc849a6c
authored
2002-09-27 13:27:40 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Use mh_iterate(). Accept message specifications from the command line.
1 parent
d2572413
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
21 deletions
mh/scan.c
mh/scan.c
View file @
e781ed9
...
...
@@ -27,7 +27,7 @@
const
char
*
argp_program_version
=
"scan ("
PACKAGE_STRING
")"
;
static
char
doc
[]
=
"GNU MH scan"
;
static
char
args_doc
[]
=
""
;
static
char
args_doc
[]
=
"
[+folder] [msgs]
"
;
/* GNU options */
static
struct
argp_option
options
[]
=
{
...
...
@@ -68,8 +68,10 @@ static int header;
static
mh_format_t
format
;
void
list_message
(
mailbox_t
mbox
,
size_t
msgno
,
char
*
bp
,
size_t
width
);
int
scan
(
mailbox_t
mbox
);
static
mh_msgset_t
msgset
;
void
list_message
__P
((
mailbox_t
mbox
,
message_t
msg
,
size_t
num
,
void
*
data
));
int
scan
__P
((
mailbox_t
mbox
));
static
int
opt_handler
(
int
key
,
char
*
arg
,
void
*
unused
)
...
...
@@ -128,8 +130,11 @@ opt_handler (int key, char *arg, void *unused)
int
main
(
int
argc
,
char
**
argv
)
{
int
index
;
mailbox_t
mbox
;
mh_argp_parse
(
argc
,
argv
,
options
,
mh_option
,
args_doc
,
doc
,
opt_handler
,
NULL
,
NULL
);
opt_handler
,
NULL
,
&
index
);
if
(
mh_format_parse
(
format_str
,
&
format
))
{
...
...
@@ -137,7 +142,13 @@ main (int argc, char **argv)
exit
(
1
);
}
return
scan
(
mh_open_folder
(
current_folder
,
0
));
mbox
=
mh_open_folder
(
current_folder
,
0
);
mh_msgset_parse
(
mbox
,
&
msgset
,
argc
-
index
,
argv
+
index
,
"all"
);
if
(
reverse
)
mh_msgset_reverse
(
&
msgset
);
return
scan
(
mbox
);
}
#ifdef HAVE_TERMCAP_H
...
...
@@ -181,13 +192,18 @@ clear_screen ()
}
}
struct
list_data
{
char
*
buffer
;
size_t
width
;
};
int
scan
(
mailbox_t
mbox
)
{
size_t
i
,
total
;
char
*
buffer
;
struct
list_data
list_data
;
buffer
=
xmalloc
(
width
);
list_data
.
buffer
=
xmalloc
(
width
);
list_data
.
width
=
width
;
if
(
header
)
{
...
...
@@ -201,26 +217,19 @@ scan (mailbox_t mbox)
printf
(
"Folder %s %s
\n
"
,
url_to_string
(
url
),
datestr
);
}
m
ailbox_messages_count
(
mbox
,
&
total
);
m
h_iterate
(
mbox
,
&
msgset
,
list_message
,
&
list_data
);
if
(
reverse
)
for
(
i
=
total
;
i
>=
1
;
i
--
)
list_message
(
mbox
,
i
,
buffer
,
width
);
else
for
(
i
=
1
;
i
<=
total
;
i
++
)
list_message
(
mbox
,
i
,
buffer
,
width
);
clear_screen
();
mh_global_save_state
();
return
0
;
}
void
list_message
(
mailbox_t
mbox
,
size_t
msgno
,
char
*
buffer
,
size_t
width
)
list_message
(
mailbox_t
mbox
,
message_t
msg
,
size_t
num
,
void
*
data
)
{
message_t
msg
;
struct
list_data
*
ld
=
data
;
buffer
[
0
]
=
0
;
mailbox_get_message
(
mbox
,
msgno
,
&
msg
);
mh_format
(
&
format
,
msg
,
msgno
,
buffer
,
width
);
printf
(
"%s
\n
"
,
buffer
);
ld
->
buffer
[
0
]
=
0
;
mh_format
(
&
format
,
msg
,
num
,
ld
->
buffer
,
ld
->
width
);
printf
(
"%s
\n
"
,
ld
->
buffer
);
}
...
...
Please
register
or
sign in
to post a comment