diff --git a/isync.1 b/isync.1 index 0a6942f..0d1f723 100644 --- a/isync.1 +++ b/isync.1 @@ -92,7 +92,8 @@ Displays a summary of command line options Specifies the port on the IMAP server to connect to (default: 143) .TP \fB-q\fR, \fB--quiet\fR -Supress feedback messages. +Suppress informational messages. +If specified twice, suppress warning messages as well. .TP \fB-r\fR, \fB--remote\fR \fIbox\fR Specifies the name of the remote IMAP mailbox to synchronize with diff --git a/src/imap.c b/src/imap.c index d4939bf..a7521a1 100644 --- a/src/imap.c +++ b/src/imap.c @@ -145,15 +145,14 @@ init_ssl (config_t * conf) SSLContext = SSL_CTX_new (method); - if (access (conf->cert_file, F_OK)) + if (access (conf->cert_file, R_OK)) { if (errno != ENOENT) { perror ("access"); return -1; } - fprintf (stderr, - "*** Warning, CertificateFile doesn't exist, can't verify server certificates\n"); + warn ("*** Warning: CertificateFile doesn't exist, can't verify server certificates\n"); } else if (!SSL_CTX_load_verify_locations @@ -775,7 +774,7 @@ imap_connect (config_t * cfg) goto bail; } else - fprintf (stderr, "IMAP warning: SSL support not available\n"); + warn ("IMAP warning: SSL support not available\n"); } } } @@ -836,7 +835,7 @@ imap_connect (config_t * cfg) #if HAVE_LIBSSL if (!use_ssl) #endif - fprintf (stderr, "*** IMAP Warning *** Password is being sent in the clear\n"); + warn ("*** IMAP Warning *** Password is being sent in the clear\n"); if (imap_exec (imap, "LOGIN \"%s\" \"%s\"", cfg->user, cfg->pass)) { fprintf (stderr, "IMAP error: LOGIN failed\n"); diff --git a/src/isync.h b/src/isync.h index a579f15..f789549 100644 --- a/src/isync.h +++ b/src/isync.h @@ -184,6 +184,7 @@ extern int Verbose, Quiet; extern void info (const char *, ...); extern void infoc (char); +extern void warn (const char *, ...); #if HAVE_LIBSSL extern SSL_CTX *SSLContext; diff --git a/src/maildir.c b/src/maildir.c index c509fe2..19cef25 100644 --- a/src/maildir.c +++ b/src/maildir.c @@ -255,7 +255,7 @@ maildir_open (const char *path, int flags) ret = m->db->get (m->db, 0, &key, &value, 0); if (ret == DB_NOTFOUND) { /* Every locally generated message triggers this ... */ - /*printf ("Warning, no UID for message %.*s\n", + /*warn ("Warning: no UID for message %.*s\n", key.size, p->file);*/ } else if (ret) { fprintf (stderr, "Unexpected error (%d) from db_get(%.*s)\n", @@ -389,7 +389,7 @@ maildir_clean_tmp (const char *mbox) /* this should happen infrequently enough that it won't be * bothersome to the user to display when it occurs. */ - printf ("Warning: removing stale file %s\n", path); + info ("Notice: removing stale file %s\n", path); if (unlink (path)) fprintf (stderr, "maildir_clean_tmp: unlink: %s: %s (errno %d)\n", diff --git a/src/main.c b/src/main.c index ec1e035..963e05e 100644 --- a/src/main.c +++ b/src/main.c @@ -59,6 +59,19 @@ infoc (char c) putchar (c); } +void +warn (const char *msg, ...) +{ + va_list va; + + if (Quiet < 2) + { + va_start (va, msg); + vfprintf (stderr, msg, va); + va_end (va); + } +} + #if HAVE_GETOPT_LONG # define _GNU_SOURCE # include @@ -265,7 +278,7 @@ main (int argc, char **argv) global.port = atoi (optarg); break; case 'q': - Quiet = 1; + Quiet++; Verbose = 0; break; case 'r': diff --git a/src/sync.c b/src/sync.c index 250ff09..5126b04 100644 --- a/src/sync.c +++ b/src/sync.c @@ -148,8 +148,8 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, if (imap->box->max_size > 0 && sb.st_size > imap->box->max_size) { - info ("Warning, local message is too large (%lu), skipping...\n", - (unsigned long) sb.st_size); + info ("Local message %s is too large (%lu), skipping...\n", + cur->file, (unsigned long) sb.st_size); continue; } fd = open (path, O_RDONLY); @@ -166,7 +166,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, /* update the db */ set_uid (mbox->db, cur->file, cur->uid); if (!cur->uid) - printf("warning: no uid for new messge %s\n", cur->file); + warn ("Warning: no UID for new messge %s\n", cur->file); else if (cur->uid > mbox->maxuid) mbox->maxuid = cur->uid; } @@ -187,7 +187,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, * exist on the server, warn that such messages exist. */ else - info ("Warning, uid %u doesn't exist on server\n", cur->uid); + info ("Local message %u doesn't exist on server\n", cur->uid); continue; } tmp->processed = 1; @@ -312,8 +312,8 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags, if (max_size && cur->size > max_size) { - info ("Warning, message skipped because it is too big (%u)\n", - cur->size); + info ("Remote message %u skipped because it is too big (%u)\n", + cur->uid, cur->size); continue; }