Compare commits
20 Commits
1d75932569
...
0.7.10
Author | SHA1 | Date | |
---|---|---|---|
29a1add6f0
|
|||
0be2cf9fda
|
|||
a7920dedf3
|
|||
5cc84ca1bd
|
|||
af7c6c8ced
|
|||
7dd6f3d69d
|
|||
10a9440e57
|
|||
994cb03fe5
|
|||
c527aff34b
|
|||
3e8c80b8e0
|
|||
f7bdabb29d
|
|||
51cc5c6d69
|
|||
654d98cbb4
|
|||
8ad7b77cf3
|
|||
2063e7fcba
|
|||
85f4938776
|
|||
3db6edf467
|
|||
50316df104 | |||
95d67d850c | |||
7c94d17bec |
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
Makefile
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
src/*.o
|
||||
src/mboxgrep
|
384
ChangeLog
384
ChangeLog
@@ -1,384 +0,0 @@
|
||||
Mon Oct 23 01:29:07 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mboxgrep.h, src/main.c, src/mbox.c, src/mbox.h, src/scan.c:
|
||||
temporary mbox file (used for deleting messages) is now created
|
||||
by tmpmbox_create(), tmpp global pointer is killed; portions of
|
||||
code in scan.c are replaced by single call of mbox_write_message();
|
||||
scan.c no longer includes zlib.h and bzlib.h
|
||||
|
||||
Thu Oct 19 03:50:38 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
|
||||
got rid off tmpp and maildir_count global variables (code
|
||||
cleanup)
|
||||
|
||||
Thu Oct 19 03:38:24 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mboxgrep.h, src/main.c, src/scan.c:
|
||||
introduction of the global runtime_t structure; mailbox counter,
|
||||
MD5 hash and other global variables are now part of it (code
|
||||
cleanup)
|
||||
|
||||
Fri Jul 7 06:10:51 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mboxgrep.h, src/re.c, src/re.h, src/scan.c:
|
||||
portions of scan_mailbox() have been moved to new functions,
|
||||
pcre_match() and regex_match() (code cleanup)
|
||||
|
||||
Thu Jul 6 13:54:23 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/main.c, src/mboxgrep.h, src/re.c, src/re.h, src/scan.c:
|
||||
main() has been partially uncluttered by moving portions of the
|
||||
code to functions pcre_init() and regex_init()
|
||||
|
||||
Thu Jul 6 12:49:59 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/main.c, src/mboxgrep.h, src/misc.c, src/misc.h:
|
||||
variables regex_s and haveregex are now part of the option_t
|
||||
structure (code cleanup)
|
||||
|
||||
Thu Jul 6 10:26:57 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/main.c, src/misc.c, src/misc.h:
|
||||
parts of main() have been moved to set_default_options() and
|
||||
get_runtime_options() (code cleanup)
|
||||
|
||||
Sat Jul 1 13:06:37 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mbox.c, src/mbox.h:
|
||||
file mode and ownership-altering code has been moved to a separate
|
||||
function, tmpfile_mod_own (code cleanup)
|
||||
|
||||
Tue Jun 27 18:48:00 CEST 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mbox.c, src/mbox.h:
|
||||
portions of the code from tmpfile_open moved to a new function,
|
||||
tmpfile_name (code cleanup)
|
||||
|
||||
Mon Feb 20 18:09:59 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/maildir.c, src/mh.c:
|
||||
removed some unused variables (have_return_path)
|
||||
|
||||
Mon Jan 30 01:35:30 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mboxgrep.h, src/maildir.c, src/mh.c, src/mbox.c, src/scan.c, src/main.c:
|
||||
boxname, outboxname, pipecmd and tmpfilename are now a part of
|
||||
the config_t structure and no longer global variables
|
||||
|
||||
Sat Jan 21 08:18:29 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/scan.c, src/misc.c, src/misc.h:
|
||||
created postmark_print() to unclutter scan_mailbox()
|
||||
|
||||
Fri Jan 20 05:36:44 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
|
||||
some repetitive code moved to malloc_message()
|
||||
|
||||
Fri Jan 20 05:13:06 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/mbox.c:
|
||||
cleanup of mbox_write_message(); use of gzwrite_loop() and
|
||||
bzwrite_loop()
|
||||
|
||||
Fri Jan 20 03:57:28 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/scan.c, src/wrap.h, src/wrap.c:
|
||||
wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
|
||||
code from scan.c
|
||||
|
||||
Fri Jan 20 02:11:50 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/scan.c:
|
||||
md5_check_message(): array b and cast in strncmp are no longer
|
||||
unsigned
|
||||
|
||||
Wed Jan 18 01:48:56 CET 2006 Daniel Spiljar <dspiljar@panix.com>
|
||||
|
||||
* src/info.c, src/mboxgrep.h:
|
||||
updated copyright information, changed author's email address
|
||||
to the one at Panix
|
||||
|
||||
Mon Apr 12 19:30:52 CEST 2004 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/info.c:
|
||||
updated copyright information
|
||||
|
||||
Sun Apr 11 23:45:08 CEST 2004 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
|
||||
mbox_write_message(); further fixes of message deletion code
|
||||
|
||||
Thu Sep 18 00:10:13 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/scan.c:
|
||||
fixed deleting messages from mbox folders compressed with
|
||||
bzip2
|
||||
|
||||
Thu Sep 18 00:08:36 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/main.c, src/mbox.c:
|
||||
moved James P. Dugal's ownership-preserving code from main()
|
||||
to tmpfile_open()
|
||||
|
||||
Sat Aug 30 23:13:01 CEST 2003 Vid Strpic <vms@bofhlet.net>
|
||||
|
||||
* src/info.c:
|
||||
If bzip2 support is compiled in, `--help' command should list
|
||||
`bz2mbox' as a valid option to `--mailbox-format='.
|
||||
|
||||
Sun Aug 24 21:49:52 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* doc/mboxgrep.1, doc/mboxgrep.texi:
|
||||
small updates
|
||||
|
||||
Sat Aug 23 20:56:39 CEST 2003 James P. Dugal <jpd@louisiana.edu>
|
||||
|
||||
* src/main.c, src/mbox.h, src/mbox.c
|
||||
If we are to use rename() to move a temp file (resulting from
|
||||
deletions done in a mailbox) back over the original mailbox, we
|
||||
must be sure the temp file is on the same file system. Also,
|
||||
we should try to preserve the same ownership and permissions.
|
||||
|
||||
Mon Aug 11 00:39:14 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* configure.ac:
|
||||
look for pcre-config(1) script; this effectively fixes a
|
||||
compilation bug on recent RedHat Linux systems
|
||||
|
||||
Sun Apr 13 21:16:25 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/info.c, src/info.h:
|
||||
print_wrap(); list of compile-time options is now printed wrapped
|
||||
|
||||
Mon Apr 7 01:24:20 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/mbox.c, src/wrap.c, src/wrap.h:
|
||||
m_gzdopen()
|
||||
|
||||
Sun Apr 6 23:04:19 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/mbox.c, src/mbox.h, src/mboxgrep.h, src/misc.c, src/scan.c:
|
||||
support for bzip2 compressed mailboxes
|
||||
|
||||
Fri Apr 4 00:14:01 CEST 2003 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* configure.ac:
|
||||
check for libbz2
|
||||
|
||||
Sun Oct 27 23:57:31 CET 2002 Daniel Spiljar <dspiljar@world.std.com>
|
||||
|
||||
* src/mbox.c:
|
||||
mbox_open() should now complain if called with an unknown argument
|
||||
mode. Shouldn't normally happen, but...
|
||||
|
||||
Sun Aug 25 22:43:38 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/mbox.c, src/mbox.h, src/scan.c:
|
||||
removed the gzmbox* functions in order to avoid code duplication;
|
||||
as a side effect, mboxgrep can now read compressed mbox folders
|
||||
from standard input
|
||||
|
||||
Sun Aug 11 01:36:02 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* configure.ac:
|
||||
AC_HEADER_STDC, which fixed another compiler warning
|
||||
|
||||
Sat Aug 10 22:03:31 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/mbox.c, src/mh.c, src/scan.c, src/misc.c, src/maildir.c, src/mboxgrep.h:
|
||||
made various code cleanups: got rid of a couple of global variables,
|
||||
fixed compiler warnings and things like that
|
||||
|
||||
Sat Aug 10 00:35:21 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mh.h, src/wrap.h, src/mboxgrep.h:
|
||||
removed some unnecessary #defines that have been causing compiler
|
||||
errors
|
||||
|
||||
Sun Aug 4 20:11:29 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/scan.c, src/scan.h:
|
||||
code clean up: moved recursive scan code from main()
|
||||
to recursive_scan()
|
||||
|
||||
Wed Jul 24 00:20:59 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/maildir.c:
|
||||
same thing with maildir as with MH below
|
||||
|
||||
Sat Jul 6 22:51:45 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mh.c:
|
||||
MH module doesn't read files which aren't RFC 2822 messages anymore
|
||||
|
||||
Sat Jun 29 01:43:36 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* configure.in, src/maildir.c, src/main.c, src/mbox.c, src/mh.c, src/scan.c:
|
||||
added debugging with dmalloc library
|
||||
|
||||
Sat Jun 29 01:39:21 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mbox.c, src/maildir.c:
|
||||
fixed potential problem as with MH folders (below)
|
||||
|
||||
Sat Jun 29 01:28:30 CEST 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mh.c, src/scan.c:
|
||||
(hopefully) fixed crashes on MH folders
|
||||
|
||||
Sat Feb 23 22:22:12 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mbox.c, src/maildir.c, src/mh.c, src/misc.c:
|
||||
removed useless code that required strptime ()
|
||||
|
||||
Sat Feb 23 15:43:05 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/mbox.h, src/mbox.c, src/scan.c:
|
||||
mboxgrep can now read mbox folders from standard input
|
||||
|
||||
Fri Feb 8 02:15:36 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c:
|
||||
fixed a bug which prevented mboxgrep from being compiled;
|
||||
this happened because I've put some assignments *before*
|
||||
declarations
|
||||
|
||||
Wed Feb 6 23:11:50 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/maildir.c, src/main.c, src/mbox.c, src/mboxgrep.h, src/mh.c, src/mh.h, src/misc.c, src/scan.c, src/wrap.c
|
||||
code cleanups; many global variables have been replaced with
|
||||
a single option_t structure
|
||||
|
||||
Fri Feb 1 00:31:05 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/maildir.c:
|
||||
fixed a bug which occured on recursive search of maildirs
|
||||
|
||||
Wed Jan 2 00:32:37 CET 2002 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/misc.c, src/wrap.h:
|
||||
applied a patch (kindly submitted by John R. Daily
|
||||
<jdaily@progeny.com>), which fixes missing prototypes that might
|
||||
cause mboxgrep to coredump on IA64 platform
|
||||
|
||||
Sat Dec 15 20:12:40 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/scan.c, src/scan.h:
|
||||
recursive search through directories has been reimplemented
|
||||
|
||||
Sat Dec 8 22:13:54 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/main.c, src/maildir.c:
|
||||
replaced remaining occurences of malloc() with xmalloc()
|
||||
|
||||
Sat Dec 8 21:21:58 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/maildir.c, src/main.c, src/mbox.c, src/mh.c, src/misc.c, src/scan.c, src/wrap.c, src/wrap.h:
|
||||
wrote xstrdup(), an error-checking wrapper around strdup() and
|
||||
replaced all occurences of strdup() with xstrdup()
|
||||
|
||||
Sun Dec 2 18:05:57 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/Makefile.in, src/info.c, src/main.c, src/mboxgrep.h, src/md5.c, src/md5.h, src/scan.c, src/scan.h, doc/mboxgrep.texi:
|
||||
mboxgrep can now ignore duplicate messages, thanks to the MD5
|
||||
algorithm
|
||||
|
||||
* src/maildir.c, src/main.c, src/scan.c, src/wrap.c, src/wrap.h:
|
||||
wrote xcalloc() and renamed m_realloc() to xrealloc()
|
||||
|
||||
Sat Nov 17 22:57:57 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mbox.c, src/mh.c, src/maildir.c
|
||||
message->headers and message->body pointers are now initially malloc'd
|
||||
to size of one character in order to prevent NULL pointers from being
|
||||
passed to regexec()
|
||||
|
||||
Wed Nov 7 22:47:34 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* configure.ac, src/mboxgrep.h, src/main.c, src/misc.h, src/misc.c, src/info.c, src/config.h, src/mbox.c:
|
||||
file locking method can now be selected at run time
|
||||
|
||||
* src/info.c, src/maildir.c, src/main.c, src/mbox.h, src/misc.c, src/scan.c, src/Makefile.in
|
||||
changed `#include "config.h"' to `#include <config.h>', and fixed
|
||||
other bugs with #including
|
||||
|
||||
Sat Nov 3 16:08:22 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* configure.ac, src/config.h.in, src/info.c, src/mbox.c
|
||||
files can be locked with flock() instead of fcntl(), if
|
||||
enabled at compile time
|
||||
|
||||
Sun Oct 28 19:01:44 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/Makefile.in:
|
||||
forgot to mention getopt.c and getopt1.c
|
||||
|
||||
Sun Oct 28 16:06:28 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/mh.c, src/main.c, src/scan.c:
|
||||
#included certain neccessary files
|
||||
|
||||
Sun Oct 28 14:43:21 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/maildir.c, src/maildir.h, src/scan.c:
|
||||
wrote functions maildir_check and maildir_create;
|
||||
if the target maildir doesn't exist, mboxgrep creates one;
|
||||
if it does exist, mboxgrep checks its consistency and refuses to
|
||||
write to it unless `tmp', `new' and `cur' subdirectories exist
|
||||
|
||||
Sun Oct 28 13:02:10 CET 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/info.c, doc/mboxgrep.texi, doc/mboxgrep.1
|
||||
the "--regexp" command was implemented in version 0.7.0, but I
|
||||
forgot to document it
|
||||
|
||||
Sat Oct 27 21:48:36 CEST 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/scan.c:
|
||||
if the input is a non-mbox folder, a proper postmark line (with
|
||||
date) is put on top of each message written to stdout
|
||||
|
||||
Mon Oct 8 22:53:34 CEST 2001 Daniel Spiljar <dspiljar@bofhlet.net>
|
||||
|
||||
* src/*:
|
||||
source code now completely rewritten
|
||||
|
||||
Sun May 27 00:19:52 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* doc/mboxgrep.1:
|
||||
updated the manual page -- it now refers to RFC 2822, instead
|
||||
of the obsoleted 822
|
||||
|
||||
Tue May 1 15:06:03 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* configure.in, doc/Makefile.in, src/Makefile.in, Makefile.in:
|
||||
moved manpage to the `doc' subdirectory; changed files above
|
||||
accordingly
|
||||
|
||||
Sun Apr 15 23:00:08 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* src/mboxgrep.h, src/main.c, src/file.c, src/scan.c, src/info.c:
|
||||
added support for writing messages to another mail folder
|
||||
|
||||
Mon Apr 9 21:55:15 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* src/file.c, src/scan.c: all calls of malloc() are now checked
|
||||
and mboxgrep exits with code 2 if it fails to allocate memory
|
||||
|
||||
Sun Apr 8 19:40:33 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* src/mboxgrep.h, src/main.c: wrote mboxgrep_stat()
|
||||
|
||||
Sun Apr 8 16:58:36 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* src/mboxgrep.h, src/main.c: wrote mboxgrep_error()
|
||||
|
||||
Tue Mar 27 01:26:22 CEST 2001 Daniel Spiljar <dspiljar@public.srce.hr>
|
||||
|
||||
* configure.in: check for gethostname()
|
||||
|
||||
|
||||
|
||||
$Id: ChangeLog,v 1.59 2006-10-22 23:34:47 dspiljar Exp $
|
123
NEWS → NEWS.md
123
NEWS → NEWS.md
@@ -1,110 +1,129 @@
|
||||
Changes of mboxgrep
|
||||
===================
|
||||
# Changes of mboxgrep
|
||||
|
||||
Changes since 0.7.9
|
||||
## Changes since 0.7.9
|
||||
|
||||
- development has been restarted after a longer hiatus
|
||||
- moved the source tree to git
|
||||
- fixed compile bug on FreeBSD and other systems
|
||||
- fixed deleting messages mbox folders compressed with bzip2
|
||||
- fixed multiple compilation errors and warnings on Linux and FreeBSD
|
||||
- started implementing a debug mode
|
||||
|
||||
## Changes since 0.7.8
|
||||
|
||||
Changes since 0.7.8
|
||||
- implemented support for mbox folders compressed with bzip2 algorithm
|
||||
- improved detection of PCRE library; this also fixes a compilation bug
|
||||
on recent RedHat Linux systems
|
||||
- fixed a problem with message deletion, which used to occur if an mbox
|
||||
folder and temporary directory were on different filesystems;
|
||||
thanks to James P. Dugal <jpd@louisiana.edu> for providing a patch
|
||||
thanks to James P. Dugal <jpd AT louisiana.edu> for providing a patch
|
||||
|
||||
## Changes since 0.7.7
|
||||
|
||||
Changes since 0.7.7
|
||||
- fixed crashes on MH folders, as well as a potential problem with mbox
|
||||
and maildir folders with the same cause
|
||||
- debugging with dmalloc library
|
||||
- debugging with the dmalloc library
|
||||
- MH and maildir functions no longer read files which aren't RFC 2822 messages
|
||||
- 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 since 0.7.6a
|
||||
|
||||
- mboxgrep can now read mbox folders from standard input
|
||||
|
||||
Changes since 0.7.6
|
||||
## Changes since 0.7.6
|
||||
|
||||
- fixed a bug which prevented mboxgrep from being compiled
|
||||
|
||||
Changes since 0.7.5
|
||||
## Changes since 0.7.5
|
||||
|
||||
- fixed a bug which caused mboxgrep to coredump on recursive search of
|
||||
maildirs
|
||||
- code cleanups
|
||||
|
||||
Changes since 0.7.4
|
||||
## Changes since 0.7.4
|
||||
|
||||
- recursive search through directories has been reimplemented
|
||||
|
||||
Changes since 0.7.3
|
||||
## Changes since 0.7.3
|
||||
|
||||
- mboxgrep can now ignore messages with identical bodies
|
||||
|
||||
Changes since 0.7.2
|
||||
## Changes since 0.7.2
|
||||
|
||||
- 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
|
||||
- file locking with flock() instead of fcntl() is now supported
|
||||
- mboxgrep should now compile on systems which don't have getopt_long()
|
||||
## Changes since 0.7.1
|
||||
|
||||
- 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 since 0.7.0
|
||||
|
||||
- bugfixes
|
||||
|
||||
Changes since 0.5.3
|
||||
## Changes since 0.5.3
|
||||
|
||||
- NOTE: there was no stable version between 0.5.x and 0.7.x
|
||||
- mboxgrep is almost completely rewritten
|
||||
- implemented message deleting feature (--delete)
|
||||
- implemented piping messages to a command (--pipe) (using this option,
|
||||
- implemented message deleting feature (`--delete`)
|
||||
- implemented piping messages to a command (`--pipe`) (using this option,
|
||||
each selected message is piped to a separate instance of the specified
|
||||
command)
|
||||
- added support for compressed mbox folders
|
||||
|
||||
Changes since 0.5.2
|
||||
## Changes since 0.5.2
|
||||
|
||||
- implemented ability to write found messages to another folder (instead
|
||||
of stdout)
|
||||
- started writing *real* changelog (while this file has been renamed to
|
||||
of standard output)
|
||||
- started writing a *real* changelog (while this file has been renamed to
|
||||
"NEWS")
|
||||
- wrote a manual in Texinfo format
|
||||
|
||||
Changes since 0.5.1
|
||||
- implemented message counting (-c, --count)
|
||||
- fixed manual page installation target in src/Makefile.in -- manual page
|
||||
is now installed in $(manpath)/man1/ rather than in $(prefix)/man/man1/
|
||||
- added `--without-sense-of-humor' switch to the configure script, which
|
||||
disables checking whether Garfield still hates Mondays
|
||||
- short version of `--version' switch is now `-V' instead of `-v',
|
||||
because `-v' will be used for inverted matching
|
||||
- implemented inverted matching (-v, --invert-match)
|
||||
- implemented recursive search through directories (-r, --recursive)
|
||||
- config.h[.in] is now wrapped (#ifndef CONFIG_H and stuff)
|
||||
## Changes since 0.5.1
|
||||
|
||||
- implemented message counting (`-c, --count`)
|
||||
- fixed manual page installation target in src/Makefile.in -- manual page
|
||||
is now installed in `$(manpath)/man1/` rather than `$(prefix)/man/man1/`
|
||||
- added `--without-sense-of-humor` switch to the configure script, which
|
||||
disables checking whether Garfield still hates Mondays
|
||||
- short version of `--version` switch is now `-V` instead of `-v`,
|
||||
because `-v` will be used for inverted matching
|
||||
- implemented inverted matching (`-v, --invert-match`)
|
||||
- implemented recursive search through directories (`-r, --recursive`)
|
||||
- config.h[.in] is now wrapped (`#ifndef CONFIG_H` and stuff)
|
||||
|
||||
## Changes since 0.5.0
|
||||
|
||||
Changes since 0.5.0
|
||||
- added support for qmail-style maildir folders
|
||||
|
||||
Changes since 0.4.0
|
||||
- source of getopt_long() is now included, so long options are also available
|
||||
## Changes since 0.4.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
|
||||
- added support for MH mailboxes
|
||||
- added scope selection switches `-B' (or `--body') and `-H' (or `--headers')
|
||||
- getopt() (or getopt_long(), if available) is now used to parse command line
|
||||
arguments, instead of my own lousy routine
|
||||
- configure script now looks for PCRE by default, unless `--with-pcre=no' or
|
||||
`--without-pcre' is specified
|
||||
- the feature of reading from standard input is gone
|
||||
- added `-v' (or `--version') switch
|
||||
## Changes since 0.2.0
|
||||
|
||||
- added support for MH mailboxes
|
||||
- added scope selection switches `-B` (or `--body`) and `-H` (or `--headers`)
|
||||
- `getopt()` (or `getopt_long()`, if available) is now used to parse command line
|
||||
arguments, instead of my own lousy routine
|
||||
- the configure script now looks for PCRE by default, unless `--with-pcre=no` or
|
||||
`--without-pcre` is specified
|
||||
- the feature of reading from standard input is gone
|
||||
- added `-v` (or `--version`) switch
|
||||
|
||||
## Changes since 0.1.1
|
||||
|
||||
Changes since 0.1.1
|
||||
- mboxgrep now puts a shared lock on a mailbox before reading it
|
||||
- various code cleanups
|
||||
|
||||
Changes since 0.1.0
|
||||
- fixed install target in Makefile (`install' is now used instead of `cp')
|
||||
## Changes since 0.1.0
|
||||
|
||||
- fixed install target in Makefile (`install` is now used instead of `cp`)
|
||||
- added support for mailboxes generated by Gnus
|
||||
|
||||
|
||||
$Id: NEWS,v 1.23 2004-04-11 21:48:53 dspiljar Exp $
|
44
TODO.md
44
TODO.md
@@ -1,21 +1,35 @@
|
||||
# The TODO list for mboxgrep
|
||||
|
||||
## 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] ignore .overview when grepping Gnus folders
|
||||
- [x] implement inverted matching
|
||||
- [x] re-implement recursive search through directories
|
||||
- [ ] implement literal date matching
|
||||
- [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
|
||||
|
||||
## File formats, encodings and standards
|
||||
|
||||
- [ ] MIME support
|
||||
- [ ] support for GnuPG
|
||||
- [x] support for compressed mbox folders
|
||||
- [x] support for bzip2 compression
|
||||
- [ ] support for XZ-format compression
|
||||
- [ ] support for mail folder conversion
|
||||
- [ ] use a more modern hash function than MD5
|
||||
|
||||
## Miscellaneous
|
||||
|
||||
- [x] write Texinfo documentation
|
||||
- [x] implement writing selected messages to a new folder
|
||||
- [x] implement deleting selected messages
|
||||
- [ ] add support for config files
|
||||
- [x] add support for reading messages from stdin
|
||||
- [x] add support for compressed mbox folders
|
||||
- [ ] 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()
|
||||
- [x] allow run-time selection of file locking method
|
||||
- [ ] make mboxgrep understand MIME
|
||||
- [x] enable removing duplicate messages w/ MD5 checksums
|
||||
- [ ] add checking for conflicting command-line options
|
||||
- [ ] add support for GnuPG
|
||||
- [x] add support for bzip2 compression
|
||||
- [ ] add support for mail folder conversion
|
||||
|
@@ -1,5 +0,0 @@
|
||||
This directory is intended to hold third-party contributions.
|
||||
|
||||
- mboxgrep.spec is an RPM spec file, kindly contributed by
|
||||
Vaclav Slavik <v.slavik@volny.cz>
|
||||
|
3
contrib/README.md
Normal file
3
contrib/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
This directory is intended to hold third-party contributions.
|
||||
|
||||
- mboxgrep.spec is an RPM spec file, kindly contributed by Vaclav Slavik <v.slavik AT volny.cz>
|
@@ -1,5 +1,4 @@
|
||||
.Id $Id: mboxgrep.1,v 1.16 2006-01-18 00:09:58 dspiljar Exp $
|
||||
.TH MBOXGREP 1 "26 Jan 2023"
|
||||
.TH MBOXGREP 1 "17 Feb 2023"
|
||||
.SH NAME
|
||||
mboxgrep \- displays email messages matching a pattern
|
||||
.SH SYNOPSIS
|
||||
@@ -84,14 +83,18 @@ caution.
|
||||
Ignore duplicate messages.
|
||||
.IP "-m, --mailbox-format=TYPE"
|
||||
Select input and output mailbox TYPE. TYPE can be either `mbox' (default),
|
||||
`zmbox' (meaning `gzip compressed mbox'), `bz2mbox' (meaning `bzip2
|
||||
compressed mbox'), `mh', `nnml', `nnmh' or `maildir'.
|
||||
`zmbox' (gzip compressed mbox), `bz2mbox' (bzip2 compressed mbox), `mh', `nnml',
|
||||
`nnmh' or `maildir'.
|
||||
.IP "-s, --no-messages"
|
||||
Suppress most error messages.
|
||||
.IP "--debug"
|
||||
Print messages useful for debugging.
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
\(bu
|
||||
Search $MAIL for messages from Dirty Harry:
|
||||
.PP
|
||||
mboxgrep '^From:.*callahan@homicide\\.SFPD\\.gov' $MAIL
|
||||
mboxgrep '^From:.*callahan@sanfranciscopolice\\.org' $MAIL
|
||||
.TP
|
||||
\(bu
|
||||
Display all messages contained in folder ~/Mail/incoming, except those
|
||||
@@ -100,9 +103,6 @@ that appear to originate from AOL:
|
||||
mboxgrep -v 'Received:.*aol\\.com' ~/Mail/incoming
|
||||
.SH BUGS
|
||||
Report them to address below.
|
||||
.SH NOTICE
|
||||
Mboxgrep was alomost completely rewritten since version 0.5.3. Additionally,
|
||||
there was no stable 0.6.x branch between 0.5.3 and 0.7.0.
|
||||
.SH SEE ALSO
|
||||
grep(1),
|
||||
regex(7),
|
||||
|
@@ -169,6 +169,9 @@ options below change such behavior.
|
||||
'-s'
|
||||
Suppress error messages.
|
||||
|
||||
'--debug'
|
||||
Print messages useful for debugging.
|
||||
|
||||
|
||||
File: mboxgrep.info, Node: Search scope selection, Next: Mailbox type selection, Prev: Output control, Up: Invoking
|
||||
|
||||
@@ -197,7 +200,7 @@ File: mboxgrep.info, Node: Examples, Next: Bugs, Prev: Invoking, Up: Top
|
||||
|
||||
Scan '$MAIL' for messages from Dirty Harry:
|
||||
|
||||
mboxgrep -H '^From:.*callahan@homicide\.SFPD\.gov' $MAIL
|
||||
mboxgrep -H '^From:.*callahan@sanfranciscopolice\.org' $MAIL
|
||||
|
||||
Re-mail to George messages that mention his name:
|
||||
|
||||
@@ -224,11 +227,11 @@ File: mboxgrep.info, Node: Bugs, Next: To Vicky, Prev: Examples, Up: Top
|
||||
******************
|
||||
|
||||
Shortly, if 'mboxgrep' crashes and/or works differently than described
|
||||
in this manual, you've found a bug.
|
||||
in this manual, you have found a bug.
|
||||
|
||||
Please report bugs to <dspiljar@datatipp.se>. Instructions how to
|
||||
reproduce the bug or output from a debugger would be highly appreciated.
|
||||
Don't, however, send any coredumps.
|
||||
Please do not, however, send any core dumps.
|
||||
|
||||
|
||||
File: mboxgrep.info, Node: To Vicky, Prev: Bugs, Up: Top
|
||||
@@ -253,11 +256,11 @@ Node: Miscellaneous1827
|
||||
Node: File locking2112
|
||||
Node: Regexp selection2749
|
||||
Node: Output control3301
|
||||
Node: Search scope selection4292
|
||||
Node: Mailbox type selection4533
|
||||
Node: Examples4854
|
||||
Node: Bugs5674
|
||||
Node: To Vicky6081
|
||||
Node: Search scope selection4345
|
||||
Node: Mailbox type selection4586
|
||||
Node: Examples4907
|
||||
Node: Bugs5731
|
||||
Node: To Vicky6149
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
\input texinfo @c -*-texinfo-*-
|
||||
@c $Id: mboxgrep.texi,v 1.20 2006-01-18 00:09:58 dspiljar Exp $
|
||||
\input texinfo
|
||||
@setfilename mboxgrep.info
|
||||
@settitle Grep through mailboxes
|
||||
@finalout
|
||||
@@ -7,7 +6,7 @@
|
||||
|
||||
@set EDITION 0.7
|
||||
@set VERSION 0.7.10
|
||||
@set UPDATED 26 Jan 2023
|
||||
@set UPDATED 17 Feb 2023
|
||||
|
||||
@dircategory Mail
|
||||
@direntry
|
||||
@@ -189,6 +188,9 @@ instance of COMMAND.
|
||||
@itemx -s
|
||||
Suppress error messages.
|
||||
|
||||
@item --debug
|
||||
Print messages useful for debugging.
|
||||
|
||||
@end table
|
||||
|
||||
@node Search scope selection, Mailbox type selection, Output control, Invoking
|
||||
@@ -224,7 +226,7 @@ mbox) @code{mh}, @code{nnml}, @code{nnmh}, and @code{maildir}.
|
||||
Scan @env{$MAIL} for messages from Dirty Harry:
|
||||
|
||||
@example
|
||||
mboxgrep -H '^From:.*callahan@@homicide\.SFPD\.gov' $MAIL
|
||||
mboxgrep -H '^From:.*callahan@@sanfranciscopolice\.org' $MAIL
|
||||
@end example
|
||||
|
||||
Re-mail to George messages that mention his name:
|
||||
@@ -258,11 +260,11 @@ mboxgrep -nd -c . spam
|
||||
@cindex bug, insect, vermin, bugreport
|
||||
|
||||
Shortly, if @code{mboxgrep} crashes and/or works differently than described
|
||||
in this manual, you've found a bug.
|
||||
in this manual, you have found a bug.
|
||||
|
||||
Please report bugs to @email{dspiljar@@datatipp.se}.
|
||||
Instructions how to reproduce the bug or output from a debugger would be
|
||||
highly appreciated. Don't, however, send any coredumps.
|
||||
highly appreciated. Please do not, however, send any core dumps.
|
||||
|
||||
@node To Vicky, , Bugs, Top
|
||||
@chapter Author's Dedication
|
||||
|
27
src/info.c
27
src/info.c
@@ -28,10 +28,9 @@
|
||||
|
||||
void
|
||||
print_wrap (char *str, int len, int *n)
|
||||
/* {{{ */
|
||||
{
|
||||
*n += len;
|
||||
fprintf (stdout, str);
|
||||
fprintf (stdout, "%s", str);
|
||||
if (*n >= 50)
|
||||
{
|
||||
fprintf (stdout, "\n");
|
||||
@@ -39,11 +38,9 @@ print_wrap (char *str, int len, int *n)
|
||||
}
|
||||
else fprintf (stdout, " ");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
version (void)
|
||||
/* {{{ */
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
@@ -91,15 +88,23 @@ version (void)
|
||||
#endif /* HAVE_SYS_DIR_H */
|
||||
#ifdef HAVE_SYS_NDIR_H
|
||||
print_wrap ("HAVE_SYS_NDIR_H", 15, &n);
|
||||
#endif
|
||||
#endif /* HAVE_SYS_NDIR_H */
|
||||
#ifdef HAVE_STRPTIME
|
||||
print_wrap ("HAVE_STRPTIME", 15, &n);
|
||||
#endif /* HAVE_STRPTIME */
|
||||
#ifdef HAVE_REGCOMP
|
||||
print_wrap ("HAVE_REGCOMP", 15, &n);
|
||||
#endif /* HAVE_REGCOMP */
|
||||
#ifdef HAVE_LIBDMALLOC
|
||||
print_wrap ("HAVE_LIBDMALLOC", 15, &n);
|
||||
#endif /* HAVE_LIBDMALLOC */
|
||||
fprintf (stdout, "\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
help (void)
|
||||
/* {{{ */
|
||||
{
|
||||
fprintf(stdout, "%s %s - search MAILBOX for messages matching PATTERN\n\n",
|
||||
APPNAME, VERSION);
|
||||
@@ -115,7 +120,8 @@ help (void)
|
||||
" -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\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");
|
||||
@@ -157,15 +163,12 @@ help (void)
|
||||
|
||||
exit(0);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
usage (void)
|
||||
/* {{{ */
|
||||
{
|
||||
printf ("Usage: %s [OPTION] PATTERN MAILBOX ...\n\n"
|
||||
"Try `%s --help' for more information.\n", APPNAME, APPNAME);
|
||||
|
||||
exit (2);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: info.h,v 1.5 2003-04-13 19:15:58 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
189
src/maildir.c
189
src/maildir.c
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2006, 2023 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,8 +15,7 @@
|
||||
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: maildir.c,v 1.25 2006-10-19 01:53:43 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -84,10 +83,10 @@ maildir_open (const char *path)
|
||||
if (mp->new == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, dirname);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, dirname);
|
||||
perror (NULL);
|
||||
}
|
||||
free (dirname);
|
||||
errno = 0;
|
||||
return NULL;
|
||||
@@ -98,14 +97,14 @@ maildir_open (const char *path)
|
||||
if (mp->cur == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, dirname);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, dirname);
|
||||
perror (NULL);
|
||||
}
|
||||
free (dirname);
|
||||
errno = 0;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
free (dirname);
|
||||
return mp;
|
||||
@@ -123,42 +122,42 @@ maildir_read_message (maildir_t *mdp)
|
||||
static FILE *fp;
|
||||
static int s;
|
||||
|
||||
message = malloc_message ();
|
||||
message = allocate_message ();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if (mdp->new != NULL)
|
||||
{
|
||||
d_content = readdir (mdp->new);
|
||||
if (d_content == NULL)
|
||||
{
|
||||
closedir (mdp->new);
|
||||
mdp->new = NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
d_content = readdir (mdp->new);
|
||||
if (d_content == NULL)
|
||||
{
|
||||
closedir (mdp->new);
|
||||
mdp->new = NULL;
|
||||
}
|
||||
}
|
||||
if (mdp->new == NULL && mdp->cur != NULL)
|
||||
{
|
||||
d_content = readdir (mdp->cur);
|
||||
if (d_content == NULL)
|
||||
{
|
||||
closedir (mdp->cur);
|
||||
mdp->cur = NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
d_content = readdir (mdp->cur);
|
||||
if (d_content == NULL)
|
||||
{
|
||||
closedir (mdp->cur);
|
||||
mdp->cur = NULL;
|
||||
}
|
||||
}
|
||||
if (mdp->new == NULL && mdp->cur == NULL)
|
||||
{
|
||||
free (message->headers);
|
||||
free (message->body);
|
||||
free (message);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
free (message->headers);
|
||||
free (message->body);
|
||||
free (message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (d_content->d_name[0] == '.')
|
||||
continue;
|
||||
continue;
|
||||
|
||||
filename =
|
||||
(char *) xmalloc ((sizeof (char)*((strlen (d_content->d_name))
|
||||
+ (strlen (config.boxname)) + 6)));
|
||||
(char *) xmalloc ((sizeof (char)*((strlen (d_content->d_name))
|
||||
+ (strlen (config.boxname)) + 6)));
|
||||
|
||||
/*
|
||||
filename =
|
||||
@@ -166,9 +165,10 @@ maildir_read_message (maildir_t *mdp)
|
||||
+ (strlen(config.boxname)) + 2)));
|
||||
*/
|
||||
if (mdp->new != NULL)
|
||||
sprintf (filename, "%s/new/%s", config.boxname, d_content->d_name);
|
||||
sprintf (filename, "%s/new/%s", config.boxname, d_content->d_name);
|
||||
else
|
||||
sprintf (filename, "%s/cur/%s", config.boxname, d_content->d_name);
|
||||
sprintf (filename, "%s/cur/%s", config.boxname, d_content->d_name);
|
||||
|
||||
message->filename = (char *) xstrdup (filename);
|
||||
free (filename);
|
||||
|
||||
@@ -176,55 +176,58 @@ maildir_read_message (maildir_t *mdp)
|
||||
fp = m_fopen(message->filename, "r");
|
||||
|
||||
if (fp == NULL)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
while (fgets (buffer, BUFSIZ, fp) != NULL)
|
||||
{
|
||||
s = strlen (buffer);
|
||||
if (0 == strncmp ("\n", buffer, 1) && isheaders == 1)
|
||||
{
|
||||
isheaders = 0;
|
||||
continue;
|
||||
} /* if */
|
||||
if (isheaders)
|
||||
{
|
||||
if (0 == strncasecmp ("From: ", buffer, 6))
|
||||
have_from = 1;
|
||||
if (0 == strncasecmp ("Sender: ", buffer, 8))
|
||||
have_sender = 1;
|
||||
if (0 == strncasecmp ("Date: ", buffer, 6))
|
||||
have_date = 1;
|
||||
if (0 == strncasecmp ("To: ", buffer, 4))
|
||||
have_to = 1;
|
||||
if (0 == strncasecmp ("Message-ID: ", buffer, 12))
|
||||
have_message_id = 1;
|
||||
if (0 == strncasecmp ("Return-Path: ", buffer, 13))
|
||||
message->from = parse_return_path(buffer);
|
||||
{
|
||||
s = strlen (buffer);
|
||||
if (0 == strncmp ("\n", buffer, 1) && isheaders == 1)
|
||||
{
|
||||
isheaders = 0;
|
||||
continue;
|
||||
} /* if */
|
||||
if (isheaders)
|
||||
{
|
||||
if (0 == strncasecmp ("From: ", buffer, 6))
|
||||
have_from = 1;
|
||||
if (0 == strncasecmp ("Sender: ", buffer, 8))
|
||||
have_sender = 1;
|
||||
if (0 == strncasecmp ("Date: ", buffer, 6))
|
||||
have_date = 1;
|
||||
if (0 == strncasecmp ("To: ", buffer, 4))
|
||||
have_to = 1;
|
||||
if (0 == strncasecmp ("Message-ID: ", buffer, 12))
|
||||
have_message_id = 1;
|
||||
if (0 == strncasecmp ("Return-Path: ", buffer, 13))
|
||||
message->from = parse_return_path(buffer);
|
||||
|
||||
message->headers =
|
||||
(char *) xrealloc (message->headers,
|
||||
((1 + s + message->hbytes) * sizeof (char)));
|
||||
|
||||
strcpy (message->headers + message->hbytes, buffer);
|
||||
message->hbytes += s;
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
message->body =
|
||||
(char *) xrealloc (message->body,
|
||||
((1 + s + message->bbytes) * sizeof (char)));
|
||||
strcpy (message->body + message->bbytes, buffer);
|
||||
message->bbytes += s;
|
||||
} /* else */
|
||||
} /* while */
|
||||
|
||||
message->headers =
|
||||
(char *) xrealloc (message->headers,
|
||||
((1 + s + message->hbytes) * sizeof (char)));
|
||||
strcpy (message->headers + message->hbytes, buffer);
|
||||
message->hbytes += s;
|
||||
} /* if */
|
||||
else
|
||||
{
|
||||
message->body =
|
||||
(char *) xrealloc (message->body,
|
||||
((1 + s + message->bbytes) * sizeof (char)));
|
||||
strcpy (message->body + message->bbytes, buffer);
|
||||
message->bbytes += s;
|
||||
} /* else */
|
||||
} /* while */
|
||||
/* if (!have_from || !have_to || !have_message_id) */
|
||||
|
||||
if ((!have_from && !have_sender)|| !have_date)
|
||||
{
|
||||
if (config.merr)
|
||||
fprintf(stderr, "%s: %s: Not a RFC 2822 message\n",
|
||||
APPNAME, message->filename);
|
||||
fclose(fp);
|
||||
continue;
|
||||
}
|
||||
{
|
||||
if (config.merr)
|
||||
fprintf(stderr, "%s: %s: Not a RFC 2822 message\n",
|
||||
APPNAME, message->filename);
|
||||
fclose(fp);
|
||||
continue;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return message;
|
||||
@@ -297,19 +300,19 @@ maildir_create (const char *path)
|
||||
sprintf(s, "%s", path);
|
||||
i = mkdir (s, S_IRWXU);
|
||||
if (-1 == i)
|
||||
break;
|
||||
break;
|
||||
sprintf(s, "%s/new", path);
|
||||
i = mkdir (s, S_IRWXU);
|
||||
if (-1 == i)
|
||||
break;
|
||||
break;
|
||||
sprintf(s, "%s/cur", path);
|
||||
i = mkdir (s, S_IRWXU);
|
||||
if (-1 == i)
|
||||
break;
|
||||
break;
|
||||
sprintf(s, "%s/tmp", path);
|
||||
i = mkdir (s, S_IRWXU);
|
||||
if (-1 == i)
|
||||
break;
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -317,9 +320,9 @@ maildir_create (const char *path)
|
||||
if (errno != 0)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf(stderr, "%s:%s: ", APPNAME, s);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf(stderr, "%s:%s: ", APPNAME, s);
|
||||
perror (NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: maildir.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MAILDIR_H
|
||||
#define MAILDIR_H
|
||||
|
83
src/main.c
83
src/main.c
@@ -15,7 +15,6 @@
|
||||
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
|
||||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
@@ -49,8 +48,6 @@ runtime_t runtime;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
int havemailbox = 0;
|
||||
int singlefile = 0;
|
||||
@@ -58,8 +55,6 @@ main (int argc, char **argv)
|
||||
runtime.maildir_count = 0;
|
||||
|
||||
static struct option long_options[] =
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
{"count", 0, 0, 'c'},
|
||||
{"delete", 0, 0, 'd'},
|
||||
@@ -81,13 +76,12 @@ main (int argc, char **argv)
|
||||
{"output", 1, 0, 'o'},
|
||||
{"no-duplicates", 0, 0, 200},
|
||||
{"no-file-lock", 0, 0, 201},
|
||||
{"debug", 0, 0, 202},
|
||||
{"file-lock", 1, 0, 'l'},
|
||||
{"recursive", 0, 0, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
|
||||
set_default_options ();
|
||||
|
||||
get_runtime_options (&argc, argv, long_options);
|
||||
@@ -113,17 +107,17 @@ main (int argc, char **argv)
|
||||
config.regex_s = xstrdup (argv[optind]);
|
||||
config.haveregex = 1;
|
||||
++optind;
|
||||
} /* if */
|
||||
}
|
||||
|
||||
if (config.haveregex)
|
||||
{
|
||||
#ifdef HAVE_LIBPCRE
|
||||
if (config.perl)
|
||||
pcre_init ();
|
||||
pcre_init ();
|
||||
else
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
regex_init ();
|
||||
} /* if */
|
||||
regex_init ();
|
||||
}
|
||||
else
|
||||
usage ();
|
||||
|
||||
@@ -131,56 +125,49 @@ main (int argc, char **argv)
|
||||
singlefile = 1;
|
||||
|
||||
while (optind < argc)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
if (config.action == DELETE) {
|
||||
tmpmbox_create (argv[optind]);
|
||||
runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, "w");
|
||||
}
|
||||
if (config.action == DELETE)
|
||||
{
|
||||
tmpmbox_create (argv[optind]);
|
||||
runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, "w");
|
||||
}
|
||||
|
||||
config.boxname = xstrdup (argv[optind]);
|
||||
|
||||
if (config.recursive)
|
||||
recursive_scan (argv[optind]);
|
||||
recursive_scan (argv[optind]);
|
||||
else
|
||||
scan_mailbox (argv[optind]);
|
||||
havemailbox = 1;
|
||||
if (config.action == COUNT)
|
||||
{
|
||||
if (singlefile)
|
||||
fprintf (stdout, "%i\n", runtime.count);
|
||||
else
|
||||
{
|
||||
if (0 == strcmp ("-", argv[optind]))
|
||||
fprintf (stdout, "(standard input):%i\n", runtime.count);
|
||||
else
|
||||
fprintf (stdout, "%s:%i\n", argv[optind], runtime.count);
|
||||
}
|
||||
}
|
||||
if (config.action == DELETE)
|
||||
{
|
||||
mbox_close (runtime.tmp_mbox);
|
||||
rename (config.tmpfilename, argv[optind]);
|
||||
}
|
||||
++optind;
|
||||
} /* while */
|
||||
scan_mailbox (argv[optind]);
|
||||
|
||||
/* }}} */
|
||||
havemailbox = 1;
|
||||
|
||||
if (config.action == COUNT)
|
||||
{
|
||||
if (singlefile)
|
||||
fprintf (stdout, "%i\n", runtime.count);
|
||||
else
|
||||
{
|
||||
if (0 == strcmp ("-", argv[optind]))
|
||||
fprintf (stdout, "(standard input):%i\n", runtime.count);
|
||||
else
|
||||
fprintf (stdout, "%s:%i\n", argv[optind], runtime.count);
|
||||
}
|
||||
}
|
||||
if (config.action == DELETE)
|
||||
{
|
||||
mbox_close (runtime.tmp_mbox);
|
||||
rename (config.tmpfilename, argv[optind]);
|
||||
}
|
||||
++optind;
|
||||
}
|
||||
|
||||
if (! havemailbox)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
config.format = MBOX;
|
||||
scan_mailbox ("-");
|
||||
if (config.action == COUNT)
|
||||
fprintf (stdout, "%i\n", runtime.count);
|
||||
fprintf (stdout, "%i\n", runtime.count);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
|
359
src/mbox.c
359
src/mbox.c
@@ -1,4 +1,4 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Daniel Spiljar
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
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: mbox.c,v 1.34 2006-10-22 23:34:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -52,7 +51,6 @@
|
||||
|
||||
mbox_t *
|
||||
mbox_open (const char *path, const char *mode)
|
||||
/* {{{ */
|
||||
{
|
||||
mbox_t *mp;
|
||||
static int fd;
|
||||
@@ -69,155 +67,153 @@ mbox_open (const char *path, const char *mode)
|
||||
else
|
||||
{
|
||||
if (mode[0] == 'r')
|
||||
fd = m_open (path, O_RDONLY, 0);
|
||||
fd = m_open (path, O_RDONLY, 0);
|
||||
else if (mode[0] == 'w')
|
||||
fd = m_open (path, (O_WRONLY | O_CREAT | O_APPEND),
|
||||
fd = m_open (path, (O_WRONLY | O_CREAT | O_APPEND),
|
||||
(S_IWUSR | S_IRUSR));
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "%s: mbox.c: Unknown mode %c. You shouldn't "
|
||||
"get this error...", APPNAME, mode[0]);
|
||||
exit (2);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: mbox.c: Unknown mode %c. You shouldn't "
|
||||
"get this error...", APPNAME, mode[0]);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (config.lock)
|
||||
{
|
||||
{
|
||||
#ifdef HAVE_FLOCK
|
||||
int op;
|
||||
int op;
|
||||
|
||||
if (mode[0] == 'r')
|
||||
op = LOCK_SH;
|
||||
else
|
||||
op = LOCK_EX;
|
||||
if (-1 == flock (fd, op))
|
||||
if (mode[0] == 'r')
|
||||
op = LOCK_SH;
|
||||
else
|
||||
op = LOCK_EX;
|
||||
if (-1 == flock (fd, op))
|
||||
#else
|
||||
memset (&lck, 0, sizeof (struct flock));
|
||||
lck.l_whence = SEEK_SET;
|
||||
if (mode[0] == 'r')
|
||||
lck.l_type = F_RDLCK;
|
||||
else
|
||||
lck.l_type = F_WRLCK;
|
||||
memset (&lck, 0, sizeof (struct flock));
|
||||
lck.l_whence = SEEK_SET;
|
||||
if (mode[0] == 'r')
|
||||
lck.l_type = F_RDLCK;
|
||||
else
|
||||
lck.l_type = F_WRLCK;
|
||||
|
||||
if (-1 == fcntl (fd, F_SETLK, &lck))
|
||||
if (-1 == fcntl (fd, F_SETLK, &lck))
|
||||
#endif /* HAVE_FLOCK */
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode[0] == 'r')
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
mp->fp = (FILE *) m_fdopen (fd, "r");
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
mp->fp = (FILE *) m_fdopen (fd, "r");
|
||||
#ifdef HAVE_LIBZ
|
||||
else if (config.format == ZMBOX)
|
||||
mp->fp = (gzFile *) m_gzdopen (fd, "rb");
|
||||
else if (config.format == ZMBOX)
|
||||
mp->fp = (gzFile *) m_gzdopen (fd, "rb");
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
else if (config.format == BZ2MBOX)
|
||||
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "rb");
|
||||
else if (config.format == BZ2MBOX)
|
||||
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "rb");
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
}
|
||||
}
|
||||
else if (mode[0] == 'w')
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
mp->fp = (FILE *) m_fdopen (fd, "w");
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
mp->fp = (FILE *) m_fdopen (fd, "w");
|
||||
#ifdef HAVE_LIBZ
|
||||
else if (config.format == ZMBOX)
|
||||
mp->fp = (gzFile *) m_gzdopen (fd, "wb");
|
||||
else if (config.format == ZMBOX)
|
||||
mp->fp = (gzFile *) m_gzdopen (fd, "wb");
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
else if (config.format == BZ2MBOX)
|
||||
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "wb");
|
||||
else if (config.format == BZ2MBOX)
|
||||
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "wb");
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
}
|
||||
}
|
||||
|
||||
if (mp->fp == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
errno = 0;
|
||||
close (fd);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (mode[0] == 'r')
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
fgets (buffer, BUFSIZ, mp->fp);
|
||||
fgets (buffer, BUFSIZ, mp->fp);
|
||||
#ifdef HAVE_LIBZ
|
||||
else if (config.format == ZMBOX)
|
||||
gzgets (mp->fp, buffer, BUFSIZ);
|
||||
gzgets (mp->fp, buffer, BUFSIZ);
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
else if (config.format == BZ2MBOX)
|
||||
{
|
||||
char c[1] = "\0";
|
||||
int n = 0;
|
||||
{
|
||||
char c[1] = "\0";
|
||||
int n = 0;
|
||||
|
||||
while (c[0] != '\n' && n < BUFSIZ)
|
||||
{
|
||||
BZ2_bzread (mp->fp, c, 1);
|
||||
buffer[n] = c[0];
|
||||
n++;
|
||||
}
|
||||
buffer[n] = '\0';
|
||||
}
|
||||
while (c[0] != '\n' && n < BUFSIZ)
|
||||
{
|
||||
BZ2_bzread (mp->fp, c, 1);
|
||||
buffer[n] = c[0];
|
||||
n++;
|
||||
}
|
||||
buffer[n] = '\0';
|
||||
}
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
|
||||
if (0 != strncmp ("From ", buffer, 5))
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
if (0 == strcmp ("-", path))
|
||||
fprintf (stderr, "%s: (standard input): Not a mbox folder\n",
|
||||
APPNAME);
|
||||
else
|
||||
fprintf (stderr, "%s: %s: Not a mbox folder\n", APPNAME, path);
|
||||
}
|
||||
if (config.format == MBOX)
|
||||
fclose (mp->fp);
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
if (0 == strcmp ("-", path))
|
||||
fprintf (stderr, "%s: (standard input): Not a mbox folder\n",
|
||||
APPNAME);
|
||||
else
|
||||
fprintf (stderr, "%s: %s: Not a mbox folder\n", APPNAME, path);
|
||||
}
|
||||
if (config.format == MBOX)
|
||||
fclose (mp->fp);
|
||||
#ifdef HAVE_LIBZ
|
||||
else if (config.format == ZMBOX)
|
||||
gzclose (mp->fp);
|
||||
else if (config.format == ZMBOX)
|
||||
gzclose (mp->fp);
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
else if (config.format == BZ2MBOX)
|
||||
BZ2_bzclose (mp->fp);
|
||||
else if (config.format == BZ2MBOX)
|
||||
BZ2_bzclose (mp->fp);
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
strcpy (mp->postmark_cache, buffer);
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
mbox_close (mbox_t * mp)
|
||||
/* {{{ */
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
fclose (mp->fp);
|
||||
@@ -233,18 +229,15 @@ mbox_close (mbox_t * mp)
|
||||
free (mp->postmark_cache);
|
||||
free (mp);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
message_t *
|
||||
mbox_read_message (mbox_t * mp)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
int isheaders = 1, s;
|
||||
char buffer[BUFSIZ];
|
||||
message_t *message;
|
||||
|
||||
message = malloc_message ();
|
||||
message = allocate_message ();
|
||||
|
||||
s = strlen (mp->postmark_cache);
|
||||
message->headers =
|
||||
@@ -256,93 +249,89 @@ mbox_read_message (mbox_t * mp)
|
||||
for (;;)
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
{
|
||||
if (fgets (buffer, BUFSIZ, mp->fp) == NULL)
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (fgets (buffer, BUFSIZ, mp->fp) == NULL)
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
else if (config.format == ZMBOX)
|
||||
{
|
||||
if (gzgets (mp->fp, buffer, BUFSIZ) == NULL)
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (gzgets (mp->fp, buffer, BUFSIZ) == NULL)
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBZ */
|
||||
|
||||
#ifdef HAVE_LIBBZ2
|
||||
else if (config.format == BZ2MBOX)
|
||||
{
|
||||
char c[1] = "\0";
|
||||
int n = 0;
|
||||
{
|
||||
char c[1] = "\0";
|
||||
int n = 0;
|
||||
|
||||
while (c[0] != '\n' && n < BUFSIZ)
|
||||
{
|
||||
BZ2_bzread (mp->fp, c, 1);
|
||||
buffer[n] = c[0];
|
||||
n++;
|
||||
}
|
||||
buffer[n] = '\0';
|
||||
while (c[0] != '\n' && n < BUFSIZ)
|
||||
{
|
||||
BZ2_bzread (mp->fp, c, 1);
|
||||
buffer[n] = c[0];
|
||||
n++;
|
||||
}
|
||||
buffer[n] = '\0';
|
||||
|
||||
if (buffer[0] == '\0')
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
if (buffer[0] == '\0')
|
||||
{
|
||||
if (isheaders)
|
||||
return NULL;
|
||||
else
|
||||
return message;
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
|
||||
s = strlen (buffer);
|
||||
|
||||
if (buffer[0] == '\n' && isheaders == 1)
|
||||
{
|
||||
isheaders = 0;
|
||||
continue;
|
||||
}
|
||||
{
|
||||
isheaders = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isheaders)
|
||||
{
|
||||
message->headers =
|
||||
(char *) realloc (message->headers,
|
||||
{
|
||||
message->headers =
|
||||
(char *) realloc (message->headers,
|
||||
((1 + s + message->hbytes) * sizeof (char)));
|
||||
strcpy (message->headers + message->hbytes, buffer);
|
||||
message->hbytes += s;
|
||||
} /* if */
|
||||
strcpy (message->headers + message->hbytes, buffer);
|
||||
message->hbytes += s;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 == strncmp (buffer, "From ", 5))
|
||||
{
|
||||
strcpy (mp->postmark_cache, buffer);
|
||||
return message;
|
||||
}
|
||||
message->body =
|
||||
(char *) realloc (message->body,
|
||||
{
|
||||
if (0 == strncmp (buffer, "From ", 5))
|
||||
{
|
||||
strcpy (mp->postmark_cache, buffer);
|
||||
return message;
|
||||
}
|
||||
message->body =
|
||||
(char *) realloc (message->body,
|
||||
((1 + s + message->bbytes) * sizeof (char)));
|
||||
strcpy (message->body + message->bbytes, buffer);
|
||||
message->bbytes += s;
|
||||
|
||||
}
|
||||
} /* for */
|
||||
strcpy (message->body + message->bbytes, buffer);
|
||||
message->bbytes += s;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
tmpmbox_create (const char *path)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -351,11 +340,9 @@ tmpmbox_create (const char *path)
|
||||
tmpfile_mod_own (foo, path);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
tmpfile_name (const char *path)
|
||||
/* {{{ */
|
||||
{
|
||||
char *fname, *tmpdir;
|
||||
|
||||
@@ -363,7 +350,7 @@ tmpfile_name (const char *path)
|
||||
{
|
||||
tmpdir = getenv ("TMPDIR");
|
||||
if (tmpdir == NULL)
|
||||
tmpdir = xstrdup ("/tmp");
|
||||
tmpdir = xstrdup ("/tmp");
|
||||
fname = xstrdup ("/mboxgrepXXXXXX");
|
||||
}
|
||||
else
|
||||
@@ -377,13 +364,10 @@ tmpfile_name (const char *path)
|
||||
* sizeof (char));
|
||||
sprintf (config.tmpfilename, "%s%s", tmpdir, fname);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
void
|
||||
mbox_write_message (message_t *msg, mbox_t *mbox)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
fprintf (mbox->fp, "%s\n%s", msg->headers, msg->body);
|
||||
@@ -404,11 +388,9 @@ mbox_write_message (message_t *msg, mbox_t *mbox)
|
||||
}
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
tmpfile_mod_own (const int fd, const char *path)
|
||||
/* {{{ */
|
||||
{
|
||||
/* If we're root, copy {owner, group, perms} of mailbox to the tmpfile
|
||||
* so rename() will thus retain the original's ownership & permissions.
|
||||
@@ -418,20 +400,18 @@ tmpfile_mod_own (const int fd, const char *path)
|
||||
struct stat s;
|
||||
|
||||
if (stat (path, &s) != -1)
|
||||
{
|
||||
if (fchown (fd, s.st_uid, s.st_gid) == -1)
|
||||
if (config.merr) perror (config.tmpfilename);
|
||||
if (fchmod (fd, s.st_mode) == -1)
|
||||
if (config.merr) perror (config.tmpfilename);
|
||||
}
|
||||
{
|
||||
if (fchown (fd, s.st_uid, s.st_gid) == -1)
|
||||
if (config.merr) perror (config.tmpfilename);
|
||||
if (fchmod (fd, s.st_mode) == -1)
|
||||
if (config.merr) perror (config.tmpfilename);
|
||||
}
|
||||
else if (config.merr) perror (path);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int
|
||||
tmpfile_create (void)
|
||||
/* {{{ */
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -439,12 +419,11 @@ tmpfile_create (void)
|
||||
if (-1 == fd)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, config.tmpfilename);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, config.tmpfilename);
|
||||
perror (NULL);
|
||||
}
|
||||
exit (2);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
/* }}} */
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2004, 2023 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,8 +15,7 @@
|
||||
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: mbox.h,v 1.13 2006-10-22 23:34:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MBOX_H
|
||||
#define MBOX_H 1
|
||||
|
@@ -107,6 +107,7 @@ typedef struct
|
||||
int merr;
|
||||
int pid;
|
||||
int haveregex;
|
||||
int debug;
|
||||
|
||||
char hostname[HOST_NAME_SIZE];
|
||||
char *boxname, *outboxname, *pipecmd, *tmpfilename, *regex_s;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2020 Daniel Spiljar
|
||||
Copyright (C) 2020, 2023 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,8 +15,7 @@
|
||||
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$ */
|
||||
*/
|
||||
|
||||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H 1
|
||||
|
2
src/mh.c
2
src/mh.c
@@ -87,7 +87,7 @@ message_t *mh_read_message (DIR *dp)
|
||||
char buffer[BUFSIZ], *filename;
|
||||
FILE *fp;
|
||||
|
||||
message = malloc_message ();
|
||||
message = allocate_message ();
|
||||
|
||||
filename = NULL;
|
||||
|
||||
|
7
src/mh.h
7
src/mh.h
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: mh.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MH_H
|
||||
#define MH_H 1
|
||||
|
253
src/misc.c
253
src/misc.c
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2004, 2006, 2023 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,8 +15,7 @@
|
||||
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: misc.c,v 1.17 2006-07-06 10:53:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE /* Pull in strptime(3) from time.h */
|
||||
#define _BSD_SOURCE /* Compensate for _XOPEN_SOURCE to pull in strdup(3)
|
||||
@@ -38,7 +37,6 @@
|
||||
|
||||
format_t
|
||||
folder_format (const char *name)
|
||||
/* {{{ */
|
||||
{
|
||||
format_t f;
|
||||
|
||||
@@ -63,16 +61,14 @@ folder_format (const char *name)
|
||||
else
|
||||
{
|
||||
if (config.merr)
|
||||
fprintf (stderr, "mboxgrep: %s: unknown folder type\n", name);
|
||||
fprintf (stderr, "%s: %s: unknown folder type\n", APPNAME, name);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
lockmethod_t lock_method (const char *name)
|
||||
/* {{{ */
|
||||
{
|
||||
lockmethod_t l;
|
||||
|
||||
@@ -97,38 +93,36 @@ lockmethod_t lock_method (const char *name)
|
||||
|
||||
return l;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* time_t parse_date(char *datestr) */
|
||||
/* {{{ */
|
||||
/* { */
|
||||
/* time_t t; */
|
||||
/* const char *fmt = "%d%n%b%n%Y%n%T"; */
|
||||
/* int h, m; */
|
||||
/* struct tm tm; */
|
||||
/* char *str2, str1[BUFSIZ]; */
|
||||
/*
|
||||
time_t parse_date(char *datestr)
|
||||
{
|
||||
time_t t;
|
||||
const char *fmt = "%d%n%b%n%Y%n%T";
|
||||
int h, m;
|
||||
struct tm tm;
|
||||
char *str2, str1[BUFSIZ];
|
||||
|
||||
/* sscanf (datestr, "Date: %[^\r\n]", str1); */
|
||||
sscanf (datestr, "Date: %[^\r\n]", str1);
|
||||
|
||||
/* str2 = (char *) strptime (str1, "%d%n%b%n%Y%n%T", &tm); */
|
||||
/* if (str2 == NULL) */
|
||||
/* str2 = (char *) strptime (str1, "%a, %d%n%b%n%Y%n%T", &tm); */
|
||||
/* if (str2 == NULL) */
|
||||
/* return (time_t) 0; */
|
||||
|
||||
/* if (sscanf (str2, "%3d%2d", &h, &m) == 2) */
|
||||
/* { */
|
||||
/* tm.tm_hour -= h; */
|
||||
/* tm.tm_min -= (h >= 0 ? m : -m); */
|
||||
/* t = (time_t) mktime (&tm); */
|
||||
/* } */
|
||||
str2 = (char *) strptime (str1, "%d%n%b%n%Y%n%T", &tm);
|
||||
if (str2 == NULL)
|
||||
str2 = (char *) strptime (str1, "%a, %d%n%b%n%Y%n%T", &tm);
|
||||
if (str2 == NULL)
|
||||
return (time_t) 0;
|
||||
|
||||
/* return t; */
|
||||
/* } */
|
||||
/* }}} */
|
||||
if (sscanf (str2, "%3d%2d", &h, &m) == 2)
|
||||
{
|
||||
tm.tm_hour -= h;
|
||||
tm.tm_min -= (h >= 0 ? m : -m);
|
||||
t = (time_t) mktime (&tm);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
*/
|
||||
|
||||
char * parse_return_path(char *rpath)
|
||||
/* {{{ */
|
||||
{
|
||||
char *blah1, blah2[BUFSIZ];
|
||||
|
||||
@@ -137,9 +131,8 @@ char * parse_return_path(char *rpath)
|
||||
|
||||
return blah1;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void * malloc_message (void)
|
||||
void * allocate_message (void)
|
||||
{
|
||||
message_t *message;
|
||||
|
||||
@@ -188,6 +181,7 @@ set_default_options (void)
|
||||
config.format = MBOX; /* default mailbox format */
|
||||
config.lock = FCNTL; /* default file locking method */
|
||||
config.merr = 1; /* report errors by default */
|
||||
config.debug = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -201,103 +195,104 @@ get_runtime_options (int *argc, char **argv, struct option *long_options)
|
||||
&option_index);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
case '?':
|
||||
usage();
|
||||
case 'c':
|
||||
config.action = COUNT;
|
||||
break;
|
||||
case 'd':
|
||||
config.action = DELETE;
|
||||
break;
|
||||
case 'e':
|
||||
config.regex_s = xstrdup (optarg);
|
||||
config.haveregex = 1;
|
||||
break;
|
||||
case 'o':
|
||||
config.outboxname = xstrdup (optarg);
|
||||
config.action = WRITE;
|
||||
break;
|
||||
case 'E':
|
||||
config.extended = 1;
|
||||
break;
|
||||
case 'G':
|
||||
config.extended = 0;
|
||||
break;
|
||||
case 'P':
|
||||
{
|
||||
case '?':
|
||||
usage();
|
||||
case 'c':
|
||||
config.action = COUNT;
|
||||
break;
|
||||
case 'd':
|
||||
config.action = DELETE;
|
||||
break;
|
||||
case 'e':
|
||||
config.regex_s = xstrdup (optarg);
|
||||
config.haveregex = 1;
|
||||
break;
|
||||
case 'o':
|
||||
config.outboxname = xstrdup (optarg);
|
||||
config.action = WRITE;
|
||||
break;
|
||||
case 'E':
|
||||
config.extended = 1;
|
||||
break;
|
||||
case 'G':
|
||||
config.extended = 0;
|
||||
break;
|
||||
case 'P':
|
||||
#ifdef HAVE_LIBPCRE
|
||||
config.extended = 0;
|
||||
config.perl = 1;
|
||||
config.extended = 0;
|
||||
config.perl = 1;
|
||||
#else
|
||||
fprintf(stderr,
|
||||
"%s: Support for Perl regular expressions not "
|
||||
"compiled in\n");
|
||||
exit(2);
|
||||
fprintf(stderr,
|
||||
"%s: Support for Perl regular expressions not "
|
||||
"compiled in\n", APPNAME);
|
||||
exit(2);
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
break;
|
||||
case 'h':
|
||||
help ();
|
||||
break;
|
||||
case 'i':
|
||||
config.ignorecase = 1;
|
||||
break;
|
||||
case 'm':
|
||||
config.format = folder_format (optarg);
|
||||
break;
|
||||
case 'l':
|
||||
config.lock = lock_method (optarg);
|
||||
break;
|
||||
case 'p':
|
||||
config.action = PIPE;
|
||||
config.pipecmd = xstrdup (optarg);
|
||||
break;
|
||||
case 'V':
|
||||
version ();
|
||||
break;
|
||||
case 'v':
|
||||
config.invert = 1;
|
||||
break;
|
||||
case 'H':
|
||||
config.headers = 1;
|
||||
break;
|
||||
case 'B':
|
||||
config.body = 1;
|
||||
break;
|
||||
case 's':
|
||||
config.merr = 0;
|
||||
break;
|
||||
case 201:
|
||||
config.lock = 0;
|
||||
break;
|
||||
case 'r':
|
||||
config.recursive = 1;
|
||||
break;
|
||||
case 200:
|
||||
config.dedup = 1;
|
||||
break;
|
||||
case 'n':
|
||||
{
|
||||
switch (optarg[0])
|
||||
{
|
||||
case 'd':
|
||||
config.dedup = 1;
|
||||
break;
|
||||
case 'l':
|
||||
config.lock = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid option -- n%c\n",
|
||||
APPNAME, optarg[0]);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
} /* switch */
|
||||
|
||||
/* }}} */
|
||||
break;
|
||||
case 'h':
|
||||
help ();
|
||||
break;
|
||||
case 'i':
|
||||
config.ignorecase = 1;
|
||||
break;
|
||||
case 'm':
|
||||
config.format = folder_format (optarg);
|
||||
break;
|
||||
case 'l':
|
||||
config.lock = lock_method (optarg);
|
||||
break;
|
||||
case 'p':
|
||||
config.action = PIPE;
|
||||
config.pipecmd = xstrdup (optarg);
|
||||
break;
|
||||
case 'V':
|
||||
version ();
|
||||
break;
|
||||
case 'v':
|
||||
config.invert = 1;
|
||||
break;
|
||||
case 'H':
|
||||
config.headers = 1;
|
||||
break;
|
||||
case 'B':
|
||||
config.body = 1;
|
||||
break;
|
||||
case 's':
|
||||
config.merr = 0;
|
||||
break;
|
||||
case 201:
|
||||
config.lock = 0;
|
||||
break;
|
||||
case 202:
|
||||
config.debug = 1;
|
||||
fprintf (stderr, "%s: %s, line %d: enable debugging\n",
|
||||
APPNAME, __FILE__, __LINE__);
|
||||
break;
|
||||
case 'r':
|
||||
config.recursive = 1;
|
||||
break;
|
||||
case 200:
|
||||
config.dedup = 1;
|
||||
break;
|
||||
case 'n':
|
||||
{
|
||||
switch (optarg[0])
|
||||
{
|
||||
case 'd':
|
||||
config.dedup = 1;
|
||||
break;
|
||||
case 'l':
|
||||
config.lock = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid option -- n%c\n",
|
||||
APPNAME, optarg[0]);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
} /* switch */
|
||||
} /* while */
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2006, 2023 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,8 +15,7 @@
|
||||
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: misc.h,v 1.9 2006-07-06 10:53:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H 1
|
||||
@@ -30,7 +29,7 @@ format_t folder_format (const char *name);
|
||||
lockmethod_t lock_method (const char *name);
|
||||
/* time_t parse_date(char *datestr); */
|
||||
char * parse_return_path(char *rpath);
|
||||
void * malloc_message (void);
|
||||
void * allocate_message (void);
|
||||
void postmark_print (message_t *msg);
|
||||
void set_default_options (void);
|
||||
void get_runtime_options (int *argc, char **argv, struct option *long_options);
|
||||
|
44
src/re.c
44
src/re.c
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2006 Daniel Spiljar
|
||||
Copyright (C) 2006, 2023 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,8 +15,7 @@
|
||||
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: re.c,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
@@ -27,6 +26,7 @@
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
#include "mboxgrep.h"
|
||||
#include "message.h"
|
||||
#include "wrap.h" /* xcalloc() et cetera */
|
||||
|
||||
#ifdef HAVE_LIBPCRE
|
||||
void
|
||||
@@ -37,13 +37,13 @@ pcre_init (void)
|
||||
|
||||
config.pcre_pattern =
|
||||
(pcre *) pcre_compile (config.regex_s,
|
||||
(config.ignorecase ? PCRE_CASELESS : 0),
|
||||
&error, &errptr, NULL);
|
||||
(config.ignorecase ? PCRE_CASELESS : 0),
|
||||
&error, &errptr, NULL);
|
||||
if (config.pcre_pattern == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s,
|
||||
error);
|
||||
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s,
|
||||
error);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -56,15 +56,15 @@ pcre_match (message_t *msg)
|
||||
if (config.headers)
|
||||
config.res1 =
|
||||
pcre_exec ((pcre *) config.pcre_pattern,
|
||||
(pcre_extra *) config.pcre_hints,
|
||||
msg->headers,
|
||||
(int) strlen (msg->headers), 0, 0, of, BUFSIZ);
|
||||
(pcre_extra *) config.pcre_hints,
|
||||
msg->headers,
|
||||
(int) strlen (msg->headers), 0, 0, of, BUFSIZ);
|
||||
if (config.body)
|
||||
config.res2 =
|
||||
pcre_exec ((pcre *) config.pcre_pattern,
|
||||
(pcre_extra *) config.pcre_hints,
|
||||
msg->body,
|
||||
(int) strlen (msg->body), 0, 0, of, BUFSIZ);
|
||||
(pcre_extra *) config.pcre_hints,
|
||||
msg->body,
|
||||
(int) strlen (msg->body), 0, 0, of, BUFSIZ);
|
||||
|
||||
config.res1 = config.res1 ^ 1;
|
||||
config.res2 = config.res2 ^ 1;
|
||||
@@ -82,17 +82,17 @@ regex_init (void)
|
||||
flag1 = REG_ICASE;
|
||||
if (config.extended)
|
||||
flag2 = REG_EXTENDED;
|
||||
|
||||
|
||||
config.posix_pattern = (regex_t *) xmalloc (sizeof (regex_t));
|
||||
errcode = regcomp ((regex_t *) config.posix_pattern, config.regex_s,
|
||||
(flag1 | flag2 | REG_NEWLINE ));
|
||||
if (0 != errcode)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
regerror (errcode, (regex_t *) config.posix_pattern, errbuf, BUFSIZ);
|
||||
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s,
|
||||
errbuf);
|
||||
}
|
||||
{
|
||||
regerror (errcode, (regex_t *) config.posix_pattern, errbuf, BUFSIZ);
|
||||
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, errbuf);
|
||||
}
|
||||
exit (2);
|
||||
}
|
||||
}
|
||||
@@ -102,8 +102,8 @@ regex_match (message_t *msg)
|
||||
{
|
||||
if (config.headers)
|
||||
config.res1 = regexec ((regex_t *) config.posix_pattern,
|
||||
msg->headers, 0, NULL, 0);
|
||||
msg->headers, 0, NULL, 0);
|
||||
if (config.body)
|
||||
config.res2 = regexec ((regex_t *) config.posix_pattern,
|
||||
msg->body, 0, NULL, 0);
|
||||
msg->body, 0, NULL, 0);
|
||||
}
|
||||
|
7
src/re.h
7
src/re.h
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2006 Daniel Spiljar
|
||||
Copyright (C) 2006, 2023 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,8 +15,7 @@
|
||||
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: re.h,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include "mboxgrep.h"
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: scan.h,v 1.7 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef SCAN_H
|
||||
#define SCAN_H 1
|
||||
|
70
src/wrap.c
70
src/wrap.c
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: wrap.c,v 1.13 2006-01-20 03:00:39 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
@@ -43,6 +42,9 @@
|
||||
#ifdef HAVE_LIBZ
|
||||
#include <zlib.h>
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
#include <bzlib.h>
|
||||
#endif /* HAVE_LIBBZ2 */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -65,13 +67,13 @@ int m_open (const char *pathname, int flags, mode_t mode)
|
||||
if (blah == -1 && config.merr)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, pathname);
|
||||
perror (NULL);
|
||||
}
|
||||
/* failure to open a file for writing should be fatal */
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, pathname);
|
||||
perror (NULL);
|
||||
}
|
||||
/* failure to open a file for writing should be fatal */
|
||||
if (((flags & O_WRONLY) == O_WRONLY) || ((flags & O_RDWR) == O_RDWR))
|
||||
exit (2);
|
||||
exit (2);
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
@@ -84,12 +86,12 @@ FILE *m_fopen (const char *path, const char *mode)
|
||||
if (blah == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
||||
perror (NULL);
|
||||
}
|
||||
if (mode[0] == 'w')
|
||||
exit (2);
|
||||
exit (2);
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
@@ -102,22 +104,22 @@ FILE *m_fdopen (int fildes, const char *mode)
|
||||
if (blah == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
|
||||
gzFile *m_gzdopen (int fildes, const char *mode)
|
||||
gzFile m_gzdopen (int fildes, const char *mode)
|
||||
{
|
||||
gzFile *blah;
|
||||
gzFile blah;
|
||||
|
||||
blah = gzdopen (fildes, mode);
|
||||
if (blah == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
@@ -132,10 +134,10 @@ DIR *m_opendir (const char *name)
|
||||
if (blah == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, name);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, name);
|
||||
perror (NULL);
|
||||
}
|
||||
}
|
||||
return blah;
|
||||
}
|
||||
@@ -150,7 +152,7 @@ void *xmalloc (size_t size)
|
||||
if (foo == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
exit (2);
|
||||
}
|
||||
return foo;
|
||||
@@ -164,7 +166,7 @@ void *xrealloc (void *ptr, size_t size)
|
||||
if (foo == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
exit (2);
|
||||
}
|
||||
return foo;
|
||||
@@ -178,7 +180,7 @@ void *xcalloc (size_t nmemb, size_t size)
|
||||
if (foo == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
exit (2);
|
||||
}
|
||||
return foo;
|
||||
@@ -192,7 +194,7 @@ char *xstrdup (const char *s)
|
||||
if (foo == NULL)
|
||||
{
|
||||
if (config.merr)
|
||||
perror (APPNAME);
|
||||
perror (APPNAME);
|
||||
exit (2);
|
||||
}
|
||||
return foo;
|
||||
@@ -208,10 +210,10 @@ int m_unlink (const char *pathname)
|
||||
if (baz == -1)
|
||||
{
|
||||
if (config.merr)
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, pathname);
|
||||
perror (NULL);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, pathname);
|
||||
perror (NULL);
|
||||
}
|
||||
}
|
||||
return baz;
|
||||
}
|
||||
@@ -227,10 +229,10 @@ void gzwrite_loop (void *fp, char *str)
|
||||
for (;;)
|
||||
{
|
||||
len = gzwrite (fp, (str+quux),
|
||||
(((quux + BUFLEN) < baz) ? BUFLEN : (baz - quux)));
|
||||
(((quux + BUFLEN) < baz) ? BUFLEN : (baz - quux)));
|
||||
quux += len;
|
||||
if (quux == baz)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,10 +249,10 @@ void bzwrite_loop (void *fp, char *str)
|
||||
for (;;)
|
||||
{
|
||||
len = BZ2_bzwrite (fp, (str+quux),
|
||||
(((quux + BUFLEN) < baz) ? BUFLEN : (baz - quux)));
|
||||
(((quux + BUFLEN) < baz) ? BUFLEN : (baz - quux)));
|
||||
quux += len;
|
||||
if (quux == baz)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +15,7 @@
|
||||
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: wrap.h,v 1.12 2006-01-20 03:00:39 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
/* This file is part of mboxgrep. */
|
||||
|
||||
@@ -57,7 +56,7 @@ int m_open (const char *pathname, int flags, mode_t mode);
|
||||
FILE *m_fopen (const char *path, const char *mode);
|
||||
FILE *m_fdopen (int fildes, const char *mode);
|
||||
#ifdef HAVE_LIBZ
|
||||
gzFile *m_gzdopen (int fildes, const char *mode);
|
||||
gzFile m_gzdopen (int fildes, const char *mode);
|
||||
void gzwrite_loop (void *fp, char *str);
|
||||
#endif /* HAVE_LIBZ */
|
||||
#ifdef HAVE_LIBBZ2
|
||||
|
Reference in New Issue
Block a user