split maildir_list_part()

the boolean argument switched two entirely separate functions.
This commit is contained in:
Oswald Buddenhagen 2013-04-01 12:20:03 +02:00
parent 167de3e438
commit daaf950878

View File

@ -195,7 +195,7 @@ maildir_invoke_bad_callback( store_t *ctx )
ctx->bad_callback( ctx->bad_callback_aux ); ctx->bad_callback( ctx->bad_callback_aux );
} }
static int maildir_list_part( store_t *gctx, int doInbox, int *flags ); static int maildir_list_inbox( store_t *gctx, int *flags );
static int static int
maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox,
@ -222,7 +222,7 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox,
const char *ent = de->d_name; const char *ent = de->d_name;
pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "%s", ent ); pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "%s", ent );
if (inbox && !memcmp( path, inbox, pl ) && !inbox[pl]) { if (inbox && !memcmp( path, inbox, pl ) && !inbox[pl]) {
if (maildir_list_part( gctx, 1, flags ) < 0) if (maildir_list_inbox( gctx, flags ) < 0)
return -1; return -1;
} else { } else {
if (!memcmp( ent, "INBOX", 6 )) { if (!memcmp( ent, "INBOX", 6 )) {
@ -248,30 +248,34 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox,
} }
static int static int
maildir_list_part( store_t *gctx, int doInbox, int *flags ) maildir_list_inbox( store_t *gctx, int *flags )
{ {
char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX];
if (doInbox) {
*flags &= ~LIST_INBOX; *flags &= ~LIST_INBOX;
return maildir_list_recurse( return maildir_list_recurse(
gctx, 1, flags, 0, gctx, 1, flags, 0,
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ),
name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) ); name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) );
} else { }
static int
maildir_list_path( store_t *gctx, int *flags )
{
char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX];
return maildir_list_recurse( return maildir_list_recurse(
gctx, 0, flags, ((maildir_store_conf_t *)gctx->conf)->inbox, gctx, 0, flags, ((maildir_store_conf_t *)gctx->conf)->inbox,
path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ), path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ),
name, 0 ); name, 0 );
}
} }
static void static void
maildir_list( store_t *gctx, int flags, maildir_list( store_t *gctx, int flags,
void (*cb)( int sts, void *aux ), void *aux ) void (*cb)( int sts, void *aux ), void *aux )
{ {
if (((flags & LIST_PATH) && maildir_list_part( gctx, 0, &flags ) < 0) || if (((flags & LIST_PATH) && maildir_list_path( gctx, &flags ) < 0) ||
((flags & LIST_INBOX) && maildir_list_part( gctx, 1, &flags ) < 0)) { ((flags & LIST_INBOX) && maildir_list_inbox( gctx, &flags ) < 0)) {
maildir_invoke_bad_callback( gctx ); maildir_invoke_bad_callback( gctx );
cb( DRV_CANCELED, aux ); cb( DRV_CANCELED, aux );
} else { } else {