CVS commit by ossi:
fix error paths wrt sync drivers
M +26 -29 drv_imap.c 1.31
M +55 -90 drv_maildir.c 1.23
M +14 -14 isync.h 1.62
M +103 -113 sync.c 1.87
--- isync/src/drv_imap.c #1.30:1.31
@@ -1427,5 +1427,4 @@ imap_open_store( store_conf_t *conf,
imap_cancel_store( &ctx->gen );
cb( 0, aux );
- return;
}
@@ -1443,7 +1442,7 @@ imap_prepare_opts( store_t *gctx, int op
}
-static void
+static int
imap_select( store_t *gctx, int minuid, int maxuid, int *excs, int nexcs,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
@@ -1500,10 +1499,10 @@ imap_select( store_t *gctx, int minuid,
if (excs)
free( excs );
- cb( ret, aux );
+ return cb( ret, aux );
}
-static void
+static int
imap_fetch_msg( store_t *ctx, message_t *msg, msg_data_t *data,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
struct imap_cmd_cb cbd;
@@ -1512,5 +1511,5 @@ imap_fetch_msg( store_t *ctx, message_t
cbd.uid = msg->uid;
cbd.ctx = data;
- cb( imap_exec_m( (imap_store_t *)ctx, &cbd, "UID FETCH %d
(%sBODY.PEEK[])",
+ return cb( imap_exec_m( (imap_store_t *)ctx, &cbd, "UID FETCH %d
(%sBODY.PEEK[])",
msg->uid, (msg->status & M_FLAGS) ? "" : "FLAGS " ),
aux );
}
@@ -1543,7 +1542,7 @@ imap_flags_helper( imap_store_t *ctx, in
}
-static void
+static int
imap_set_flags( store_t *gctx, message_t *msg, int uid, int add, int del,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
@@ -1560,17 +1559,17 @@ imap_set_flags( store_t *gctx, message_t
(!del || (ret = imap_flags_helper( ctx, uid, '-', del )) == DRV_OK))
ret = DRV_OK;
- cb( ret, aux );
+ return cb( ret, aux );
}
-static void
+static int
imap_close( store_t *ctx,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
- cb( imap_exec_b( (imap_store_t *)ctx, 0, "CLOSE" ), aux );
+ return cb( imap_exec_b( (imap_store_t *)ctx, 0, "CLOSE" ), aux );
}
-static void
+static int
imap_trash_msg( store_t *gctx, message_t *msg,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
@@ -1579,11 +1578,11 @@ imap_trash_msg( store_t *gctx, message_t
memset( &cbd, 0, sizeof(cbd) );
cbd.create = 1;
- cb( imap_exec_m( ctx, &cbd, "UID COPY %d \"%s%s\"",
+ return cb( imap_exec_m( ctx, &cbd, "UID COPY %d \"%s%s\"",
msg->uid, ctx->prefix, gctx->conf->trash ), aux );
}
-static void
+static int
imap_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
- void (*cb)( int sts, int uid, void *aux ), void *aux )
+ int (*cb)( int sts, int uid, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
@@ -1621,8 +1620,6 @@ imap_store_msg( store_t *gctx, msg_data_
ret = imap_exec_m( ctx, &cbd, "APPEND \"%s%s\" %s", prefix, box,
flagstr );
ctx->caps = ctx->rcaps;
- if (ret != DRV_OK) {
- cb( ret, -1, aux );
- return;
- }
+ if (ret != DRV_OK)
+ return cb( ret, -1, aux );
if (to_trash)
ctx->trashnc = 0;
@@ -1631,10 +1628,10 @@ imap_store_msg( store_t *gctx, msg_data_
}
- cb( DRV_OK, uid, aux );
+ return cb( DRV_OK, uid, aux );
}
-static void
+static int
imap_find_msg( store_t *gctx, const char *tuid,
- void (*cb)( int sts, int uid, void *aux ), void *aux )
+ int (*cb)( int sts, int uid, void *aux ), void *aux )
{
imap_store_t *ctx = (imap_store_t *)gctx;
@@ -1647,7 +1644,7 @@ imap_find_msg( store_t *gctx, const char
uid = -1; /* in case we get no SEARCH response at all */
if ((ret = imap_exec_m( ctx, &cbd, "UID SEARCH HEADER X-TUID %."
stringify(TUIDL) "s", tuid )) != DRV_OK)
- cb( ret, -1, aux );
+ return cb( ret, -1, aux );
else
- cb( uid <= 0 ? DRV_MSG_BAD : DRV_OK, uid, aux );
+ return cb( uid <= 0 ? DRV_MSG_BAD : DRV_OK, uid, aux );
}
--- isync/src/drv_maildir.c #1.22:1.23
@@ -768,7 +768,7 @@ maildir_prepare_opts( store_t *gctx, int
}
-static void
+static int
maildir_select( store_t *gctx, int minuid, int maxuid, int *excs, int nexcs,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
maildir_store_t *ctx = (maildir_store_t *)gctx;
@@ -786,8 +786,6 @@ maildir_select( store_t *gctx, int minui
ctx->nexcs = nexcs;
- if (maildir_validate( gctx->path, "", ctx->gen.opts & OPEN_CREATE ) !=
DRV_OK) {
- cb( DRV_BOX_BAD, aux );
- return;
- }
+ if (maildir_validate( gctx->path, "", ctx->gen.opts & OPEN_CREATE ) !=
DRV_OK)
+ return cb( DRV_BOX_BAD, aux );
nfsnprintf( uvpath, sizeof(uvpath), "%s/.uidvalidity", gctx->path );
@@ -795,6 +793,5 @@ maildir_select( store_t *gctx, int minui
if ((ctx->uvfd = open( uvpath, O_RDWR|O_CREAT, 0600 )) < 0) {
perror( uvpath );
- cb( DRV_BOX_BAD, aux );
- return;
+ return cb( DRV_BOX_BAD, aux );
}
#else
@@ -811,6 +808,5 @@ maildir_select( store_t *gctx, int minui
}
perror( uvpath );
- cb( DRV_BOX_BAD, aux );
- return;
+ return cb( DRV_BOX_BAD, aux );
}
dbok:
@@ -824,6 +820,5 @@ maildir_select( store_t *gctx, int minui
close( ctx->uvfd );
ctx->uvfd = -1;
- cb( DRV_BOX_BAD, aux );
- return;
+ return cb( DRV_BOX_BAD, aux );
}
if (db_create( &ctx->db, 0, 0 )) {
@@ -855,8 +850,6 @@ maildir_select( store_t *gctx, int minui
#endif /* USE_DB */
- if (maildir_scan( ctx, &msglist ) != DRV_OK) {
- cb( DRV_BOX_BAD, aux );
- return;
- }
+ if (maildir_scan( ctx, &msglist ) != DRV_OK)
+ return cb( DRV_BOX_BAD, aux );
msgapp = &ctx->gen.msgs;
for (i = 0; i < msglist.nents; i++)
@@ -864,5 +857,5 @@ maildir_select( store_t *gctx, int minui
maildir_free_scan( &msglist );
- cb( DRV_OK, aux );
+ return cb( DRV_OK, aux );
}
@@ -932,7 +925,7 @@ maildir_again( maildir_store_t *ctx, mai
}
-static void
+static int
maildir_fetch_msg( store_t *gctx, message_t *gmsg, msg_data_t *data,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
maildir_store_t *ctx = (maildir_store_t *)gctx;
@@ -946,8 +939,6 @@ maildir_fetch_msg( store_t *gctx, messag
if ((fd = open( buf, O_RDONLY )) >= 0)
break;
- if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK) {
- cb( ret, aux );
- return;
- }
+ if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK)
+ return cb( ret, aux );
}
fstat( fd, &st );
@@ -957,11 +948,10 @@ maildir_fetch_msg( store_t *gctx, messag
perror( buf );
close( fd );
- cb( DRV_MSG_BAD, aux );
- return;
+ return cb( DRV_MSG_BAD, aux );
}
close( fd );
if (!(gmsg->status & M_FLAGS))
data->flags = maildir_parse_flags( msg->base );
- cb( DRV_OK, aux );
+ return cb( DRV_OK, aux );
}
@@ -981,7 +971,7 @@ maildir_make_flags( int flags, char *buf
}
-static void
+static int
maildir_store_msg( store_t *gctx, msg_data_t *data, int to_trash,
- void (*cb)( int sts, int uid, void *aux ), void *aux )
+ int (*cb)( int sts, int uid, void *aux ), void *aux )
{
maildir_store_t *ctx = (maildir_store_t *)gctx;
@@ -996,6 +986,5 @@ maildir_store_msg( store_t *gctx, msg_da
if ((ret = maildir_set_uid( ctx, base, &uid )) !=
DRV_OK) {
free( data->data );
- cb( ret, 0, aux );
- return;
+ return cb( ret, 0, aux );
}
} else
@@ -1003,8 +992,6 @@ maildir_store_msg( store_t *gctx, msg_da
{
if ((ret = maildir_uidval_lock( ctx )) != DRV_OK ||
- (ret = maildir_obtain_uid( ctx, &uid )) != DRV_OK) {
- cb( ret, 0, aux );
- return;
- }
+ (ret = maildir_obtain_uid( ctx, &uid )) != DRV_OK)
+ return cb( ret, 0, aux );
maildir_uidval_unlock( ctx );
nfsnprintf( base + bl, sizeof(base) - bl, ",U=%d", uid
);
@@ -1023,17 +1010,14 @@ maildir_store_msg( store_t *gctx, msg_da
perror( buf );
free( data->data );
- cb( DRV_BOX_BAD, 0, aux );
- return;
+ return cb( DRV_BOX_BAD, 0, aux );
}
if ((ret = maildir_validate( gctx->conf->path,
gctx->conf->trash, gctx->opts & OPEN_CREATE )) != DRV_OK) {
free( data->data );
- cb( ret, 0, aux );
- return;
+ return cb( ret, 0, aux );
}
if ((fd = open( buf, O_WRONLY|O_CREAT|O_EXCL, 0600 )) < 0) {
perror( buf );
free( data->data );
- cb( DRV_BOX_BAD, 0, aux );
- return;
+ return cb( DRV_BOX_BAD, 0, aux );
}
}
@@ -1046,6 +1030,5 @@ maildir_store_msg( store_t *gctx, msg_da
error( "Maildir error: %s: partial write\n", buf );
close( fd );
- cb( DRV_BOX_BAD, 0, aux );
- return;
+ return cb( DRV_BOX_BAD, 0, aux );
}
close( fd );
@@ -1054,13 +1037,12 @@ maildir_store_msg( store_t *gctx, msg_da
if (rename( buf, nbuf )) {
perror( nbuf );
- cb( DRV_BOX_BAD, 0, aux );
- return;
+ return cb( DRV_BOX_BAD, 0, aux );
}
- cb( DRV_OK, uid, aux );
+ return cb( DRV_OK, uid, aux );
}
-static void
+static int
maildir_find_msg( store_t *gctx, const char *tuid,
- void (*cb)( int sts, int uid, void *aux ), void *aux )
+ int (*cb)( int sts, int uid, void *aux ), void *aux )
{
message_t *msg;
@@ -1068,14 +1050,12 @@ maildir_find_msg( store_t *gctx, const c
/* using a hash table might turn out to be more appropriate ... */
for (msg = gctx->msgs; msg; msg = msg->next)
- if (!(msg->status & M_DEAD) && !memcmp( ((maildir_message_t
*)msg)->tuid, tuid, TUIDL )) {
- cb( DRV_OK, msg->uid, aux );
- return;
- }
- cb( DRV_MSG_BAD, -1, aux );
+ if (!(msg->status & M_DEAD) && !memcmp( ((maildir_message_t
*)msg)->tuid, tuid, TUIDL ))
+ return cb( DRV_OK, msg->uid, aux );
+ return cb( DRV_MSG_BAD, -1, aux );
}
-static void
+static int
maildir_set_flags( store_t *gctx, message_t *gmsg, int uid, int add, int del,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
maildir_store_t *ctx = (maildir_store_t *)gctx;
@@ -1119,8 +1099,6 @@ maildir_set_flags( store_t *gctx, messag
if (!rename( buf, nbuf ))
break;
- if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK) {
- cb( ret, aux );
- return;
- }
+ if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK)
+ return cb( ret, aux );
}
free( msg->base );
@@ -1131,5 +1109,5 @@ maildir_set_flags( store_t *gctx, messag
gmsg->status &= ~M_RECENT;
- cb( DRV_OK, aux );
+ return cb( DRV_OK, aux );
}
@@ -1151,7 +1129,7 @@ maildir_purge_msg( maildir_store_t *ctx,
#endif /* USE_DB */
-static void
+static int
maildir_trash_msg( store_t *gctx, message_t *gmsg,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
maildir_store_t *ctx = (maildir_store_t *)gctx;
@@ -1170,20 +1148,15 @@ maildir_trash_msg( store_t *gctx, messag
break;
if (!stat( buf, &st )) {
- if ((ret = maildir_validate( gctx->conf->path,
gctx->conf->trash, 1 )) != DRV_OK) {
- cb( ret, aux );
- return;
- }
+ if ((ret = maildir_validate( gctx->conf->path,
gctx->conf->trash, 1 )) != DRV_OK)
+ return cb( ret, aux );
if (!rename( buf, nbuf ))
break;
if (errno != ENOENT) {
perror( nbuf );
- cb( DRV_BOX_BAD, aux );
- return;
- }
+ return cb( DRV_BOX_BAD, aux );
}
- if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK) {
- cb( ret, aux );
- return;
}
+ if ((ret = maildir_again( ctx, msg, buf )) != DRV_OK)
+ return cb( ret, aux );
}
gmsg->status |= M_DEAD;
@@ -1191,15 +1164,13 @@ maildir_trash_msg( store_t *gctx, messag
#ifdef USE_DB
- if (ctx->db) {
- cb( maildir_purge_msg( ctx, msg->base ), aux );
- return;
- }
+ if (ctx->db)
+ return cb( maildir_purge_msg( ctx, msg->base ), aux );
#endif /* USE_DB */
- cb( DRV_OK, aux );
+ return cb( DRV_OK, aux );
}
-static void
+static int
maildir_close( store_t *gctx,
- void (*cb)( int sts, void *aux ), void *aux )
+ int (*cb)( int sts, void *aux ), void *aux )
{
#ifdef USE_DB
@@ -1225,19 +1196,13 @@ maildir_close( store_t *gctx,
gctx->count--;
#ifdef USE_DB
- if (ctx->db && (ret =
maildir_purge_msg( ctx, ((maildir_message_t *)msg)->base )) != DRV_OK) {
- cb( ret, aux );
- return;
- }
+ if (ctx->db && (ret =
maildir_purge_msg( ctx, ((maildir_message_t *)msg)->base )) != DRV_OK)
+ return cb( ret, aux );
#endif /* USE_DB */
}
}
- if (!retry) {
- cb( DRV_OK, aux );
- return;
- }
- if ((ret = maildir_rescan( (maildir_store_t *)gctx )) !=
DRV_OK) {
- cb( ret, aux );
- return;
- }
+ if (!retry)
+ return cb( DRV_OK, aux );
+ if ((ret = maildir_rescan( (maildir_store_t *)gctx )) != DRV_OK)
+ return cb( ret, aux );
}
}
--- isync/src/isync.h #1.61:1.62
@@ -192,18 +192,18 @@ struct driver {
void (*prepare_paths)( store_t *ctx );
void (*prepare_opts)( store_t *ctx, int opts );
- void (*select)( store_t *ctx, int minuid, int maxuid, int *excs, int
nexcs,
- void (*cb)( int sts, void *aux ), void *aux );
- void (*fetch_msg)( store_t *ctx, message_t *msg, msg_data_t *data,
- void (*cb)( int sts, void *aux ), void *aux );
- void (*store_msg)( store_t *ctx, msg_data_t *data, int to_trash,
- void (*cb)( int sts, int uid, void *aux ), void *aux
);
- void (*find_msg)( store_t *ctx, const char *tuid,
- void (*cb)( int sts, int uid, void *aux ), void *aux
);
- void (*set_flags)( store_t *ctx, message_t *msg, int uid, int add, int
del, /* msg can be null, therefore uid as a fallback */
- void (*cb)( int sts, void *aux ), void *aux );
- void (*trash_msg)( store_t *ctx, message_t *msg, /* This may expunge
the original message immediately, but it needn't to */
- void (*cb)( int sts, void *aux ), void *aux );
- void (*close)( store_t *ctx, /* IMAP-style: expunge inclusive */
- void (*cb)( int sts, void *aux ), void *aux );
+ int (*select)( store_t *ctx, int minuid, int maxuid, int *excs, int
nexcs,
+ int (*cb)( int sts, void *aux ), void *aux );
+ int (*fetch_msg)( store_t *ctx, message_t *msg, msg_data_t *data,
+ int (*cb)( int sts, void *aux ), void *aux );
+ int (*store_msg)( store_t *ctx, msg_data_t *data, int to_trash,
+ int (*cb)( int sts, int uid, void *aux ), void *aux );
+ int (*find_msg)( store_t *ctx, const char *tuid,
+ int (*cb)( int sts, int uid, void *aux ), void *aux );
+ int (*set_flags)( store_t *ctx, message_t *msg, int uid, int add, int
del, /* msg can be null, therefore uid as a fallback */
+ int (*cb)( int sts, void *aux ), void *aux );
+ int (*trash_msg)( store_t *ctx, message_t *msg, /* This may expunge the
original message immediately, but it needn't to */
+ int (*cb)( int sts, void *aux ), void *aux );
+ int (*close)( store_t *ctx, /* IMAP-style: expunge inclusive */
+ int (*cb)( int sts, void *aux ), void *aux );
void (*cancel)( store_t *ctx, /* only not yet sent commands */
void (*cb)( int sts, void *aux ), void *aux );
--- isync/src/sync.c #1.86:1.87
@@ -153,5 +153,5 @@ typedef struct {
int trash_total[2], trash_done[2];
int maxuid[2], uidval[2], smaxxuid, lfd;
- unsigned find:1, cancel:1;
+ unsigned find:1;
} sync_vars_t;
@@ -186,5 +186,5 @@ typedef struct {
typedef struct copy_vars {
- void (*cb)( int sts, int uid, struct copy_vars *vars );
+ int (*cb)( int sts, int uid, struct copy_vars *vars );
void *aux;
sync_rec_t *srec; /* also ->tuid */
@@ -193,7 +193,7 @@ typedef struct copy_vars {
} copy_vars_t;
-static void msg_fetched( int sts, void *aux );
+static int msg_fetched( int sts, void *aux );
-static void
+static int
copy_msg( copy_vars_t *vars )
{
@@ -201,10 +201,10 @@ copy_msg( copy_vars_t *vars )
vars->data.flags = vars->msg->flags;
- svars->drv[1-t]->fetch_msg( svars->ctx[1-t], vars->msg, &vars->data,
msg_fetched, vars );
+ return svars->drv[1-t]->fetch_msg( svars->ctx[1-t], vars->msg,
&vars->data, msg_fetched, vars );
}
-static void msg_stored( int sts, int uid, void *aux );
+static int msg_stored( int sts, int uid, void *aux );
-static void
+static int
msg_fetched( int sts, void *aux )
{
@@ -255,6 +255,5 @@ msg_fetched( int sts, void *aux )
/* invalid message */
free( fmap );
- vars->cb( SYNC_NOGOOD, 0, vars );
- break;
+ return vars->cb( SYNC_NOGOOD, 0, vars );
}
oke:
@@ -311,22 +310,17 @@ msg_fetched( int sts, void *aux )
}
- svars->drv[t]->store_msg( svars->ctx[t], &vars->data,
!vars->srec, msg_stored, vars );
- break;
+ return svars->drv[t]->store_msg( svars->ctx[t], &vars->data,
!vars->srec, msg_stored, vars );
case DRV_CANCELED:
- vars->cb( SYNC_CANCELED, 0, vars );
- break;
+ return vars->cb( SYNC_CANCELED, 0, vars );
case DRV_MSG_BAD:
- vars->cb( SYNC_NOGOOD, 0, vars );
- break;
+ return vars->cb( SYNC_NOGOOD, 0, vars );
case DRV_STORE_BAD:
- vars->cb( SYNC_BAD(1-t), 0, vars );
- break;
+ return vars->cb( SYNC_BAD(1-t), 0, vars );
default:
- vars->cb( SYNC_FAIL, 0, vars );
- break;
+ return vars->cb( SYNC_FAIL, 0, vars );
}
}
-static void
+static int
msg_stored( int sts, int uid, void *aux )
{
@@ -337,15 +331,11 @@ msg_stored( int sts, int uid, void *aux
switch (sts) {
case DRV_OK:
- vars->cb( SYNC_OK, uid, vars );
- break;
+ return vars->cb( SYNC_OK, uid, vars );
case DRV_CANCELED:
- vars->cb( SYNC_CANCELED, 0, vars );
- break;
+ return vars->cb( SYNC_CANCELED, 0, vars );
case DRV_STORE_BAD:
- vars->cb( SYNC_BAD(t), 0, vars );
- break;
+ return vars->cb( SYNC_BAD(t), 0, vars );
default:
- vars->cb( SYNC_FAIL, 0, vars );
- break;
+ return vars->cb( SYNC_FAIL, 0, vars );
}
}
@@ -388,5 +378,5 @@ cancel_sync( sync_vars_t *svars )
int t;
- svars->cancel = 1;
+ /* the 1st round is guaranteed not to trash svars */
for (t = 0; t < 2; t++)
if (svars->ret & SYNC_BAD(t))
@@ -458,5 +448,5 @@ clean_strdup( const char *s )
#define JOURNAL_VERSION "2"
-static void select_box( sync_vars_t *svars, int t, int minwuid, int *mexcs,
int nmexcs );
+static int select_box( sync_vars_t *svars, int t, int minwuid, int *mexcs, int
nmexcs );
void
@@ -495,4 +485,5 @@ sync_boxes( store_t *ctx[], const char *
if (!ctx[S]->path) {
error( "Error: store '%s' does not support in-box sync
state\n", chan->stores[S]->name );
+ free( svars );
cb( SYNC_BAD(S), aux );
return;
@@ -514,4 +505,5 @@ sync_boxes( store_t *ctx[], const char *
error( "Error: invalid SyncState '%s'\n", svars->dname );
free( svars->dname );
+ free( svars );
cb( SYNC_BAD(S), aux );
return;
@@ -521,4 +513,5 @@ sync_boxes( store_t *ctx[], const char *
error( "Error: cannot create SyncState directory '%s': %s\n",
svars->dname, strerror(errno) );
free( svars->dname );
+ free( svars );
cb( SYNC_BAD(S), aux );
return;
@@ -824,12 +817,12 @@ sync_boxes( store_t *ctx[], const char *
svars->find = line != 0;
- if (!svars->smaxxuid)
- select_box( svars, M, (ctx[M]->opts & OPEN_OLD) ? 1 : INT_MAX,
0, 0 );
+ if (!svars->smaxxuid && select_box( svars, M, (ctx[M]->opts & OPEN_OLD)
? 1 : INT_MAX, 0, 0 ))
+ return;
select_box( svars, S, (ctx[S]->opts & OPEN_OLD) ? 1 : INT_MAX, 0, 0 );
}
-static void box_selected( int sts, void *aux );
+static int box_selected( int sts, void *aux );
-static void
+static int
select_box( sync_vars_t *svars, int t, int minwuid, int *mexcs, int nmexcs )
{
@@ -850,5 +843,5 @@ select_box( sync_vars_t *svars, int t, i
info( "Selecting %s %s...\n", str_ms[t], svars->ctx[t]->name );
debug( maxwuid == INT_MAX ? "selecting %s [%d,inf]\n" : "selecting %s
[%d,%d]\n", str_ms[t], minwuid, maxwuid );
- svars->drv[t]->select( svars->ctx[t], minwuid, maxwuid, mexcs, nmexcs,
box_selected, AUX );
+ return svars->drv[t]->select( svars->ctx[t], minwuid, maxwuid, mexcs,
nmexcs, box_selected, AUX );
}
@@ -858,8 +851,8 @@ typedef struct {
} find_vars_t;
-static void msg_found_sel( int sts, int uid, void *aux );
-static void msgs_found_sel( sync_vars_t *svars, int t );
+static int msg_found_sel( int sts, int uid, void *aux );
+static int msgs_found_sel( sync_vars_t *svars, int t );
-static void
+static int
box_selected( int sts, void *aux )
{
@@ -869,5 +862,5 @@ box_selected( int sts, void *aux )
if (check_ret( sts, svars, t ))
- return;
+ return 1;
if (svars->uidval[t] && svars->uidval[t] != svars->ctx[t]->uidvalidity)
{
error( "Error: UIDVALIDITY of %s changed (got %d, expected
%d)\n",
@@ -875,5 +868,5 @@ box_selected( int sts, void *aux )
svars->ret |= SYNC_FAIL;
cancel_sync( svars );
- return;
+ return 1;
}
info( "%s: %d messages, %d recent\n", str_ms[t], svars->ctx[t]->count,
svars->ctx[t]->recent );
@@ -898,15 +891,14 @@ box_selected( int sts, void *aux )
fv->aux = AUX;
fv->srec = srec;
- svars->drv[t]->find_msg( svars->ctx[t],
srec->tuid, msg_found_sel, fv );
- if (svars->cancel)
- return;
+ if (svars->drv[t]->find_msg( svars->ctx[t],
srec->tuid, msg_found_sel, fv ))
+ return 1;
}
}
}
svars->state[t] |= ST_SENT_FIND_OLD;
- msgs_found_sel( svars, t );
+ return msgs_found_sel( svars, t );
}
-static void
+static int
msg_found_sel( int sts, int uid, void *aux )
{
@@ -915,5 +907,5 @@ msg_found_sel( int sts, int uid, void *a
if (check_ret_aux( sts, svars, t, vars ))
- return;
+ return 1;
switch (sts) {
case DRV_OK:
@@ -933,5 +925,5 @@ msg_found_sel( int sts, int uid, void *a
svars->find_old_done[t]++;
stats( svars );
- msgs_found_sel( svars, t );
+ return msgs_found_sel( svars, t );
}
@@ -942,13 +934,13 @@ typedef struct {
} flag_vars_t;
-static void flags_set_del( int sts, void *aux );
-static void flags_set_sync( int sts, void *aux );
+static int flags_set_del( int sts, void *aux );
+static int flags_set_sync( int sts, void *aux );
static void flags_set_sync_p2( sync_vars_t *svars, sync_rec_t *srec, int t );
-static void msgs_flags_set( sync_vars_t *svars, int t );
-static void msg_copied( int sts, int uid, copy_vars_t *vars );
+static int msgs_flags_set( sync_vars_t *svars, int t );
+static int msg_copied( int sts, int uid, copy_vars_t *vars );
static void msg_copied_p2( sync_vars_t *svars, sync_rec_t *srec, int t,
message_t *tmsg, int uid );
-static void msgs_copied( sync_vars_t *svars, int t );
+static int msgs_copied( sync_vars_t *svars, int t );
-static void
+static int
msgs_found_sel( sync_vars_t *svars, int t )
{
@@ -963,5 +955,5 @@ msgs_found_sel( sync_vars_t *svars, int
if (!(svars->state[t] & ST_SENT_FIND_OLD) || svars->find_old_done[t] <
svars->find_new_total[t])
- return;
+ return 0;
/*
@@ -1059,10 +1051,9 @@ msgs_found_sel( sync_vars_t *svars, int
debugn( " %d", mexcs[t] );
debug( "\n" );
- select_box( svars, M, minwuid, mexcs, nmexcs );
- return;
+ return select_box( svars, M, minwuid, mexcs, nmexcs );
}
if (!(svars->state[1-t] & ST_SENT_FIND_OLD) ||
svars->find_old_done[1-t] < svars->find_new_total[1-t])
- return;
+ return 0;
if (!svars->uidval[M] || !svars->uidval[S]) {
@@ -1119,7 +1110,6 @@ msgs_found_sel( sync_vars_t *svars, int
Fprintf( svars->jfp, "# %d %d
%." stringify(TUIDL) "s\n", srec->uid[M], srec->uid[S], srec->tuid );
debug( " -> %sing message,
TUID %." stringify(TUIDL) "s\n", str_hl[t], srec->tuid );
- copy_msg( cv );
- if (svars->cancel)
- return;
+ if (copy_msg( cv ))
+ return 1;
} else {
if (tmsg->srec) {
@@ -1133,5 +1123,6 @@ msgs_found_sel( sync_vars_t *svars, int
}
svars->state[t] |= ST_SENT_NEW;
- msgs_copied( svars, t );
+ if (msgs_copied( svars, t ))
+ return 1;
}
@@ -1171,7 +1162,6 @@ msgs_found_sel( sync_vars_t *svars, int
fv->aux = AUX;
fv->srec = srec;
- svars->drv[t]->set_flags(
svars->ctx[t], srec->msg[t], srec->uid[t], F_DELETED, 0, flags_set_del, fv );
- if (svars->cancel)
- return;
+ if (svars->drv[t]->set_flags(
svars->ctx[t], srec->msg[t], srec->uid[t], F_DELETED, 0, flags_set_del, fv ))
+ return 1;
} else
debug( " not %sing delete\n",
str_hl[t] );
@@ -1283,7 +1273,6 @@ msgs_found_sel( sync_vars_t *svars, int
fv->aflags = aflags;
fv->dflags = dflags;
- svars->drv[t]->set_flags( svars->ctx[t],
srec->msg[t], srec->uid[t], aflags, dflags, flags_set_sync, fv );
- if (svars->cancel)
- return;
+ if (svars->drv[t]->set_flags( svars->ctx[t],
srec->msg[t], srec->uid[t], aflags, dflags, flags_set_sync, fv ))
+ return 1;
} else
flags_set_sync_p2( svars, srec, t );
@@ -1293,9 +1282,11 @@ msgs_found_sel( sync_vars_t *svars, int
svars->drv[t]->commit( svars->ctx[t] );
svars->state[t] |= ST_SENT_FLAGS;
- msgs_flags_set( svars, t );
+ if (msgs_flags_set( svars, t ))
+ return 1;
}
+ return 0;
}
-static void
+static int
msg_copied( int sts, int uid, copy_vars_t *vars )
{
@@ -1315,10 +1306,10 @@ msg_copied( int sts, int uid, copy_vars_
case SYNC_CANCELED:
free( vars );
- return;
+ return 1;
}
free( vars );
svars->new_done[t]++;
stats( svars );
- msgs_copied( svars, t );
+ return msgs_copied( svars, t );
}
@@ -1341,8 +1332,8 @@ msg_copied_p2( sync_vars_t *svars, sync_
}
-static void msg_found_new( int sts, int uid, void *aux );
-static void sync_close( sync_vars_t *svars, int t );
+static int msg_found_new( int sts, int uid, void *aux );
+static int sync_close( sync_vars_t *svars, int t );
-static void
+static int
msgs_copied( sync_vars_t *svars, int t )
{
@@ -1351,5 +1342,5 @@ msgs_copied( sync_vars_t *svars, int t )
if (!(svars->state[t] & ST_SENT_NEW) || svars->new_done[t] <
svars->new_total[t])
- return;
+ return 0;
debug( "finding just copied messages on %s\n", str_ms[t] );
@@ -1364,14 +1355,13 @@ msgs_copied( sync_vars_t *svars, int t )
fv->aux = AUX;
fv->srec = srec;
- svars->drv[t]->find_msg( svars->ctx[t], srec->tuid,
msg_found_new, fv );
- if (svars->cancel)
- return;
+ if (svars->drv[t]->find_msg( svars->ctx[t], srec->tuid,
msg_found_new, fv ))
+ return 1;
}
}
svars->state[t] |= ST_SENT_FIND_NEW;
- sync_close( svars, t );
+ return sync_close( svars, t );
}
-static void
+static int
msg_found_new( int sts, int uid, void *aux )
{
@@ -1380,5 +1370,5 @@ msg_found_new( int sts, int uid, void *a
if (check_ret_aux( sts, svars, t, vars ))
- return;
+ return 1;
switch (sts) {
case DRV_OK:
@@ -1396,8 +1386,8 @@ msg_found_new( int sts, int uid, void *a
svars->find_new_done[t]++;
stats( svars );
- sync_close( svars, t );
+ return sync_close( svars, t );
}
-static void
+static int
flags_set_del( int sts, void *aux )
{
@@ -1406,5 +1396,5 @@ flags_set_del( int sts, void *aux )
if (check_ret_aux( sts, svars, t, vars ))
- return;
+ return 1;
switch (sts) {
case DRV_OK:
@@ -1417,8 +1407,8 @@ flags_set_del( int sts, void *aux )
svars->flags_done[t]++;
stats( svars );
- msgs_flags_set( svars, t );
+ return msgs_flags_set( svars, t );
}
-static void
+static int
flags_set_sync( int sts, void *aux )
{
@@ -1427,5 +1417,5 @@ flags_set_sync( int sts, void *aux )
if (check_ret_aux( sts, svars, t, vars ))
- return;
+ return 1;
switch (sts) {
case DRV_OK:
@@ -1440,5 +1430,5 @@ flags_set_sync( int sts, void *aux )
svars->flags_done[t]++;
stats( svars );
- msgs_flags_set( svars, t );
+ return msgs_flags_set( svars, t );
}
@@ -1470,8 +1460,8 @@ flags_set_sync_p2( sync_vars_t *svars, s
}
-static void msg_trashed( int sts, void *aux );
-static void msg_rtrashed( int sts, int uid, copy_vars_t *vars );
+static int msg_trashed( int sts, void *aux );
+static int msg_rtrashed( int sts, int uid, copy_vars_t *vars );
-static void
+static int
msgs_flags_set( sync_vars_t *svars, int t )
{
@@ -1480,5 +1470,5 @@ msgs_flags_set( sync_vars_t *svars, int
if (!(svars->state[t] & ST_SENT_FLAGS) || svars->flags_done[t] <
svars->flags_total[t])
- return;
+ return 0;
if ((svars->chan->ops[t] & OP_EXPUNGE) &&
@@ -1492,7 +1482,6 @@ msgs_flags_set( sync_vars_t *svars, int
svars->trash_total[t]++;
stats( svars );
- svars->drv[t]->trash_msg(
svars->ctx[t], tmsg, msg_trashed, AUX );
- if (svars->cancel)
- return;
+ if (svars->drv[t]->trash_msg(
svars->ctx[t], tmsg, msg_trashed, AUX ))
+ return 1;
} else
debug( "%s: not trashing
message %d - not new\n", str_ms[t], tmsg->uid );
@@ -1508,7 +1497,6 @@ msgs_flags_set( sync_vars_t *svars, int
cv->srec = 0;
cv->msg = tmsg;
- copy_msg( cv );
- if (svars->cancel)
- return;
+ if (copy_msg( cv ))
+ return 1;
} else
debug( "%s: not remote
trashing message %d - too big\n", str_ms[t], tmsg->uid );
@@ -1519,8 +1507,8 @@ msgs_flags_set( sync_vars_t *svars, int
}
svars->state[t] |= ST_SENT_TRASH;
- sync_close( svars, t );
+ return sync_close( svars, t );
}
-static void
+static int
msg_trashed( int sts, void *aux )
{
@@ -1530,11 +1518,11 @@ msg_trashed( int sts, void *aux )
sts = DRV_BOX_BAD;
if (check_ret( sts, svars, t ))
- return;
+ return 1;
svars->trash_done[t]++;
stats( svars );
- sync_close( svars, t );
+ return sync_close( svars, t );
}
-static void
+static int
msg_rtrashed( int sts, int uid, copy_vars_t *vars )
{
@@ -1550,16 +1538,16 @@ msg_rtrashed( int sts, int uid, copy_var
case SYNC_CANCELED:
free( vars );
- return;
+ return 1;
}
free( vars );
svars->trash_done[t]++;
stats( svars );
- sync_close( svars, t );
+ return sync_close( svars, t );
}
-static void box_closed( int sts, void *aux );
+static int box_closed( int sts, void *aux );
static void box_closed_p2( sync_vars_t *svars, int t );
-static void
+static int
sync_close( sync_vars_t *svars, int t )
{
@@ -1567,14 +1555,15 @@ sync_close( sync_vars_t *svars, int t )
svars->find_new_done[t] < svars->find_new_total[t] ||
svars->trash_done[t] < svars->trash_total[t])
- return;
+ return 0;
if ((svars->chan->ops[t] & OP_EXPUNGE) /*&& !(svars->state[t] &
ST_TRASH_BAD)*/) {
debug( "expunging %s\n", str_ms[t] );
- svars->drv[t]->close( svars->ctx[t], box_closed, AUX );
- } else
+ return svars->drv[t]->close( svars->ctx[t], box_closed, AUX );
+ }
box_closed_p2( svars, t );
+ return 0;
}
-static void
+static int
box_closed( int sts, void *aux )
{
@@ -1582,7 +1571,8 @@ box_closed( int sts, void *aux )
if (check_ret( sts, svars, t ))
- return;
+ return 1;
svars->state[t] |= ST_DID_EXPUNGE;
box_closed_p2( svars, t );
+ return 0;
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel