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
This commit is contained in:
Michael Elkins 2001-10-31 19:50:01 +00:00
parent 9647c79504
commit c84a888a7d
5 changed files with 62 additions and 37 deletions

View File

@ -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)

16
imap.c
View File

@ -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);

View File

@ -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;

5
main.c
View File

@ -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);

69
sync.c
View File

@ -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;
}