split Verbosity off from DFlags

this clearly documents the permitted states.
This commit is contained in:
Oswald Buddenhagen 2022-06-06 12:29:48 +02:00
parent d3f118be79
commit c1eb3566b1
5 changed files with 41 additions and 36 deletions

View File

@ -83,6 +83,13 @@ typedef unsigned long ulong;
/* main.c */ /* main.c */
enum {
VERYQUIET,
QUIET,
TERSE,
VERBOSE,
};
#define DEBUG_CRASH 0x01 #define DEBUG_CRASH 0x01
#define DEBUG_MAILDIR 0x02 #define DEBUG_MAILDIR 0x02
#define DEBUG_NET 0x04 #define DEBUG_NET 0x04
@ -91,10 +98,7 @@ typedef unsigned long ulong;
#define DEBUG_MAIN 0x20 #define DEBUG_MAIN 0x20
#define DEBUG_DRV 0x40 #define DEBUG_DRV 0x40
#define DEBUG_DRV_ALL 0x80 #define DEBUG_DRV_ALL 0x80
#define QUIET 0x100
#define VERYQUIET 0x200
#define PROGRESS 0x400 #define PROGRESS 0x400
#define VERBOSE 0x800
#define KEEPJOURNAL 0x1000 #define KEEPJOURNAL 0x1000
#define ZERODELAY 0x2000 #define ZERODELAY 0x2000
#define FORCEASYNC 0x4000 #define FORCEASYNC 0x4000
@ -103,6 +107,7 @@ typedef unsigned long ulong;
#define DEBUG_ALL (DEBUG_ANY | DEBUG_CRASH) #define DEBUG_ALL (DEBUG_ANY | DEBUG_CRASH)
// Global options // Global options
extern int Verbosity;
extern int DFlags; extern int DFlags;
extern int JLimit; extern int JLimit;
extern int UseFSync; extern int UseFSync;

View File

