@ -41,6 +41,7 @@ struct option Opts[] = {
{ " remote " , 1 , NULL , ' r ' } ,
{ " remote " , 1 , NULL , ' r ' } ,
{ " host " , 1 , NULL , ' s ' } ,
{ " host " , 1 , NULL , ' s ' } ,
{ " port " , 1 , NULL , ' p ' } ,
{ " port " , 1 , NULL , ' p ' } ,
{ " quiet " , 0 , NULL , ' q ' } ,
{ " user " , 1 , NULL , ' u ' } ,
{ " user " , 1 , NULL , ' u ' } ,
{ " version " , 0 , NULL , ' v ' } ,
{ " version " , 0 , NULL , ' v ' } ,
{ " verbose " , 0 , NULL , ' V ' } ,
{ " verbose " , 0 , NULL , ' V ' } ,
@ -134,6 +135,7 @@ main (int argc, char **argv)
int delete = 0 ;
int delete = 0 ;
char * config = 0 ;
char * config = 0 ;
struct passwd * pw ;
struct passwd * pw ;
int quiet = 0 ;
pw = getpwuid ( getuid ( ) ) ;
pw = getpwuid ( getuid ( ) ) ;
@ -142,6 +144,7 @@ main (int argc, char **argv)
global . port = 143 ;
global . port = 143 ;
global . box = " INBOX " ;
global . box = " INBOX " ;
global . user = strdup ( pw - > pw_name ) ;
global . user = strdup ( pw - > pw_name ) ;
global . maildir = strdup ( pw - > pw_dir ) ;
global . max_size = 0 ;
global . max_size = 0 ;
global . use_namespace = 1 ;
global . use_namespace = 1 ;
# if HAVE_LIBSSL
# if HAVE_LIBSSL
@ -155,9 +158,9 @@ main (int argc, char **argv)
# endif
# endif
# if HAVE_GETOPT_LONG
# if HAVE_GETOPT_LONG
while ( ( i = getopt_long ( argc , argv , " c:defhp:u:r:s:vV " , Opts , NULL ) ) ! = - 1 )
while ( ( i = getopt_long ( argc , argv , " c:defhp:q u:r:s:vV " , Opts , NULL ) ) ! = - 1 )
# else
# else
while ( ( i = getopt ( argc , argv , " c:defhp:u:r:s:vV " ) ) ! = - 1 )
while ( ( i = getopt ( argc , argv , " c:defhp:u:q r:s:vV " ) ) ! = - 1 )
# endif
# endif
{
{
switch ( i )
switch ( i )
@ -177,6 +180,10 @@ main (int argc, char **argv)
case ' p ' :
case ' p ' :
global . port = atoi ( optarg ) ;
global . port = atoi ( optarg ) ;
break ;
break ;
case ' q ' :
quiet = 1 ;
Verbose = 0 ;
break ;
case ' r ' :
case ' r ' :
global . box = optarg ;
global . box = optarg ;
break ;
break ;
@ -241,6 +248,7 @@ main (int argc, char **argv)
box - > pass = strdup ( global . pass ) ;
box - > pass = strdup ( global . pass ) ;
}
}
if ( ! quiet )
printf ( " Reading %s \n " , box - > path ) ;
printf ( " Reading %s \n " , box - > path ) ;
mail = maildir_open ( box - > path , fast ) ;
mail = maildir_open ( box - > path , fast ) ;
if ( ! mail )
if ( ! mail )
@ -253,6 +261,7 @@ main (int argc, char **argv)
if ( ! imap )
if ( ! imap )
exit ( 1 ) ;
exit ( 1 ) ;
if ( ! quiet )
puts ( " Synchronizing " ) ;
puts ( " Synchronizing " ) ;
i = delete ? SYNC_DELETE : 0 ;
i = delete ? SYNC_DELETE : 0 ;
i | = ( expunge | | box - > expunge ) ? SYNC_EXPUNGE : 0 ;
i | = ( expunge | | box - > expunge ) ? SYNC_EXPUNGE : 0 ;
@ -264,9 +273,11 @@ main (int argc, char **argv)
if ( expunge & & ( imap - > deleted | | mail - > deleted ) )
if ( expunge & & ( imap - > deleted | | mail - > deleted ) )
{
{
/* remove messages marked for deletion */
/* remove messages marked for deletion */
if ( ! quiet )
printf ( " Expunging %d messages from server \n " , imap - > deleted ) ;
printf ( " Expunging %d messages from server \n " , imap - > deleted ) ;
if ( imap_expunge ( imap ) )
if ( imap_expunge ( imap ) )
exit ( 1 ) ;
exit ( 1 ) ;
if ( ! quiet )
printf ( " Expunging %d messages from local mailbox \n " ,
printf ( " Expunging %d messages from local mailbox \n " ,
mail - > deleted ) ;
mail - > deleted ) ;
if ( maildir_expunge ( mail , 0 ) )
if ( maildir_expunge ( mail , 0 ) )
@ -280,10 +291,14 @@ main (int argc, char **argv)
maildir_expunge ( mail , 1 ) ;
maildir_expunge ( mail , 1 ) ;
/* write changed flags back to the mailbox */
/* write changed flags back to the mailbox */
if ( mail - > changed )
{
if ( ! quiet )
printf ( " Committing changes to %s \n " , mail - > path ) ;
printf ( " Committing changes to %s \n " , mail - > path ) ;
if ( maildir_sync ( mail ) )
if ( maildir_sync ( mail ) )
exit ( 1 ) ;
exit ( 1 ) ;
}
}
}
maildir_close ( mail ) ;
maildir_close ( mail ) ;
}
}