2023-01-30 20:51:37 +00:00
|
|
|
/*
|
2018-10-04 19:28:05 +00:00
|
|
|
mboxgrep - scan mailbox for messages matching a regular expression
|
2024-09-18 21:48:21 +00:00
|
|
|
Copyright (C) 2000 - 2004, 2006, 2023 - 2024 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-01-30 20:51:37 +00:00
|
|
|
*/
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <time.h>
|
|
|
|
#ifdef HAVE_FLOCK
|
2023-03-03 21:49:48 +00:00
|
|
|
# include <sys/file.h>
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_FLOCK */
|
|
|
|
#ifdef HAVE_LIBZ
|
2023-03-03 21:49:48 +00:00
|
|
|
# include <zlib.h>
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-03-03 21:49:48 +00:00
|
|
|
# include <bzlib.h>
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
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
|
|
|
#define BUFLEN 16384
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
#include "mboxgrep.h"
|
|
|
|
#include "mbox.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "wrap.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBDMALLOC
|
2023-03-03 21:49:48 +00:00
|
|
|
# include <dmalloc.h>
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBDMALLOC */
|
|
|
|
|
|
|
|
mbox_t *
|
2024-09-19 20:40:20 +00:00
|
|
|
mbox_open (const char *path, const mbox_mode_t mbox_mode)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
|
|
|
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));
|
|
|
|
|
|
|
|
if (0 == strcmp ("-", path))
|
|
|
|
mp->fp = stdin;
|
|
|
|
else
|
|
|
|
{
|
2024-09-19 20:40:20 +00:00
|
|
|
if (mbox_mode == w)
|
2023-01-30 20:51:37 +00:00
|
|
|
fd = m_open (path, (O_WRONLY | O_CREAT | O_APPEND),
|
2023-03-03 21:49:48 +00:00
|
|
|
(S_IWUSR | S_IRUSR));
|
2018-10-04 19:28:05 +00:00
|
|
|
else
|
2024-09-19 20:40:20 +00:00
|
|
|
fd = m_open (path, O_RDONLY, 0);
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
if (fd == -1)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
|
|
|
perror (NULL);
|
|
|
|
}
|
|
|
|
errno = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-03-03 21:49:48 +00:00
|
|
|
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.lock > LOCK_NONE)
|
2024-09-19 20:40:20 +00:00
|
|
|
mbox_lock (fd, path, mbox_mode);
|
2018-10-04 19:28:05 +00:00
|
|
|
|
2024-09-19 20:40:20 +00:00
|
|
|
if (mbox_mode == r)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (FILE *) m_fdopen (fd, "r");
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (gzFile *) m_gzdopen (fd, "rb");
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "rb");
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
2023-01-30 20:51:37 +00:00
|
|
|
}
|
2024-09-19 20:40:20 +00:00
|
|
|
else if (mbox_mode == w)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (FILE *) m_fdopen (fd, "w");
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (gzFile *) m_gzdopen (fd, "wb");
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
mp->fp = (BZFILE *) BZ2_bzdopen (fd, "wb");
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
2023-01-30 20:51:37 +00:00
|
|
|
}
|
2023-03-03 21:49:48 +00:00
|
|
|
|
2018-10-04 19:28:05 +00:00
|
|
|
if (mp->fp == NULL)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (config.merr)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: %s: ", APPNAME, path);
|
|
|
|
perror (NULL);
|
|
|
|
}
|
|
|
|
errno = 0;
|
|
|
|
close (fd);
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
}
|
|
|
|
|
2024-09-18 22:24:21 +00:00
|
|
|
memset (buffer, 0, BUFSIZ);
|
|
|
|
|
2024-09-19 20:40:20 +00:00
|
|
|
if (mbox_mode == r)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
fgets (buffer, BUFSIZ, mp->fp);
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
gzgets (mp->fp, buffer, BUFSIZ);
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
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';
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
|
|
|
|
|
|
|
if (0 != strncmp ("From ", buffer, 5))
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
2024-09-18 22:24:21 +00:00
|
|
|
if ((config.merr) && (buffer[0] != '\0'))
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (0 == strcmp ("-", path))
|
2024-09-18 22:24:21 +00:00
|
|
|
fprintf (stderr, "%s: (standard input): Not an mbox folder\n",
|
2023-03-03 21:49:48 +00:00
|
|
|
APPNAME);
|
2023-01-30 20:51:37 +00:00
|
|
|
else
|
2024-09-18 22:24:21 +00:00
|
|
|
fprintf (stderr, "%s: %s: Not an mbox folder\n", APPNAME,
|
2023-03-03 21:49:48 +00:00
|
|
|
path);
|
2023-01-30 20:51:37 +00:00
|
|
|
}
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
fclose (mp->fp);
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
gzclose (mp->fp);
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
BZ2_bzclose (mp->fp);
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
2023-01-30 20:51:37 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
strcpy (mp->postmark_cache, buffer);
|
|
|
|
}
|
|
|
|
return mp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mbox_close (mbox_t * mp)
|
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2018-10-04 19:28:05 +00:00
|
|
|
fclose (mp->fp);
|
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2018-10-04 19:28:05 +00:00
|
|
|
gzclose (mp->fp);
|
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2018-10-04 19:28:05 +00:00
|
|
|
BZ2_bzclose (mp->fp);
|
|
|
|
#endif /* HAVE_LIBBZ2 */
|
|
|
|
|
|
|
|
free (mp->postmark_cache);
|
|
|
|
free (mp);
|
|
|
|
}
|
|
|
|
|
|
|
|
message_t *
|
|
|
|
mbox_read_message (mbox_t * mp)
|
|
|
|
{
|
|
|
|
int isheaders = 1, s;
|
|
|
|
char buffer[BUFSIZ];
|
|
|
|
message_t *message;
|
|
|
|
|
2023-02-10 12:26:45 +00:00
|
|
|
message = allocate_message ();
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
s = strlen (mp->postmark_cache);
|
|
|
|
message->headers =
|
|
|
|
(char *) realloc (message->headers,
|
|
|
|
((1 + s + message->hbytes) * sizeof (char)));
|
|
|
|
strcpy (message->headers + message->hbytes, mp->postmark_cache);
|
|
|
|
message->hbytes += s;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2023-04-19 19:55:25 +00:00
|
|
|
if (config.format == FORMAT_MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (fgets (buffer, BUFSIZ, mp->fp) == NULL)
|
|
|
|
{
|
|
|
|
if (isheaders)
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (gzgets (mp->fp, buffer, BUFSIZ) == NULL)
|
|
|
|
{
|
|
|
|
if (isheaders)
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
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';
|
|
|
|
|
|
|
|
if (buffer[0] == '\0')
|
|
|
|
{
|
|
|
|
if (isheaders)
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBBZ2 */
|
|
|
|
|
|
|
|
s = strlen (buffer);
|
|
|
|
|
|
|
|
if (buffer[0] == '\n' && isheaders == 1)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
isheaders = 0;
|
|
|
|
continue;
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
|
|
|
|
if (isheaders)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
message->headers =
|
|
|
|
(char *) realloc (message->headers,
|
2023-03-03 21:49:48 +00:00
|
|
|
((1 + s + message->hbytes) * sizeof (char)));
|
2023-01-30 20:51:37 +00:00
|
|
|
strcpy (message->headers + message->hbytes, buffer);
|
|
|
|
message->hbytes += s;
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
else
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (0 == strncmp (buffer, "From ", 5))
|
|
|
|
{
|
|
|
|
strcpy (mp->postmark_cache, buffer);
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
message->body =
|
|
|
|
(char *) realloc (message->body,
|
2023-03-03 21:49:48 +00:00
|
|
|
((1 + s + message->bbytes) * sizeof (char)));
|
2023-01-30 20:51:37 +00:00
|
|
|
strcpy (message->body + message->bbytes, buffer);
|
|
|
|
message->bbytes += s;
|
|
|
|
}
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
tmpmbox_create (const char *path)
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
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
|
|
|
tmpfile_name (path);
|
|
|
|
foo = tmpfile_create ();
|
|
|
|
tmpfile_mod_own (foo, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
tmpfile_name (const char *path)
|
|
|
|
{
|
|
|
|
char *fname, *tmpdir;
|
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
if (path == NULL) /* no path prefix given, use /tmp or TMPDIR */
|
2018-10-04 19:28:05 +00:00
|
|
|
{
|
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
|
|
|
tmpdir = getenv ("TMPDIR");
|
|
|
|
if (tmpdir == NULL)
|
2023-01-30 20:51:37 +00:00
|
|
|
tmpdir = xstrdup ("/tmp");
|
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
|
|
|
fname = xstrdup ("/mboxgrepXXXXXX");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpdir = xstrdup (path);
|
|
|
|
fname = xstrdup (".XXXXXX");
|
2018-10-04 19:28:05 +00:00
|
|
|
}
|
|
|
|
|
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.tmpfilename =
|
|
|
|
(char *) xmalloc ((strlen (tmpdir) + (strlen (fname) + 1))
|
2023-03-03 21:49:48 +00:00
|
|
|
* sizeof (char));
|
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
|
|
|
sprintf (config.tmpfilename, "%s%s", tmpdir, fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-03 21:49:48 +00:00
|
|
|
void
|
|
|
|
mbox_write_message (message_t * msg, mbox_t * mbox)
|
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
|
|
|
if (config.format == FORMAT_MBOX)
|
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
|
|
|
fprintf (mbox->fp, "%s\n%s", msg->headers, msg->body);
|
2018-10-04 19:28:05 +00:00
|
|
|
#ifdef HAVE_LIBZ
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_ZMBOX)
|
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
|
|
|
{
|
|
|
|
gzwrite_loop (mbox->fp, msg->headers);
|
2023-03-03 21:49:48 +00:00
|
|
|
gzwrite (mbox->fp, "\n", 1);
|
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
|
|
|
gzwrite_loop (mbox->fp, msg->body);
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
#endif /* HAVE_LIBZ */
|
|
|
|
#ifdef HAVE_LIBBZ2
|
2023-04-19 19:55:25 +00:00
|
|
|
else if (config.format == FORMAT_BZ2MBOX)
|
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
|
|
|
{
|
|
|
|
bzwrite_loop (mbox->fp, msg->headers);
|
|
|
|
BZ2_bzwrite (mbox->fp, "\n", 1);
|
|
|
|
bzwrite_loop (mbox->fp, msg->body);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LIBBZ2 */
|
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
|
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
|
|
|
|
tmpfile_mod_own (const int fd, const char *path)
|
|
|
|
{
|
|
|
|
/* If we're root, copy {owner, group, perms} of mailbox to the tmpfile
|
|
|
|
* so rename() will thus retain the original's ownership & permissions.
|
|
|
|
*/
|
|
|
|
if (geteuid () == 0)
|
|
|
|
{
|
|
|
|
struct stat s;
|
|
|
|
|
|
|
|
if (stat (path, &s) != -1)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
if (fchown (fd, s.st_uid, s.st_gid) == -1)
|
2023-03-03 21:49:48 +00:00
|
|
|
if (config.merr)
|
|
|
|
perror (config.tmpfilename);
|
2023-01-30 20:51:37 +00:00
|
|
|
if (fchmod (fd, s.st_mode) == -1)
|
2023-03-03 21:49:48 +00:00
|
|
|
if (config.merr)
|
|
|
|
perror (config.tmpfilename);
|
2023-01-30 20:51:37 +00:00
|
|
|
}
|
2023-03-03 21:49:48 +00:00
|
|
|
else if (config.merr)
|
|
|
|
perror (path);
|
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
|
|
|
}
|
2018-10-04 19:28:05 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
tmpfile_create (void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = mkstemp (config.tmpfilename);
|
|
|
|
if (-1 == fd)
|
|
|
|
{
|
|
|
|
if (config.merr)
|
2023-01-30 20:51:37 +00:00
|
|
|
{
|
|
|
|
fprintf (stderr, "%s: %s: ", APPNAME, config.tmpfilename);
|
|
|
|
perror (NULL);
|
|
|
|
}
|
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
|
|
|
exit (2);
|
|
|
|
}
|
|
|
|
return fd;
|
|
|
|
}
|
2024-09-18 21:48:21 +00:00
|
|
|
|
|
|
|
void
|
2024-09-19 20:40:20 +00:00
|
|
|
mbox_lock (int fd, const char *path, const mbox_mode_t mbox_mode)
|
2024-09-18 21:48:21 +00:00
|
|
|
{
|
|
|
|
#ifdef HAVE_FLOCK
|
|
|
|
int op;
|
|
|
|
|
2024-09-19 20:40:20 +00:00
|
|
|
if (mbox_mode == r)
|
2024-09-18 21:48:21 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|