summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/dict.h
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2018-12-23 16:06:25 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2018-12-23 16:06:25 +0000
commit50ad5f6435c8737ea52b3bf25cefe896402c0ef1 (patch)
tree83a084db2142de82e874861fc71064f3845e49e2 /usr.sbin/smtpd/dict.h
parent91a6e40712b2bc1ca440d48a53a5b234494d0a74 (diff)
the tree_* and dict_* api's in smtpd can be used standalone, do not have
them depend on smtpd.h, it makes it hard to reuse them elsewhere ok eric@
Diffstat (limited to 'usr.sbin/smtpd/dict.h')
-rw-r--r--usr.sbin/smtpd/dict.h48
1 files changed, 48 insertions, 0 deletions
diff --git a/usr.sbin/smtpd/dict.h b/usr.sbin/smtpd/dict.h
new file mode 100644
index 00000000000..c5d47e1ae47
--- /dev/null
+++ b/usr.sbin/smtpd/dict.h
@@ -0,0 +1,48 @@
+/* $OpenBSD: dict.h,v 1.1 2018/12/23 16:06:24 gilles Exp $ */
+
+/*
+ * Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
+ * Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _DICT_H_
+#define _DICT_H_
+
+SPLAY_HEAD(_dict, dictentry);
+
+struct dict {
+ struct _dict dict;
+ size_t count;
+};
+
+
+/* dict.c */
+#define dict_init(d) do { SPLAY_INIT(&((d)->dict)); (d)->count = 0; } while(0)
+#define dict_empty(d) SPLAY_EMPTY(&((d)->dict))
+#define dict_count(d) ((d)->count)
+int dict_check(struct dict *, const char *);
+void *dict_set(struct dict *, const char *, void *);
+void dict_xset(struct dict *, const char *, void *);
+void *dict_get(struct dict *, const char *);
+void *dict_xget(struct dict *, const char *);
+void *dict_pop(struct dict *, const char *);
+void *dict_xpop(struct dict *, const char *);
+int dict_poproot(struct dict *, void **);
+int dict_root(struct dict *, const char **, void **);
+int dict_iter(struct dict *, void **, const char **, void **);
+int dict_iterfrom(struct dict *, void **, const char *, const char **, void **);
+void dict_merge(struct dict *, struct dict *);
+
+#endif