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') {
b->buf[b->offset] = 0; /* terminate the string */
b->offset += 2; /* next line */
if (Verbose)
if (DFlags & VERBOSE)
puts( *s );
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) ?
"%d %s{%d+}\r\n" : "%d %s{%d}\r\n" : "%d %s\r\n",
cmd->tag, cmd->cmd, cmd->cb.dlen );
if (Verbose) {
if (DFlags & VERBOSE) {
if (imap->num_in_progress)
printf( "(%d in progress) ", imap->num_in_progress );
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 );
if (Verbose)
if (DFlags & VERBOSE)
printf( ">+> %s\n", resp );
l = strlen( resp );
n = socket_write( &imap->buf.sock, resp, l );

View File

@ -192,7 +192,12 @@ extern const char *Home;
/* 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 info( const char *, ... );

View File

@ -203,17 +203,16 @@ main( int argc, char **argv )
usage( 0 );
else if (!strcmp( opt, "version" ))
version();
else if (!strcmp( opt, "quiet" ))
Quiet++;
else if (!strcmp( opt, "verbose" )) {
Verbose = 1;
if (!Quiet)
Quiet = 1;
} else if (!strcmp( opt, "debug" )) {
Debug = 1;
if (!Quiet)
Quiet = 1;
} else if (!strcmp( opt, "pull" ))
else if (!strcmp( opt, "quiet" )) {
if (DFlags & QUIET)
DFlags |= VERYQUIET;
else
DFlags |= QUIET;
} else if (!strcmp( opt, "verbose" ))
DFlags |= VERBOSE | QUIET;
else if (!strcmp( opt, "debug" ))
DFlags |= DEBUG | QUIET;
else if (!strcmp( opt, "pull" ))
cops |= XOP_PULL, ops[M] |= XOP_HAVE_TYPE;
else if (!strcmp( opt, "push" ))
cops |= XOP_PUSH, ops[M] |= XOP_HAVE_TYPE;
@ -362,17 +361,16 @@ main( int argc, char **argv )
op = XOP_PUSH;
goto cac;
case 'q':
Quiet++;
if (DFlags & QUIET)
DFlags |= VERYQUIET;
else
DFlags |= QUIET;
break;
case 'V':
Verbose = 1;
if (!Quiet)
Quiet = 1;
DFlags |= VERBOSE | QUIET;
break;
case 'D':
Debug = 1;
if (!Quiet)
Quiet = 1;
DFlags |= DEBUG | QUIET;
break;
case 'v':
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) {
uid = msg->uid;
if (Debug) {
if (DFlags & DEBUG) {
make_flags( msg->flags, fbuf );
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 <ctype.h>
int Verbose, Quiet, Debug;
int DFlags;
void
debug( const char *msg, ... )
{
va_list va;
if (Debug) {
if (DFlags & DEBUG) {
va_start( va, msg );
vprintf( msg, va );
va_end( va );
@ -50,7 +50,7 @@ info( const char *msg, ... )
{
va_list va;
if (!Quiet) {
if (!(DFlags & QUIET)) {
va_start( va, msg );
vprintf( msg, va );
va_end( va );
@ -61,7 +61,7 @@ info( const char *msg, ... )
void
infoc( char c )
{
if (!Quiet) {
if (!(DFlags & QUIET)) {
putchar( c );
fflush( stdout );
}
@ -72,7 +72,7 @@ warn( const char *msg, ... )
{
va_list va;
if (Quiet < 2) {
if (!(DFlags & VERYQUIET)) {
va_start( va, msg );
vfprintf( stderr, msg, va );
va_end( va );