+static void
+_config_set_list (notmuch_config_t *config,
+ const char *group, const char *key,
+ const char *list[],
+ size_t length, const char ***config_var )
+{
+ g_key_file_set_string_list (config->key_file, group, key, list, length);
+
+ /* drop the cached value */
+ talloc_free (*config_var);
+ *config_var = NULL;
+}
+
+const char *
+notmuch_config_get_database_path (notmuch_config_t *config)
+{
+ char *db_path = (char *)_config_get (config, &config->database_path, "database", "path");
+
+ if (db_path && *db_path != '/') {
+ /* If the path in the configuration file begins with any
+ * character other than /, presume that it is relative to
+ * $HOME and update as appropriate.
+ */
+ char *abs_path = talloc_asprintf (config, "%s/%s", getenv ("HOME"), db_path);
+ talloc_free (db_path);
+ db_path = config->database_path = abs_path;
+ }
+
+ return db_path;
+}
+
+void
+notmuch_config_set_database_path (notmuch_config_t *config,
+ const char *database_path)
+{
+ _config_set (config, &config->database_path, "database", "path", database_path);
+}
+
+const char *
+notmuch_config_get_user_name (notmuch_config_t *config)
+{
+ return _config_get (config, &config->user_name, "user", "name");
+}
+
+void
+notmuch_config_set_user_name (notmuch_config_t *config,
+ const char *user_name)
+{
+ _config_set (config, &config->user_name, "user", "name", user_name);
+}
+
+const char *
+notmuch_config_get_user_primary_email (notmuch_config_t *config)
+{
+ return _config_get (config, &config->user_primary_email, "user", "primary_email");
+}
+
+void
+notmuch_config_set_user_primary_email (notmuch_config_t *config,
+ const char *primary_email)
+{
+ _config_set (config, &config->user_primary_email, "user", "primary_email", primary_email);
+}
+