isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit decc33c2cf2c51179a4b287160e70dc853c52f99
parent f485d69332d90128f8c2d5769fd88aff2df50566
Author: Oswald Buddenhagen <ossi@users.sf.net>
Date:   Sat,  7 Dec 2013 17:24:08 +0100

factor out sync_listed_boxes()

Diffstat:
Msrc/main.c | 28+++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/main.c b/src/main.c @@ -502,6 +502,7 @@ main( int argc, char **argv ) static void store_opened( store_t *ctx, void *aux ); static void store_listed( int sts, void *aux ); +static int sync_listed_boxes( main_vars_t *mvars, string_list_t *mbox ); static void done_sync_dyn( int sts, void *aux ); static void done_sync( int sts, void *aux ); @@ -625,25 +626,17 @@ sync_chans( main_vars_t *mvars, int ent ) if (mvars->boxlist) { if ((mbox = mvars->cboxes)) { mvars->cboxes = mbox->next; - if (!mvars->list) { - mvars->names[M] = mvars->names[S] = mbox->string; - sync_boxes( mvars->ctx, mvars->names, mvars->chan, done_sync_dyn, mvars ); + if (sync_listed_boxes( mvars, mbox )) goto syncw; - } - puts( mbox->string ); - free( mbox ); goto syncmlx; } for (t = 0; t < 2; t++) if ((mbox = mvars->boxes[t])) { mvars->boxes[t] = mbox->next; if ((mvars->chan->ops[1-t] & OP_MASK_TYPE) && (mvars->chan->ops[1-t] & OP_CREATE)) { - if (!mvars->list) { - mvars->names[M] = mvars->names[S] = mbox->string; - sync_boxes( mvars->ctx, mvars->names, mvars->chan, done_sync_dyn, mvars ); + if (sync_listed_boxes( mvars, mbox )) goto syncw; - } - puts( mbox->string ); + goto syncmlx; } free( mbox ); goto syncmlx; @@ -789,6 +782,19 @@ store_listed( int sts, void *aux ) sync_chans( mvars, E_OPEN ); } +static int +sync_listed_boxes( main_vars_t *mvars, string_list_t *mbox ) +{ + if (!mvars->list) { + mvars->names[M] = mvars->names[S] = mbox->string; + sync_boxes( mvars->ctx, (const char **)mvars->names, mvars->chan, done_sync_dyn, mvars ); + return 1; + } + puts( mbox->string ); + free( mbox ); + return 0; +} + static void done_sync_dyn( int sts, void *aux ) {