Code indentation and other minor cleanups. #1
11
src/info.c
11
src/info.c
@ -28,7 +28,6 @@
|
||||
|
||||
void
|
||||
print_wrap (char *str, int len, int *n)
|
||||
/* {{{ */
|
||||
{
|
||||
*n += len;
|
||||
fprintf (stdout, str);
|
||||
@ -39,11 +38,9 @@ print_wrap (char *str, int len, int *n)
|
||||
}
|
||||
else fprintf (stdout, " ");
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
version (void)
|
||||
/* {{{ */
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
@ -93,13 +90,12 @@ 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);
|
||||
@ -157,15 +153,12 @@ 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);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: info.h,v 1.5 2003-04-13 19:15:58 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef INFO_H
|
||||
#define INFO_H
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2006, 2023 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,8 +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
|
||||
|
||||
$Id: maildir.c,v 1.25 2006-10-19 01:53:43 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@ -146,12 +145,12 @@ maildir_read_message (maildir_t *mdp)
|
||||
}
|
||||
}
|
||||
if (mdp->new == NULL && mdp->cur == NULL)
|
||||
{
|
||||
{
|
||||
free (message->headers);
|
||||
free (message->body);
|
||||
free (message);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (d_content->d_name[0] == '.')
|
||||
continue;
|
||||
@ -169,6 +168,7 @@ 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,6 +204,7 @@ 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 */
|
||||
@ -216,7 +217,9 @@ 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)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: maildir.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MAILDIR_H
|
||||
#define MAILDIR_H
|
||||
|
@ -15,7 +15,6 @@
|
||||
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>
|
||||
|
29
src/mbox.c
29
src/mbox.c
@ -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,8 +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
|
||||
|
||||
$Id: mbox.c,v 1.34 2006-10-22 23:34:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@ -52,7 +51,6 @@
|
||||
|
||||
mbox_t *
|
||||
mbox_open (const char *path, const char *mode)
|
||||
/* {{{ */
|
||||
{
|
||||
mbox_t *mp;
|
||||
static int fd;
|
||||
@ -213,11 +211,9 @@ mbox_open (const char *path, const char *mode)
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
mbox_close (mbox_t * mp)
|
||||
/* {{{ */
|
||||
{
|
||||
if (config.format == MBOX)
|
||||
fclose (mp->fp);
|
||||
@ -233,12 +229,9 @@ 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];
|
||||
@ -318,7 +311,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))
|
||||
@ -331,18 +324,14 @@ 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;
|
||||
|
||||
@ -351,11 +340,9 @@ tmpmbox_create (const char *path)
|
||||
tmpfile_mod_own (foo, path);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
void
|
||||
tmpfile_name (const char *path)
|
||||
/* {{{ */
|
||||
{
|
||||
char *fname, *tmpdir;
|
||||
|
||||
@ -377,13 +364,10 @@ 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);
|
||||
@ -404,11 +388,9 @@ 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.
|
||||
@ -427,11 +409,9 @@ tmpfile_mod_own (const int fd, const char *path)
|
||||
else if (config.merr) perror (path);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int
|
||||
tmpfile_create (void)
|
||||
/* {{{ */
|
||||
{
|
||||
int fd;
|
||||
|
||||
@ -447,4 +427,3 @@ tmpfile_create (void)
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2004, 2023 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,8 +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
|
||||
|
||||
$Id: mbox.h,v 1.13 2006-10-22 23:34:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MBOX_H
|
||||
#define MBOX_H 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2020 Daniel Spiljar
|
||||
Copyright (C) 2020, 2023 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,8 +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
|
||||
|
||||
$Id$ */
|
||||
*/
|
||||
|
||||
#ifndef MESSAGE_H
|
||||
#define MESSAGE_H 1
|
||||
|
7
src/mh.h
7
src/mh.h
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: mh.h,v 1.6 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MH_H
|
||||
#define MH_H 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2006, 2023 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,8 +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
|
||||
|
||||
$Id: misc.h,v 1.9 2006-07-06 10:53:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef MISC_H
|
||||
#define MISC_H 1
|
||||
|
10
src/re.c
10
src/re.c
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2006 Daniel Spiljar
|
||||
Copyright (C) 2006, 2023 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,8 +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
|
||||
|
||||
$Id: re.c,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
@ -90,8 +89,7 @@ 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);
|
||||
}
|
||||
|
7
src/re.h
7
src/re.h
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2006 Daniel Spiljar
|
||||
Copyright (C) 2006, 2023 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,8 +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
|
||||
|
||||
$Id: re.h,v 1.3 2006-07-07 04:15:44 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include "mboxgrep.h"
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: scan.h,v 1.7 2003-03-30 23:07:10 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#ifndef SCAN_H
|
||||
#define SCAN_H 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: wrap.c,v 1.13 2006-01-20 03:00:39 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <unistd.h>
|
||||
@ -69,7 +68,7 @@ int m_open (const char *pathname, int flags, mode_t mode)
|
||||
fprintf (stderr, "%s: %s: ", APPNAME, pathname);
|
||||
perror (NULL);
|
||||
}
|
||||
/* failure to open a file for writing should be fatal */
|
||||
/* failure to open a file for writing should be fatal */
|
||||
if (((flags & O_WRONLY) == O_WRONLY) || ((flags & O_RDWR) == O_RDWR))
|
||||
exit (2);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2003, 2023 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,8 +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
|
||||
|
||||
$Id: wrap.h,v 1.12 2006-01-20 03:00:39 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
/* This file is part of mboxgrep. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user