summaryrefslogtreecommitdiff
path: root/include/git2/sys
diff options
context:
space:
mode:
authorVicent Martí <vicent@github.com>2013-08-28 06:04:51 -0700
committerVicent Martí <vicent@github.com>2013-08-28 06:04:51 -0700
commitb8b22d774eca054fe43005accd6f3ff58fc1fb62 (patch)
tree69d507f28a168f4f7f4cd3172e331403ff14e36e /include/git2/sys
parent21a3bbe419e8edb8a119f5c2a2de85f462078d3d (diff)
parentf4be8209afd3cc996667196a1e437aac21485691 (diff)
downloadlibgit2-b8b22d774eca054fe43005accd6f3ff58fc1fb62.tar.gz
Merge pull request #1772 from libgit2/config-iter
Configuration iterators redux
Diffstat (limited to 'include/git2/sys')
-rw-r--r--include/git2/sys/config.h30
1 files changed, 28 insertions, 2 deletions
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h
index 11e59cf03..7572ace51 100644
--- a/include/git2/sys/config.h
+++ b/include/git2/sys/config.h
@@ -21,6 +21,33 @@
GIT_BEGIN_DECL
/**
+ * Every iterator must have this struct as its first element, so the
+ * API can talk to it. You'd define your iterator as
+ *
+ * struct my_iterator {
+ * git_config_iterator parent;
+ * ...
+ * }
+ *
+ * and assign `iter->parent.backend` to your `git_config_backend`.
+ */
+struct git_config_iterator {
+ git_config_backend *backend;
+ unsigned int flags;
+
+ /**
+ * Return the current entry and advance the iterator. The
+ * memory belongs to the library.
+ */
+ int (*next)(git_config_entry **entry, git_config_iterator *iter);
+
+ /**
+ * Free the iterator
+ */
+ void (*free)(git_config_iterator *iter);
+};
+
+/**
* Generic backend that implements the interface to
* access a configuration file
*/
@@ -31,11 +58,10 @@ struct git_config_backend {
/* Open means open the file/database and parse if necessary */
int (*open)(struct git_config_backend *, git_config_level_t level);
int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
- int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
int (*set)(struct git_config_backend *, const char *key, const char *value);
int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
int (*del)(struct git_config_backend *, const char *key);
- int (*foreach)(struct git_config_backend *, const char *, git_config_foreach_cb callback, void *payload);
+ int (*iterator)(git_config_iterator **, struct git_config_backend *);
int (*refresh)(struct git_config_backend *);
void (*free)(struct git_config_backend *);
};