diff options
author | Patrick Steinhardt <ps@pks.im> | 2018-08-10 13:33:02 +0200 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2018-09-28 11:14:13 +0200 |
commit | 04f57d51605ffe624aab37919c03e50a5ae3b16a (patch) | |
tree | 6b6308b500ac8df4340e01945e374dc83c87cf3a /src/config_entries.h | |
parent | d75bbea187a04aedfa2de13f3e31f42ce985f818 (diff) | |
download | libgit2-04f57d51605ffe624aab37919c03e50a5ae3b16a.tar.gz |
config_entries: pull out implementation of entry store
The configuration entry store that is used for configuration files needs
to keep track of all entries in two different structures:
- a singly linked list is being used to be able to iterate through
configuration files in the order they have been found
- a string map is being used to efficiently look up configuration
entries by their key
This store is thus something that may be used by other, future backends
as well to abstract away implementation details and iteration over the
entries.
Pull out the necessary functions from "config_file.c" and moves them
into their own "config_entries.c" module. For now, this is simply moving
over code without any renames and/or refactorings to help reviewing.
Diffstat (limited to 'src/config_entries.h')
-rw-r--r-- | src/config_entries.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/config_entries.h b/src/config_entries.h new file mode 100644 index 000000000..fbb901b4b --- /dev/null +++ b/src/config_entries.h @@ -0,0 +1,37 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" + +#include "git2/sys/config.h" +#include "config.h" + +typedef struct config_entry_list { + struct config_entry_list *next; + struct config_entry_list *last; + git_config_entry *entry; +} config_entry_list; + +typedef struct { + git_atomic refcount; + git_strmap *map; + config_entry_list *list; +} diskfile_entries; + +typedef struct git_config_file_iter { + git_config_iterator parent; + config_entry_list *head; +} git_config_file_iter; + +int diskfile_entries_alloc(diskfile_entries **out); +void diskfile_entries_free(diskfile_entries *entries); +/* Add or append the new config option */ +int diskfile_entries_append(diskfile_entries *entries, git_config_entry *entry); + +void config_iterator_free(git_config_iterator* iter); +int config_iterator_next(git_config_entry **entry, + git_config_iterator *iter); |