Browse Source

split Verbosity off from DFlags

this clearly documents the permitted states.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
c1eb3566b1
  1. 11
      src/common.h
  2. 2
      src/driver.h
  3. 53
      src/main.c
  4. 2
      src/sync.c
  5. 9
      src/util.c

11
src/common.h

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

2
src/driver.h

@ -124,7 +124,7 @@ typedef struct {
*/
#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
/*

53
src/main.c

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

2
src/sync.c

@ -64,7 +64,7 @@ static int check_cancel( sync_vars_t *svars );
static uchar
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_
// each mailbox can support different flags according to the IMAP spec.
uchar bflags = tflags & ~(svars->good_flags[t] | svars->bad_flags[t]);

9
src/util.c

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

Loading…
Cancel
Save