Implement a debug mode ("--debug").
This commit is contained in:
@@ -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");
|
||||
|
@@ -76,6 +76,7 @@ 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}
|
||||
|
@@ -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;
|
||||
|
10
src/misc.c
10
src/misc.c
@@ -61,7 +61,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -181,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
|
||||
@@ -227,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;
|
||||
@@ -265,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;
|
||||
|
Reference in New Issue
Block a user