merge Quiet, Verbose & Debug into DFlags

This commit is contained in:
Oswald Buddenhagen 2006-01-29 14:46:16 +00:00
parent 185769640b
commit a1a5a817bb
5 changed files with 31 additions and 28 deletions

View File

@ -398,7 +398,7 @@ buffer_gets( buffer_t * b, char **s )
if (b->buf[b->offset + 1] == '\n') { if (b->buf[b->offset + 1] == '\n') {
b->buf[b->offset] = 0; /* terminate the string */ b->buf[b->offset] = 0; /* terminate the string */
b->offset += 2; /* next line */ b->offset += 2; /* next line */
if (Verbose) if (DFlags & VERBOSE)
puts( *s ); puts( *s );
return 0; return 0;
} }
@ -433,7 +433,7 @@ v_issue_imap_cmd( imap_store_t *ctx, struct imap_cmd_cb *cb,
bufl = nfsnprintf( buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ? bufl = nfsnprintf( buf, sizeof(buf), cmd->cb.data ? CAP(LITERALPLUS) ?
"%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n", "%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n",
cmd->tag, cmd->cmd, cmd->cb.dlen ); cmd->tag, cmd->cmd, cmd->cb.dlen );
if (Verbose) { if (DFlags & VERBOSE) {
if (imap->num_in_progress) if (imap->num_in_progress)
printf( "(%d in progress) ", imap->num_in_progress ); printf( "(%d in progress) ", imap->num_in_progress );
if (memcmp( cmd->cmd, "LOGIN", 5 )) if (memcmp( cmd->cmd, "LOGIN", 5 ))
@ -1173,7 +1173,7 @@ do_cram_auth (imap_store_t *ctx, struct imap_cmd *cmdp, const char *prompt)
resp = cram( prompt, srvc->user, srvc->pass ); resp = cram( prompt, srvc->user, srvc->pass );
if (Verbose) if (DFlags & VERBOSE)
printf( ">+> %s\n", resp ); printf( ">+> %s\n", resp );
l = strlen( resp ); l = strlen( resp );
n = socket_write( &imap->buf.sock, resp, l ); n = socket_write( &imap->buf.sock, resp, l );

View File

@ -192,7 +192,12 @@ extern const char *Home;
/* util.c */ /* util.c */
extern int Verbose, Quiet, Debug; #define DEBUG 1
#define VERBOSE 2
#define QUIET 4
#define VERYQUIET 8
extern int DFlags;
void debug( const char *, ... ); void debug( const char *, ... );
void info( const char *, ... ); void info( const char *, ... );

View File

@ -203,17 +203,16 @@ main( int argc, char **argv )
usage( 0 ); usage( 0 );
else if (!strcmp( opt, "version" )) else if (!strcmp( opt, "version" ))
version(); version();
else if (!strcmp( opt, "quiet" )) else if (!strcmp( opt, "quiet" )) {
Quiet++; if (DFlags & QUIET)
else if (!strcmp( opt, "verbose" )) { DFlags |= VERYQUIET;
Verbose = 1; else
if (!Quiet) DFlags |= QUIET;
Quiet = 1; } else if (!strcmp( opt, "verbose" ))
} else if (!strcmp( opt, "debug" )) { DFlags |= VERBOSE | QUIET;
Debug = 1; else if (!strcmp( opt, "debug" ))
if (!Quiet) DFlags |= DEBUG | QUIET;
Quiet = 1; else if (!strcmp( opt, "pull" ))
} else if (!strcmp( opt, "pull" ))
cops |= XOP_PULL, ops[M] |= XOP_HAVE_TYPE; cops |= XOP_PULL, ops[M] |= XOP_HAVE_TYPE;
else if (!strcmp( opt, "push" )) else if (!strcmp( opt, "push" ))
cops |= XOP_PUSH, ops[M] |= XOP_HAVE_TYPE; cops |= XOP_PUSH, ops[M] |= XOP_HAVE_TYPE;
@ -362,17 +361,16 @@ main( int argc, char **argv )
op = XOP_PUSH; op = XOP_PUSH;
goto cac; goto cac;
case 'q': case 'q':
Quiet++; if (DFlags & QUIET)
DFlags |= VERYQUIET;
else
DFlags |= QUIET;
break; break;
case 'V': case 'V':
Verbose = 1; DFlags |= VERBOSE | QUIET;
if (!Quiet)
Quiet = 1;
break; break;
case 'D': case 'D':
Debug = 1; DFlags |= DEBUG | QUIET;
if (!Quiet)
Quiet = 1;
break; break;
case 'v': case 'v':
version(); version();

View File

@ -102,7 +102,7 @@ findmsgs( sync_rec_t *srecs, store_t *ctx[], int t )
for (msg = ctx[t]->msgs; msg; msg = msg->next) { for (msg = ctx[t]->msgs; msg; msg = msg->next) {
uid = msg->uid; uid = msg->uid;
if (Debug) { if (DFlags & DEBUG) {
make_flags( msg->flags, fbuf ); make_flags( msg->flags, fbuf );
printf( ctx[t]->opts & OPEN_SIZE ? " message %5d, %-4s, %6d: " : " message %5d, %-4s: ", uid, fbuf, msg->size ); printf( ctx[t]->opts & OPEN_SIZE ? " message %5d, %-4s, %6d: " : " message %5d, %-4s: ", uid, fbuf, msg->size );
} }

View File

@ -30,14 +30,14 @@
#include <pwd.h> #include <pwd.h>
#include <ctype.h> #include <ctype.h>
int Verbose, Quiet, Debug; int DFlags;
void void
debug( const char *msg, ... ) debug( const char *msg, ... )
{ {
va_list va; va_list va;
if (Debug) { if (DFlags & DEBUG) {
va_start( va, msg ); va_start( va, msg );
vprintf( msg, va ); vprintf( msg, va );
va_end( va ); va_end( va );
@ -50,7 +50,7 @@ info( const char *msg, ... )
{ {
va_list va; va_list va;
if (!Quiet) { if (!(DFlags & QUIET)) {
va_start( va, msg ); va_start( va, msg );
vprintf( msg, va ); vprintf( msg, va );
va_end( va ); va_end( va );
@ -61,7 +61,7 @@ info( const char *msg, ... )
void void
infoc( char c ) infoc( char c )
{ {
if (!Quiet) { if (!(DFlags & QUIET)) {
putchar( c ); putchar( c );
fflush( stdout ); fflush( stdout );
} }
@ -72,7 +72,7 @@ warn( const char *msg, ... )
{ {
va_list va; va_list va;
if (Quiet < 2) { if (!(DFlags & VERYQUIET)) {
va_start( va, msg ); va_start( va, msg );
vfprintf( stderr, msg, va ); vfprintf( stderr, msg, va );
va_end( va ); va_end( va );