@ -318,9 +318,6 @@ maildir_set_uid( maildir_store_t *ctx, const char *name, int *uid )
if ( ( ret = ctx - > db - > put ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
if ( ( ret = ctx - > db - > put ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
tbork :
tbork :
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->put() " ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->put() " ) ;
bork :
ctx - > db - > close ( ctx - > db , 0 ) ;
ctx - > db = 0 ;
return DRV_BOX_BAD ;
return DRV_BOX_BAD ;
}
}
if ( uid ) {
if ( uid ) {
@ -332,7 +329,7 @@ maildir_set_uid( maildir_store_t *ctx, const char *name, int *uid )
}
}
if ( ( ret = ctx - > db - > sync ( ctx - > db , 0 ) ) ) {
if ( ( ret = ctx - > db - > sync ( ctx - > db , 0 ) ) ) {
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->sync() " ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->sync() " ) ;
goto bork ;
return DRV_BOX_BAD ;
}
}
return DRV_OK ;
return DRV_OK ;
}
}
@ -523,6 +520,7 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
}
}
if ( ( tdb - > open ) ( tdb , 0 , 0 , 0 , DB_HASH , DB_CREATE , 0 ) ) {
if ( ( tdb - > open ) ( tdb , 0 , 0 , 0 , DB_HASH , DB_CREATE , 0 ) ) {
fputs ( " Maildir error: tdb->open() failed \n " , stderr ) ;
fputs ( " Maildir error: tdb->open() failed \n " , stderr ) ;
bork :
tdb - > close ( tdb , 0 ) ;
tdb - > close ( tdb , 0 ) ;
return DRV_BOX_BAD ;
return DRV_BOX_BAD ;
}
}
@ -533,13 +531,6 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
memcpy ( buf + bl , subdirs [ i ] , 4 ) ;
memcpy ( buf + bl , subdirs [ i ] , 4 ) ;
if ( ! ( d = opendir ( buf ) ) ) {
if ( ! ( d = opendir ( buf ) ) ) {
sys_error ( " Maildir error: cannot list %s " , buf ) ;
sys_error ( " Maildir error: cannot list %s " , buf ) ;
# ifdef USE_DB
if ( ! ctx - > db )
# endif /* USE_DB */
maildir_uidval_unlock ( ctx ) ;
# ifdef USE_DB
bork :
# endif /* USE_DB */
maildir_free_scan ( msglist ) ;
maildir_free_scan ( msglist ) ;
# ifdef USE_DB
# ifdef USE_DB
if ( ctx - > db )
if ( ctx - > db )
@ -558,8 +549,8 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
if ( ( ret = ctx - > db - > get ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
if ( ( ret = ctx - > db - > get ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
if ( ret ! = DB_NOTFOUND ) {
if ( ret ! = DB_NOTFOUND ) {
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->get() " ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->get() " ) ;
ctx - > db - > close ( ctx - > db , 0 ) ;
mbork :
ctx - > db = 0 ;
maildir_free_scan ( msglist ) ;
goto bork ;
goto bork ;
}
}
uid = INT_MAX ;
uid = INT_MAX ;
@ -567,7 +558,7 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
value . size = 0 ;
value . size = 0 ;
if ( ( ret = tdb - > put ( tdb , 0 , & key , & value , 0 ) ) ) {
if ( ( ret = tdb - > put ( tdb , 0 , & key , & value , 0 ) ) ) {
tdb - > err ( tdb , ret , " Maildir error: tdb->put() " ) ;
tdb - > err ( tdb , ret , " Maildir error: tdb->put() " ) ;
goto bork ;
goto m bork;
}
}
uid = * ( int * ) value . data ;
uid = * ( int * ) value . data ;
}
}
@ -674,7 +665,6 @@ maildir_scan( maildir_store_t *ctx, msglist_t *msglist )
if ( errno ! = ENOENT ) {
if ( errno ! = ENOENT ) {
sys_error ( " Maildir error: cannot rename %s to %s " , nbuf , buf ) ;
sys_error ( " Maildir error: cannot rename %s to %s " , nbuf , buf ) ;
fail :
fail :
maildir_uidval_unlock ( ctx ) ;
maildir_free_scan ( msglist ) ;
maildir_free_scan ( msglist ) ;
return DRV_BOX_BAD ;
return DRV_BOX_BAD ;
}
}
@ -808,31 +798,31 @@ maildir_select( store_t *gctx, int create,
lck . l_type = F_WRLCK ;
lck . l_type = F_WRLCK ;
if ( fcntl ( ctx - > uvfd , F_SETLKW , & lck ) ) {
if ( fcntl ( ctx - > uvfd , F_SETLKW , & lck ) ) {
sys_error ( " Maildir error: cannot lock %s " , uvpath ) ;
sys_error ( " Maildir error: cannot lock %s " , uvpath ) ;
bork :
close ( ctx - > uvfd ) ;
ctx - > uvfd = - 1 ;
cb ( DRV_BOX_BAD , aux ) ;
cb ( DRV_BOX_BAD , aux ) ;
return ;
return ;
}
}
if ( db_create ( & ctx - > db , 0 , 0 ) ) {
if ( db_create ( & ctx - > db , 0 , 0 ) ) {
fputs ( " Maildir error: db_create() failed \n " , stderr ) ;
fputs ( " Maildir error: db_create() failed \n " , stderr ) ;
goto bork ;
cb ( DRV_BOX_BAD , aux ) ;
return ;
}
}
if ( ( ret = ( ctx - > db - > open ) ( ctx - > db , 0 , uvpath , 0 , DB_HASH , DB_CREATE , 0 ) ) ) {
if ( ( ret = ( ctx - > db - > open ) ( ctx - > db , 0 , uvpath , 0 , DB_HASH , DB_CREATE , 0 ) ) ) {
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->open(%s) " , uvpath ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->open(%s) " , uvpath ) ;
dbork :
cb ( DRV_BOX_BAD , aux ) ;
ctx - > db - > close ( ctx - > db , 0 ) ;
return ;
goto bork ;
}
}
key . data = ( void * ) " UIDVALIDITY " ;
key . data = ( void * ) " UIDVALIDITY " ;
key . size = 11 ;
key . size = 11 ;
if ( ( ret = ctx - > db - > get ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
if ( ( ret = ctx - > db - > get ( ctx - > db , 0 , & key , & value , 0 ) ) ) {
if ( ret ! = DB_NOTFOUND ) {
if ( ret ! = DB_NOTFOUND ) {
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->get() " ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->get() " ) ;
goto dbork ;
cb ( DRV_BOX_BAD , aux ) ;
return ;
}
if ( maildir_init_uid_new ( ctx ) ! = DRV_OK ) {
cb ( DRV_BOX_BAD , aux ) ;
return ;
}
}
if ( maildir_init_uid_new ( ctx ) ! = DRV_OK )
goto dbork ;
} else {
} else {
ctx - > gen . uidvalidity = ( ( int * ) value . data ) [ 0 ] ;
ctx - > gen . uidvalidity = ( ( int * ) value . data ) [ 0 ] ;
ctx - > nuid = ( ( int * ) value . data ) [ 1 ] ;
ctx - > nuid = ( ( int * ) value . data ) [ 1 ] ;
@ -1164,8 +1154,6 @@ maildir_purge_msg( maildir_store_t *ctx, const char *name )
make_key ( & key , ( char * ) name ) ;
make_key ( & key , ( char * ) name ) ;
if ( ( ret = ctx - > db - > del ( ctx - > db , 0 , & key , 0 ) ) ) {
if ( ( ret = ctx - > db - > del ( ctx - > db , 0 , & key , 0 ) ) ) {
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->del() " ) ;
ctx - > db - > err ( ctx - > db , ret , " Maildir error: db->del() " ) ;
ctx - > db - > close ( ctx - > db , 0 ) ;
ctx - > db = 0 ;
return DRV_BOX_BAD ;
return DRV_BOX_BAD ;
}
}
return DRV_OK ;
return DRV_OK ;