Code indentation and other minor cleanups.

This commit is contained in:
Daniel Spiljar 2023-01-30 21:51:37 +01:00
parent 1d75932569
commit 8d46c633da
11 changed files with 330 additions and 364 deletions

View File

@ -28,7 +28,6 @@
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);
@ -39,11 +38,9 @@ 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;
@ -93,13 +90,12 @@ 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);
@ -157,15 +153,12 @@ 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, 2001, 2002, 2003 Daniel Spiljar Copyright (C) 2000 - 2003, 2023 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,8 +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
*/
$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, 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 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,8 +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
*/
$Id: maildir.c,v 1.25 2006-10-19 01:53:43 dspiljar Exp $ */
#include <config.h> #include <config.h>
@ -169,6 +168,7 @@ 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,6 +204,7 @@ 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 */
@ -216,7 +217,9 @@ 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

@ -15,7 +15,6 @@
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,8 +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
*/
$Id: mbox.c,v 1.34 2006-10-22 23:34:49 dspiljar Exp $ */
#include <config.h> #include <config.h>
@ -52,7 +51,6 @@
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;
@ -213,11 +211,9 @@ 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);
@ -233,12 +229,9 @@ 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];
@ -318,7 +311,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))
@ -331,18 +324,14 @@ 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;
@ -351,11 +340,9 @@ 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;
@ -377,13 +364,10 @@ 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);
@ -404,11 +388,9 @@ 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.
@ -427,11 +409,9 @@ 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;
@ -447,4 +427,3 @@ 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, 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 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,8 +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
*/
$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 Daniel Spiljar Copyright (C) 2020, 2023 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,8 +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
*/
$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) 2006 Daniel Spiljar Copyright (C) 2006, 2023 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,8 +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
*/
$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>
@ -90,8 +89,7 @@ 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, fprintf (stderr, "%s: %s: %s\n", APPNAME, config.regex_s, errbuf);
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 Daniel Spiljar Copyright (C) 2006, 2023 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,8 +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
*/
$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 -*- /* -*- 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 Daniel Spiljar Copyright (C) 2000 - 2003, 2023 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,8 +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
*/
$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, 2001, 2002, 2003 Daniel Spiljar Copyright (C) 2000 - 2003, 2023 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,8 +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
*/
$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. */