commit bbe79dedc88498035179c4fa2c45e9b3ddea1532 Author: Oswald Buddenhagen <o...@kde.org> Date: Sat Sep 15 11:46:42 2012 +0200
store config error status in conffile_t object this makes passing it around more straight-forward src/config.c | 37 +++++++++++++++++++------------------ src/drv_imap.c | 16 ++++++++-------- src/drv_maildir.c | 4 ++-- src/isync.h | 5 +++-- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/config.c b/src/config.c index 1404c32..0a5eadd 100644 --- a/src/config.c +++ b/src/config.c @@ -296,7 +296,7 @@ load_config( const char *where, int pseudo ) group_conf_t *group, **groupapp = &groups; string_list_t *chanlist, **chanlistapp; char *arg, *p; - int err, len, cops, gcops, max_size, ms, i; + int len, cops, gcops, max_size, ms, i; char path[_POSIX_PATH_MAX]; char buf[1024]; @@ -317,14 +317,15 @@ load_config( const char *where, int pseudo ) cfile.buf = buf; cfile.bufl = sizeof(buf) - 1; cfile.line = 0; + cfile.err = 0; - gcops = err = 0; + gcops = 0; reloop: while (getcline( &cfile )) { if (!cfile.cmd) continue; for (i = 0; i < N_DRIVERS; i++) - if (drivers[i]->parse_store( &cfile, &store, &err )) { + if (drivers[i]->parse_store( &cfile, &store )) { if (store) { if (!store->path) store->path = ""; @@ -362,7 +363,7 @@ load_config( const char *where, int pseudo ) if (*cfile.val != ':' || !(p = strchr( cfile.val + 1, ':' ))) { error( "%s:%d: malformed mailbox spec\n", cfile.file, cfile.line ); - err = 1; + cfile.err = 1; continue; } *p = 0; @@ -373,24 +374,24 @@ load_config( const char *where, int pseudo ) } error( "%s:%d: unknown store '%s'\n", cfile.file, cfile.line, cfile.val + 1 ); - err = 1; + cfile.err = 1; continue; stpcom: if (*++p) channel->boxes[ms] = nfstrdup( p ); } else if (!getopt_helper( &cfile, &cops, channel->ops, &channel->sync_state )) { error( "%s:%d: unknown keyword '%s'\n", cfile.file, cfile.line, cfile.cmd ); - err = 1; + cfile.err = 1; } } if (!channel->stores[M]) { error( "channel '%s' refers to no master store\n", channel->name ); - err = 1; + cfile.err = 1; } else if (!channel->stores[S]) { error( "channel '%s' refers to no slave store\n", channel->name ); - err = 1; + cfile.err = 1; } else if (merge_ops( cops, channel->ops )) - err = 1; + cfile.err = 1; else { if (max_size >= 0) channel->stores[M]->max_size = channel->stores[S]->max_size = max_size; @@ -429,7 +430,7 @@ load_config( const char *where, int pseudo ) { error( "%s:%d: unknown keyword '%s'\n", cfile.file, cfile.line, cfile.cmd ); - err = 1; + cfile.err = 1; } } break; @@ -438,7 +439,7 @@ load_config( const char *where, int pseudo ) { error( "%s:%d: unknown section keyword '%s'\n", cfile.file, cfile.line, cfile.cmd ); - err = 1; + cfile.err = 1; while (getcline( &cfile )) if (!cfile.cmd) goto reloop; @@ -446,16 +447,16 @@ load_config( const char *where, int pseudo ) } } fclose (cfile.fp); - err |= merge_ops( gcops, global_ops ); + cfile.err |= merge_ops( gcops, global_ops ); if (!global_sync_state) global_sync_state = expand_strdup( "~/." EXE "/" ); - if (!err && pseudo) + if (!cfile.err && pseudo) unlink( where ); - return err; + return cfile.err; } void -parse_generic_store( store_conf_t *store, conffile_t *cfg, int *err ) +parse_generic_store( store_conf_t *store, conffile_t *cfg ) { if (!strcasecmp( "Trash", cfg->cmd )) store->trash = nfstrdup( cfg->val ); @@ -471,15 +472,15 @@ parse_generic_store( store_conf_t *store, conffile_t *cfg, int *err ) int sl = strlen( cfg->val ); if (sl != 1) { error( "%s:%d: malformed flattened hierarchy delimiter\n", cfg->file, cfg->line ); - *err = 1; + cfg->err = 1; } else if (cfg->val[0] == '/') { error( "%s:%d: flattened hierarchy delimiter cannot be the canonical delimiter '/'\n", cfg->file, cfg->line ); - *err = 1; + cfg->err = 1; } else { store->flat_delim = cfg->val[0]; } } else { error( "%s:%d: unknown keyword '%s'\n", cfg->file, cfg->line, cfg->cmd ); - *err = 1; + cfg->err = 1; } } diff --git a/src/drv_imap.c b/src/drv_imap.c index 51d7d10..bb069f8 100644 --- a/src/drv_imap.c +++ b/src/drv_imap.c @@ -1876,7 +1876,7 @@ imap_commit( store_t *gctx ) imap_server_conf_t *servers, **serverapp = &servers; static int -imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) +imap_parse_store( conffile_t *cfg, store_conf_t **storep ) { imap_store_conf_t *store; imap_server_conf_t *server, *srv, sserver; @@ -1937,7 +1937,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) else if (!strcasecmp( "PipelineDepth", cfg->cmd )) { if ((server->max_in_progress = parse_int( cfg )) < 1) { error( "%s:%d: PipelineDepth must be at least 1\n", cfg->file, cfg->line ); - *err = 1; + cfg->err = 1; } } #ifdef HAVE_LIBSSL @@ -1946,7 +1946,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) if (access( server->sconf.cert_file, R_OK )) { sys_error( "%s:%d: CertificateFile '%s'", cfg->file, cfg->line, server->sconf.cert_file ); - *err = 1; + cfg->err = 1; } } else if (!strcasecmp( "RequireSSL", cfg->cmd )) server->require_ssl = parse_bool( cfg ); @@ -1969,7 +1969,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) if (srv->name && !strcmp( srv->name, cfg->val )) goto gotsrv; error( "%s:%d: unknown IMAP account '%s'\n", cfg->file, cfg->line, cfg->val ); - *err = 1; + cfg->err = 1; continue; gotsrv: store->server = srv; @@ -1980,11 +1980,11 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) else if (!strcasecmp( "PathDelimiter", cfg->cmd )) store->delimiter = *cfg->val; else - parse_generic_store( &store->gen, cfg, err ); + parse_generic_store( &store->gen, cfg ); continue; } else { error( "%s:%d: unknown/misplaced keyword '%s'\n", cfg->file, cfg->line, cfg->cmd ); - *err = 1; + cfg->err = 1; continue; } acc_opt = 1; @@ -1995,7 +1995,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) error( "IMAP store '%s' has incomplete/missing connection details\n", store->gen.name ); else error( "IMAP account '%s' has incomplete/missing connection details\n", server->name ); - *err = 1; + cfg->err = 1; return 1; } } @@ -2006,7 +2006,7 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) store->server->name = store->gen.name; } else if (acc_opt) { error( "IMAP store '%s' has both Account and account-specific options\n", store->gen.name ); - *err = 1; + cfg->err = 1; } } return 1; diff --git a/src/drv_maildir.c b/src/drv_maildir.c index 771cf48..164f7b5 100644 --- a/src/drv_maildir.c +++ b/src/drv_maildir.c @@ -1417,7 +1417,7 @@ maildir_commit( store_t *gctx ) } static int -maildir_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) +maildir_parse_store( conffile_t *cfg, store_conf_t **storep ) { maildir_store_conf_t *store; @@ -1437,7 +1437,7 @@ maildir_parse_store( conffile_t *cfg, store_conf_t **storep, int *err ) store->alt_map = parse_bool( cfg ); #endif /* USE_DB */ else - parse_generic_store( &store->gen, cfg, err ); + parse_generic_store( &store->gen, cfg ); if (!store->inbox) store->inbox = expand_strdup( "~/Maildir" ); *storep = &store->gen; diff --git a/src/isync.h b/src/isync.h index 4cb2f3e..3ea5fd0 100644 --- a/src/isync.h +++ b/src/isync.h @@ -113,6 +113,7 @@ typedef struct { char *buf; int bufl; int line; + int err; char *cmd, *val, *rest; } conffile_t; @@ -267,7 +268,7 @@ struct driver { int flags; /* Parse configuration. */ - int (*parse_store)( conffile_t *cfg, store_conf_t **storep, int *err ); + int (*parse_store)( conffile_t *cfg, store_conf_t **storep ); /* Close remaining server connections. All stores must be disowned first. */ void (*cleanup)( void ); @@ -486,7 +487,7 @@ int parse_size( conffile_t *cfile ); int getcline( conffile_t *cfile ); int merge_ops( int cops, int ops[] ); int load_config( const char *filename, int pseudo ); -void parse_generic_store( store_conf_t *store, conffile_t *cfg, int *err ); +void parse_generic_store( store_conf_t *store, conffile_t *cfg ); /* drv_*.c */ extern driver_t maildir_driver, imap_driver; ------------------------------------------------------------------------------ How fast is your code? 3 out of 4 devs don\\\'t know how their code performs in production. Find out how slow your code is with AppDynamics Lite. http://ad.doubleclick.net/clk;262219672;13503038;z? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel