Compare commits

...

46 Commits

Author SHA1 Message Date
b93a60572b
Remove an obsolete macro. 2024-09-28 12:36:22 +02:00
1938d25ced
Update the copyright statement. 2024-09-28 12:35:18 +02:00
7b7bafd5f8
Re-arrange the TODO list for readability. 2024-09-27 23:42:13 +02:00
eec14b33ff
Fix a typo. 2024-09-27 23:41:15 +02:00
fdab5e8c5e
Automake settings
Omit the contrib subdirectory from the distribution tarball.
2024-09-27 11:11:11 +02:00
66dd5fed23
Git settings
- Clean up the .gitignore file.
- Treat Info pages as binary files.
2024-09-27 10:46:40 +02:00
4cb77488bc
Bump the version to 0.7.13. 2024-09-23 21:34:04 +02:00
6f8e688a46
Merge branch 'master' of github.com:dspiljar/mboxgrep 2024-09-23 16:04:20 +02:00
d8f44235f5
Fix Automake to include AUTHORS.md. 2024-09-23 14:37:53 +02:00
6e9600426a
Minor update to the man and info pages
Sync the examples section, refer to RFC 4155 for the mbox mailbox
format, and add URLs to Gitea and Github.
2024-09-23 13:15:05 +02:00
b4d3034c8c
Minor update to the man and info pages
Sync the examples section, refer to RFC 4155 for the mbox mailbox
format, and add URLs to Gitea and Github.
2024-09-23 12:59:51 +02:00
9515236244
Merge branch 'mbox_cleanup' 2024-09-20 23:43:29 +02:00
a790494133
Code refactoring
Refactor of mbox_open(). Checking for a "postmark" line, i.e. whether
the file is an mbox mailbox, has been moved to mbox_check_postmark().
2024-09-20 22:18:30 +02:00
ec8062309d
Readability of the news file
Headings in the news file now refer to changes in the current version,
as opposed to changes since the last version.
2024-09-20 13:48:55 +02:00
631998a849
Code refactoring
Partial refactor of mbox_open(). Opening of file descripts has been
moved to mbox_fdopen().
2024-09-20 13:11:06 +02:00
bd64536e89
Function prototype
Use an enum type instead of a string to define the file opening mode.
2024-09-19 22:40:20 +02:00
b30f2f2362
Suppress "Not an mbox folder" error messages on empty files. 2024-09-19 00:24:21 +02:00
1a63374e73
Move file locking code to a separate function.
Failure to lock a file is now fatal.
2024-09-18 23:48:21 +02:00
efc6f92cdb
Update the TODO list. 2024-09-13 15:54:50 +02:00
191b24433f
Mention the contributors and convert to Markdown. 2024-09-11 18:07:50 +02:00
40b6f8799f
Merge branch 'giachello-master' 2024-09-11 13:47:18 +02:00
Giovanni Iachello
13bf23b9a2 fix autoconf on Windows 2024-09-10 22:39:39 -07:00
c732d4f949
Phrasing
Clarify that the parameter to the "-o" switch is a MAILBOX instead of a
FOLDER (which could be confused with an ordinary filesystem folder).

Added per Roman Nezval's comment.
2023-12-29 00:59:25 +01:00
7255fae5d0
Bump the version to 0.7.12a. 2023-05-21 15:09:44 +02:00
03407c7afb
Correction of Automake macros
Fix Automake macros to include the license file and other files and
directories in the distribution tarball.
2023-05-21 12:05:18 +02:00
dd5fefe22d
Update the TODO list and bump the version to 0.7.12. 2023-05-20 20:34:23 +02:00
cbba5c2a33
Remove config.h.in from the git repo, as it is autogenerated. 2023-05-20 20:09:23 +02:00
27082f9629
Minor updates of the documentation. 2023-05-18 13:43:09 +02:00
d17f37b3c5
Include the contrib subdirectory in the distribution tarball. 2023-05-18 13:35:35 +02:00
e004f116b7
Merge branch 'pcre2-port' 2023-05-17 19:40:41 +02:00
e5409a897d
Port to the pcre2 library. 2023-05-17 17:58:59 +02:00
55aa25eca3
Add migration from pcre to pcre2 to the TODO list. 2023-05-08 22:54:58 +02:00
7ebef4a322
Fix a compile error caused by an extra curly bracket. 2023-04-22 17:36:28 +02:00
d04349e9b4
Minor code cleanup and fix a compilation warning. 2023-04-19 23:04:57 +02:00
c19253d080
Check command-line options for conflicting matchers and actions. 2023-04-19 21:55:25 +02:00
3040f9c363
Fix Automake macros. Remove autogenerated files from the git repo. 2023-03-28 00:59:16 +02:00
033063befc
Version bump to 0.7.11. 2023-03-24 15:18:53 +01:00
7720415afa
Updates to the news and installation instructions. 2023-03-24 15:00:06 +01:00
68c0ddee91
Merge branch 'automake' 2023-03-24 14:10:14 +01:00
53d3381cd4
Merge branch 'automake' of git.datatipp.se:dspiljar/mboxgrep into automake 2023-03-24 13:50:10 +01:00
c02deefbd5
Utilize GNU Automake instead of manually written Makefile.in files. 2023-03-24 13:47:16 +01:00
b7006b77b5
Utilize GNU Automake instead of manually written Makefile.in files. 2023-03-23 22:10:04 +01:00
43e7695eac
Update the basic documentation. 2023-03-08 15:19:20 +01:00
844dc84974
Ignore backup files. 2023-03-07 16:54:41 +01:00
ee2489483b
Code cleanup and indentation.
C source files (with the exception of third-party files, i.e. getopt and
md5) have been indented with GNU indent.

