summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/options.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-10-27 15:58:42 +0000
committernicm <nicm@openbsd.org>2015-10-27 15:58:42 +0000
commitd89252e541ebb5e90a6b7e1089b8f396e19ca235 (patch)
tree6fd0ce863c715f2818c48c94c4f8de9afdb057e9 /usr.bin/tmux/options.c
parentUse AF_UNIX instead of AF_LOCAL. (diff)
downloadwireguard-openbsd-d89252e541ebb5e90a6b7e1089b8f396e19ca235.tar.xz
wireguard-openbsd-d89252e541ebb5e90a6b7e1089b8f396e19ca235.zip
Move struct options into options.c.
Diffstat (limited to 'usr.bin/tmux/options.c')
-rw-r--r--usr.bin/tmux/options.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index 506a819dfda..59494c12985 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.12 2015/02/18 15:32:37 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.13 2015/10/27 15:58:42 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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 *