Commit 25db453e 25db453e96894f1f8c7320ec49a8213b9a2cdd1f by Alain Magloire

* doc/texinfo/programs.texi: Descibe the readmsg utility.

	* configure.in: Enable readmsg.
	* Makefile.in: Enable readmsg.
	* readmsg/readmsg.c: Implementation.
	* readmsg/msglist.c: Implement Elm weird expansion.
1 parent 89287b76
2001-12-31 Alain Magloire
* doc/texinfo/programs.texi: Descibe the readmsg utility.
* configure.in: Enable readmsg.
* Makefile.in: Enable readmsg.
* readmsg/readmsg.c: Implementation.
* readmsg/msglist.c: Implement Elm weird expansion.
2001-12-29 Sergey Poznyakoff
* guimb/scm/numaddr.scm: (new) Implements "numaddr" extension
......@@ -5,7 +13,7 @@
that contain addresses. It returns true if the total number of
addresses satisfies the requested relation, e.g.:
if numaddr :over [ "To", "Cc" ] 50 { discard; }
* guimb/scm/Makefile.am: Added numaddr.scm.
* guimb/scm/redirect.scm: Use mu-message-send instead of
sieve-message-bounce.
......
......@@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu 1.4
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = include doc m4 lib MySql argp mailbox frm from pop3d imap4d mail sieve \
scripts libmu_scm guimb messages comsat
scripts libmu_scm guimb messages comsat readmsg
EXTRA_DIST = mailutils.spec mailutils.spec.in README-alpha COPYING.FDL
......
......@@ -140,7 +140,7 @@ AC_FUNC_FNMATCH
if test "$ac_cv_func_fnmatch_works" = "no"; then
: LIBOBJS="$LIBOBJS fnmatch.o"
fi
AC_REPLACE_FUNCS(fgetpwent setenv snprintf strtok_r strncasecmp strcasecmp \
AC_REPLACE_FUNCS(fgetpwent getpass setenv snprintf strtok_r strncasecmp strcasecmp \
strsignal vasprintf)
AC_CHECK_FUNCS(mkstemp sigaction sysconf getdelim vsyslog)
......@@ -307,4 +307,5 @@ AC_OUTPUT(Makefile mailutils.spec include/Makefile include/mailutils/Makefile
mailbox/include/Makefile from/Makefile mail/Makefile pop3d/Makefile
frm/Makefile sieve/Makefile messages/Makefile scripts/Makefile
libmu_scm/Makefile guimb/Makefile guimb/scm/Makefile
readmsg/Makefile
MySql/Makefile mh/Makefile comsat/Makefile)
......
......@@ -3,7 +3,7 @@
@c See file mailutils.texi for copying conditions.
@comment *******************************************************************
GNU Mailutils provides a set of programs for handling the email.
GNU Mailutils provides a set of programs for handling the email.
@menu
* imap4d:: IMAP4 daemon.
......@@ -54,7 +54,7 @@ it defaults to 20 processes.
Display short help message and exit.
@item -i
@itemx --inetd
Run in inetd mode.
Run in inetd mode.
@item -p NUMBER
@itemx --port NUMBER
Listen on given port NUMBER. This option is meaningful only in
......@@ -108,7 +108,7 @@ it defaults to 10 processes.
Display short help message and exit.
@item -i
@itemx --inetd
Run in inetd mode.
Run in inetd mode.
@item -p NUMBER
@itemx --port NUMBER
Listen on given port NUMBER. This option is meaningful only in
......@@ -395,7 +395,7 @@ are single-character commands, preceded by special @dfn{escape character},
which defaults to @samp{~}. The combination @code{escape character + command}
is recognized as a compose escape only if it occurs at the beginning of
a line. If the escape character must appear at the beginning of a
line, enter it twice.
line, enter it twice.
The actual escape character may be changed by setting the value of
@code{escape} mail variable (@pxref{Mail Variables}).
......@@ -476,7 +476,7 @@ To change the @code{Subject} header, use @samp{~s} escape, e.g.:
Finally, to edit all headers, type @samp{~h} escape. This will present
you with the values of @code{To}, @code{Cc}, @code{Bcc}, and
@code{Subject} headers allowing to edit them with normal text editing
commands.
commands.
@node Enclosing Another Message
@subsubsection Enclosing Another Message: ~m and ~M
......@@ -668,7 +668,7 @@ Following commands can be used during the session to request online
help:
@table @samp
@item help [@var{command}]
@item help [@var{command}]
@itemx hel [@var{command}]
@itemx ? [@var{command}]
Display detailed command synopsis. If no @var{command} is given, help for
......@@ -815,7 +815,7 @@ out specified message parts. E.g.
@example
& decode 15[2]
+---------------------------------------
| Message=15[2]
| Message=15[2]
| Type=message/delivery-status
| encoding=7bit
+---------------------------------------
......@@ -1044,7 +1044,7 @@ unset prompt
endif
if s
alt gray@@farlep.net gray@@mirddin.farlep.net
set
set
@end example
@node Aliasing
......@@ -1225,7 +1225,7 @@ denoting escapes.
The name of the directory to use for storing folders of messages. If
unset, $HOME is assumed.
@item header
@*Type: Boolean.
@*Default: True, unless started with @samp{--nosum} (@samp{-N}) option.
......@@ -1444,7 +1444,71 @@ Output program version and exit.
@section readmsg --- Extract messages from a folder.
@pindex readmsg
The program is currently in development
The program, readmsg, extracts with the selection argument messages from
a mailbox. Selection can be specify by:
@enumerate
@item
A lone ``*'' means select all messages in the mailbox.
@item
A list of message numbers may be specified. Values
of ``0'' and ``$'' in the list both mean the last
message in the mailbox. For example:
@example
readmsg 1 3 0
@end example
extracts three messages from the folder: the first, the third, and the last.
@item
Finally, the selection may be some text to match. This will select a mail
message which exactly matches the specified text. For example,
@example
readmsg staff meeting
@end example
extracts the message which contains the words ``staff meeting.'' Note that it
will not match a message containing ``Staff Meeting'' - the matching is case
sensitive. Normally only the first message which matches the pattern will be
printed.
@end enumerate
@subheading Command line options
@table @samp
@item -a
@itemx --show-all
If a pattern is use for selection show all messages that match pattern
by default only the first one is presented.
@item -d
@itemx --debug
Display mailbox debuging information.
@item -f @var{MAILBOX}
@itemx --folder=@var{MAILBOX}
Specified the default mailbox.
@item -h
@itemx --header
Show the entire header and ignore the weedlist.
@item -n
@itemx --no-header
Do not print the message header.
@item -p
@itemx --form-feed
Put form-feed (Control-L) between messages instead of newline.
@item -w @var{weedlist}
@itemx --weedlist=@var{weedlist}
A whitespace or coma separated list of header names to show per message.
Default is --weedlist=''From Subject Date To CC Apparently-''
@end table
@page
@node sieve
......@@ -1467,7 +1531,7 @@ format.
* Specifying Scheme Program to Execute::
* Specifying Mailboxes to Operate Upon::
* Passing Options to Scheme::
* Guimb Invocation Summary::
* Guimb Invocation Summary::
* Scheme Procedures and Variables::
@end menu
......@@ -1816,7 +1880,7 @@ The server is started from @file{/etc/inetd.conf} file:
@example
comsat dgram udp wait root /usr/sbin/comsatd \
comsatd -c /etc/comsat.conf
comsatd -c /etc/comsat.conf
@end example
This is the default operation mode.
......@@ -1868,7 +1932,7 @@ it is enabled.
@subsubsection Security Settings
These statements control the way @file{comsatd} fights possible
flooding attacks.
flooding attacks.
@table @asis
@item max-requests @var{number}
......@@ -1886,7 +1950,7 @@ within @var{number} seconds, the overflow-delay-time is doubled.
@subsubsection Access Control Lists
Access control lists determine from which addresses @file{comsatd}
will receive mail notification messages.
will receive mail notification messages.
The access control lists are introduced in configuration file using
keyword @samp{acl}. General format for an ACL rule is
......
......@@ -37,74 +37,104 @@ addset (int **set, int *n, unsigned val)
return 0;
}
static int
isnumber (const char *s)
{
int is_number = 1;
if (*s == '\0')
is_number = 0;
for (; *s; s++)
{
if (!isdigit ((unsigned char)*s))
{
is_number = 0;
break;
}
}
return is_number;
}
/*
According to ELM readmsg(1):
1. A lone ``*'' means select all messages in the mailbox.
2. A list of message numbers may be specified. Values of ``0'' and ``$'' in the
list both mean the last message in the mailbox. For example:
readmsg 1 3 0
extracts three messages from the folder: the first, the third, and the last.
3. Finally, the selection may be some text to match. This will select a mail
message which exactly matches the specified text. For example,
readmsg staff meeting
extracts the message which contains the words ``staff meeting.'' Note that it
will not match a message containing ``Staff Meeting'' - the matching is case
sensitive. Normally only the first message which matches the pattern will be
printed. The -a option discussed in a moment changes this.
*/
int
msgset (const int argc, char **argv, int **set, int *n)
msglist (mailbox_t mbox, int show_all, int argc, char **argv, int **set, int *n)
{
int i = 0, lc = 0;
int undelete = 0;
int *ret = NULL;
int i = 0;
size_t total = 0;
mailbox_messages_count (mbox, &total);
for (i = 0; i < argc; i++)
{
/* Last message */
if (!strcmp (argv[i], "$") || !strcmp (argv[i], "0"))
/* 1. A lone ``*'' means select all messages in the mailbox. */
if (!strcmp (argv[i], "*"))
{
addset (set, n, total);
size_t j;
/* all messages */
for (j = 1; j <= total; j++)
addset (set, n, j);
j = argc + 1;
}
else if (!strcmp (argv[i], "*"))
/* 2. A list of message numbers may be specified. Values of ``0'' and ``$'' in the
list both mean the last message in the mailbox. */
else if (!strcmp (argv[i], "$") || !strcmp (argv[i], "0"))
{
/* all messages */
for (i = 1; i <= total; i++)
addset (set, n, i);
i = argc + 1;
size_t j;
mailbox_messages_count (mbox, &total);
for (j = 1; j < total; j++)
addset (set, n, j);
}
else if (argv[i][0] == '/')
/* 3. Finally, the selection may be some text to match. This will select a mail
message which exactly matches the specified text. */
else if (!isnumber(argv[i]))
{
/* FIXME: all messages with pattern following / in
the subject line, case insensitive */
/* This currently appears to be quit b0rked */
message_t msg;
header_t hdr;
char subj[128];
int j = 1, k = 0, len2 = 0;
int len = strlen (&argv[i][1]);
size_t j;
int found = 0;
for (j = 1; j <= total; j++)
{
char buf[128];
size_t len = 0;
off_t offset = 0;
message_t msg = NULL;
stream_t stream = NULL;
mailbox_get_message (mbox, j, &msg);
message_get_header (msg, &hdr);
header_get_value (hdr, MU_HEADER_SUBJECT, subj, 128, NULL);
len2 = strlen (subj);
for (k = 0; i < strlen (subj); k++)
message_get_stream (msg, &stream);
while (stream_readline (stream, buf, sizeof buf, offset, &len) == 0 && len > 0)
{
if (len2 - k >= len
&& !strncasecmp (&argv[i][1], &subj[k], len))
if (strstr (buf, argv[i]) != NULL)
{
addset (set, n, j);
k = 128;
found = 1;
break;
}
offset += len;
}
if (found && !show_all)
break;
}
}
else if (isalpha(argv[i][0]))
{
/* FIXME: all messages from sender argv[i] */
}
else if (strchr (argv[i], '-') != NULL)
{
/* message range */
int j, x, y;
char *arg = strdup (argv[i]);
for (j = 0; j < strlen (arg); j++)
if (arg[j] == '-')
break;
arg[j] = '\0';
x = strtol (arg, NULL, 10);
y = strtol (&(arg[j + 1]), NULL, 10);
for (; x <= y; x++)
addset (set, n, x);
free (arg);
}
else
else if (isdigit (argv[i][0]))
{
/* single message */
addset (set, n, strtol (argv[i], NULL, 10));
......
......@@ -22,9 +22,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <getopt.h>
#include <mailutils/mailbox.h>
#include <mailutils/header.h>
......@@ -32,7 +34,13 @@
#include <mailutils/filter.h>
#include <mailutils/registrar.h>
extern mailbox_t mbox;
extern size_t total;
#ifndef __P
#ifdef __STDC__
#define __P(args) args
#else
#define __P(args) ()
#endif
#endif /*__P */
int msglist __P ((mailbox_t mbox, int show_all, int argc, char **argv, int **set, int *n));
#endif
......