Skip to content
Snippets Groups Projects
Commit 429a0ab1 authored by Stephan Bosch's avatar Stephan Bosch Committed by Timo Sirainen
Browse files

lib-sieve: sieve-storage - Use int for sieve_storage_list_init() status result

parent 1fb536e7
No related branches found
No related tags found
No related merge requests found
...@@ -54,8 +54,8 @@ struct sieve_storage_vfuncs { ...@@ -54,8 +54,8 @@ struct sieve_storage_vfuncs {
time_t *last_change_r); time_t *last_change_r);
/* listing scripts */ /* listing scripts */
struct sieve_storage_list_context *(*list_init)( int (*list_init)(struct sieve_storage *storage,
struct sieve_storage *storage); struct sieve_storage_list_context **lctx_r);
const char *(*list_next)(struct sieve_storage_list_context *lctx, const char *(*list_next)(struct sieve_storage_list_context *lctx,
bool *active_r); bool *active_r);
int (*list_deinit)(struct sieve_storage_list_context *lctx); int (*list_deinit)(struct sieve_storage_list_context *lctx);
......
...@@ -997,18 +997,20 @@ int sieve_storage_active_script_get_last_change(struct sieve_storage *storage, ...@@ -997,18 +997,20 @@ int sieve_storage_active_script_get_last_change(struct sieve_storage *storage,
* Listing scripts * Listing scripts
*/ */
struct sieve_storage_list_context * int sieve_storage_list_init(struct sieve_storage *storage,
sieve_storage_list_init(struct sieve_storage *storage) struct sieve_storage_list_context **lctx_r)
{ {
struct sieve_storage_list_context *lctx; struct sieve_storage_list_context *lctx;
i_assert(storage->v.list_init != NULL); *lctx_r = NULL;
lctx = storage->v.list_init(storage);
if (lctx != NULL) i_assert(storage->v.list_init != NULL);
lctx->storage = storage; if (storage->v.list_init(storage, &lctx) < 0)
return -1;
return lctx; lctx->storage = storage;
*lctx_r = lctx;
return 0;
} }
const char * const char *
......
...@@ -80,8 +80,8 @@ int sieve_storage_active_script_get_last_change(struct sieve_storage *storage, ...@@ -80,8 +80,8 @@ int sieve_storage_active_script_get_last_change(struct sieve_storage *storage,
struct sieve_storage_list_context; struct sieve_storage_list_context;
/* Create a context for listing the scripts in the storage */ /* Create a context for listing the scripts in the storage */
struct sieve_storage_list_context * int sieve_storage_list_init(struct sieve_storage *storage,
sieve_storage_list_init(struct sieve_storage *storage); struct sieve_storage_list_context **lctx_r);
/* Get the next script in the storage. */ /* Get the next script in the storage. */
const char *sieve_storage_list_next(struct sieve_storage_list_context *lctx, const char *sieve_storage_list_next(struct sieve_storage_list_context *lctx,
bool *active_r) ATTR_NULL(2); bool *active_r) ATTR_NULL(2);
......
...@@ -22,8 +22,8 @@ struct sieve_file_list_context { ...@@ -22,8 +22,8 @@ struct sieve_file_list_context {
DIR *dirp; DIR *dirp;
}; };
struct sieve_storage_list_context * int sieve_file_storage_list_init(struct sieve_storage *storage,
sieve_file_storage_list_init(struct sieve_storage *storage) struct sieve_storage_list_context **lctx_r)
{ {
struct sieve_file_storage *fstorage = struct sieve_file_storage *fstorage =
container_of(storage, struct sieve_file_storage, storage); container_of(storage, struct sieve_file_storage, storage);
...@@ -54,7 +54,7 @@ sieve_file_storage_list_init(struct sieve_storage *storage) ...@@ -54,7 +54,7 @@ sieve_file_storage_list_init(struct sieve_storage *storage)
"opendir(%s) failed: %m", fstorage->path); "opendir(%s) failed: %m", fstorage->path);
break; break;
} }
return NULL; return -1;
} }
T_BEGIN { T_BEGIN {
...@@ -78,9 +78,10 @@ sieve_file_storage_list_init(struct sieve_storage *storage) ...@@ -78,9 +78,10 @@ sieve_file_storage_list_init(struct sieve_storage *storage)
e_error(storage->event, e_error(storage->event,
"closedir(%s) failed: %m", fstorage->path); "closedir(%s) failed: %m", fstorage->path);
} }
return NULL; return -1;
} }
return &flctx->context; *lctx_r = &flctx->context;
return 0;
} }
const char * const char *
......
...@@ -78,8 +78,8 @@ int sieve_file_storage_active_script_get_last_change( ...@@ -78,8 +78,8 @@ int sieve_file_storage_active_script_get_last_change(
/* Listing */ /* Listing */
struct sieve_storage_list_context * int sieve_file_storage_list_init(struct sieve_storage *storage,
sieve_file_storage_list_init(struct sieve_storage *storage); struct sieve_storage_list_context **lctx_r);
const char * const char *
sieve_file_storage_list_next(struct sieve_storage_list_context *lctx, sieve_file_storage_list_next(struct sieve_storage_list_context *lctx,
bool *active); bool *active);
......
...@@ -25,8 +25,7 @@ bool cmd_listscripts(struct client_command_context *cmd) ...@@ -25,8 +25,7 @@ bool cmd_listscripts(struct client_command_context *cmd)
if (!client_read_no_args(cmd)) if (!client_read_no_args(cmd))
return FALSE; return FALSE;
lctx = sieve_storage_list_init(client->storage); if (sieve_storage_list_init(client->storage, &lctx) < 0) {
if (lctx == NULL) {
client_command_storage_error( client_command_storage_error(
cmd, "Failed to list scripts"); cmd, "Failed to list scripts");
return TRUE; return TRUE;
......
...@@ -19,8 +19,7 @@ static int cmd_sieve_list_run(struct doveadm_sieve_cmd_context *_ctx) ...@@ -19,8 +19,7 @@ static int cmd_sieve_list_run(struct doveadm_sieve_cmd_context *_ctx)
const char *scriptname; const char *scriptname;
bool active; bool active;
lctx = sieve_storage_list_init(storage); if (sieve_storage_list_init(storage, &lctx) < 0) {
if (lctx == NULL) {
e_error(event, "Listing Sieve scripts failed: %s", e_error(event, "Listing Sieve scripts failed: %s",
sieve_storage_get_last_error(storage, &error_code)); sieve_storage_get_last_error(storage, &error_code));
doveadm_sieve_cmd_failed_error(_ctx, error_code); doveadm_sieve_cmd_failed_error(_ctx, error_code);
......
...@@ -625,8 +625,7 @@ sieve_attribute_iter_script_init(struct sieve_mailbox_attribute_iter *siter) ...@@ -625,8 +625,7 @@ sieve_attribute_iter_script_init(struct sieve_mailbox_attribute_iter *siter)
if (ret <= 0) if (ret <= 0)
return ret; return ret;
siter->sieve_list = sieve_storage_list_init(svstorage); if (sieve_storage_list_init(svstorage, &siter->sieve_list) < 0) {
if (siter->sieve_list == NULL) {
mail_storage_set_critical( mail_storage_set_critical(
siter->iter.box->storage, siter->iter.box->storage,
"Failed to iterate sieve scripts: %s", "Failed to iterate sieve scripts: %s",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.