From 5cc84ca1bd62225ccaf70fe13c11a1a98cad18f1 Mon Sep 17 00:00:00 2001 From: Daniel Spiljar Date: Fri, 17 Feb 2023 22:19:36 +0100 Subject: [PATCH] Implement a debug mode ("--debug"). --- doc/mboxgrep.1 | 7 +++++-- doc/mboxgrep.info | Bin 6823 -> 6876 bytes doc/mboxgrep.texi | 5 ++++- src/info.c | 3 ++- src/main.c | 1 + src/mboxgrep.h | 1 + src/misc.c | 10 ++++++++-- 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/mboxgrep.1 b/doc/mboxgrep.1 index 5b226ab..b0fbb53 100644 --- a/doc/mboxgrep.1 +++ b/doc/mboxgrep.1 @@ -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 diff --git a/doc/mboxgrep.info b/doc/mboxgrep.info index 4f3ddbe80f35fb2650e539dea5fe8692b0228b25..11a3e89fb298ea13be905c7413a37eb9496527a9 100644 GIT binary patch delta 138 zcmZ2(ddGCb5dkB0UEP$_q|$VCE(H(>D9X$$QOHd#E>28OEmkNkPE9M#QAo=#QUI$; z&&*5Td{7{elf~G?lxy-?K^fb66H^N_F2DSgR4WD7ip1Q4oYdla6H5bgsF+h}dU3s} axv?RXACj*SmYJMgS#M@&VmUcq$^rm@k}S~x delta 87 zcmca(y4-Zb5rN51dE_>W3mR}T8(A7n_L5StGB)P&%TGzQQgE$E%q_@CEv`4QFg1aS hIhCdt*PEJ|TR{0C`3hl~$=Q|lW(JmKlb1+Y007VR8-M@+ diff --git a/doc/mboxgrep.texi b/doc/mboxgrep.texi index 68280f1..4bdfb52 100644 --- a/doc/mboxgrep.texi +++ b/doc/mboxgrep.texi @@ -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 diff --git a/src/info.c b/src/info.c index 4dc1022..b041ae4 100644 --- a/src/info.c +++ b/src/info.c @@ -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"); diff --git a/src/main.c b/src/main.c index f046caf..efe8716 100644 --- a/src/main.c +++ b/src/main.c @@ -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} diff --git a/src/mboxgrep.h b/src/mboxgrep.h index d49e01c..05f87dc 100644 --- a/src/mboxgrep.h +++ b/src/mboxgrep.h @@ -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; diff --git a/src/misc.c b/src/misc.c index c82d3af..9c7154f 100644 --- a/src/misc.c +++ b/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;