Compare commits
	
		
			28 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						3c96a4bd4e
	
				 | 
					
					
						|||
| 
						
						
							
						
						103e532c02
	
				 | 
					
					
						|||
| 4ada8db692 | |||
| 
						 | 
					ad59739005 | ||
| 
						 | 
					ba1513796b | ||
| 
						
						
							
						
						b93a60572b
	
				 | 
					
					
						|||
| 
						
						
							
						
						1938d25ced
	
				 | 
					
					
						|||
| 
						
						
							
						
						7b7bafd5f8
	
				 | 
					
					
						|||
| 
						
						
							
						
						eec14b33ff
	
				 | 
					
					
						|||
| 
						
						
							
						
						fdab5e8c5e
	
				 | 
					
					
						|||
| 
						
						
							
						
						66dd5fed23
	
				 | 
					
					
						|||
| 
						
						
							
						
						4cb77488bc
	
				 | 
					
					
						|||
| 
						
						
							
						
						6f8e688a46
	
				 | 
					
					
						|||
| 
						
						
							
						
						d8f44235f5
	
				 | 
					
					
						|||
| 
						
						
							
						
						6e9600426a
	
				 | 
					
					
						|||
| 
						
						
							
						
						b4d3034c8c
	
				 | 
					
					
						|||
| 
						
						
							
						
						9515236244
	
				 | 
					
					
						|||
| 
						
						
							
						
						a790494133
	
				 | 
					
					
						|||
| 
						
						
							
						
						ec8062309d
	
				 | 
					
					
						|||
| 
						
						
							
						
						631998a849
	
				 | 
					
					
						|||
| 
						
						
							
						
						bd64536e89
	
				 | 
					
					
						|||
| 
						
						
							
						
						b30f2f2362
	
				 | 
					
					
						|||
| 
						
						
							
						
						1a63374e73
	
				 | 
					
					
						|||
| 
						
						
							
						
						efc6f92cdb
	
				 | 
					
					
						|||
| 
						
						
							
						
						191b24433f
	
				 | 
					
					
						|||
| 
						
						
							
						
						40b6f8799f
	
				 | 
					
					
						|||
| 
						 | 
					13bf23b9a2 | ||
| 
						
						
							
						
						c732d4f949
	
				 | 
					
					
						
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
*.info binary
 | 
			
		||||
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -4,8 +4,7 @@ config.h.in
 | 
			
		||||
config.log
 | 
			
		||||
config.status
 | 
			
		||||
