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

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef INFO_H
#define INFO_H #define INFO_H

View File

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

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef MAILDIR_H
#define MAILDIR_H #define MAILDIR_H

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef MBOX_H
#define MBOX_H 1 #define MBOX_H 1

View File

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

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef MH_H
#define MH_H 1 #define MH_H 1

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef MISC_H
#define MISC_H 1 #define MISC_H 1

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 <config.h>
#include <stdio.h> #include <stdio.h>
@ -89,7 +90,8 @@ regex_init (void)
if (config.merr) if (config.merr)
{ {
regerror (errcode, (regex_t *) config.posix_pattern, errbuf, BUFSIZ); 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); exit (2);
} }

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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" #include "mboxgrep.h"

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 #ifndef SCAN_H
#define SCAN_H 1 #define SCAN_H 1

View File

@ -1,6 +1,6 @@
/* -*- C -*- /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 <config.h>
#include <unistd.h> #include <unistd.h>

View File

@ -1,6 +1,6 @@
/* /* -*- C -*-
mboxgrep - scan mailbox for messages matching a regular expression 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 Mboxgrep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by 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 You should have received a copy of the GNU General Public License
along with mboxgrep; if not, write to the Free Software Foundation, along with mboxgrep; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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. */ /* This file is part of mboxgrep. */