Code cleanup and indentation.
This commit is contained in:
parent
882a38f908
commit
fe1b5cdbd0
33
src/scan.c
33
src/scan.c
@ -1,6 +1,6 @@
|
||||
/* -*- C -*-
|
||||
/*
|
||||
mboxgrep - scan mailbox for messages matching a regular expression
|
||||
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006 Daniel Spiljar
|
||||
Copyright (C) 2000 - 2004, 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: scan.c,v 1.32 2006-10-22 23:34:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@ -70,7 +69,6 @@
|
||||
#endif /* HAVE_LIBDMALLOC */
|
||||
|
||||
void scan_mailbox (char path[])
|
||||
/* {{{ */
|
||||
{
|
||||
static FILE *outf;
|
||||
static mbox_t *mbox, *out;
|
||||
@ -85,7 +83,8 @@ void scan_mailbox (char path[])
|
||||
foo = opendir (config.outboxname); /* do NOT change this to m_opendir! */
|
||||
if (foo == NULL && errno == ENOENT)
|
||||
maildir_create (config.outboxname);
|
||||
else closedir (foo);
|
||||
else
|
||||
closedir (foo);
|
||||
|
||||
if (-1 == maildir_check (config.outboxname))
|
||||
{
|
||||
@ -115,7 +114,9 @@ void scan_mailbox (char path[])
|
||||
else if (config.format == MAILDIR)
|
||||
{
|
||||
maildird = maildir_open (path);
|
||||
if (maildird == NULL) return;
|
||||
|
||||
if (maildird == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
@ -156,6 +157,7 @@ void scan_mailbox (char path[])
|
||||
&& config.format != BZ2MBOX
|
||||
&& 0 != strncmp ("From ", msg->headers, 5))
|
||||
postmark_print (msg);
|
||||
|
||||
fprintf (stdout, "%s\n%s", msg->headers, msg->body);
|
||||
}
|
||||
else if (config.action == WRITE)
|
||||
@ -197,8 +199,7 @@ void scan_mailbox (char path[])
|
||||
mbox_write_message (msg, runtime.tmp_mbox);
|
||||
}
|
||||
|
||||
else if (((((config.res1 == 0) | (config.res2 == 0)) ^
|
||||
config.invert) && delete) &&
|
||||
else if (((((config.res1 == 0) | (config.res2 == 0)) ^ config.invert) && delete) &&
|
||||
((config.format == MH) || (config.format == NNMH) ||
|
||||
(config.format == NNML) || (config.format == MAILDIR)))
|
||||
m_unlink(msg->filename);
|
||||
@ -207,6 +208,7 @@ void scan_mailbox (char path[])
|
||||
free(msg->headers);
|
||||
free(msg);
|
||||
} /* for */
|
||||
|
||||
if ((config.format == MBOX) || (config.format == ZMBOX) ||
|
||||
(config.format == BZ2MBOX))
|
||||
mbox_close (mbox);
|
||||
@ -214,11 +216,8 @@ void scan_mailbox (char path[])
|
||||
(config.format == NNML))
|
||||
mh_close(boxd);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void recursive_scan (char path[])
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
#ifdef HAVE_FTS_OPEN
|
||||
FTS *ftsfoo;
|
||||
@ -251,20 +250,19 @@ void recursive_scan (char path[])
|
||||
#endif /* HAVE_FTS_OPEN */
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
int md5_check_message (char *body, checksum_t *chksum)
|
||||
/* {{{ */
|
||||
{
|
||||
struct md5_ctx a;
|
||||
char b[16];
|
||||
int i;
|
||||
|
||||
md5_init_ctx (&a);
|
||||
|
||||
if (body == NULL)
|
||||
md5_process_bytes ("", 0, &a);
|
||||
else
|
||||
md5_process_bytes (body, strlen(body), &a);
|
||||
|
||||
md5_finish_ctx(&a, b);
|
||||
|
||||
for (i = 0; i < chksum->n; i++)
|
||||
@ -273,12 +271,11 @@ int md5_check_message (char *body, checksum_t *chksum)
|
||||
return 1;
|
||||
}
|
||||
|
||||
chksum->md5 =
|
||||
(char **) xrealloc (chksum->md5, (1 + chksum->n) * sizeof (char *));
|
||||
chksum->md5 = (char **) xrealloc (chksum->md5, (1 + chksum->n) * sizeof (char *));
|
||||
|
||||
chksum->md5[chksum->n] = xstrdup (b);
|
||||
|
||||
(chksum->n)++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user