diff options
| author | David Bremner <david@tethera.net> | 2020-08-08 11:16:49 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-02-06 19:08:12 -0400 |
| commit | fd6f8e6c30e0443d1ead248047ab572120df85e9 (patch) | |
| tree | 26e07a0890b9184fcff6a90f71dfbb91d9a87e8d /notmuch.c | |
| parent | 3fb123f215668a54cd6084b2a520f767d2be6712 (diff) | |
lib/config: add config values iterator
This is intended to avoid duplicating the string splitting and
traversal code for all clients of the config API.
Diffstat (limited to 'notmuch.c')
| -rw-r--r-- | notmuch.c | 35 |
1 files changed, 29 insertions, 6 deletions
@@ -457,6 +457,7 @@ main (int argc, char *argv[]) command_t *command; const char *config_file_name = NULL; notmuch_config_t *config = NULL; + notmuch_database_t *notmuch = NULL; int opt_index; int ret; @@ -500,13 +501,35 @@ main (int argc, char *argv[]) goto DONE; } - config = notmuch_config_open (local, config_file_name, command->mode); - if (! config) { - ret = EXIT_FAILURE; - goto DONE; - } + if (command->mode & NOTMUCH_COMMAND_DATABASE_EARLY) { + char *status_string = NULL; + notmuch_database_mode_t mode; + if (command->mode & NOTMUCH_COMMAND_DATABASE_WRITE) + mode = NOTMUCH_DATABASE_MODE_READ_WRITE; + else + mode = NOTMUCH_DATABASE_MODE_READ_ONLY; + + if (notmuch_database_open_with_config (NULL, + mode, + config_file_name, + NULL, + ¬much, + &status_string)) { + if (status_string) { + fputs (status_string, stderr); + free (status_string); + } - ret = (command->function)(config, NULL, argc - opt_index, argv + opt_index); + return EXIT_FAILURE; + } + } else { + config = notmuch_config_open (local, config_file_name, command->mode); + if (! config) { + ret = EXIT_FAILURE; + goto DONE; + } + } + ret = (command->function)(config, notmuch, argc - opt_index, argv + opt_index); DONE: if (config) |