@ -124,7 +124,7 @@ typedef struct {
*/ */
#define DRV_CRLF 1 #define DRV_CRLF 1
/* /*
This flag says that the driver will act upon (DFlags & VERBOSE). This flag says that the driver will act upon (Verbosity >= VERBOSE).
*/ */
#define DRV_VERBOSE 2 #define DRV_VERBOSE 2
/* /*

View File

@ -429,32 +429,30 @@ main( int argc, char **argv )
} else if (!strcmp( opt, "version" )) { } else if (!strcmp( opt, "version" )) {
version(); version();
} else if (!strcmp( opt, "quiet" )) { } else if (!strcmp( opt, "quiet" )) {
if (DFlags & QUIET) if (Verbosity > VERYQUIET)
DFlags |= VERYQUIET; Verbosity--;
else
DFlags |= QUIET;
} else if (!strcmp( opt, "verbose" )) { } else if (!strcmp( opt, "verbose" )) {
DFlags |= VERBOSE; Verbosity = VERBOSE;
} else if (starts_with( opt, -1, "debug", 5 )) { } else if (starts_with( opt, -1, "debug", 5 )) {
opt += 5; opt += 5;
if (!*opt) if (!*opt)
op = VERBOSE | DEBUG_ALL; op = DEBUG_ALL;
else if (!strcmp( opt, "-crash" )) else if (!strcmp( opt, "-crash" ))
op = DEBUG_CRASH; op = DEBUG_CRASH;
else if (!strcmp( opt, "-driver" )) else if (!strcmp( opt, "-driver" ))
op = VERBOSE | DEBUG_DRV; op = DEBUG_DRV;
else if (!strcmp( opt, "-driver-all" )) else if (!strcmp( opt, "-driver-all" ))
op = VERBOSE | DEBUG_DRV | DEBUG_DRV_ALL; op = DEBUG_DRV | DEBUG_DRV_ALL;
else if (!strcmp( opt, "-maildir" )) else if (!strcmp( opt, "-maildir" ))
op = VERBOSE | DEBUG_MAILDIR; op = DEBUG_MAILDIR;
else if (!strcmp( opt, "-main" )) else if (!strcmp( opt, "-main" ))
op = VERBOSE | DEBUG_MAIN; op = DEBUG_MAIN;
else if (!strcmp( opt, "-net" )) else if (!strcmp( opt, "-net" ))
op = VERBOSE | DEBUG_NET; op = DEBUG_NET;
else if (!strcmp( opt, "-net-all" )) else if (!strcmp( opt, "-net-all" ))
op = VERBOSE | DEBUG_NET | DEBUG_NET_ALL; op = DEBUG_NET | DEBUG_NET_ALL;
else if (!strcmp( opt, "-sync" )) else if (!strcmp( opt, "-sync" ))
op = VERBOSE | DEBUG_SYNC; op = DEBUG_SYNC;
else else
goto badopt; goto badopt;
DFlags |= op; DFlags |= op;
@ -623,13 +621,11 @@ main( int argc, char **argv )
op = XOP_PUSH; op = XOP_PUSH;
goto cac; goto cac;
case 'q': case 'q':
if (DFlags & QUIET) if (Verbosity > VERYQUIET)
DFlags |= VERYQUIET; Verbosity--;
else
DFlags |= QUIET;
break; break;
case 'V': case 'V':
DFlags |= VERBOSE; Verbosity = VERBOSE;
break; break;
case 'D': case 'D':
for (op = 0; *ochar; ochar++) { for (op = 0; *ochar; ochar++) {
@ -638,25 +634,25 @@ main( int argc, char **argv )
op |= DEBUG_CRASH; op |= DEBUG_CRASH;
break; break;
case 'd': case 'd':
op |= DEBUG_DRV | VERBOSE; op |= DEBUG_DRV;
break; break;
case 'D': case 'D':
op |= DEBUG_DRV | DEBUG_DRV_ALL | VERBOSE; op |= DEBUG_DRV | DEBUG_DRV_ALL;
break; break;
case 'm': case 'm':
op |= DEBUG_MAILDIR | VERBOSE; op |= DEBUG_MAILDIR;
break; break;
case 'M': case 'M':
op |= DEBUG_MAIN | VERBOSE; op |= DEBUG_MAIN;
break; break;
case 'n': case 'n':
op |= DEBUG_NET | VERBOSE; op |= DEBUG_NET;
break; break;
case 'N': case 'N':
op |= DEBUG_NET | DEBUG_NET_ALL | VERBOSE; op |= DEBUG_NET | DEBUG_NET_ALL;
break; break;
case 's': case 's':
op |= DEBUG_SYNC | VERBOSE; op |= DEBUG_SYNC;
break; break;
default: default:
error( "Unknown -D flag '%c'\n", *ochar ); error( "Unknown -D flag '%c'\n", *ochar );
@ -664,7 +660,7 @@ main( int argc, char **argv )
} }
} }
if (!op) if (!op)
op = DEBUG_ALL | VERBOSE; op = DEBUG_ALL;
DFlags |= op; DFlags |= op;
break; break;
case 'T': case 'T':
@ -698,8 +694,11 @@ main( int argc, char **argv )
if (ms_warn) if (ms_warn)
warn( "Notice: -master/-slave/m/s suffixes are deprecated; use -far/-near/f/n instead.\n" ); warn( "Notice: -master/-slave/m/s suffixes are deprecated; use -far/-near/f/n instead.\n" );
if (!(DFlags & (QUIET | DEBUG_ANY)) && isatty( 1 )) if (DFlags & DEBUG_ANY) {
Verbosity = VERBOSE;
} else if (Verbosity >= TERSE && isatty( 1 )) {
DFlags |= PROGRESS; DFlags |= PROGRESS;
}
#ifdef __linux__ #ifdef __linux__
if (DFlags & DEBUG_CRASH) { if (DFlags & DEBUG_CRASH) {

View File

@ -64,7 +64,7 @@ static int check_cancel( sync_vars_t *svars );
static uchar static uchar
sanitize_flags( uchar tflags, sync_vars_t *svars, int t ) sanitize_flags( uchar tflags, sync_vars_t *svars, int t )
{ {
if (!(DFlags & QUIET)) { if (Verbosity >= TERSE) {
// We complain only once per flag per store - even though _theoretically_ // We complain only once per flag per store - even though _theoretically_
// each mailbox can support different flags according to the IMAP spec. // each mailbox can support different flags according to the IMAP spec.
uchar bflags = tflags & ~(svars->good_flags[t] | svars->bad_flags[t]); uchar bflags = tflags & ~(svars->good_flags[t] | svars->bad_flags[t]);

View File

@ -13,6 +13,7 @@
#include <ctype.h> #include <ctype.h>
#include <pwd.h> #include <pwd.h>
int Verbosity = TERSE;
int DFlags; int DFlags;
int JLimit; int JLimit;
int UseFSync = 1; int UseFSync = 1;
@ -95,7 +96,7 @@ info( const char *msg, ... )
{ {
va_list va; va_list va;
if (DFlags & VERBOSE) { if (Verbosity >= VERBOSE) {
va_start( va, msg ); va_start( va, msg );
nvprint( msg, va ); nvprint( msg, va );
va_end( va ); va_end( va );
@ -107,7 +108,7 @@ infon( const char *msg, ... )
{ {
va_list va; va_list va;
if (DFlags & VERBOSE) { if (Verbosity >= VERBOSE) {
va_start( va, msg ); va_start( va, msg );
nvprint( msg, va ); nvprint( msg, va );
va_end( va ); va_end( va );
@ -120,7 +121,7 @@ notice( const char *msg, ... )
{ {
va_list va; va_list va;
if (!(DFlags & QUIET)) { if (Verbosity >= TERSE) {
va_start( va, msg ); va_start( va, msg );
nvprint( msg, va ); nvprint( msg, va );
va_end( va ); va_end( va );
@ -132,7 +133,7 @@ warn( const char *msg, ... )
{ {
va_list va; va_list va;
if (!(DFlags & VERYQUIET)) { if (Verbosity >= QUIET) {
flushn(); flushn();
va_start( va, msg ); va_start( va, msg );
vfprintf( stderr, msg, va ); vfprintf( stderr, msg, va );