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
bd9881d4
...
bd9881d4e9e2de1848ae4ed7357e491f803cf8b8
authored
2001-07-21 00:09:38 +0000
by
Jakob Kaivo
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
new file, implementation of elm messages command
1 parent
12d6c725
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
messages/messages.c
messages/messages.c
0 → 100644
View file @
bd9881d
#include "config.h"
#include <mailutils/mailutils.h>
#include <stdio.h>
#include <argp.h>
const
char
*
argp_program_version
=
"messages ("
PACKAGE
") "
VERSION
;
const
char
*
argp_program_bug_address
=
"<bug-mailutils@gnu.org>"
;
static
char
doc
[]
=
"GNU messages -- count the number of messages in a mailbox"
;
static
char
args_doc
[]
=
"[mailbox...]"
;
static
struct
argp_option
options
[]
=
{
{
0
}
};
struct
arguments
{
char
**
args
;
};
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
return
0
;
}
static
struct
argp
argp
=
{
options
,
parse_opt
,
args_doc
,
doc
};
int
main
(
int
argc
,
char
**
argv
)
{
int
i
=
1
;
list_t
bookie
;
mailbox_t
mbox
;
int
count
;
int
err
=
0
;
struct
arguments
args
;
args
.
args
=
NULL
;
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
args
);
registrar_get_list
(
&
bookie
);
list_append
(
bookie
,
path_record
);
/* FIXME: if argc < 2, check on $MAIL and exit */
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
mailbox_create_default
(
&
mbox
,
argv
[
i
])
!=
0
)
{
fprintf
(
stderr
,
"Couldn't create mailbox %s.
\n
"
,
argv
[
i
]);
err
=
1
;
continue
;
}
if
(
mailbox_open
(
mbox
,
MU_STREAM_READ
)
!=
0
)
{
fprintf
(
stderr
,
"Couldn't open mailbox %s.
\n
"
,
argv
[
i
]);
err
=
1
;
continue
;
}
if
(
mailbox_messages_count
(
mbox
,
&
count
)
!=
0
)
{
fprintf
(
stderr
,
"Couldn't count messages in %s.
\n
"
,
argv
[
i
]);
err
=
1
;
continue
;
}
printf
(
"Number of messages in %s: %d
\n
"
,
argv
[
i
],
count
);
if
(
mailbox_close
(
mbox
)
!=
0
)
{
fprintf
(
stderr
,
"Couldn't close %s.
\n
"
,
argv
[
i
]);
err
=
1
;
continue
;
}
mailbox_destroy
(
&
mbox
);
}
return
0
;
}
Please
register
or
sign in
to post a comment