aboutsummaryrefslogtreecommitdiff
path: root/options.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-10-27 23:27:26 +0000
committerThomas Adam <thomas@xteddy.org>2015-10-27 23:27:26 +0000
commitda1f6fc2c8477c99e986061bcdd7c3e854a60076 (patch)
treef5934e2f96c43f80bad7e3a219230d6337c9d208 /options.c
parent147b5ae5145dc29e9bf4d0ebbc635939b6fdc60b (diff)
parent44657bf932b068aff5ce1019a4e8a2e7b00b5321 (diff)
downloadrtmux-da1f6fc2c8477c99e986061bcdd7c3e854a60076.tar.gz
rtmux-da1f6fc2c8477c99e986061bcdd7c3e854a60076.tar.bz2
rtmux-da1f6fc2c8477c99e986061bcdd7c3e854a60076.zip
Merge branch 'obsd-master'
Conflicts: Makefile client.c server-client.c server.c tmux.c tmux.h
Diffstat (limited to 'options.c')
-rw-r--r--options.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/options.c b/options.c
index 030cfd51..487918fd 100644
--- a/options.c
+++ b/options.c
@@ -29,6 +29,13 @@
* a red-black tree.
*/
+struct options {
+ RB_HEAD(options_tree, options_entry) tree;
+ struct options *parent;
+};
+
+int options_cmp(struct options_entry *, struct options_entry *);
+RB_PROTOTYPE(options_tree, options_entry, entry, options_cmp);
RB_GENERATE(options_tree, options_entry, entry, options_cmp);
int
@@ -37,11 +44,15 @@ options_cmp(struct options_entry *o1, struct options_entry *o2)
return (strcmp(o1->name, o2->name));
}
-void
-options_init(struct options *oo, struct options *parent)
+struct options *
+options_create(struct options *parent)
{
+ struct options *oo;
+
+ oo = xcalloc(1, sizeof *oo);
RB_INIT(&oo->tree);
oo->parent = parent;
+ return (oo);
}
void
@@ -57,6 +68,19 @@ options_free(struct options *oo)
free(o->str);
free(o);
}
+ free(oo);
+}
+
+struct options_entry *
+options_first(struct options *oo)
+{
+ return (RB_MIN(options_tree, &oo->tree));
+}
+
+struct options_entry *
+options_next(struct options_entry *o)
+{
+ return (RB_NEXT(options_tree, &oo->tree, o));
}
struct options_entry *