The indentation "standard" has been documented in the readme file.
2023-03-07 16:51:33 +01:00
882a38f908
Refinement of the TODO list. 2023-03-01 20:53:15 +01:00
42 changed files with 13051 additions and 6728 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.info binary

15
.gitignore vendored
View File

@ -1,6 +1,21 @@
Makefile
config.h
config.h.in
config.log
config.status
src/*.o
src/*.exe
src/mboxgrep
src/.deps/
src/stamp-h1
aclocal.m4
autom4te.cache/
Makefile.in
configure
compile
depcomp
install-sh
missing
.gitignore
.vscode/*
*~

View File

@ -1,5 +0,0 @@
-*- text -*-
mboxgrep is written and maintained by Daniel Spiljar.
$Id: AUTHORS,v 1.3 2005-11-16 01:37:18 dspiljar Exp $

1
AUTHORS.md Normal file
View File

@ -0,0 +1 @@
mboxgrep is written and maintained by Daniel Spiljar with contributors.

View File

26
INSTALL.md Normal file
View File

@ -0,0 +1,26 @@
# Compilation and installation of mboxgrep
`mboxgrep` should compile on a modern Unix-like operating system, such as GNU/Linux or FreeBSD.
Autoconf and Automake are used, and the most basic compilation procedure consists of:
```
autoreconf --install
./configure
make
make install # root rights probably needed here, prefix with sudo in such case
```
(Invocation of `autoreconf` is only required if the source tree has been cloned from the
git repository.)
To see the list of flags accepted by the configure script, run:
```
./configure --help
```
Optionally, `mboxgrep` can be linked with the following libraries:
- PCRE2, to enable support for regular expressions compatible with Perl 5;
- zlib and bzlib, to enable support for compressed mbox folders.

2
Makefile.am Normal file
View File

@ -0,0 +1,2 @@
SUBDIRS = doc src
EXTRA_DIST = COPYING.md INSTALL.md NEWS.md README.md TODO.md AUTHORS.md

View File

@ -1,37 +0,0 @@
# mboxgrep - scan mailbox for messages matching a regular expression
# Copyright (C) 2000, 01 Daniel Spiljar
#
# Mboxgrep is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Mboxgrep is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mboxgrep; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id: Makefile.in,v 1.1 2001-10-26 13:07:28 dspiljar Exp $
SHELL = /bin/sh
all:
cd src; $(MAKE)
clean:
cd src; $(MAKE) clean
distclean:
rm -f *~ Makefile config.status config.log config.cache
cd src; $(MAKE) distclean
cd doc; $(MAKE) distclean
install:
cd src; $(MAKE) install
cd doc; $(MAKE) install
.NOEXPORT:

60
NEWS.md
View File

@ -1,6 +1,28 @@
# Changes of mboxgrep
## Changes since 0.7.9
## Changes in 0.7.13
- Improve the readability of this file.
- Failure to lock a file (mbox) is now a fatal error.
- Fix Autoconf on Windows.
- Code refactoring, mostly of mbox-related functions.
## Changes in 0.7.12a
- Fix Automake macros to include the license file and others.
## Changes in 0.7.12
- Port to the pcre2 library (pcre1 is no longer supported).
- Check command-line options for conflicting matchers and actions.
- Various minor code cleanups.
## Changes in 0.7.11
- GNU Automake is now utilized instead of manually written Makefile.in files.
- Code indentation has been corrected and documented (GNU indent is used for this purpose).
## Changes in 0.7.10
- development has been restarted after a longer hiatus
- moved the source tree to git
@ -9,7 +31,7 @@
- fixed multiple compilation errors and warnings on Linux and FreeBSD
- started implementing a debug mode
## Changes since 0.7.8
## Changes in 0.7.9
- implemented support for mbox folders compressed with bzip2 algorithm
- improved detection of PCRE library; this also fixes a compilation bug
@ -18,7 +40,7 @@
folder and temporary directory were on different filesystems;
thanks to James P. Dugal <jpd AT louisiana.edu> for providing a patch
## Changes since 0.7.7
## Changes in 0.7.8
- fixed crashes on MH folders, as well as a potential problem with mbox
and maildir folders with the same cause
@ -27,46 +49,46 @@
- mboxgrep can now read gzip compressed mbox folders from standard input
(which is a side effect of a code cleanup!)
## Changes since 0.7.6a
## Changes in 0.7.7
- mboxgrep can now read mbox folders from standard input
## Changes since 0.7.6
## Changes in 0.7.6a
- fixed a bug which prevented mboxgrep from being compiled
## Changes since 0.7.5
## Changes in 0.7.6
- fixed a bug which caused mboxgrep to coredump on recursive search of
maildirs
- code cleanups
## Changes since 0.7.4
## Changes in 0.7.5
- recursive search through directories has been reimplemented
## Changes since 0.7.3
## Changes in 0.7.4
- mboxgrep can now ignore messages with identical bodies
## Changes since 0.7.2
## Changes in 0.7.3
- file locking method can be selected at runtime
- mboxgrep used to coredump on messages with empty headers; the problem is
now hopefully fixed
- mboxgrep now compiles on FreeBSD
## Changes since 0.7.1
## Changes in 0.7.2
- file locking with `flock()` instead of `fcntl()` is now supported
- mboxgrep should now compile on systems which don't have `getopt_long()`
- other minor bugfixes
## Changes since 0.7.0
## Changes in 0.7.1
- bugfixes
## Changes since 0.5.3
## Changes in 0.7.0
- NOTE: there was no stable version between 0.5.x and 0.7.x
- mboxgrep is almost completely rewritten
@ -76,7 +98,7 @@
command)
- added support for compressed mbox folders
## Changes since 0.5.2
## Changes in 0.5.3
- implemented ability to write found messages to another folder (instead
of standard output)
@ -84,7 +106,7 @@
"NEWS")
- wrote a manual in Texinfo format
## Changes since 0.5.1
## Changes in 0.5.2
- implemented message counting (`-c, --count`)
- fixed manual page installation target in src/Makefile.in -- manual page
@ -97,17 +119,17 @@
- implemented recursive search through directories (`-r, --recursive`)
- config.h[.in] is now wrapped (`#ifndef CONFIG_H` and stuff)
## Changes since 0.5.0
## Changes in 0.5.1
- added support for qmail-style maildir folders
## Changes since 0.4.0
## Changes in 0.5.0
- the source of `getopt_long()` is now included, so long options are also available
on platforms that don't use GNU libc
- file locking is now performed on mbox folders only
## Changes since 0.2.0
## Changes in 0.4.0
- added support for MH mailboxes
- added scope selection switches `-B` (or `--body`) and `-H` (or `--headers`)
@ -118,12 +140,12 @@
- the feature of reading from standard input is gone
- added `-v` (or `--version`) switch
## Changes since 0.1.1
## Changes in 0.2.0
- mboxgrep now puts a shared lock on a mailbox before reading it
- various code cleanups
## Changes since 0.1.0
## Changes in 0.1.1
- fixed install target in Makefile (`install` is now used instead of `cp`)
- added support for mailboxes generated by Gnus

View File

@ -1,4 +1,7 @@
mboxgrep - displays e-mail messages matching a pattern
# mboxgrep - selects e-mail messages matching a pattern
`mboxgrep` is a `grep(1)`-like tool which scans mailboxes and selects
e-mail messages matching a pattern.
Full description of mboxgrep is contained in the documentation,
which is provided both in manpage and texinfo format, to satisfy
@ -11,5 +14,8 @@ are welcome.
If you intend to bundle mboxgrep with an operating system (such as a
GNU/Linux distrubution, for example), please drop me a line about it.
For build instructions, read the file "INSTALL", and run
For build instructions, read the file `INSTALL.md`, and run
`./configure --help`.
This project aims to follow the [GNU coding style](https://www.gnu.org/prep/standards/html_node/Formatting.html),
at least loosely. The code should be indented with `indent -gnu -nut -ppi2`.

20
TODO.md
View File

@ -3,33 +3,39 @@
## Behavior
- [x] use cryptographic hashes for detecting duplicate messages
- [ ] add checking for conflicting command-line options
- [ ] support for deletion of messages after being matched and displayed
- [x] add checking for conflicting command-line options
- [x] ignore .overview when grepping Gnus folders
- [x] inverted matching
- [x] recursive search through directories
- [x] writing selected messages to a new folder
- [x] deleting selected messages
- [ ] literal date matching
- [x] reading messages from standard input
- [x] run-time selection of file locking method
- [x] add a debug function
- [ ] support for deletion of messages after being matched and displayed
- [ ] basic time and date matching
- [ ] more advanced time and date matching, with strings such as "yesterday"
- [ ] Remove the option to recursively traverse directories and instruct the users to run mboxgrep in conjuction with find(1) instead.
## File formats, encodings and standards
- [ ] MIME support
- [ ] support for GnuPG
- [x] migrate to pcre2, as pcre is obsolete
- [x] support for compressed mbox folders
- [x] support for bzip2 compression
- [ ] use a more modern hash function than MD5
- [ ] MIME support
- [ ] support for GnuPG
- [ ] support for XZ-format compression
- [ ] support for mail folder conversion
- [ ] use a more modern hash function than MD5
- [ ] improve error detection when a directory is not a Maildir or MH folder
- [ ] document criteria for folder format detection
- [ ] Maildir: check if an atomic rename() fails. This could be caused if "new" and "cur" subdirectories are not on the same filesystem, for example.
## Miscellaneous
- [x] write Texinfo documentation
- [x] provide possibility to use flock() instead of fcntl()
- [ ] configuration files
- [ ] make use of lockfile library
- [ ] make use of Solaris' maillock library
- [x] provide possibility to use flock() instead of fcntl()
- [ ] provide national language support with gettext()

5274
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
# mboxgrep - scan mailbox for messages matching a regular expression
# Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
# Copyright (C) 2000 - 2003, 2023 - 2024 Daniel Spiljar
#
# Mboxgrep is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -15,53 +15,52 @@
# along with mboxgrep; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id: configure.ac,v 1.13 2003-08-10 22:45:45 dspiljar Exp $
# Process this file with autoconf to produce a configure script.
# Yawn.
AC_INIT
AC_LANG(C)
AC_CONFIG_HEADER([src/config.h])
AC_INIT([mboxgrep],[0.7.13],[dspiljar@datatipp.se],[mboxgrep],[https://www.mboxgrep.org/])
#AM_INIT_AUTOMAKE
AM_INIT_AUTOMAKE([foreign])
AC_LANG([C])
AC_CONFIG_HEADERS([src/config.h])
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
# Checks for standard (sp?) header files
AC_HEADER_STDC
AC_HEADER_DIRENT
# Checks for libraries.
# Check for PCRE library
AC_ARG_WITH(pcre, [ --without-pcre Compile without Perl regexp support],,
# Check for PCRE2 library
AC_ARG_WITH(pcre2, [ --without-pcre2 Compile without Perl regexp support],,
[
AC_PATH_PROG(PCRE_CONFIG, pcre-config)
AC_PATH_PROG(PCRE2_CONFIG, pcre2-config)
if test "$PCRE_CONFIG"; then
CFLAGS="$CFLAGS `$PCRE_CONFIG --cflags`"
LIBS="$LIBS `$PCRE_CONFIG --libs`"
if test "$PCRE2_CONFIG"; then
CFLAGS="$CFLAGS `$PCRE2_CONFIG --cflags`"
LIBS="$LIBS `$PCRE2_CONFIG --libs32`"
AC_LINK_IFELSE(
[
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 32
#include <pcre2.h>
int main ()
{
return 0;
}
],
AC_DEFINE(HAVE_LIBPCRE),
AC_DEFINE(HAVE_LIBPCRE2),
[
AC_MSG_NOTICE(found pcre-config but could not compile test program.)
AC_MSG_FAILURE(is PCRE properly installed?)
AC_MSG_NOTICE(found pcre2-config but could not compile test program.)
AC_MSG_FAILURE(is PCRE2 properly installed?)
]
)
else
AC_MSG_NOTICE(pcre-config not found)
AC_MSG_NOTICE(trying to find PCRE anyway)
AC_CHECK_LIB(pcre, main)
AC_MSG_NOTICE(pcre2-config not found)
AC_MSG_NOTICE(trying to find PCRE2 anyway)
AC_CHECK_LIB(pcre2, main)
fi
]
)
@ -92,7 +91,5 @@ AC_CHECK_FUNCS([strptime])
AC_CHECK_FUNCS(ftw)
AC_CHECK_FUNCS(fts_open)
AC_CONFIG_FILES([Makefile
doc/Makefile
src/Makefile])
AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile])
AC_OUTPUT

2
doc/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
dist_man_MANS = mboxgrep.1
info_TEXINFOS = mboxgrep.texi

View File

@ -1,41 +0,0 @@
# mboxgrep - search mailbox for messages matching a regular expression
# Copyright (C) 2000, 01 Daniel Spiljar
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id: Makefile.in,v 1.1 2001-10-26 13:07:55 dspiljar Exp $
MANPAGE = mboxgrep.1
INSTALL = @INSTALL@
prefix = @prefix@
mandir = @mandir@
infodir = @infodir@
SHELL = /bin/sh
.PHONY: all
all:
.PHONY: distclean
distclean:
rm -f *~ Makefile
.PHONY: install
install: mboxgrep.1
$(INSTALL) -d $(mandir)/man1
$(INSTALL) -m 0644 $(MANPAGE) $(mandir)/man1
$(INSTALL) -d $(infodir)
$(INSTALL) -m 0644 mboxgrep.info $(infodir)
.NOEXPORT:

View File

@ -1,4 +1,4 @@
.TH MBOXGREP 1 "17 Feb 2023"
.TH MBOXGREP 1 "27 September 2024"
.SH NAME
mboxgrep \- displays email messages matching a pattern
.SH SYNOPSIS
@ -10,7 +10,7 @@ mboxgrep \- displays email messages matching a pattern
This manual page refers to
.B mboxgrep
version
.BR 0.7.10 .
.BR 0.7.13 .
.PP
.B mboxgrep
scans a
@ -18,7 +18,7 @@ scans a
and displays messages matching
.I PATTERN.
.PP
If a mailbox name is ommited, or a single dash (-) is given instead,
If a mailbox name is omitted, or a single dash (-) is given instead,
it reads from standard input.
It can read mbox folders or output from another
.B mboxgrep
@ -72,8 +72,8 @@ Do not lock files. This option is meaningful only if a mbox folder (see below)
is scanned.
.IP "-c, --count"
Suppress normal output and print a count of matching messages.
.IP "-o, --output=FOLDER"
Suppress normal output and write messages to destination folder FOLDER instead.
.IP "-o, --output=MAILBOX"
Suppress normal output and write messages to destination MAILBOX instead.
.IP "-p, --pipe=COMMAND"
Pipe each found message to COMMAND
.IP "-d, --delete"
@ -97,10 +97,26 @@ Search $MAIL for messages from Dirty Harry:
mboxgrep '^From:.*callahan@sanfranciscopolice\\.org' $MAIL
.TP
\(bu
Re-mail to George messages that mention his name:
.PP
mboxgrep --pipe="/usr/lib/sendmail george" --ignore-case george ~/Mail/*
.TP
\(bu
Display all messages contained in folder ~/Mail/incoming, except those
that appear to originate from AOL:
.PP
mboxgrep -v 'Received:.*aol\\.com' ~/Mail/incoming
.TP
\(bu
Do a case-insensitive scan of ~/Mail/incoming for messages with subject
``Weekly News'' and write them to folder ~/Mail/archive:
.PP
mboxgrep -o ~/Mail/archive -H -i '^Subject: Weekly News' ~/Mail/incoming
.TP
\(bu
Count all messages stored in folder spam, ignoring duplicates:
.PP
mboxgrep -nd -c . spam
.SH BUGS
Report them to address below.
.SH SEE ALSO
@ -108,7 +124,8 @@ grep(1),
regex(7),
perlre(1),
mbox(5),
RFC 2822
RFC 2822,
RFC 4155
.SH DEDICATION
Mboxgrep is dedicated in loving memory of Vicky, my cat who died of
tumor on Sep 12, 2002.
@ -116,7 +133,11 @@ tumor on Sep 12, 2002.
You haven't been long with us, but you gave us a lot of joy and all your
big heart that stopped ticking too early. I will never forget you. Sleep
well, little friend.
.SH URL
http://www.mboxgrep.org/
.SH HOMEPAGE
https://www.mboxgrep.org/
.SH GIT
https://git.datatipp.se/dspiljar/mboxgrep
.PP
https://github.com/dspiljar/mboxgrep
.SH AUTHOR
Daniel Spiljar <dspiljar AT datatipp.se>
Daniel Spiljar <dspiljar@datatipp.se>

Binary file not shown.

View File

@ -5,8 +5,8 @@
@setchapternewpage odd
@set EDITION 0.7
@set VERSION 0.7.10
@set UPDATED 17 Feb 2023
@set VERSION 0.7.13
@set UPDATED 23 September 2024
@dircategory Mail
@direntry
@ -19,7 +19,7 @@
This file documents @code{mboxgrep} (version @value{VERSION}), a
mailbox scanning utility.
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Copyright (C) 2000 - 2003, 2024 Daniel Spiljar
@end ifinfo
@menu
@ -171,10 +171,9 @@ Use with extreme caution.
@itemx -nd
Ignore duplicate messages.
@item --output=FOLDER
@itemx -o FOLDER
Suppress normal output and write messages to destination folder FOLDER
instead.
@item --output=MAILBOX
@itemx -o MAILBOX
Suppress normal output and write messages to destination MAILBOX instead.
Note that @code{mboxgrep} assumes the output folder is of the same format
as the input folder. Currently there is no possibility to convert folders.

11772
doc/texinfo.tex Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,251 +0,0 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

6
src/Makefile.am Normal file
View File

@ -0,0 +1,6 @@
bin_PROGRAMS = mboxgrep
mboxgrep_SOURCES = info.c info.h maildir.c maildir.h main.c mbox.c mbox.h \
mboxgrep.h md5.c md5.h message.h misc.c misc.h mh.c mh.h \
getopt.c getopt1.c getopt.h re.c re.h scan.c scan.h wrap.c wrap.h
mboxgrep_LDADD = $(LIBOBJS)

View File

@ -1,57 +0,0 @@
# mboxgrep - scan mailbox for messages matching a regular expression
# Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
#
# Mboxgrep is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Mboxgrep is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mboxgrep; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# $Id: Makefile.in,v 1.12 2006-07-07 04:38:53 dspiljar Exp $
srcdir = @srcdir@
CC = @CC@
OBJS = info.o main.o mh.o scan.o maildir.o mbox.o misc.o \
wrap.o getopt.o getopt1.o md5.o re.o
SRCS = info.c main.c mh.c scan.c maildir.c mbox.c misc.c \
wrap.c getopt.c getopt1.c md5.c re.c
TARGET = mboxgrep
CFLAGS = @CFLAGS@
LIBS = @LIBS@
INSTALL = @INSTALL@
prefix = @prefix@
SHELL = /bin/sh
INCLUDES = -I. -I$(srcdir)
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $<
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
.PHONY: clean
clean:
rm -f $(TARGET) $(OBJS) core
.PHONY: distclean
distclean:
rm -f *~ Makefile config.h
.PHONY: install
install: mboxgrep
$(INSTALL) -d $(prefix)/bin
$(INSTALL) -s $(TARGET) $(prefix)/bin
.NOEXPORT:

View File

@ -1,67 +0,0 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#undef HAVE_DIRENT_H
/* Define to 1 if you have the `fcntl' function. */
#undef HAVE_FCNTL
/* Define to 1 if you have the `flock' function. */
#undef HAVE_FLOCK
/* Define to 1 if you have the `fts_open' function. */
#undef HAVE_FTS_OPEN
/* Define to 1 if you have the `ftw' function. */
#undef HAVE_FTW
/* Define to 1 if you have the `bz2' library (-lbz2). */
#undef HAVE_LIBBZ2
/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */
#undef HAVE_LIBDMALLOC
/* Define to 1 if you have the `garfield' library (-lgarfield). */
#undef HAVE_LIBGARFIELD
/* Define to 1 if you have the `pcre' library (-lpcre). */
#undef HAVE_LIBPCRE
/* Define to 1 if you have the `z' library (-lz). */
#undef HAVE_LIBZ
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP
/* Define to 1 if you have the `strptime' function. */
#undef HAVE_STRPTIME
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_NDIR_H
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