src/*.o
 | 
			
		||||
src/*.c~
 | 
			
		||||
src/*.h~
 | 
			
		||||
src/*.exe
 | 
			
		||||
src/mboxgrep
 | 
			
		||||
src/.deps/
 | 
			
		||||
src/stamp-h1
 | 
			
		||||
@@ -17,3 +16,6 @@ compile
 | 
			
		||||
depcomp
 | 
			
		||||
install-sh
 | 
			
		||||
missing
 | 
			
		||||
.gitignore
 | 
			
		||||
.vscode/*
 | 
			
		||||
*~
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								AUTHORS
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								AUTHORS
									
									
									
									
									
								
							@@ -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
									
								
							
							
						
						
									
										1
									
								
								AUTHORS.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
mboxgrep is written and maintained by Daniel Spiljar with contributors.
 | 
			
		||||
@@ -1,2 +1,2 @@
 | 
			
		||||
SUBDIRS = doc src
 | 
			
		||||
EXTRA_DIST = contrib COPYING.md INSTALL.md NEWS.md README.md TODO.md
 | 
			
		||||
EXTRA_DIST = COPYING.md INSTALL.md NEWS.md README.md TODO.md AUTHORS.md
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										51
									
								
								NEWS.md
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								NEWS.md
									
									
									
									
									
								
							@@ -1,21 +1,28 @@
 | 
			
		||||
# Changes of mboxgrep
 | 
			
		||||
 | 
			
		||||
## Changes since 0.7.12
 | 
			
		||||
## 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 since 0.7.11
 | 
			
		||||
## 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 since 0.7.10
 | 
			
		||||
## 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 since 0.7.9
 | 
			
		||||
## Changes in 0.7.10
 | 
			
		||||
 | 
			
		||||
- development has been restarted after a longer hiatus
 | 
			
		||||
- moved the source tree to git
 | 
			
		||||
@@ -24,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
 | 
			
		||||
@@ -33,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
 | 
			
		||||
@@ -42,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
 | 
			
		||||
@@ -91,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)
 | 
			
		||||
@@ -99,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 
 | 
			
		||||
@@ -112,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`)
 | 
			
		||||
@@ -133,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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								TODO.md
									
									
									
									
									
								
							@@ -4,36 +4,38 @@
 | 
			
		||||
 | 
			
		||||
- [x] use cryptographic hashes for detecting duplicate messages
 | 
			
		||||
- [x] 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] inverted matching
 | 
			
		||||
- [x] recursive search through directories
 | 
			
		||||
- [x] writing selected messages to a new folder
 | 
			
		||||
- [x] deleting selected messages
 | 
			
		||||
- [ ] basic time and date matching
 | 
			
		||||
- [ ] more advanced time and date matching, with strings such as "yesterday"
 | 
			
		||||
- [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
 | 
			
		||||
 | 
			
		||||
- [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
 | 
			
		||||
- [x] support for compressed mbox folders
 | 
			
		||||
- [x] support for bzip2 compression
 | 
			
		||||
- [ ] support for XZ-format compression
 | 
			
		||||
- [ ] support for mail folder conversion
 | 
			
		||||
- [ ] 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()
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								configure.ac
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								configure.ac
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
#  mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
#  Copyright (C) 2000 - 2003, 2023  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
 | 
			
		||||
@@ -18,18 +18,16 @@
 | 
			
		||||
# Process this file with autoconf to produce a configure script.
 | 
			
		||||
 | 
			
		||||
# Yawn.
 | 
			
		||||
AC_INIT([mboxgrep], [0.7.12a], [dspiljar@datatipp.se], [mboxgrep], [https://www.mboxgrep.org/])
 | 
			
		||||
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_HEADER([src/config.h])
 | 
			
		||||
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.
 | 
			
		||||
@@ -93,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
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
.TH MBOXGREP 1 "21 May 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.12a .
 | 
			
		||||
.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>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
This is mboxgrep.info, produced by makeinfo version 6.7 from
 | 
			
		||||
This is mboxgrep.info, produced by makeinfo version 6.8 from
 | 
			
		||||
mboxgrep.texi.
 | 
			
		||||
 | 
			
		||||
INFO-DIR-SECTION Mail
 | 
			
		||||
@@ -9,10 +9,10 @@ END-INFO-DIR-ENTRY
 | 
			
		||||
 | 
			
		||||
File: mboxgrep.info,  Node: Top,  Up: (dir)
 | 
			
		||||
 | 
			
		||||
This file documents 'mboxgrep' (version 0.7.12a), a mailbox scanning
 | 
			
		||||
This file documents 'mboxgrep' (version 0.7.13), a mailbox scanning
 | 
			
		||||
utility.
 | 
			
		||||
 | 
			
		||||
   Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
 | 
			
		||||
   Copyright (C) 2000 - 2003, 2024 Daniel Spiljar
 | 
			
		||||
 | 
			
		||||
* Menu:
 | 
			
		||||
 | 
			
		||||
@@ -151,10 +151,10 @@ options below change such behavior.
 | 
			
		||||
'-nd'
 | 
			
		||||
     Ignore duplicate messages.
 | 
			
		||||
 | 
			
		||||
'--output=FOLDER'
 | 
			
		||||
'-o FOLDER'
 | 
			
		||||
     Suppress normal output and write messages to destination folder
 | 
			
		||||
     FOLDER instead.
 | 
			
		||||
'--output=MAILBOX'
 | 
			
		||||
'-o MAILBOX'
 | 
			
		||||
     Suppress normal output and write messages to destination MAILBOX
 | 
			
		||||
     instead.
 | 
			
		||||
 | 
			
		||||
     Note that 'mboxgrep' assumes the output folder is of the same
 | 
			
		||||
     format as the input folder.  Currently there is no possibility to
 | 
			
		||||
@@ -250,17 +250,17 @@ Sleep well, little friend.
 | 
			
		||||
 | 
			
		||||
Tag Table:
 | 
			
		||||
Node: Top197
 | 
			
		||||
Node: Introduction597
 | 
			
		||||
Node: Invoking1466
 | 
			
		||||
Node: Miscellaneous1828
 | 
			
		||||
Node: File locking2113
 | 
			
		||||
Node: Regexp selection2750
 | 
			
		||||
Node: Output control3302
 | 
			
		||||
Node: Search scope selection4346
 | 
			
		||||
Node: Mailbox type selection4587
 | 
			
		||||
Node: Examples4908
 | 
			
		||||
Node: Bugs5732
 | 
			
		||||
Node: To Vicky6150
 | 
			
		||||
Node: Introduction591
 | 
			
		||||
Node: Invoking1460
 | 
			
		||||
Node: Miscellaneous1822
 | 
			
		||||
Node: File locking2107
 | 
			
		||||
Node: Regexp selection2744
 | 
			
		||||
Node: Output control3296
 | 
			
		||||
Node: Search scope selection4336
 | 
			
		||||
Node: Mailbox type selection4577
 | 
			
		||||
Node: Examples4898
 | 
			
		||||
Node: Bugs5722
 | 
			
		||||
Node: To Vicky6140
 | 
			
		||||
 | 
			
		||||
End Tag Table
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@
 | 
			
		||||
@setchapternewpage odd
 | 
			
		||||
 | 
			
		||||
@set EDITION 0.7
 | 
			
		||||
@set VERSION 0.7.12a
 | 
			
		||||
@set UPDATED 21 May 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.
 | 
			
		||||
 
 | 
			
		||||
@@ -52,6 +52,7 @@ char *alloca ();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
/* Comment out all this code if we are using the GNU C Library, and are not
 | 
			
		||||
   actually compiling the library itself.  This code is part of the GNU C
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
@@ -47,7 +47,7 @@ void
 | 
			
		||||
version (void)
 | 
			
		||||
{
 | 
			
		||||
  fprintf (stdout, "%s %s\n\n"
 | 
			
		||||
           "Copyright (C) 2000 - 2004, 2006, 2010, 2023  Daniel Spiljar\n"
 | 
			
		||||
           "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 "
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
  mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
  Copyright (C) 2000 - 2004, 2006, 2023  Daniel Spiljar
 | 
			
		||||
  Copyright (C) 2000 - 2004, 2006, 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
 | 
			
		||||
@@ -117,7 +117,7 @@ main (int argc, char **argv)
 | 
			
		||||
      if (config.action == ACTION_DELETE)
 | 
			
		||||
        {
 | 
			
		||||
          tmpmbox_create (argv[optind]);
 | 
			
		||||
          runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, "w");
 | 
			
		||||
          runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, w);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      config.boxname = xstrdup (argv[optind]);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										267
									
								
								src/mbox.c
									
									
									
									
									
								
							
							
						
						
									
										267
									
								
								src/mbox.c
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
   mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2023  Daniel Spiljar
 | 
			
		||||
   Copyright (C) 2000 - 2004, 2006, 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
 | 
			
		||||
@@ -50,166 +50,47 @@
 | 
			
		||||
#endif /* HAVE_LIBDMALLOC */
 | 
			
		||||
 | 
			
		||||
