commit decc33c2cf2c51179a4b287160e70dc853c52f99
Author: Oswald Buddenhagen <[email protected]>
Date:   Sat Dec 7 17:24:08 2013 +0100

    factor out sync_listed_boxes()

 src/main.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/main.c b/src/main.c
index cc44877..292ec5f 100644
--- 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 )
 {

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel

Reply via email to