Compare commits

..

No commits in common. "95d67d850c0339ef2a7facc34e2a77416ca8b53a" and "1d75932569010ec039b902eaecb575e06e19a652" have entirely different histories.

15 changed files with 380 additions and 342 deletions

View File

@ -28,6 +28,7 @@
void
print_wrap (char *str, int len, int *n)
/* {{{ */
{
*n += len;
fprintf (stdout, str);
@ -38,9 +39,11 @@ print_wrap (char *str, int len, int *n)
}
else fprintf (stdout, " ");
}
/* }}} */
void
version (void)
/* {{{ */
{
int n = 0;
@ -90,12 +93,13 @@ version (void)
print_wrap ("HAVE_SYS_NDIR_H", 15, &n);
#endif
fprintf (stdout, "\n");
exit(0);
}
/* }}} */
void
help (void)
/* {{{ */
{
fprintf(stdout, "%s %s - search MAILBOX for messages matching PATTERN\n\n",
APPNAME, VERSION);
@ -153,12 +157,15 @@ help (void)
exit(0);
}
/* }}} */
void
usage (void)
/* {{{ */
{
printf ("Usage: %s [OPTION] PATTERN MAILBOX ...\n\n"
"Try `%s --help' for more information.\n", APPNAME, APPNAME);
exit (2);
}
/* }}} */

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: info.h,v 1.5 2003-04-13 19:15:58 dspiljar Exp $ */
#ifndef INFO_H
#define INFO_H

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2006, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: maildir.c,v 1.25 2006-10-19 01:53:43 dspiljar Exp $ */
#include <config.h>
@ -168,7 +169,6 @@ maildir_read_message (maildir_t *mdp)
sprintf (filename, "%s/new/%s", config.boxname, d_content->d_name);
else
sprintf (filename, "%s/cur/%s", config.boxname, d_content->d_name);
message->filename = (char *) xstrdup (filename);
free (filename);
@ -204,7 +204,6 @@ maildir_read_message (maildir_t *mdp)
message->headers =
(char *) xrealloc (message->headers,
((1 + s + message->hbytes) * sizeof (char)));
strcpy (message->headers + message->hbytes, buffer);
message->hbytes += s;
} /* if */
@ -217,9 +216,7 @@ maildir_read_message (maildir_t *mdp)
message->bbytes += s;
} /* else */
} /* while */
/* if (!have_from || !have_to || !have_message_id) */
if ((!have_from && !have_sender)|| !have_date)
{
if (config.merr)

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: maildir.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
#ifndef MAILDIR_H
#define MAILDIR_H

View File

@ -15,6 +15,7 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>

View File

@ -1,4 +1,4 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Daniel Spiljar
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: mbox.c,v 1.34 2006-10-22 23:34:49 dspiljar Exp $ */
#include <config.h>
@ -51,6 +52,7 @@
mbox_t *
mbox_open (const char *path, const char *mode)
/* {{{ */
{
mbox_t *mp;
static int fd;
@ -211,9 +213,11 @@ mbox_open (const char *path, const char *mode)
}
return mp;
}
/* }}} */
void
mbox_close (mbox_t * mp)
/* {{{ */
{
if (config.format == MBOX)
fclose (mp->fp);
@ -229,9 +233,12 @@ mbox_close (mbox_t * mp)
free (mp->postmark_cache);
free (mp);
}
/* }}} */
message_t *
mbox_read_message (mbox_t * mp)
/* {{{ */
{
int isheaders = 1, s;
char buffer[BUFSIZ];
@ -311,7 +318,7 @@ mbox_read_message (mbox_t * mp)
((1 + s + message->hbytes) * sizeof (char)));
strcpy (message->headers + message->hbytes, buffer);
message->hbytes += s;
}
} /* if */
else
{
if (0 == strncmp (buffer, "From ", 5))
@ -324,14 +331,18 @@ mbox_read_message (mbox_t * mp)
((1 + s + message->bbytes) * sizeof (char)));
strcpy (message->body + message->bbytes, buffer);
message->bbytes += s;
}
}
} /* for */
return NULL;
}
/* }}} */
void
tmpmbox_create (const char *path)
/* {{{ */
{
int foo;
@ -340,9 +351,11 @@ tmpmbox_create (const char *path)
tmpfile_mod_own (foo, path);
}
/* }}} */
void
tmpfile_name (const char *path)
/* {{{ */
{
char *fname, *tmpdir;
@ -364,10 +377,13 @@ tmpfile_name (const char *path)
* sizeof (char));
sprintf (config.tmpfilename, "%s%s", tmpdir, fname);
}
/* }}} */
void
mbox_write_message (message_t *msg, mbox_t *mbox)
/* {{{ */
{
if (config.format == MBOX)
fprintf (mbox->fp, "%s\n%s", msg->headers, msg->body);
@ -388,9 +404,11 @@ mbox_write_message (message_t *msg, mbox_t *mbox)
}
#endif /* HAVE_LIBBZ2 */
}
/* }}} */
void
tmpfile_mod_own (const int fd, const char *path)
/* {{{ */
{
/* If we're root, copy {owner, group, perms} of mailbox to the tmpfile
* so rename() will thus retain the original's ownership & permissions.
@ -409,9 +427,11 @@ tmpfile_mod_own (const int fd, const char *path)
else if (config.merr) perror (path);
}
}
/* }}} */
int
tmpfile_create (void)
/* {{{ */
{
int fd;
@ -427,3 +447,4 @@ tmpfile_create (void)
}
return fd;
}
/* }}} */

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2004, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003, 2004 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: mbox.h,v 1.13 2006-10-22 23:34:49 dspiljar Exp $ */
#ifndef MBOX_H
#define MBOX_H 1

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2020, 2023 Daniel Spiljar
Copyright (C) 2020 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id$ */
#ifndef MESSAGE_H
#define MESSAGE_H 1

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: mh.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
#ifndef MH_H
#define MH_H 1

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2006, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: misc.h,v 1.9 2006-07-06 10:53:49 dspiljar Exp $ */
#ifndef MISC_H
#define MISC_H 1

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2006, 2023 Daniel Spiljar
Copyright (C) 2006 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: re.c,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
#include <config.h>
#include <stdio.h>
@ -89,7 +90,8 @@ regex_init (void)
if (config.merr)
{
regerror (errcode, (regex_t *) config.posix_pattern, errbuf, BUFSIZ);
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, errbuf);
fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s,
errbuf);
}
exit (2);
}

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2006, 2023 Daniel Spiljar
Copyright (C) 2006 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: re.h,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
#include "mboxgrep.h"

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: scan.h,v 1.7 2003-03-30 23:07:10 dspiljar Exp $ */
#ifndef SCAN_H
#define SCAN_H 1

View File

@ -1,6 +1,6 @@
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: wrap.c,v 1.13 2006-01-20 03:00:39 dspiljar Exp $ */
#include <config.h>
#include <unistd.h>

View File

@ -1,6 +1,6 @@
/*
/* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression
Copyright (C) 2000 - 2003, 2023 Daniel Spiljar
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
@ -15,7 +15,8 @@
You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
$Id: wrap.h,v 1.12 2006-01-20 03:00:39 dspiljar Exp $ */
/* This file is part of mboxgrep. */