mbox_t *
 | 
			
		||||
mbox_open (const char *path, const char *mode)
 | 
			
		||||
mbox_open (const char *path, const mbox_mode_t mbox_mode)
 | 
			
		||||
{
 | 
			
		||||
  mbox_t *mp;
 | 
			
		||||
  static int fd;
 | 
			
		||||
#ifndef HAVE_FLOCK
 | 
			
		||||
  struct flock lck;
 | 
			
		||||
#endif /* HAVE_FLOCK */
 | 
			
		||||
  char buffer[BUFSIZ];
 | 
			
		||||
 | 
			
		||||
  mp = (mbox_t *) xmalloc (sizeof (mbox_t));
 | 
			
		||||
  mp->postmark_cache = (char *) xmalloc (BUFSIZ * sizeof (char));
 | 
			
		||||
  mp->postmark_cache = NULL;
 | 
			
		||||
 | 
			
		||||
  if (0 == strcmp ("-", path))
 | 
			
		||||
    mp->fp = stdin;
 | 
			
		||||
  else
 | 
			
		||||
    {
 | 
			
		||||
      if (mode[0] == 'r')
 | 
			
		||||
        fd = m_open (path, O_RDONLY, 0);
 | 
			
		||||
      else if (mode[0] == 'w')
 | 
			
		||||
      if (mbox_mode == w)
 | 
			
		||||
        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);
 | 
			
		||||
        }
 | 
			
		||||
        fd = m_open (path, O_RDONLY, 0);
 | 
			
		||||
 | 
			
		||||
      if (fd == -1)
 | 
			
		||||
        {
 | 
			
		||||
          if (config.merr)
 | 
			
		||||
            {
 | 
			
		||||
              fprintf (stderr, "%s: %s: ", APPNAME, path);
 | 
			
		||||
              perror (NULL);
 | 
			
		||||
            }
 | 
			
		||||
          errno = 0;
 | 
			
		||||
          return NULL;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
      if (config.lock > LOCK_NONE)
 | 
			
		||||
        {
 | 
			
		||||
#ifdef HAVE_FLOCK
 | 
			
		||||
          int op;
 | 
			
		||||
        mbox_lock (fd, path, mbox_mode);
 | 
			
		||||
 | 
			
		||||
          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;
 | 
			
		||||
 | 
			
		||||
          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 (mode[0] == 'r')
 | 
			
		||||
        {
 | 
			
		||||
          if (config.format == FORMAT_MBOX)
 | 
			
		||||
            mp->fp = (FILE *) m_fdopen (fd, "r");
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
          else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
            mp->fp = (gzFile *) m_gzdopen (fd, "rb");
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
          else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
            mp->fp = (BZFILE *) BZ2_bzdopen (fd, "rb");
 | 
			
		||||
#endif /* HAVE_LIBBZ2 */
 | 
			
		||||
        }
 | 
			
		||||
      else if (mode[0] == 'w')
 | 
			
		||||
        {
 | 
			
		||||
          if (config.format == FORMAT_MBOX)
 | 
			
		||||
            mp->fp = (FILE *) m_fdopen (fd, "w");
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
          else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
            mp->fp = (gzFile *) m_gzdopen (fd, "wb");
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
          else if (config.format == 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;
 | 
			
		||||
        }
 | 
			
		||||
      mp->fp = mbox_fdopen (fd, path, mbox_mode);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (mode[0] == 'r')
 | 
			
		||||
  if (mbox_mode == r)
 | 
			
		||||
    {
 | 
			
		||||
      if (config.format == FORMAT_MBOX)
 | 
			
		||||
        fgets (buffer, BUFSIZ, mp->fp);
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
      else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
        gzgets (mp->fp, buffer, BUFSIZ);
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
      else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
        {
 | 
			
		||||
          char c[1] = "\0";
 | 
			
		||||
          int n = 0;
 | 
			
		||||
      mp->postmark_cache = mbox_check_postmark (mp, path);
 | 
			
		||||
 | 
			
		||||
          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 == FORMAT_MBOX)
 | 
			
		||||
            fclose (mp->fp);
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
          else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
            gzclose (mp->fp);
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
          else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
            BZ2_bzclose (mp->fp);
 | 
			
		||||
#endif /* HAVE_LIBBZ2 */
 | 
			
		||||
          return NULL;
 | 
			
		||||
        }
 | 
			
		||||
      strcpy (mp->postmark_cache, buffer);
 | 
			
		||||
      if (! mp->postmark_cache)
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return mp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -431,3 +312,127 @@ tmpfile_create (void)
 | 
			
		||||
    }
 | 
			
		||||
  return fd;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
mbox_lock (int fd, const char *path, const mbox_mode_t mbox_mode)
 | 
			
		||||
{
 | 
			
		||||
#ifdef HAVE_FLOCK
 | 
			
		||||
  int op;
 | 
			
		||||
 | 
			
		||||
  if (mbox_mode == 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;
 | 
			
		||||
 | 
			
		||||
  if (-1 == fcntl (fd, F_SETLK, &lck))
 | 
			
		||||
#endif /* HAVE_FLOCK */
 | 
			
		||||
    {
 | 
			
		||||
      if (config.merr)
 | 
			
		||||
        {
 | 
			
		||||
          fprintf (stderr, "%s: %s: ", APPNAME, path);
 | 
			
		||||
          perror (NULL);
 | 
			
		||||
          exit (2);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void *
 | 
			
		||||
mbox_fdopen (int fd, const char *path, const mbox_mode_t mbox_mode)
 | 
			
		||||
{
 | 
			
		||||
  void *f;
 | 
			
		||||
  char *file_mode;
 | 
			
		||||
 | 
			
		||||
  if (mbox_mode == w)
 | 
			
		||||
    file_mode = xstrdup("wb");
 | 
			
		||||
  else
 | 
			
		||||
    file_mode = xstrdup("rb");
 | 
			
		||||
 | 
			
		||||
  if (config.format == FORMAT_MBOX)
 | 
			
		||||
    f = (FILE *) m_fdopen (fd, file_mode);
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
  else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
    f = (gzFile *) m_gzdopen (fd, file_mode);
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
  else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
    f = (BZFILE *) BZ2_bzdopen (fd, file_mode);
 | 
			
		||||
#endif /* HAVE_LIBBZ2 */
 | 
			
		||||
 | 
			
		||||
  if (f == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      if (config.merr)
 | 
			
		||||
        {
 | 
			
		||||
          fprintf (stderr, "%s: %s: ", APPNAME, path);
 | 
			
		||||
          perror (NULL);
 | 
			
		||||
        }
 | 
			
		||||
      errno = 0;
 | 
			
		||||
      close (fd);
 | 
			
		||||
      return NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return f;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
char *
 | 
			
		||||
mbox_check_postmark(mbox_t *mp, const char *path)
 | 
			
		||||
{
 | 
			
		||||
  char *buffer;
 | 
			
		||||
 | 
			
		||||
  buffer = (char *) xmalloc (BUFSIZ * sizeof (char));
 | 
			
		||||
  memset (buffer, 0, BUFSIZ);
 | 
			
		||||
 | 
			
		||||
  if (config.format == FORMAT_MBOX)
 | 
			
		||||
    fgets (buffer, BUFSIZ, mp->fp);
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
  else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
    gzgets (mp->fp, buffer, BUFSIZ);
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
  else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
    {
 | 
			
		||||
      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';
 | 
			
		||||
    }
 | 
			
		||||
#endif /* HAVE_LIBBZ2 */
 | 
			
		||||
 | 
			
		||||
  if (0 != strncmp ("From ", buffer, 5))
 | 
			
		||||
    {
 | 
			
		||||
      if ((config.merr) && (buffer[0] != '\0'))
 | 
			
		||||
        {
 | 
			
		||||
          if (0 == strcmp ("-", path))
 | 
			
		||||
            fprintf (stderr, "%s: (standard input): Not an mbox folder\n",
 | 
			
		||||
                     APPNAME);
 | 
			
		||||
          else
 | 
			
		||||
            fprintf (stderr, "%s: %s: Not an mbox folder\n", APPNAME,
 | 
			
		||||
                     path);
 | 
			
		||||
        }
 | 
			
		||||
      if (config.format == FORMAT_MBOX)
 | 
			
		||||
        fclose (mp->fp);
 | 
			
		||||
#ifdef HAVE_LIBZ
 | 
			
		||||
      else if (config.format == FORMAT_ZMBOX)
 | 
			
		||||
        gzclose (mp->fp);
 | 
			
		||||
#endif /* HAVE_LIBZ */
 | 
			
		||||
#ifdef HAVE_LIBBZ2
 | 
			
		||||
      else if (config.format == FORMAT_BZ2MBOX)
 | 
			
		||||
        BZ2_bzclose (mp->fp);
 | 
			
		||||
#endif /* HAVE_LIBBZ2 */
 | 
			
		||||
      return NULL;
 | 
			
		||||
    }
 | 
			
		||||
  return buffer;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								src/mbox.h
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/mbox.h
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
   mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
   Copyright (C) 2000 - 2004, 2023  Daniel Spiljar
 | 
			
		||||
   Copyright (C) 2000 - 2004, 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
 | 
			
		||||
@@ -19,9 +19,7 @@
 | 
			
		||||
 | 
			
		||||
#ifndef MBOX_H
 | 
			
		||||
#  define MBOX_H 1
 | 
			
		||||
 | 
			
		||||
#  include <config.h>
 | 
			
		||||
 | 
			
		||||
#  include "message.h"
 | 
			
		||||
 | 
			
		||||
typedef struct
 | 
			
		||||
@@ -31,8 +29,14 @@ typedef struct
 | 
			
		||||
  char *postmark_cache;
 | 
			
		||||
} mbox_t;
 | 
			
		||||
 | 
			
		||||
typedef enum
 | 
			
		||||
{
 | 
			
		||||
  r,
 | 
			
		||||
  w,
 | 
			
		||||
} mbox_mode_t;
 | 
			
		||||
 | 
			
		||||
mbox_t *mbox_open (const char *path, const char *mode);
 | 
			
		||||
 | 
			
		||||
mbox_t *mbox_open (const char *path, const mbox_mode_t mbox_mode);
 | 
			
		||||
void tmpmbox_create (const char *path);
 | 
			
		||||
void tmpfile_name (const char *path);
 | 
			
		||||
void tmpfile_mod_own (const int fd, const char *path);
 | 
			
		||||
@@ -40,5 +44,8 @@ int tmpfile_create (void);
 | 
			
		||||
void mbox_close (mbox_t * mbp);
 | 
			
		||||
message_t *mbox_read_message (mbox_t * mp);
 | 
			
		||||
void mbox_write_message (message_t * m, mbox_t * mbox);
 | 
			
		||||
void mbox_lock (int fd, const char *path, const mbox_mode_t mbox_mode);
 | 
			
		||||
void *mbox_fdopen (int fd, const char *path, const mbox_mode_t mbox_mode);
 | 
			
		||||
char *mbox_check_postmark(mbox_t *mp, const char *path);
 | 
			
		||||
 | 
			
		||||
#endif /* MBOX_H */
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
  mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
  Copyright (C) 2000 - 2003, 2006, 2023  Daniel Spiljar
 | 
			
		||||
  Copyright (C) 2000 - 2003, 2006, 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
 | 
			
		||||
@@ -21,8 +21,8 @@
 | 
			
		||||
#define MBOXGREP_H
 | 
			
		||||
 | 
			
		||||
#define APPNAME "mboxgrep"
 | 
			
		||||
#define VERSION "0.7.12a"
 | 
			
		||||
#define BUGREPORT_ADDR "dspiljar AT datatipp.se"
 | 
			
		||||
#define VERSION "0.7.13"
 | 
			
		||||
#define BUGREPORT_ADDR "dspiljar@datatipp.se"
 | 
			
		||||
 | 
			
		||||
#define HOST_NAME_SIZE 256
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										45
									
								
								src/md5.c
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								src/md5.c
									
									
									
									
									
								
							@@ -24,19 +24,12 @@
 | 
			
		||||
# include <config.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#if STDC_HEADERS || defined _LIBC
 | 
			
		||||
# include <stdlib.h>
 | 
			
		||||
# include <string.h>
 | 
			
		||||
#else
 | 
			
		||||
# ifndef HAVE_MEMCPY
 | 
			
		||||
#  define memcpy(d, s, n) bcopy ((s), (d), (n))
 | 
			
		||||
# endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "md5.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <sys/types.h>
 | 
			
		||||
 | 
			
		||||
#ifdef _LIBC
 | 
			
		||||
# include <endian.h>
 | 
			
		||||
# if __BYTE_ORDER == __BIG_ENDIAN
 | 
			
		||||
@@ -69,8 +62,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
 | 
			
		||||
/* Initialize structure containing state of computation.
 | 
			
		||||
   (RFC 1321, 3.3: Step 3)  */
 | 
			
		||||
void
 | 
			
		||||
md5_init_ctx (ctx)
 | 
			
		||||
     struct md5_ctx *ctx;
 | 
			
		||||
md5_init_ctx (struct md5_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
  ctx->A = 0x67452301;
 | 
			
		||||
  ctx->B = 0xefcdab89;
 | 
			
		||||
@@ -87,9 +79,7 @@ md5_init_ctx (ctx)
 | 
			
		||||
   IMPORTANT: On some systems it is required that RESBUF is correctly
 | 
			
		||||
   aligned for a 32 bits value.  */
 | 
			
		||||
void *
 | 
			
		||||
md5_read_ctx (ctx, resbuf)
 | 
			
		||||
     const struct md5_ctx *ctx;
 | 
			
		||||
     void *resbuf;
 | 
			
		||||
md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
 | 
			
		||||
{
 | 
			
		||||
  ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
 | 
			
		||||
  ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
 | 
			
		||||
@@ -105,9 +95,7 @@ md5_read_ctx (ctx, resbuf)
 | 
			
		||||
   IMPORTANT: On some systems it is required that RESBUF is correctly
 | 
			
		||||
   aligned for a 32 bits value.  */
 | 
			
		||||
void *
 | 
			
		||||
md5_finish_ctx (ctx, resbuf)
 | 
			
		||||
     struct md5_ctx *ctx;
 | 
			
		||||
     void *resbuf;
 | 
			
		||||
md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
 | 
			
		||||
{
 | 
			
		||||
  /* Take yet unprocessed bytes into account.  */
 | 
			
		||||
  md5_uint32 bytes = ctx->buflen;
 | 
			
		||||
@@ -136,9 +124,7 @@ md5_finish_ctx (ctx, resbuf)
 | 
			
		||||
   resulting message digest number will be written into the 16 bytes
 | 
			
		||||
   beginning at RESBLOCK.  */
 | 
			
		||||
int
 | 
			
		||||
md5_stream (stream, resblock)
 | 
			
		||||
     FILE *stream;
 | 
			
		||||
     void *resblock;
 | 
			
		||||
md5_stream (FILE *stream, void *resblock)
 | 
			
		||||
{
 | 
			
		||||
  /* Important: BLOCKSIZE must be a multiple of 64.  */
 | 
			
		||||
#define BLOCKSIZE 4096
 | 
			
		||||
@@ -193,10 +179,7 @@ md5_stream (stream, resblock)
 | 
			
		||||
   output yields to the wanted ASCII representation of the message
 | 
			
		||||
   digest.  */
 | 
			
		||||
void *
 | 
			
		||||
md5_buffer (buffer, len, resblock)
 | 
			
		||||
     const char *buffer;
 | 
			
		||||
     size_t len;
 | 
			
		||||
     void *resblock;
 | 
			
		||||
md5_buffer (const char *buffer, size_t len, void *resblock)
 | 
			
		||||
{
 | 
			
		||||
  struct md5_ctx ctx;
 | 
			
		||||
 | 
			
		||||
@@ -212,10 +195,7 @@ md5_buffer (buffer, len, resblock)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
md5_process_bytes (buffer, len, ctx)
 | 
			
		||||
     const void *buffer;
 | 
			
		||||
     size_t len;
 | 
			
		||||
     struct md5_ctx *ctx;
 | 
			
		||||
md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
  //const void aligned_buffer = buffer;
 | 
			
		||||
 | 
			
		||||
@@ -285,10 +265,7 @@ md5_process_bytes (buffer, len, ctx)
 | 
			
		||||
   It is assumed that LEN % 64 == 0.  */
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
md5_process_block (buffer, len, ctx)
 | 
			
		||||
     const void *buffer;
 | 
			
		||||
     size_t len;
 | 
			
		||||
     struct md5_ctx *ctx;
 | 
			
		||||
md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
  md5_uint32 correct_words[16];
 | 
			
		||||
  const md5_uint32 *words = buffer;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								src/md5.h
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/md5.h
									
									
									
									
									
								
							@@ -22,10 +22,7 @@
 | 
			
		||||
#define _MD5_H 1
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
#if defined HAVE_LIMITS_H || _LIBC
 | 
			
		||||
# include <limits.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
 | 
			
		||||
/* The following contortions are an attempt to use the C preprocessor
 | 
			
		||||
   to determine an unsigned integral type that is 32 bits wide.  An
 | 
			
		||||
@@ -38,20 +35,7 @@
 | 
			
		||||
# include <sys/types.h>
 | 
			
		||||
typedef u_int32_t md5_uint32;
 | 
			
		||||
#else
 | 
			
		||||
# if defined __STDC__ && __STDC__
 | 
			
		||||
#  define UINT_MAX_32_BITS 4294967295U
 | 
			
		||||
# else
 | 
			
		||||
#  define UINT_MAX_32_BITS 0xFFFFFFFF
 | 
			
		||||
# endif
 | 
			
		||||
 | 
			
		||||
/* If UINT_MAX isn't defined, assume it's a 32-bit type.
 | 
			
		||||
   This should be valid for all systems GNU cares about because
 | 
			
		||||
   that doesn't include 16-bit systems, and only modern systems
 | 
			
		||||
   (that certainly have <limits.h>) have 64+-bit integral types.  */
 | 
			
		||||
 | 
			
		||||
# ifndef UINT_MAX
 | 
			
		||||
#  define UINT_MAX UINT_MAX_32_BITS
 | 
			
		||||
# endif
 | 
			
		||||
#define UINT_MAX_32_BITS 4294967295U
 | 
			
		||||
 | 
			
		||||
# if UINT_MAX == UINT_MAX_32_BITS
 | 
			
		||||
   typedef unsigned int md5_uint32;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
/*
 | 
			
		||||
   mboxgrep - scan mailbox for messages matching a regular expression
 | 
			
		||||
   Copyright (C) 2000 - 2004, 2006, 2023  Daniel Spiljar
 | 
			
		||||
   Copyright (C) 2000 - 2004, 2006, 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
 | 
			
		||||
@@ -107,7 +107,7 @@ scan_mailbox (char path[])
 | 
			
		||||
  if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX)
 | 
			
		||||
      || (config.format == FORMAT_BZ2MBOX))
 | 
			
		||||
    {
 | 
			
		||||
      mbox = (mbox_t *) mbox_open (path, "r");
 | 
			
		||||
      mbox = (mbox_t *) mbox_open (path, r);
 | 
			
		||||
      if (mbox == NULL)
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
@@ -179,7 +179,7 @@ scan_mailbox (char path[])
 | 
			
		||||
              else if ((config.format == FORMAT_MBOX) || (config.format == FORMAT_ZMBOX)
 | 
			
		||||
                       || (config.format == FORMAT_BZ2MBOX))
 | 
			
		||||
                {
 | 
			
		||||
                  out = mbox_open (config.outboxname, "w");
 | 
			
		||||
                  out = mbox_open (config.outboxname, w);
 | 
			
		||||
                  /* fprintf (out->fp, "%s\n%s", msg->headers, msg->body); */
 | 
			
		||||
                  mbox_write_message (msg, out);
 | 
			
		||||
                  mbox_close (out);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user