Compare commits
2 Commits
7dd6f3d69d
...
5cc84ca1bd
Author | SHA1 | Date | |
---|---|---|---|
5cc84ca1bd | |||
af7c6c8ced |
@ -1,5 +1,4 @@
|
||||
.Id $Id: mboxgrep.1,v 1.16 2006-01-18 00:09:58 dspiljar Exp $
|
||||
.TH MBOXGREP 1 "26 Jan 2023"
|
||||
.TH MBOXGREP 1 "17 Feb 2023"
|
||||
.SH NAME
|
||||
mboxgrep \- displays email messages matching a pattern
|
||||
.SH SYNOPSIS
|
||||
@ -86,6 +85,10 @@ Ignore duplicate messages.
|
||||
Select input and output mailbox TYPE. TYPE can be either `mbox' (default),
|
||||
`zmbox' (gzip compressed mbox), `bz2mbox' (bzip2 compressed mbox), `mh', `nnml',
|
||||
`nnmh' or `maildir'.
|
||||
.IP "-s, --no-messages"
|
||||
Suppress most error messages.
|
||||
.IP "--debug"
|
||||
Print messages useful for debugging.
|
||||
.SH EXAMPLES
|
||||
.TP
|
||||
\(bu
|
||||
|
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
|
||||
@set EDITION 0.7
|
||||
@set VERSION 0.7.10
|
||||
@set UPDATED 26 Jan 2023
|
||||
@set UPDATED 17 Feb 2023
|
||||
|
||||
@dircategory Mail
|
||||
@direntry
|
||||
@ -188,6 +188,9 @@ instance of COMMAND.
|
||||
@itemx -s
|
||||
Suppress error messages.
|
||||
|
||||
@item --debug
|
||||
Print messages useful for debugging.
|
||||
|
||||
@end table
|
||||
|
||||
@node Search scope selection, Mailbox type selection, Output control, Invoking
|
||||
|
@ -120,7 +120,8 @@ help (void)
|
||||
" -nd, --no-duplicates\t\tIgnore duplicate messages\n"
|
||||
" -o, --output=MAILBOX\t\tWrite messages to MAILBOX\n"
|
||||
" -p, --pipe=COMMAND\t\tPipe each found message to COMMAND\n"
|
||||
" -s, --no-messages\t\tSuppress most error messages\n\n"
|
||||
" -s, --no-messages\t\tSuppress most error messages\n"
|
||||
" --debug\t\t\tPrint messages useful for debugging\n\n"
|
||||
"Matching criteria:\n\n"
|
||||
" -E, --extended-regexp\tPATTERN is an extended regular expression\n"
|
||||
" -G, --basic-regexp\t\tPATTERN is a basic regular expression\n");
|
||||
|
30
src/main.c
30
src/main.c
@ -48,8 +48,6 @@ runtime_t runtime;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
int havemailbox = 0;
|
||||
int singlefile = 0;
|
||||
@ -57,8 +55,6 @@ main (int argc, char **argv)
|
||||
runtime.maildir_count = 0;
|
||||
|
||||
static struct option long_options[] =
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
{"count", 0, 0, 'c'},
|
||||
{"delete", 0, 0, 'd'},
|
||||
@ -80,13 +76,12 @@ main (int argc, char **argv)
|
||||
{"output", 1, 0, 'o'},
|
||||
{"no-duplicates", 0, 0, 200},
|
||||
{"no-file-lock", 0, 0, 201},
|
||||
{"debug", 0, 0, 202},
|
||||
{"file-lock", 1, 0, 'l'},
|
||||
{"recursive", 0, 0, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/* }}} */
|
||||
|
||||
set_default_options ();
|
||||
|
||||
get_runtime_options (&argc, argv, long_options);
|
||||
@ -112,7 +107,7 @@ main (int argc, char **argv)
|
||||
config.regex_s = xstrdup (argv[optind]);
|
||||
config.haveregex = 1;
|
||||
++optind;
|
||||
} /* if */
|
||||
}
|
||||
|
||||
if (config.haveregex)
|
||||
{
|
||||
@ -122,7 +117,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
regex_init ();
|
||||
} /* if */
|
||||
}
|
||||
else
|
||||
usage ();
|
||||
|
||||
@ -130,10 +125,9 @@ main (int argc, char **argv)
|
||||
singlefile = 1;
|
||||
|
||||
while (optind < argc)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
if (config.action == DELETE) {
|
||||
if (config.action == DELETE)
|
||||
{
|
||||
tmpmbox_create (argv[optind]);
|
||||
runtime.tmp_mbox = (mbox_t *) mbox_open (config.tmpfilename, "w");
|
||||
}
|
||||
@ -144,7 +138,9 @@ main (int argc, char **argv)
|
||||
recursive_scan (argv[optind]);
|
||||
else
|
||||
scan_mailbox (argv[optind]);
|
||||
|
||||
havemailbox = 1;
|
||||
|
||||
if (config.action == COUNT)
|
||||
{
|
||||
if (singlefile)
|
||||
@ -163,13 +159,9 @@ main (int argc, char **argv)
|
||||
rename (config.tmpfilename, argv[optind]);
|
||||
}
|
||||
++optind;
|
||||
} /* while */
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
|
||||
if (! havemailbox)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
config.format = MBOX;
|
||||
scan_mailbox ("-");
|
||||
@ -177,9 +169,5 @@ main (int argc, char **argv)
|
||||
fprintf (stdout, "%i\n", runtime.count);
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
return 0;
|
||||
} /* main */
|
||||
|
||||
/* }}} */
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ typedef struct
|
||||
int merr;
|
||||
int pid;
|
||||
int haveregex;
|
||||
int debug;
|
||||
|
||||
char hostname[HOST_NAME_SIZE];
|
||||
char *boxname, *outboxname, *pipecmd, *tmpfilename, *regex_s;
|
||||
|
73
src/misc.c
73
src/misc.c
@ -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 - 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: misc.c,v 1.17 2006-07-06 10:53:49 dspiljar Exp $ */
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE /* Pull in strptime(3) from time.h */
|
||||
#define _BSD_SOURCE /* Compensate for _XOPEN_SOURCE to pull in strdup(3)
|
||||
@ -38,7 +37,6 @@
|
||||
|
||||
format_t
|
||||
folder_format (const char *name)
|
||||
/* {{{ */
|
||||
{
|
||||
format_t f;
|
||||
|
||||
@ -63,16 +61,14 @@ folder_format (const char *name)
|
||||
else
|
||||
{
|
||||
if (config.merr)
|
||||
fprintf (stderr, "mboxgrep: %s: unknown folder type\n", name);
|
||||
fprintf (stderr, "%s: %s: unknown folder type\n", APPNAME, name);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
lockmethod_t lock_method (const char *name)
|
||||
/* {{{ */
|
||||
{
|
||||
lockmethod_t l;
|
||||
|
||||
@ -97,38 +93,36 @@ lockmethod_t lock_method (const char *name)
|
||||
|
||||
return l;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* time_t parse_date(char *datestr) */
|
||||
/* {{{ */
|
||||
/* { */
|
||||
/* time_t t; */
|
||||
/* const char *fmt = "%d%n%b%n%Y%n%T"; */
|
||||
/* int h, m; */
|
||||
/* struct tm tm; */
|
||||
/* char *str2, str1[BUFSIZ]; */
|
||||
/*
|
||||
time_t parse_date(char *datestr)
|
||||
{
|
||||
time_t t;
|
||||
const char *fmt = "%d%n%b%n%Y%n%T";
|
||||
int h, m;
|
||||
struct tm tm;
|
||||
char *str2, str1[BUFSIZ];
|
||||
|
||||
/* sscanf (datestr, "Date: %[^\r\n]", str1); */
|
||||
sscanf (datestr, "Date: %[^\r\n]", str1);
|
||||
|
||||
/* str2 = (char *) strptime (str1, "%d%n%b%n%Y%n%T", &tm); */
|
||||
/* if (str2 == NULL) */
|
||||
/* str2 = (char *) strptime (str1, "%a, %d%n%b%n%Y%n%T", &tm); */
|
||||
/* if (str2 == NULL) */
|
||||
/* return (time_t) 0; */
|
||||
str2 = (char *) strptime (str1, "%d%n%b%n%Y%n%T", &tm);
|
||||
if (str2 == NULL)
|
||||
str2 = (char *) strptime (str1, "%a, %d%n%b%n%Y%n%T", &tm);
|
||||
if (str2 == NULL)
|
||||
return (time_t) 0;
|
||||
|
||||
/* if (sscanf (str2, "%3d%2d", &h, &m) == 2) */
|
||||
/* { */
|
||||
/* tm.tm_hour -= h; */
|
||||
/* tm.tm_min -= (h >= 0 ? m : -m); */
|
||||
/* t = (time_t) mktime (&tm); */
|
||||
/* } */
|
||||
if (sscanf (str2, "%3d%2d", &h, &m) == 2)
|
||||
{
|
||||
tm.tm_hour -= h;
|
||||
tm.tm_min -= (h >= 0 ? m : -m);
|
||||
t = (time_t) mktime (&tm);
|
||||
}
|
||||
|
||||
/* return t; */
|
||||
/* } */
|
||||
/* }}} */
|
||||
return t;
|
||||
}
|
||||
*/
|
||||
|
||||
char * parse_return_path(char *rpath)
|
||||
/* {{{ */
|
||||
{
|
||||
char *blah1, blah2[BUFSIZ];
|
||||
|
||||
@ -137,7 +131,6 @@ char * parse_return_path(char *rpath)
|
||||
|
||||
return blah1;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void * allocate_message (void)
|
||||
{
|
||||
@ -188,6 +181,7 @@ set_default_options (void)
|
||||
config.format = MBOX; /* default mailbox format */
|
||||
config.lock = FCNTL; /* default file locking method */
|
||||
config.merr = 1; /* report errors by default */
|
||||
config.debug = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -204,8 +198,6 @@ get_runtime_options (int *argc, char **argv, struct option *long_options)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
/* {{{ */
|
||||
|
||||
{
|
||||
case '?':
|
||||
usage();
|
||||
@ -236,7 +228,7 @@ get_runtime_options (int *argc, char **argv, struct option *long_options)
|
||||
#else
|
||||
fprintf(stderr,
|
||||
"%s: Support for Perl regular expressions not "
|
||||
"compiled in\n");
|
||||
"compiled in\n", APPNAME);
|
||||
exit(2);
|
||||
#endif /* HAVE_LIBPCRE */
|
||||
break;
|
||||
@ -274,6 +266,11 @@ get_runtime_options (int *argc, char **argv, struct option *long_options)
|
||||
case 201:
|
||||
config.lock = 0;
|
||||
break;
|
||||
case 202:
|
||||
config.debug = 1;
|
||||
fprintf (stderr, "%s: %s, line %d: enable debugging\n",
|
||||
APPNAME, __FILE__, __LINE__);
|
||||
break;
|
||||
case 'r':
|
||||
config.recursive = 1;
|
||||
break;
|
||||
@ -297,7 +294,5 @@ get_runtime_options (int *argc, char **argv, struct option *long_options)
|
||||
}
|
||||
}
|
||||
} /* switch */
|
||||
|
||||
/* }}} */
|
||||
} /* while */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user