From f90b2906508887e7b45c6d93bfed13ee75a8cf43 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 21 Mar 2006 10:38:30 +0000 Subject: [PATCH] split box list preparation from "consumption". --- src/main.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/main.c b/src/main.c index 23e8207..867fea8 100644 --- a/src/main.c +++ b/src/main.c @@ -194,7 +194,7 @@ main( int argc, char **argv ) driver_t *driver[2]; store_t *ctx[2]; string_list_t *boxes[2], *mbox, *sbox, **mboxp, **sboxp, *cboxes, *chanptr; - char *config = 0, *channame, *boxlist, *opt, *ochar; + char *config = 0, *channame, *boxlist, *boxp, *opt, *ochar; const char *names[2]; int all = 0, list = 0, cops = 0, ops[2] = { 0, 0 }; int oind, ret, op, multiple, pseudo = 0, t; @@ -495,21 +495,9 @@ main( int argc, char **argv ) goto next; } } - if (list && multiple) - printf( "%s:\n", chan->name ); - if (boxlist) { - for (boxlist = strtok( boxlist, ",\n" ); boxlist; boxlist = strtok( 0, ",\n" )) - if (list) - puts( boxlist ); - else { - names[M] = names[S] = boxlist; - switch (sync_boxes( ctx, names, chan )) { - case SYNC_BAD(M): t = M; goto screwt; - case SYNC_BAD(S): t = S; goto screwt; - case SYNC_FAIL: ret = 1; - } - } - } else if (chan->patterns) { + if (boxlist) + boxp = boxlist; + else if (chan->patterns) { for (t = 0; t < 2; t++) { if (!ctx[t]->listed) { if (driver[t]->list( ctx[t] ) != DRV_OK) { @@ -536,6 +524,24 @@ main( int argc, char **argv ) mboxp = &mbox->next; gotdupe: ; } + } + + if (list && multiple) + printf( "%s:\n", chan->name ); + if (boxlist) { + while ((names[S] = strsep( &boxp, ",\n" ))) { + if (list) + puts( names[S] ); + else { + names[M] = names[S]; + switch (sync_boxes( ctx, names, chan )) { + case SYNC_BAD(M): t = M; goto screwt; + case SYNC_BAD(S): t = S; goto screwt; + case SYNC_FAIL: ret = 1; + } + } + } + } else if (chan->patterns) { for (mbox = cboxes; mbox; mbox = mbox->next) if (list) puts( mbox->string );