provide a proper getter callback for driver capabilities

that way driver_t contains only callbacks.
This commit is contained in:
Oswald Buddenhagen 2017-03-19 13:50:41 +01:00
parent d54809e268
commit f46cf8c887
6 changed files with 19 additions and 6 deletions

View File

@ -147,7 +147,8 @@ typedef struct {
#define LIST_PATH_MAYBE 4
struct driver {
int flags;
/* Return driver capabilities. */
int (*get_caps)( store_t *ctx );
/* Parse configuration. */
int (*parse_store)( conffile_t *cfg, store_conf_t **storep );

View File

@ -3183,8 +3183,14 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
return 1;
}
static int
imap_get_caps( store_t *gctx ATTR_UNUSED )
{
return DRV_CRLF | DRV_VERBOSE;
}
struct driver imap_driver = {
DRV_CRLF | DRV_VERBOSE,
imap_get_caps,
imap_parse_store,
imap_cleanup,
imap_alloc_store,

View File

@ -1865,8 +1865,14 @@ maildir_parse_store( conffile_t *cfg, store_conf_t **storep )
return 1;
}
static int
maildir_get_caps( store_t *gctx ATTR_UNUSED )
{
return 0; /* XXX DRV_CRLF? */
}
struct driver maildir_driver = {
0, /* XXX DRV_CRLF? */
maildir_get_caps,
maildir_parse_store,
maildir_cleanup_drv,
maildir_alloc_store,

0
src/drv_proxy.c Normal file
View File

View File

@ -810,7 +810,7 @@ sync_chans( main_vars_t *mvars, int ent )
if (mvars->skip)
goto next2;
mvars->state[M] = mvars->state[S] = ST_FRESH;
if (mvars->chan->stores[M]->driver->flags & mvars->chan->stores[S]->driver->flags & DRV_VERBOSE)
if (mvars->chan->stores[M]->driver->get_caps( 0 ) & mvars->chan->stores[S]->driver->get_caps( 0 ) & DRV_VERBOSE)
labels[M] = "M: ", labels[S] = "S: ";
else
labels[M] = labels[S] = "";

View File

@ -407,8 +407,8 @@ msg_fetched( int sts, void *aux )
vars->msg->flags = vars->data.flags;
scr = (svars->drv[1-t]->flags / DRV_CRLF) & 1;
tcr = (svars->drv[t]->flags / DRV_CRLF) & 1;
scr = (svars->drv[1-t]->get_caps( svars->ctx[1-t] ) / DRV_CRLF) & 1;
tcr = (svars->drv[t]->get_caps( svars->ctx[t] ) / DRV_CRLF) & 1;
if (vars->srec || scr != tcr) {
if (!copy_msg_convert( scr, tcr, vars )) {
warn( "Warning: message %d from %s has incomplete header.\n",