commit c84a888a7d287634218a5e4f9c7ac8d51d6e6765
parent 9647c79504956e0955fcbddd23f84823533ad9ca
Author: Michael Elkins <me@mutt.org>
Date: Wed, 31 Oct 2001 19:50:01 +0000
set compiler warnings for gcc-3.0 as well
display message with count of uploaded messages
--quiet now supresses warnings in sync_mailbox()
fixed compiler warnings with -Wshadow
Diffstat:
5 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/configure.in b/configure.in
@@ -1,9 +1,6 @@
AC_INIT(isync.h)
AM_INIT_AUTOMAKE(isync,0.6)
AM_PROG_CC_STDC
-if test $CC = gcc; then
- CFLAGS="$CFLAGS -pipe"
-fi
AC_ARG_WITH(ssl-dir, [ --with-ssl-dir=DIR location where openssl is insalled],
[if test -d $withval/lib; then
LIBS="$LIBS -L$withval/lib"
@@ -17,5 +14,8 @@ AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(nsl,inet_ntoa)
AC_CHECK_LIB(crypto,ERR_error_string)
AC_CHECK_LIB(ssl,SSL_library_init)
-CFLAGS="$CFLAGS -W -Wall -pedantic -Wmissing-prototypes -Wmissing-declarations"
+dnl test for gcc. use the prefix so we know that gcc-3.0 is also gcc
+if test `echo $CC | sed s,^gcc.*,gcc,` = gcc; then
+ CFLAGS="$CFLAGS -pipe -W -Wall -Wshadow -Wmissing-prototypes"
+fi
AC_OUTPUT(Makefile)
diff --git a/imap.c b/imap.c
@@ -559,7 +559,7 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap)
{
int ret;
int s;
- struct sockaddr_in sin;
+ struct sockaddr_in addr;
struct hostent *he;
int reuse = 0;
#if HAVE_LIBSSL
@@ -612,9 +612,9 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap)
{
/* open connection to IMAP server */
- memset (&sin, 0, sizeof (sin));
- sin.sin_port = htons (box->port);
- sin.sin_family = AF_INET;
+ memset (&addr, 0, sizeof (addr));
+ addr.sin_port = htons (box->port);
+ addr.sin_family = AF_INET;
printf ("Resolving %s... ", box->host);
fflush (stdout);
@@ -626,14 +626,14 @@ imap_open (config_t * box, unsigned int minuid, imap_t * imap)
}
puts ("ok");
- sin.sin_addr.s_addr = *((int *) he->h_addr_list[0]);
+ addr.sin_addr.s_addr = *((int *) he->h_addr_list[0]);
s = socket (PF_INET, SOCK_STREAM, 0);
- printf ("Connecting to %s:%hu... ", inet_ntoa (sin.sin_addr),
- ntohs (sin.sin_port));
+ printf ("Connecting to %s:%hu... ", inet_ntoa (addr.sin_addr),
+ ntohs (addr.sin_port));
fflush (stdout);
- if (connect (s, (struct sockaddr *) &sin, sizeof (sin)))
+ if (connect (s, (struct sockaddr *) &addr, sizeof (addr)))
{
perror ("connect");
exit (1);
diff --git a/isync.h b/isync.h
@@ -150,6 +150,7 @@ imap_t;
/* flags for sync_mailbox */
#define SYNC_DELETE (1<<0) /* delete local that don't exist on server */
#define SYNC_EXPUNGE (1<<1) /* don't fetch deleted messages */
+#define SYNC_QUIET (1<<2) /* only display critical errors */
extern config_t global;
extern config_t *boxes;
diff --git a/main.c b/main.c
@@ -286,7 +286,10 @@ main (int argc, char **argv)
if (!quiet)
puts ("Synchronizing");
- i = (delete || box->delete) ? SYNC_DELETE : 0;
+ i = 0;
+ if (quiet)
+ i |= SYNC_QUIET;
+ i |= (delete || box->delete) ? SYNC_DELETE : 0;
i |= (expunge || box->expunge) ? SYNC_EXPUNGE : 0;
if (sync_mailbox (mail, imap, i, box->max_size))
exit (1);
diff --git a/sync.c b/sync.c
@@ -53,6 +53,7 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
int fd;
int ret;
int fetched = 0;
+ int upload = 0;
if (mbox->uidvalidity > 0)
{
@@ -91,9 +92,17 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
if (cur->uid == (unsigned int) -1)
{
struct stat sb;
- int fd;
int uid;
+ if ((flags & SYNC_QUIET) == 0)
+ {
+ if (!upload)
+ fputs ("Uploading messages", stdout);
+ fputc ('.', stdout);
+ fflush (stdout);
+ upload++;
+ }
+
/* upload the message if its not too big */
snprintf (path, sizeof (path), "%s/%s/%s", mbox->path,
cur->new ? "new" : "cur", cur->file);
@@ -106,9 +115,10 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
}
if (imap->box->max_size > 0 && sb.st_size > imap->box->max_size)
{
- printf
- ("Warning, local message is too large (%ld), skipping...\n",
- sb.st_size);
+ if ((flags & SYNC_QUIET) == 0)
+ printf
+ ("Warning, local message is too large (%ld), skipping...\n",
+ sb.st_size);
continue;
}
fd = open (path, O_RDONLY);
@@ -130,9 +140,6 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
*/
if (uid != -1)
{
- char newpath[_POSIX_PATH_MAX];
- char *p;
-
strfcpy (newpath, path, sizeof (newpath));
/* kill :info field */
p = strchr (newpath, ':');
@@ -153,17 +160,18 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
perror ("rename");
}
}
- else
+ else if (flags & SYNC_DELETE)
{
+ cur->flags |= D_DELETED;
+ cur->dead = 1;
+ mbox->deleted++;
+ }
+ /* if the user doesn't want local msgs deleted when they don't
+ * exist on the server, warn that such messages exist.
+ */
+ else if ((flags & SYNC_QUIET) == 0)
printf ("Warning, uid %u doesn't exist on server\n",
cur->uid);
- if (flags & SYNC_DELETE)
- {
- cur->flags |= D_DELETED;
- cur->dead = 1;
- mbox->deleted++;
- }
- }
continue;
}
tmp->processed = 1;
@@ -203,8 +211,15 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
}
}
- fputs ("Fetching new messages", stdout);
- fflush (stdout);
+ if (upload)
+ fprintf (stdout, " %d messages.\n", upload);
+
+
+ if ((flags & SYNC_QUIET) == 0)
+ {
+ fputs ("Fetching new messages", stdout);
+ fflush (stdout);
+ }
for (cur = imap->msgs; cur; cur = cur->next)
{
if (!cur->processed)
@@ -222,9 +237,10 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
if (max_size && cur->size > max_size)
{
- printf
- ("Warning, message skipped because it is too big (%u)\n",
- cur->size);
+ if ((flags & SYNC_QUIET) == 0)
+ printf
+ ("Warning, message skipped because it is too big (%u)\n",
+ cur->size);
continue;
}
@@ -261,9 +277,12 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
if (fd < 0)
continue;
- /* give some visual feedback that something is happening */
- fputs (".", stdout);
- fflush (stdout);
+ if ((flags & SYNC_QUIET) == 0)
+ {
+ /* give some visual feedback that something is happening */
+ fputs (".", stdout);
+ fflush (stdout);
+ }
fetched++;
ret = imap_fetch_message (imap, cur->uid, fd);
@@ -293,7 +312,9 @@ sync_mailbox (mailbox_t * mbox, imap_t * imap, int flags,
unlink (path);
}
}
- printf (" %d messages\n", fetched);
+
+ if ((flags & SYNC_QUIET) == 0)
+ printf (" %d messages\n", fetched);
return 0;
}