2023-02-17 19:55:52 +00:00
|
|
|
/*
|
2018-10-04 19:28:05 +00:00
|
|
|
mboxgrep - scan mailbox for messages matching a regular expression
|
2023-02-17 19:55:52 +00:00
|
|
|
Copyright (C) 2000 - 2004, 2006, 2023 Daniel Spiljar
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
Mboxgrep is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Mboxgrep is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with mboxgrep; if not, write to the Free Software Foundation,
|
|
|
|
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2023-02-17 19:55:52 +00:00
|
|
|
*/
|
2018-10-04 19:28:05 +00:00
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
#define _XOPEN_SOURCE /* Pull in strptime(3) from time.h */
|
2023-04-19 21:04:57 +00:00
|
|
|
#define _DEFAULT_SOURCE /* Compensate for _XOPEN_SOURCE to pull in strdup(3)
|
2023-03-03 21:49:48 +00:00
|
|
|
* from string.h. */
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
2023-04-19 19:55:25 +00:00
|
|
|
#include <unistd.h>
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
#include "mboxgrep.h"
|
2023-04-19 19:55:25 +00:00
|
|
|
#include "misc.h"
|
2018-10-04 19:28:05 +00:00
|
|
|
#include "wrap.h"
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
#include "getopt.h"
|
2020-12-19 20:53:34 +00:00
|
|
|
#include "info.h"
|
|
|
|
#include "message.h"
|
2018-10-04 19:28:05 +00:00
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
/* Determine the folder format passed to -m. */
|
|
|
|
|
|
|
|
void
|
|
|
|
set_folder_format (const char *name)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format > 0)
|
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
fprintf (stderr, "%s: multiple mailbox types specified\n", APPNAME);
|
|
|
|
exit (2);
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
if (0 == strncasecmp (name, "mbox", 4))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_MBOX;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "zmbox", 5))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_ZMBOX;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "gzmbox", 6))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_ZMBOX;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "bzmbox", 5))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_BZ2MBOX;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "bz2mbox", 5))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_BZ2MBOX;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "mh", 2))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_MH;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "nnml", 4))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_NNML;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "nnmh", 4))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_NNMH;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "maildir", 7))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_MAILDIR;
|
2018-10-04 19:28:05 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (config.merr)
|
2023-02-17 21:19:36 +00:00
|
|
|
fprintf (stderr, "%s: %s: unknown folder type\n", APPNAME, name);
|
2018-10-04 19:28:05 +00:00
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
/* Determine the file locking method passed to -l. */
|
|
|
|
|
|
|
|
void
|
|
|
|
set_lock_method (const char *name)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.lock > 0)
|
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
fprintf (stderr, "%s: conflicting file locking options specified\n", APPNAME);
|
|
|
|
exit (2);
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
if (0 == strncasecmp (name, "none", 4))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.lock = LOCK_NONE;
|
2018-10-04 19:28:05 +00:00
|
|
|
else if (0 == strncasecmp (name, "off", 3))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.lock = LOCK_NONE;
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_FCNTL
|
|
|
|
else if (0 == strncasecmp (name, "fcntl", 5))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.lock = LOCK_FCNTL;
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_FCNTL */
|
|
|
|
#ifdef HAVE_FLOCK
|
|
|
|
else if (0 == strncasecmp (name, "flock", 5))
|
2023-04-19 19:55:25 +00:00
|
|
|
config.lock = LOCK_FLOCK;
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_FLOCK */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (config.merr)
|
2023-03-03 21:49:48 +00:00
|
|
|
fprintf (stderr, "mboxgrep: %s: unknown file locking method\n", name);
|
2018-10-04 19:28:05 +00:00
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
}
|
2023-02-17 19:55:52 +00:00
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
/* Dead code */
|
|
|
|
|
2023-02-17 19:55:52 +00:00
|
|
|
/*
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
*/
|
2018-10-04 19:28:05 +00:00
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
char *
|
|
|
|
parse_return_path (char *rpath)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
|
|
|
char *blah1, blah2[BUFSIZ];
|
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
sscanf (rpath, "Return-Path: <%[^\r\n>]>", blah2);
|
2018-10-04 19:28:05 +00:00
|
|
|
blah1 = xstrdup (blah2);
|
|
|
|
|
|
|
|
return blah1;
|
|
|
|
}
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
void *
|
|
|
|
allocate_message (void)
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
{
|
|
|
|
message_t *message;
|
|
|
|
|
|
|
|
message = (message_t *) xmalloc (sizeof (message_t));
|
|
|
|
|
|
|
|
message->headers = (char *) xmalloc (sizeof (char));
|
|
|
|
message->headers[0] = '\0';
|
|
|
|
message->hbytes = 0;
|
|
|
|
|
|
|
|
message->body = (char *) xmalloc (sizeof (char));
|
|
|
|
message->body[0] = '\0';
|
|
|
|
message->bbytes = 0;
|
|
|
|
|
|
|
|
message->from = NULL;
|
|
|
|
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
void
|
|
|
|
postmark_print (message_t * msg)
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
{
|
|
|
|
time_t tt;
|
|
|
|
struct tm *ct;
|
|
|
|
char date_str[80];
|
|
|
|
|
|
|
|
tt = time (NULL);
|
|
|
|
ct = localtime (&tt);
|
|
|
|
strftime (date_str, 80, "%a %b %d %H:%M:%S %Y", ct);
|
|
|
|
if (msg->from)
|
|
|
|
fprintf (stdout, "From %s %s\n", msg->from, date_str);
|
|
|
|
else
|
|
|
|
fprintf (stdout, "From nobody %s\n", date_str);
|
|
|
|
}
|
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
/* Initialize the option_t struct. */
|
|
|
|
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
void
|
2023-04-19 19:55:25 +00:00
|
|
|
init_options (void)
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
config.regextype = REGEX_UNDEF;
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
config.invert = 0;
|
|
|
|
config.headers = 0;
|
|
|
|
config.body = 0;
|
2023-04-19 19:55:25 +00:00
|
|
|
config.action = ACTION_UNDEF;
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
config.dedup = 0;
|
|
|
|
config.recursive = 0;
|
|
|
|
config.ignorecase = 0;
|
2023-04-19 19:55:25 +00:00
|
|
|
config.format = FORMAT_UNDEF;
|
|
|
|
config.lock = LOCK_UNDEF; /* default file locking method */
|
2023-03-03 21:49:48 +00:00
|
|
|
config.merr = 1; /* report errors by default */
|
2023-02-17 21:19:36 +00:00
|
|
|
config.debug = 0;
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
}
|
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
/* Parse command-line arguments and assign values to option_t. */
|
|
|
|
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
void
|
2023-04-19 19:55:25 +00:00
|
|
|
get_options (int *argc, char **argv, struct option *long_options)
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
{
|
|
|
|
int option_index = 0, c;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2023-03-03 21:49:48 +00:00
|
|
|
c = getopt_long (*argc, argv, "BcdEe:GHhil:m:n:o:Pp:rsVv", long_options,
|
|
|
|
&option_index);
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
|
|
|
|
if (c == -1)
|
2023-02-17 19:55:52 +00:00
|
|
|
break;
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
|
|
|
|
switch (c)
|
2023-02-17 19:55:52 +00:00
|
|
|
{
|
2023-03-03 21:49:48 +00:00
|
|
|
case '?':
|
|
|
|
usage ();
|
|
|
|
case 'c':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_action (ACTION_COUNT, NULL);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_action (ACTION_DELETE, NULL);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
config.regex_s = xstrdup (optarg);
|
|
|
|
config.haveregex = 1;
|
|
|
|
break;
|
|
|
|
case 'o':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_action (ACTION_WRITE, optarg);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'E':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_regextype (REGEX_EXTENDED);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'G':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_regextype (REGEX_BASIC);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'P':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_regextype (REGEX_PERL);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
help ();
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
config.ignorecase = 1;
|
|
|
|
break;
|
|
|
|
case 'm':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_folder_format (optarg);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'l':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_lock_method (optarg);
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
case 'p':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_option_action (ACTION_PIPE, optarg);
|
2023-03-03 21:49:48 +00:00
|
|
|
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':
|
2023-04-19 19:55:25 +00:00
|
|
|
set_lock_method ("none");
|
2023-03-03 21:49:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf (stderr, "%s: invalid option -- n%c\n",
|
|
|
|
APPNAME, optarg[0]);
|
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* switch */
|
|
|
|
} /* while */
|
Bump to version 0.7.10 and import of changes that have been made between
2003 and 2006 and haven't been tracked by any SCM.
The changes are the following, in reverse order:
* 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.
* src/mboxgrep.h, src/main.c, src/maildir.c, src/scan.c:
Got rid off tmpp and maildir_count global variables (code
cleanup).
* 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).
* 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).
* 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().
* 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).
* 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).
* src/mbox.c, src/mbox.h:
File mode and ownership-altering code has been moved to a separate
function, tmpfile_mod_own (code cleanup).
* src/mbox.c, src/mbox.h:
Portions of the code from tmpfile_open moved to a new function,
tmpfile_name (code cleanup).
* src/maildir.c, src/mh.c:
Removed some unused variables (have_return_path).
* 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.
* src/scan.c, src/misc.c, src/misc.h:
Created postmark_print() to unclutter scan_mailbox().
* src/misc.c, src/misc.h, src/mbox.c, src/maildir.c, src/mh.c:
Some repetitive code moved to malloc_message().
* src/mbox.c:
Cleanup of mbox_write_message(); use of gzwrite_loop() and
bzwrite_loop().
* src/scan.c, src/wrap.h, src/wrap.c:
Wrote gzwrite_loop() and bzwrite_loop() to remove some repetitive
code from scan.c.
* src/scan.c:
md5_check_message(): array b and cast in strncmp are no longer
unsigned.
* src/info.c, src/mboxgrep.h:
Updated copyright information, changed author's email address
to the one at Panix.
* src/mbox.h, src/mbox.c, src/scan.c, src/main.c:
mbox_write_message(); further fixes of message deletion code.
* src/scan.c:
Fixed deleting messages from mbox folders compressed with
bzip2.
* src/main.c, src/mbox.c:
Moved James P. Dugal's ownership-preserving code from main()
to tmpfile_open().
* src/info.c:
If bzip2 support is compiled in, `--help' command should list
`bz2mbox' as a valid option to `--mailbox-format='.
2018-10-04 20:07:27 +00:00
|
|
|
}
|
2023-04-19 19:55:25 +00:00
|
|
|
|
|
|
|
/* Check the state of command-line options after parsing them.
|
|
|
|
* Raise error on conflicting options and set uninitialized ones to default values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
check_options (void)
|
|
|
|
{
|
|
|
|
gethostname (config.hostname, HOST_NAME_SIZE);
|
|
|
|
config.pid = (int) getpid ();
|
|
|
|
|
|
|
|
if (config.action == ACTION_UNDEF)
|
|
|
|
{
|
|
|
|
config.action = ACTION_DISPLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.format == FORMAT_UNDEF)
|
|
|
|
{
|
|
|
|
config.format = FORMAT_MBOX; /* default mailbox format */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config.regextype == REGEX_UNDEF)
|
|
|
|
{
|
|
|
|
config.regextype = REGEX_EXTENDED; /* default regex type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((config.body == 0) && (config.headers == 0))
|
|
|
|
{
|
|
|
|
config.body = 1;
|
|
|
|
config.headers = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_option_action (action_t action, char *path)
|
|
|
|
{
|
|
|
|
if (config.action > 0)
|
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
fprintf (stderr, "%s: conflicting actions specified\n", APPNAME);
|
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
|
|
|
|
config.action = action;
|
|
|
|
|
|
|
|
if (action == ACTION_WRITE)
|
|
|
|
{
|
|
|
|
config.outboxname = xstrdup (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (action == ACTION_PIPE)
|
|
|
|
{
|
|
|
|
config.pipecmd = xstrdup (optarg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set_option_regextype (regextype_t regextype)
|
|
|
|
{
|
|
|
|
if (config.regextype > 0)
|
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
fprintf (stderr, "%s: conflicting matchers specified\n", APPNAME);
|
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
|
2023-05-17 14:27:47 +00:00
|
|
|
#ifndef HAVE_LIBPCRE2
|
2023-04-19 19:55:25 +00:00
|
|
|
if (regextype == REGEX_PERL);
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"%s: Support for Perl regular expressions not compiled in\n",
|
|
|
|
APPNAME);
|
|
|
|
exit (2);
|
|
|
|
}
|
2023-05-17 14:27:47 +00:00
|
|
|
#endif /* HAVE_LIBPCRE2 */
|
2023-04-19 19:55:25 +00:00
|
|
|
config.regextype = regextype;
|
|
|
|
}
|