static int notmuch_config_command_set (notmuch_config_t *config, char *item, int argc, char *argv[]) { char *group, *key; if (_item_split (item, &group, &key)) return 1; /* With only the name of an item, we clear it from the * configuration file. * * With a single value, we set it as a string. * * With multiple values, we set them as a string list. */ switch (argc) { case 0: g_key_file_remove_key (config->key_file, group, key, NULL); break; case 1: g_key_file_set_string (config->key_file, group, key, argv[0]); break; default: g_key_file_set_string_list (config->key_file, group, key, (const gchar **) argv, argc); break; } return notmuch_config_save (config); }
static int notmuch_config_command_get (void *ctx, char *item) { notmuch_config_t *config; config = notmuch_config_open (ctx, NULL, NULL); if (config == NULL) return 1; if (strcmp(item, "database.path") == 0) { printf ("%s\n", notmuch_config_get_database_path (config)); } else if (strcmp(item, "user.name") == 0) { printf ("%s\n", notmuch_config_get_user_name (config)); } else if (strcmp(item, "user.primary_email") == 0) { printf ("%s\n", notmuch_config_get_user_primary_email (config)); } else if (strcmp(item, "user.other_email") == 0) { const char **other_email; size_t i, length; other_email = notmuch_config_get_user_other_email (config, &length); for (i = 0; i < length; i++) printf ("%s\n", other_email[i]); } else if (strcmp(item, "new.tags") == 0) { const char **tags; size_t i, length; tags = notmuch_config_get_new_tags (config, &length); for (i = 0; i < length; i++) printf ("%s\n", tags[i]); } else { char **value; size_t i, length; char *group, *key; if (_item_split (item, &group, &key)) return 1; value = g_key_file_get_string_list (config->key_file, group, key, &length, NULL); if (value == NULL) { fprintf (stderr, "Unknown configuration item: %s.%s\n", group, key); return 1; } for (i = 0; i < length; i++) printf ("%s\n", value[i]); g_strfreev (value); } notmuch_config_close (config); return 0; }