View File

@ -1,6 +1,6 @@
/*
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2004, 2006, 2010, 2023 Daniel Spiljar
Copyright (C) 2000 - 2004, 2006, 2010, 2023 - 2024 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -22,149 +22,152 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mboxgrep.h"
void
print_wrap (char *str, int len, int *n)
print_wrap (char *str)
{
*n += len;
static int n = 0;
n += strlen (str);
fprintf (stdout, "%s", str);
if (*n >= 50)
if (n >= 50)
{
fprintf (stdout, "\n");
*n = 0;
n = 0;
}
else fprintf (stdout, " ");
else
fprintf (stdout, " ");
}
void
version (void)
{
int n = 0;
fprintf (stdout, "%s %s\n\n"
"Copyright (C) 2000 - 2004, 2006, 2010, 2023 Daniel Spiljar\n"
"This program is free software; you can redistribute it and/or "
"modify\nit under the terms of the GNU General Public License "
"as published by\nthe Free Software Foundation; either version "
"2 of the License, or\n(at your option) any later version.\n\n",
APPNAME, VERSION);
"Copyright (C) 2000 - 2004, 2006, 2010, 2023 - 2024 Daniel Spiljar\n"
"This program is free software; you can redistribute it and/or "
"modify\nit under the terms of the GNU General Public License "
"as published by\nthe Free Software Foundation; either version "
"2 of the License, or\n(at your option) any later version.\n\n",
APPNAME, VERSION);
fprintf (stdout, "Compilation options:\n");
#ifdef HAVE_DIRENT_H
print_wrap ("HAVE_DIRENT_H", 13, &n);
print_wrap ("HAVE_DIRENT_H");
#endif /* HAVE_DIRENT_H */
#ifdef HAVE_FCNTL
print_wrap ("HAVE_FCNTL", 10, &n);
print_wrap ("HAVE_FCNTL");
#endif /* HAVE_FCNTL */
#ifdef HAVE_FLOCK
print_wrap ("HAVE_FLOCK", 10, &n);
print_wrap ("HAVE_FLOCK");
#endif /* HAVE_FLOCK */
#ifdef HAVE_FTS_OPEN
print_wrap ("HAVE_FTS_OPEN", 13, &n);
print_wrap ("HAVE_FTS_OPEN");
#else
# ifdef HAVE_FTW
print_wrap ("HAVE_FTW", 8, &n);
# endif /* HAVE_FTW */
# ifdef HAVE_FTW
print_wrap ("HAVE_FTW");
# endif
/* HAVE_FTW */
#endif /* HAVE_FTS_OPEN */
/*
fprintf (stdout, "HAVE_LIBLOCKFILE ");
*/
#ifdef HAVE_LIBPCRE
print_wrap ("HAVE_LIBPCRE", 12, &n);
#endif /* HAVE_LIBPCRE */
#ifdef HAVE_LIBPCRE2
print_wrap ("HAVE_LIBPCRE2");
#endif /* HAVE_LIBPCRE2 */
#ifdef HAVE_LIBZ
print_wrap ("HAVE_LIBZ", 9, &n);
print_wrap ("HAVE_LIBZ");
#endif /* HAVE_LIBZ */
#ifdef HAVE_LIBBZ2
print_wrap ("HAVE_LIBBZ2", 11, &n);
print_wrap ("HAVE_LIBBZ2");
#endif /* HAVE_LIBBZ2 */
#ifdef HAVE_NDIR_H
print_wrap ("HAVE_NDIR_H", 11, &n);
print_wrap ("HAVE_NDIR_H");
#endif /* HAVE_NDIR_H */
#ifdef HAVE_SYS_DIR_H
print_wrap ("HAVE_SYS_DIR_H", 14, &n);
print_wrap ("HAVE_SYS_DIR_H");
#endif /* HAVE_SYS_DIR_H */
#ifdef HAVE_SYS_NDIR_H
print_wrap ("HAVE_SYS_NDIR_H", 15, &n);
print_wrap ("HAVE_SYS_NDIR_H");
#endif /* HAVE_SYS_NDIR_H */
#ifdef HAVE_STRPTIME
print_wrap ("HAVE_STRPTIME", 15, &n);
print_wrap ("HAVE_STRPTIME");
#endif /* HAVE_STRPTIME */
#ifdef HAVE_REGCOMP
print_wrap ("HAVE_REGCOMP", 15, &n);
print_wrap ("HAVE_REGCOMP");
#endif /* HAVE_REGCOMP */
#ifdef HAVE_LIBDMALLOC
print_wrap ("HAVE_LIBDMALLOC", 15, &n);
print_wrap ("HAVE_LIBDMALLOC");
#endif /* HAVE_LIBDMALLOC */
fprintf (stdout, "\n");
exit(0);
exit (0);
}
void
void
help (void)
{
fprintf(stdout, "%s %s - search MAILBOX for messages matching PATTERN\n\n",
APPNAME, VERSION);
fprintf(stdout,
"Miscellaneous:\n\n"
" -h, --help\t\t\tThis help screen\n"
" -V, --version\t\tDisplay version, copyright and\n"
"\t\t\t\tcompile-time options information\n"
" -r, --recursive\t\tDescend into directories recursively\n\n"
"Output control:\n\n"
" -c, --count\t\t\tPrint a count of matching messages\n"
" -d, --delete\t\t\tDelete matching messages\n"
" -nd, --no-duplicates\t\tIgnore duplicate messages\n"
" -o, --output=MAILBOX\t\tWrite messages to MAILBOX\n"
" -p, --pipe=COMMAND\t\tPipe each found message to COMMAND\n"
" -s, --no-messages\t\tSuppress most error messages\n"
" --debug\t\t\tPrint messages useful for debugging\n\n"
"Matching criteria:\n\n"
" -E, --extended-regexp\tPATTERN is an extended regular expression\n"
" -G, --basic-regexp\t\tPATTERN is a basic regular expression\n");
#ifdef HAVE_LIBPCRE
fprintf(stdout,
" -P, --perl-regexp\t\tPATTERN is a Perl regular expression\n");
#endif /* HAVE_LIBPCRE */
fprintf(stdout,
" -e, --regexp=PATTERN\t\tUse PATTERN as a regular expression\n"
" -i, --ignore-case\t\tIgnore case distinctions\n"
" -v, --invert-match\t\tSelect non-matching messages\n\n"
"Search scope selection:\n\n"
" -H, --headers\t\tMatch PATTERN against message headers\n"
" -B, --body\t\t\tMatch PATTERN against message body\n\n"
"File locking:\n\n"
" -nl, --no-file-lock\t\tDo not lock files\n"
" -l, --file-lock=METHOD\tSelect file locking METHOD\n"
"\t\t\t\tMETHOD is");
fprintf (stdout, "%s %s - search MAILBOX for messages matching PATTERN\n\n",
APPNAME, VERSION);
fprintf (stdout,
"Miscellaneous:\n\n"
" -h, --help\t\t\tThis help screen\n"
" -V, --version\t\tDisplay version, copyright and\n"
"\t\t\t\tcompile-time options information\n"
" -r, --recursive\t\tDescend into directories recursively\n\n"
"Output control:\n\n"
" -c, --count\t\t\tPrint a count of matching messages\n"
" -d, --delete\t\t\tDelete matching messages\n"
" -nd, --no-duplicates\t\tIgnore duplicate messages\n"
" -o, --output=MAILBOX\t\tWrite messages to MAILBOX\n"
" -p, --pipe=COMMAND\t\tPipe each found message to COMMAND\n"
" -s, --no-messages\t\tSuppress most error messages\n"
" --debug\t\t\tPrint messages useful for debugging\n\n"
"Matching criteria:\n\n"
" -E, --extended-regexp\tPATTERN is an extended regular expression\n"
" -G, --basic-regexp\t\tPATTERN is a basic regular expression\n");
#ifdef HAVE_LIBPCRE2
fprintf (stdout,
" -P, --perl-regexp\t\tPATTERN is a Perl regular expression\n");
#endif /* HAVE_LIBPCRE2 */
fprintf (stdout,
" -e, --regexp=PATTERN\t\tUse PATTERN as a regular expression\n"
" -i, --ignore-case\t\tIgnore case distinctions\n"
" -v, --invert-match\t\tSelect non-matching messages\n\n"
"Search scope selection:\n\n"
" -H, --headers\t\tMatch PATTERN against message headers\n"
" -B, --body\t\t\tMatch PATTERN against message body\n\n"
"File locking:\n\n"
" -nl, --no-file-lock\t\tDo not lock files\n"
" -l, --file-lock=METHOD\tSelect file locking METHOD\n"
"\t\t\t\tMETHOD is");
#ifdef HAVE_FCNTL
fprintf(stdout, " `fcntl',");
fprintf (stdout, " `fcntl',");
#endif /* HAVE_FCNTL */
#ifdef HAVE_FLOCK
fprintf(stdout, " `flock',");
fprintf (stdout, " `flock',");
#endif /* HAVE_FLOCK */
fprintf(stdout, " or `none'\n\n"
"Mailbox type selection:\n\n"
" -m, --mailbox-format=TYPE\tSelect mailbox TYPE\n"
"\t\t\t\tTYPE is `mbox', ");
fprintf (stdout, " or `none'\n\n"
"Mailbox type selection:\n\n"
" -m, --mailbox-format=TYPE\tSelect mailbox TYPE\n"
"\t\t\t\tTYPE is `mbox', ");
#ifdef HAVE_LIBZ
fprintf(stdout, "`zmbox', ");
fprintf (stdout, "`zmbox', ");
#endif /* HAVE_LIBZ */
#ifdef HAVE_LIBBZ2
fprintf(stdout, "`bz2mbox', ");
fprintf (stdout, "`bz2mbox', ");
#endif /* HAVE_LIBBZ2 */
fprintf(stdout,
"`mh',\n"
"\t\t\t\t`nnml', `nnmh', or `maildir'.\n\n"
"Mail bug reports and flames to <%s>.\n", BUGREPORT_ADDR);
fprintf (stdout,
"`mh',\n"
"\t\t\t\t`nnml', `nnmh', or `maildir'.\n\n"
"Mail bug reports and flames to <%s>.\n", BUGREPORT_ADDR);
exit(0);
exit (0);
}
void
void
usage (void)
{
printf ("Usage: %s [OPTION] PATTERN MAILBOX ...\n\n"

View File

@ -18,9 +18,9 @@
*/
#ifndef INFO_H
#define INFO_H
# define INFO_H
void print_wrap (char *str, int len, int *n);
void print_wrap (char *str);
void version (void);
void help (void);
void usage (void);

View File

@ -23,20 +23,23 @@
#include <string.h>
#ifdef HAVE_DIRENT_H