From daaf9508784e33cf2ed191c152ad0f9300e05da6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 1 Apr 2013 12:20:03 +0200 Subject: [PATCH] split maildir_list_part() the boolean argument switched two entirely separate functions. --- src/drv_maildir.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 39489c4..2bddfdc 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -195,7 +195,7 @@ maildir_invoke_bad_callback( store_t *ctx ) 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 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; pl = pathLen + nfsnprintf( path + pathLen, _POSIX_PATH_MAX - pathLen, "%s", ent ); 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; } else { if (!memcmp( ent, "INBOX", 6 )) { @@ -248,30 +248,34 @@ maildir_list_recurse( store_t *gctx, int isBox, int *flags, const char *inbox, } 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]; - if (doInbox) { - *flags &= ~LIST_INBOX; - return maildir_list_recurse( - gctx, 1, flags, 0, - path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), - name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) ); - } else { - return maildir_list_recurse( - gctx, 0, flags, ((maildir_store_conf_t *)gctx->conf)->inbox, - path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ), - name, 0 ); - } + *flags &= ~LIST_INBOX; + return maildir_list_recurse( + gctx, 1, flags, 0, + path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", ((maildir_store_conf_t *)gctx->conf)->inbox ), + name, nfsnprintf( name, _POSIX_PATH_MAX, "INBOX" ) ); +} + +static int +maildir_list_path( store_t *gctx, int *flags ) +{ + char path[_POSIX_PATH_MAX], name[_POSIX_PATH_MAX]; + + return maildir_list_recurse( + gctx, 0, flags, ((maildir_store_conf_t *)gctx->conf)->inbox, + path, nfsnprintf( path, _POSIX_PATH_MAX, "%s", gctx->conf->path ), + name, 0 ); } static void maildir_list( store_t *gctx, int flags, void (*cb)( int sts, void *aux ), void *aux ) { - if (((flags & LIST_PATH) && maildir_list_part( gctx, 0, &flags ) < 0) || - ((flags & LIST_INBOX) && maildir_list_part( gctx, 1, &flags ) < 0)) { + if (((flags & LIST_PATH) && maildir_list_path( gctx, &flags ) < 0) || + ((flags & LIST_INBOX) && maildir_list_inbox( gctx, &flags ) < 0)) { maildir_invoke_bad_callback( gctx ); cb( DRV_CANCELED, aux ); } else {