1 /* notmuch - Not much of an email program, (just index and search)
3 * Copyright © 2009 Carl Worth
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see https://www.gnu.org/licenses/ .
18 * Author: Carl Worth <cworth@cworth.org>
21 #include "notmuch-client.h"
27 static const char toplevel_config_comment[] =
28 " .notmuch-config - Configuration file for the notmuch mail system\n"
30 " For more information about notmuch, see https://notmuchmail.org";
32 static const char database_config_comment[] =
33 " Database configuration\n"
35 " The only value supported here is 'path' which should be the top-level\n"
36 " directory where your mail currently exists and to where mail will be\n"
37 " delivered in the future. Files should be individual email messages.\n"
38 " Notmuch will store its database within a sub-directory of the path\n"
39 " configured here named \".notmuch\".\n";
41 static const char new_config_comment[] =
42 " Configuration for \"notmuch new\"\n"
44 " The following options are supported here:\n"
46 "\ttags A list (separated by ';') of the tags that will be\n"
47 "\t added to all messages incorporated by \"notmuch new\".\n"
49 "\tignore A list (separated by ';') of file and directory names\n"
50 "\t that will not be searched for messages by \"notmuch new\".\n"
52 "\t NOTE: *Every* file/directory that goes by one of those\n"
53 "\t names will be ignored, independent of its depth/location\n"
54 "\t in the mail store.\n";
56 static const char user_config_comment[] =
57 " User configuration\n"
59 " Here is where you can let notmuch know how you would like to be\n"
60 " addressed. Valid settings are\n"
62 "\tname Your full name.\n"
63 "\tprimary_email Your primary email address.\n"
64 "\tother_email A list (separated by ';') of other email addresses\n"
65 "\t at which you receive email.\n"
67 " Notmuch will use the various email addresses configured here when\n"
68 " formatting replies. It will avoid including your own addresses in the\n"
69 " recipient list of replies, and will set the From address based on the\n"
70 " address to which the original email was addressed.\n";
72 static const char maildir_config_comment[] =
73 " Maildir compatibility configuration\n"
75 " The following option is supported here:\n"
77 "\tsynchronize_flags Valid values are true and false.\n"
79 "\tIf true, then the following maildir flags (in message filenames)\n"
80 "\twill be synchronized with the corresponding notmuch tags:\n"
88 "\t\tS unread (added when 'S' flag is not present)\n"
90 "\tThe \"notmuch new\" command will notice flag changes in filenames\n"
91 "\tand update tags, while the \"notmuch tag\" and \"notmuch restore\"\n"
92 "\tcommands will notice tag changes and update flags in filenames\n";
94 static const char search_config_comment[] =
95 " Search configuration\n"
97 " The following option is supported here:\n"
100 "\t\tA ;-separated list of tags that will be excluded from\n"
101 "\t\tsearch results by default. Using an excluded tag in a\n"
102 "\t\tquery will override that exclusion.\n";
104 static const char crypto_config_comment[] =
105 " Cryptography related configuration\n"
107 " The following option is supported here:\n"
110 "\t\tbinary name or full path to invoke gpg.\n";
112 struct _notmuch_config {
115 notmuch_bool_t is_new;
118 char *crypto_gpg_path;
120 char *user_primary_email;
121 const char **user_other_email;
122 size_t user_other_email_length;
123 const char **new_tags;
124 size_t new_tags_length;
125 const char **new_ignore;
126 size_t new_ignore_length;
127 notmuch_bool_t maildir_synchronize_flags;
128 const char **search_exclude_tags;
129 size_t search_exclude_tags_length;
133 notmuch_config_destructor (notmuch_config_t *config)
135 if (config->key_file)
136 g_key_file_free (config->key_file);
142 get_name_from_passwd_file (void *ctx)
146 struct passwd passwd, *ignored;
150 pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
151 if (pw_buf_size == -1) pw_buf_size = 64;
152 pw_buf = talloc_size (ctx, pw_buf_size);
154 while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
155 pw_buf_size, &ignored)) == ERANGE) {
156 pw_buf_size = pw_buf_size * 2;
157 pw_buf = talloc_zero_size(ctx, pw_buf_size);
161 char *comma = strchr (passwd.pw_gecos, ',');
163 name = talloc_strndup (ctx, passwd.pw_gecos,
164 comma - passwd.pw_gecos);
166 name = talloc_strdup (ctx, passwd.pw_gecos);
168 name = talloc_strdup (ctx, "");
171 talloc_free (pw_buf);
177 get_username_from_passwd_file (void *ctx)
181 struct passwd passwd, *ignored;
185 pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
186 if (pw_buf_size == -1) pw_buf_size = 64;
187 pw_buf = talloc_zero_size (ctx, pw_buf_size);
189 while ((e = getpwuid_r (getuid (), &passwd, pw_buf,
190 pw_buf_size, &ignored)) == ERANGE) {
191 pw_buf_size = pw_buf_size * 2;
192 pw_buf = talloc_zero_size(ctx, pw_buf_size);
196 name = talloc_strdup (ctx, passwd.pw_name);
198 name = talloc_strdup (ctx, "");
200 talloc_free (pw_buf);
205 static notmuch_bool_t
206 get_config_from_file (notmuch_config_t *config, notmuch_bool_t create_new)
208 GError *error = NULL;
209 notmuch_bool_t ret = FALSE;
211 if (g_key_file_load_from_file (config->key_file, config->filename,
212 G_KEY_FILE_KEEP_COMMENTS, &error))
215 if (error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT) {
216 /* If create_new is true, then the caller is prepared for a
217 * default configuration file in the case of FILE NOT FOUND.
220 config->is_new = TRUE;
223 fprintf (stderr, "Configuration file %s not found.\n"
224 "Try running 'notmuch setup' to create a configuration.\n",
228 fprintf (stderr, "Error reading configuration file %s: %s\n",
229 config->filename, error->message);
232 g_error_free (error);
237 /* Open the named notmuch configuration file. If the filename is NULL,
238 * the value of the environment variable $NOTMUCH_CONFIG will be used.
239 * If $NOTMUCH_CONFIG is unset, the default configuration file
240 * ($HOME/.notmuch-config) will be used.
242 * If any error occurs, (out of memory, or a permission-denied error,
243 * etc.), this function will print a message to stderr and return
246 * FILE NOT FOUND: When the specified configuration file (whether from
247 * 'filename' or the $NOTMUCH_CONFIG environment variable) does not
248 * exist, the behavior of this function depends on the 'is_new_ret'
251 * If is_new_ret is NULL, then a "file not found" message will be
252 * printed to stderr and NULL will be returned.
254 * If is_new_ret is non-NULL then a default configuration will be
255 * returned and *is_new_ret will be set to 1 on return so that
256 * the caller can recognize this case.
258 * These default configuration settings are determined as
261 * database_path: $MAILDIR, otherwise $HOME/mail
263 * user_name: $NAME variable if set, otherwise
264 * read from /etc/passwd
266 * user_primary_mail: $EMAIL variable if set, otherwise
267 * constructed from the username and
268 * hostname of the current machine.
270 * user_other_email: Not set.
272 * The default configuration also contains comments to guide the
273 * user in editing the file directly.
276 notmuch_config_open (void *ctx,
277 const char *filename,
278 notmuch_bool_t create_new)
280 GError *error = NULL;
282 char *notmuch_config_env = NULL;
283 int file_had_database_group;
284 int file_had_new_group;
285 int file_had_user_group;
286 int file_had_maildir_group;
287 int file_had_search_group;
288 int file_had_crypto_group;
290 notmuch_config_t *config = talloc (ctx, notmuch_config_t);
291 if (config == NULL) {
292 fprintf (stderr, "Out of memory.\n");
296 talloc_set_destructor (config, notmuch_config_destructor);
299 config->filename = talloc_strdup (config, filename);
300 } else if ((notmuch_config_env = getenv ("NOTMUCH_CONFIG"))) {
301 config->filename = talloc_strdup (config, notmuch_config_env);
303 config->filename = talloc_asprintf (config, "%s/.notmuch-config",
307 config->key_file = g_key_file_new ();
309 config->is_new = FALSE;
310 config->database_path = NULL;
311 config->user_name = NULL;
312 config->user_primary_email = NULL;
313 config->user_other_email = NULL;
314 config->user_other_email_length = 0;
315 config->new_tags = NULL;
316 config->new_tags_length = 0;
317 config->new_ignore = NULL;
318 config->new_ignore_length = 0;
319 config->maildir_synchronize_flags = TRUE;
320 config->search_exclude_tags = NULL;
321 config->search_exclude_tags_length = 0;
322 config->crypto_gpg_path = NULL;
324 if (! get_config_from_file (config, create_new)) {
325 talloc_free (config);
329 /* Whenever we know of configuration sections that don't appear in
330 * the configuration file, we add some comments to help the user
331 * understand what can be done.
333 * It would be convenient to just add those comments now, but
334 * apparently g_key_file will clear any comments when keys are
335 * added later that create the groups. So we have to check for the
336 * groups now, but add the comments only after setting all of our
339 file_had_database_group = g_key_file_has_group (config->key_file,
341 file_had_new_group = g_key_file_has_group (config->key_file, "new");
342 file_had_user_group = g_key_file_has_group (config->key_file, "user");
343 file_had_maildir_group = g_key_file_has_group (config->key_file, "maildir");
344 file_had_search_group = g_key_file_has_group (config->key_file, "search");
345 file_had_crypto_group = g_key_file_has_group (config->key_file, "crypto");
347 if (notmuch_config_get_database_path (config) == NULL) {
348 char *path = getenv ("MAILDIR");
350 path = talloc_strdup (config, path);
352 path = talloc_asprintf (config, "%s/mail",
354 notmuch_config_set_database_path (config, path);
358 if (notmuch_config_get_user_name (config) == NULL) {
359 char *name = getenv ("NAME");
361 name = talloc_strdup (config, name);
363 name = get_name_from_passwd_file (config);
364 notmuch_config_set_user_name (config, name);
368 if (notmuch_config_get_user_primary_email (config) == NULL) {
369 char *email = getenv ("EMAIL");
371 notmuch_config_set_user_primary_email (config, email);
374 struct hostent *hostent;
375 const char *domainname;
377 char *username = get_username_from_passwd_file (config);
379 gethostname (hostname, 256);
380 hostname[255] = '\0';
382 hostent = gethostbyname (hostname);
383 if (hostent && (domainname = strchr (hostent->h_name, '.')))
386 domainname = "(none)";
388 email = talloc_asprintf (config, "%s@%s.%s",
389 username, hostname, domainname);
391 notmuch_config_set_user_primary_email (config, email);
393 talloc_free (username);
398 if (notmuch_config_get_new_tags (config, &tmp) == NULL) {
399 const char *tags[] = { "unread", "inbox" };
400 notmuch_config_set_new_tags (config, tags, 2);
403 if (notmuch_config_get_new_ignore (config, &tmp) == NULL) {
404 notmuch_config_set_new_ignore (config, NULL, 0);
407 if (notmuch_config_get_search_exclude_tags (config, &tmp) == NULL) {
408 if (config->is_new) {
409 const char *tags[] = { "deleted", "spam" };
410 notmuch_config_set_search_exclude_tags (config, tags, 2);
412 notmuch_config_set_search_exclude_tags (config, NULL, 0);
417 config->maildir_synchronize_flags =
418 g_key_file_get_boolean (config->key_file,
419 "maildir", "synchronize_flags", &error);
421 notmuch_config_set_maildir_synchronize_flags (config, TRUE);
422 g_error_free (error);
425 if (notmuch_config_get_crypto_gpg_path (config) == NULL) {
426 notmuch_config_set_crypto_gpg_path (config, "gpg");
429 /* Whenever we know of configuration sections that don't appear in
430 * the configuration file, we add some comments to help the user
431 * understand what can be done. */
433 g_key_file_set_comment (config->key_file, NULL, NULL,
434 toplevel_config_comment, NULL);
436 if (! file_had_database_group)
437 g_key_file_set_comment (config->key_file, "database", NULL,
438 database_config_comment, NULL);
440 if (! file_had_new_group)
441 g_key_file_set_comment (config->key_file, "new", NULL,
442 new_config_comment, NULL);
444 if (! file_had_user_group)
445 g_key_file_set_comment (config->key_file, "user", NULL,
446 user_config_comment, NULL);
448 if (! file_had_maildir_group)
449 g_key_file_set_comment (config->key_file, "maildir", NULL,
450 maildir_config_comment, NULL);
452 if (! file_had_search_group)
453 g_key_file_set_comment (config->key_file, "search", NULL,
454 search_config_comment, NULL);
456 if (! file_had_crypto_group)
457 g_key_file_set_comment (config->key_file, "crypto", NULL,
458 crypto_config_comment, NULL);
463 /* Close the given notmuch_config_t object, freeing all resources.
465 * Note: Any changes made to the configuration are *not* saved by this
466 * function. To save changes, call notmuch_config_save before
467 * notmuch_config_close.
470 notmuch_config_close (notmuch_config_t *config)
472 talloc_free (config);
475 /* Save any changes made to the notmuch configuration.
477 * Any comments originally in the file will be preserved.
479 * Returns 0 if successful, and 1 in case of any error, (after
480 * printing a description of the error to stderr).
483 notmuch_config_save (notmuch_config_t *config)
486 char *data, *filename;
487 GError *error = NULL;
489 data = g_key_file_to_data (config->key_file, &length, NULL);
491 fprintf (stderr, "Out of memory.\n");
495 /* Try not to overwrite symlinks. */
496 filename = canonicalize_file_name (config->filename);
498 if (errno == ENOENT) {
499 filename = strdup (config->filename);
501 fprintf (stderr, "Out of memory.\n");
506 fprintf (stderr, "Error canonicalizing %s: %s\n", config->filename,
513 if (! g_file_set_contents (filename, data, length, &error)) {
514 if (strcmp (filename, config->filename) != 0) {
515 fprintf (stderr, "Error saving configuration to %s (-> %s): %s\n",
516 config->filename, filename, error->message);
518 fprintf (stderr, "Error saving configuration to %s: %s\n",
519 filename, error->message);
521 g_error_free (error);
533 notmuch_config_is_new (notmuch_config_t *config)
535 return config->is_new;
539 _config_get (notmuch_config_t *config, char **field,
540 const char *group, const char *key)
542 /* read from config file and cache value, if not cached already */
543 if (*field == NULL) {
545 value = g_key_file_get_string (config->key_file, group, key, NULL);
547 *field = talloc_strdup (config, value);
555 _config_set (notmuch_config_t *config, char **field,
556 const char *group, const char *key, const char *value)
558 g_key_file_set_string (config->key_file, group, key, value);
560 /* drop the cached value */
561 talloc_free (*field);
566 _config_get_list (notmuch_config_t *config,
567 const char *section, const char *key,
568 const char ***outlist, size_t *list_length, size_t *ret_length)
572 /* read from config file and cache value, if not cached already */
573 if (*outlist == NULL) {
575 char **inlist = g_key_file_get_string_list (config->key_file,
576 section, key, list_length, NULL);
580 *outlist = talloc_size (config, sizeof (char *) * (*list_length + 1));
582 for (i = 0; i < *list_length; i++)
583 (*outlist)[i] = talloc_strdup (*outlist, inlist[i]);
585 (*outlist)[i] = NULL;
592 *ret_length = *list_length;
598 _config_set_list (notmuch_config_t *config,
599 const char *group, const char *name,
601 size_t length, const char ***config_var )
603 g_key_file_set_string_list (config->key_file, group, name, list, length);
605 /* drop the cached value */
606 talloc_free (*config_var);
611 notmuch_config_get_database_path (notmuch_config_t *config)
613 return _config_get (config, &config->database_path, "database", "path");
617 notmuch_config_set_database_path (notmuch_config_t *config,
618 const char *database_path)
620 _config_set (config, &config->database_path, "database", "path", database_path);
624 notmuch_config_get_user_name (notmuch_config_t *config)
626 return _config_get (config, &config->user_name, "user", "name");
630 notmuch_config_set_user_name (notmuch_config_t *config,
631 const char *user_name)
633 _config_set (config, &config->user_name, "user", "name", user_name);
637 notmuch_config_get_user_primary_email (notmuch_config_t *config)
639 return _config_get (config, &config->user_primary_email, "user", "primary_email");
643 notmuch_config_set_user_primary_email (notmuch_config_t *config,
644 const char *primary_email)
646 _config_set (config, &config->user_primary_email, "user", "primary_email", primary_email);
650 notmuch_config_get_user_other_email (notmuch_config_t *config, size_t *length)
652 return _config_get_list (config, "user", "other_email",
653 &(config->user_other_email),
654 &(config->user_other_email_length), length);
658 notmuch_config_get_new_tags (notmuch_config_t *config, size_t *length)
660 return _config_get_list (config, "new", "tags",
662 &(config->new_tags_length), length);
666 notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)
668 return _config_get_list (config, "new", "ignore",
669 &(config->new_ignore),
670 &(config->new_ignore_length), length);
674 notmuch_config_set_user_other_email (notmuch_config_t *config,
678 _config_set_list (config, "user", "other_email", list, length,
679 &(config->user_other_email));
683 notmuch_config_set_new_tags (notmuch_config_t *config,
687 _config_set_list (config, "new", "tags", list, length,
688 &(config->new_tags));
692 notmuch_config_set_new_ignore (notmuch_config_t *config,
696 _config_set_list (config, "new", "ignore", list, length,
697 &(config->new_ignore));
701 notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t *length)
703 return _config_get_list (config, "search", "exclude_tags",
704 &(config->search_exclude_tags),
705 &(config->search_exclude_tags_length), length);
709 notmuch_config_set_search_exclude_tags (notmuch_config_t *config,
713 _config_set_list (config, "search", "exclude_tags", list, length,
714 &(config->search_exclude_tags));
718 notmuch_config_get_crypto_gpg_path (notmuch_config_t *config)
720 return _config_get (config, &config->crypto_gpg_path, "crypto", "gpg_path");
724 notmuch_config_set_crypto_gpg_path (notmuch_config_t *config,
725 const char *gpg_path)
727 _config_set (config, &config->crypto_gpg_path, "crypto", "gpg_path", gpg_path);
731 /* Given a configuration item of the form <group>.<key> return the
732 * component group and key. If any error occurs, print a message on
733 * stderr and return 1. Otherwise, return 0.
735 * Note: This function modifies the original 'item' string.
738 _item_split (char *item, char **group, char **key)
744 period = strchr (item, '.');
745 if (period == NULL || *(period+1) == '\0') {
747 "Invalid configuration name: %s\n"
748 "(Should be of the form <section>.<item>)\n", item);
758 #define BUILT_WITH_PREFIX "built_with."
759 #define QUERY_PREFIX "query."
762 _print_db_config(notmuch_config_t *config, const char *name)
764 notmuch_database_t *notmuch;
767 if (notmuch_database_open (notmuch_config_get_database_path (config),
768 NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
771 /* XXX Handle UUID mismatch? */
773 if (print_status_database ("notmuch config", notmuch,
774 notmuch_database_get_config (notmuch, name, &val)))
783 notmuch_config_command_get (notmuch_config_t *config, char *item)
785 if (strcmp(item, "database.path") == 0) {
786 printf ("%s\n", notmuch_config_get_database_path (config));
787 } else if (strcmp(item, "user.name") == 0) {
788 printf ("%s\n", notmuch_config_get_user_name (config));
789 } else if (strcmp(item, "user.primary_email") == 0) {
790 printf ("%s\n", notmuch_config_get_user_primary_email (config));
791 } else if (strcmp(item, "user.other_email") == 0) {
792 const char **other_email;
795 other_email = notmuch_config_get_user_other_email (config, &length);
796 for (i = 0; i < length; i++)
797 printf ("%s\n", other_email[i]);
798 } else if (strcmp(item, "new.tags") == 0) {
802 tags = notmuch_config_get_new_tags (config, &length);
803 for (i = 0; i < length; i++)
804 printf ("%s\n", tags[i]);
805 } else if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
807 notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)) ? "true" : "false");
808 } else if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
809 return _print_db_config (config, item);
815 if (_item_split (item, &group, &key))
818 value = g_key_file_get_string_list (config->key_file,
822 fprintf (stderr, "Unknown configuration item: %s.%s\n",
827 for (i = 0; i < length; i++)
828 printf ("%s\n", value[i]);
837 _set_db_config(notmuch_config_t *config, const char *key, int argc, char **argv)
839 notmuch_database_t *notmuch;
840 const char *val = "";
843 /* XXX handle lists? */
844 fprintf (stderr, "notmuch config set: at most one value expected for %s\n", key);
852 if (notmuch_database_open (notmuch_config_get_database_path (config),
853 NOTMUCH_DATABASE_MODE_READ_WRITE, ¬much))
856 /* XXX Handle UUID mismatch? */
858 if (print_status_database ("notmuch config", notmuch,
859 notmuch_database_set_config (notmuch, key, val)))
862 if (print_status_database ("notmuch config", notmuch,
863 notmuch_database_close (notmuch)))
870 notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char *argv[])
874 if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
875 fprintf (stderr, "Error: read only option: %s\n", item);
879 if (STRNCMP_LITERAL (item, QUERY_PREFIX) == 0) {
880 return _set_db_config (config, item, argc, argv);
883 if (_item_split (item, &group, &key))
886 /* With only the name of an item, we clear it from the
887 * configuration file.
889 * With a single value, we set it as a string.
891 * With multiple values, we set them as a string list.
895 g_key_file_remove_key (config->key_file, group, key, NULL);
898 g_key_file_set_string (config->key_file, group, key, argv[0]);
901 g_key_file_set_string_list (config->key_file, group, key,
902 (const gchar **) argv, argc);
906 return notmuch_config_save (config);
911 _notmuch_config_list_built_with ()
913 printf("%scompact=%s\n",
915 notmuch_built_with ("compact") ? "true" : "false");
916 printf("%sfield_processor=%s\n",
918 notmuch_built_with ("field_processor") ? "true" : "false");
919 printf("%sretry_lock=%s\n",
921 notmuch_built_with ("retry_lock") ? "true" : "false");
925 _list_db_config (notmuch_config_t *config)
927 notmuch_database_t *notmuch;
928 notmuch_config_list_t *list;
930 if (notmuch_database_open (notmuch_config_get_database_path (config),
931 NOTMUCH_DATABASE_MODE_READ_ONLY, ¬much))
934 /* XXX Handle UUID mismatch? */
937 if (print_status_database ("notmuch config", notmuch,
938 notmuch_database_get_config_list (notmuch, "", &list)))
941 for (; notmuch_config_list_valid (list); notmuch_config_list_move_to_next (list)) {
942 printf("%s=%s\n", notmuch_config_list_key (list), notmuch_config_list_value(list));
944 notmuch_config_list_destroy (list);
950 notmuch_config_command_list (notmuch_config_t *config)
953 size_t g, groups_length;
955 groups = g_key_file_get_groups (config->key_file, &groups_length);
959 for (g = 0; g < groups_length; g++) {
961 size_t k, keys_length;
963 keys = g_key_file_get_keys (config->key_file,
964 groups[g], &keys_length, NULL);
968 for (k = 0; k < keys_length; k++) {
971 value = g_key_file_get_string (config->key_file,
972 groups[g], keys[k], NULL);
974 printf ("%s.%s=%s\n", groups[g], keys[k], value);
984 _notmuch_config_list_built_with ();
985 return _list_db_config (config);
989 notmuch_config_command (notmuch_config_t *config, int argc, char *argv[])
994 opt_index = notmuch_minimal_options ("config", argc, argv);
998 if (notmuch_requested_db_uuid)
999 fprintf (stderr, "Warning: ignoring --uuid=%s\n",
1000 notmuch_requested_db_uuid);
1002 /* skip at least subcommand argument */
1007 fprintf (stderr, "Error: notmuch config requires at least one argument.\n");
1008 return EXIT_FAILURE;
1011 if (strcmp (argv[0], "get") == 0) {
1013 fprintf (stderr, "Error: notmuch config get requires exactly "
1015 return EXIT_FAILURE;
1017 ret = notmuch_config_command_get (config, argv[1]);
1018 } else if (strcmp (argv[0], "set") == 0) {
1020 fprintf (stderr, "Error: notmuch config set requires at least "
1022 return EXIT_FAILURE;
1024 ret = notmuch_config_command_set (config, argv[1], argc - 2, argv + 2);
1025 } else if (strcmp (argv[0], "list") == 0) {
1026 ret = notmuch_config_command_list (config);
1028 fprintf (stderr, "Unrecognized argument for notmuch config: %s\n",
1030 return EXIT_FAILURE;
1033 return ret ? EXIT_FAILURE : EXIT_SUCCESS;
1038 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config)
1040 return config->maildir_synchronize_flags;
1044 notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,
1045 notmuch_bool_t synchronize_flags)
1047 g_key_file_set_boolean (config->key_file,
1048 "maildir", "synchronize_flags", synchronize_flags);
1049 config->maildir_synchronize_flags = synchronize_flags;