aboutsummaryrefslogtreecommitdiffstats
path: root/net-mgmt
diff options
context:
space:
mode:
authorgarga <garga@FreeBSD.org>2005-10-06 00:56:52 +0800
committergarga <garga@FreeBSD.org>2005-10-06 00:56:52 +0800
commitda4ac8e92b2241d274cf333d640d298db43ad02d (patch)
tree843c040f984b706877cac720eabaa818f09874c3 /net-mgmt
parent5977e0542e4b5d89ec92f1ca730600b58360f6c3 (diff)
downloadfreebsd-ports-gnome-da4ac8e92b2241d274cf333d640d298db43ad02d.tar.gz
freebsd-ports-gnome-da4ac8e92b2241d274cf333d640d298db43ad02d.tar.zst
freebsd-ports-gnome-da4ac8e92b2241d274cf333d640d298db43ad02d.zip
- Update to 1.11
PR: ports/86945 Submitted by: maintainer
Diffstat (limited to 'net-mgmt')
-rw-r--r--net-mgmt/bsnmpd/Makefile4
-rw-r--r--net-mgmt/bsnmpd/distinfo4
-rw-r--r--net-mgmt/bsnmpd/files/patch-config__Makefile.post60
-rw-r--r--net-mgmt/bsnmpd/files/patch-config__Makefile.pre19
-rw-r--r--net-mgmt/bsnmpd/files/patch-configure.ac57
-rw-r--r--net-mgmt/bsnmpd/files/patch-gensnmptree__gensnmptree.c12
-rw-r--r--net-mgmt/bsnmpd/files/patch-lib__asn1.c14
-rw-r--r--net-mgmt/bsnmpd/files/patch-lib__asn1.h13
-rw-r--r--net-mgmt/bsnmpd/files/patch-lib__snmp.c14
-rw-r--r--net-mgmt/bsnmpd/files/patch-lib__snmpagent.c14
-rw-r--r--net-mgmt/bsnmpd/files/patch-lib__snmpclient.c14
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII.h16
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_ipaddr.c15
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_route.c14
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmp_mibII__tree.h682
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmp_ntp__snmp_ntp.c48
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmpd.config14
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmpd__config.c20
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmpd__main.c10
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmpd__snmpd.config14
-rw-r--r--net-mgmt/bsnmpd/files/patch-snmpd__trap.c11
21 files changed, 736 insertions, 333 deletions
diff --git a/net-mgmt/bsnmpd/Makefile b/net-mgmt/bsnmpd/Makefile
index 87e8de048cca..4745926e4029 100644
--- a/net-mgmt/bsnmpd/Makefile
+++ b/net-mgmt/bsnmpd/Makefile
@@ -6,7 +6,7 @@
#
PORTNAME= bsnmpd
-PORTVERSION= 1.10
+PORTVERSION= 1.11
CATEGORIES= net-mgmt
MASTER_SITES= http://people.freebsd.org/~harti/bsnmp/
DISTNAME= bsnmp-${PORTVERSION}
@@ -28,7 +28,7 @@ INSTALLS_SHLIB= yes
USE_GCC= 3.2+
USE_RC_SUBR= bsnmpd.sh
-MAN1= bsnmpd.1 gensnmpdef.1 gensnmptree.1
+MAN1= bsnmpd.1 gensnmptree.1 gensnmpdef.1
MAN3= asn1.3 bsnmplib.3 bsnmpclient.3 bsnmpagent.3 snmpmod.3 \
snmp_mibII.3
diff --git a/net-mgmt/bsnmpd/distinfo b/net-mgmt/bsnmpd/distinfo
index ca6c3e429e93..91c3ef81ea3d 100644
--- a/net-mgmt/bsnmpd/distinfo
+++ b/net-mgmt/bsnmpd/distinfo
@@ -1,2 +1,2 @@
-MD5 (bsnmp-1.10.tar.gz) = d0d8d538639c899eb3e8602876bd28be
-SIZE (bsnmp-1.10.tar.gz) = 451797
+MD5 (bsnmp-1.11.tar.gz) = 67e04891d97346bec1e0b7c4f8520f62
+SIZE (bsnmp-1.11.tar.gz) = 407985
diff --git a/net-mgmt/bsnmpd/files/patch-config__Makefile.post b/net-mgmt/bsnmpd/files/patch-config__Makefile.post
index 5dbf5294df88..f3a2a0112451 100644
--- a/net-mgmt/bsnmpd/files/patch-config__Makefile.post
+++ b/net-mgmt/bsnmpd/files/patch-config__Makefile.post
@@ -1,67 +1,13 @@
---- config/Makefile.post.orig Thu Sep 22 08:33:16 2005
-+++ config/Makefile.post Thu Sep 22 08:37:05 2005
-@@ -31,7 +31,7 @@
- install-man1:
- @$(srcdir)/../config/mkinstalldirs $(mandir)/man1
- for f in $(MAN1) ; do \
-- $(INSTALL_DATA) $${f}out $(mandir)/man1/$${f} ; \
-+ $(BSD_INSTALL_MAN) $${f}out $(mandir)/man1/$${f} ; \
- done
-
- %.1out: %.1
-@@ -48,7 +48,7 @@
- install-man3:
- @$(srcdir)/../config/mkinstalldirs $(mandir)/man3
- for f in $(MAN3) ; do \
-- $(INSTALL_DATA) $${f}out $(mandir)/man3/$${f} ; \
-+ $(BSD_INSTALL_MAN) $${f}out $(mandir)/man3/$${f} ; \
- done
-
- %.3out: %.3
-@@ -61,7 +61,7 @@
- ifneq "$(DEFS)" ""
- install-defs:
- @$(srcdir)/../config/mkinstalldirs $(DEFSDIR)
-- $(INSTALL_DATA) $(DEFS:%=$(srcdir)/%) $(DEFSDIR)
-+ $(BSD_INSTALL_DATA) $(DEFS:%=$(srcdir)/%) $(DEFSDIR)
-
- DEFSDIR= ${datadir}/snmp/defs
-
-@@ -76,7 +76,7 @@
- install-incs:
- @$(srcdir)/../config/mkinstalldirs $(INCDIR)
- for f in $(INCS) ; do \
-- $(INSTALL_DATA) $(srcdir)/$$f $(INCDIR) ; \
-+ $(BSD_INSTALL_DATA) $(srcdir)/$$f $(INCDIR) ; \
- done
-
- else
-@@ -90,7 +90,7 @@
- install-mibs:
- @$(srcdir)/../config/mkinstalldirs $(BMIBSDIR)
- for f in $(BMIBS) ; do \
-- $(INSTALL_DATA) $(srcdir)/$$f $(BMIBSDIR) ; \
-+ $(BSD_INSTALL_DATA) $(srcdir)/$$f $(BMIBSDIR) ; \
- done
-
- else
+--- config/Makefile.post Tue Oct 4 15:21:28 2005
++++ config/Makefile.post Wed Oct 5 10:47:01 2005
@@ -101,8 +101,8 @@
build-prog: $(PROG)
install-prog:
- @$(srcdir)/../config/mkinstalldirs $(bindir)
-- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(builddir)/$(PROG) $(bindir)/$(PROG)
+- $(LIBTOOL) --mode=install $(BSD_INSTALL_PROGRAM) $(builddir)/$(PROG) $(bindir)/$(PROG)
+ @$(srcdir)/../config/mkinstalldirs $(sbindir)
+ $(LIBTOOL) --mode=install $(BSD_INSTALL_PROGRAM) $(builddir)/$(PROG) $(sbindir)/$(PROG)
else
build-prog:
-@@ -114,7 +114,7 @@
-
- install-lib:
- @$(srcdir)/../config/mkinstalldirs $(libdir)
-- $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(LIB) $(libdir)
-+ $(LIBTOOL) --mode=install $(BSD_INSTALL_DATA) $(LIB) $(libdir)
-
- else
- build-lib:
diff --git a/net-mgmt/bsnmpd/files/patch-config__Makefile.pre b/net-mgmt/bsnmpd/files/patch-config__Makefile.pre
deleted file mode 100644
index 11b55a885648..000000000000
--- a/net-mgmt/bsnmpd/files/patch-config__Makefile.pre
+++ /dev/null
@@ -1,19 +0,0 @@
---- config/Makefile.pre.orig Mon Sep 19 22:07:05 2005
-+++ config/Makefile.pre Mon Sep 19 22:09:02 2005
-@@ -17,6 +17,7 @@
- prefix= @prefix@
- exec_prefix= @exec_prefix@
- bindir= @bindir@
-+sbindir= @sbindir@
- libdir= @libdir@
- includedir= @includedir@
- mandir= @mandir@
-@@ -34,7 +35,7 @@
-
- LIBEV= @LIBEV@
-
--SUBMAKE= $(MAKE) -$(MAKEFLAGS) --no-print-directory
-+SUBMAKE= $(MAKE) $(MAKEFLAGS) --no-print-directory
-
- WARNS= -Wsystem-headers -Werror -Wall -Wno-format-y2k -W \
- -Wstrict-prototypes -Wmissing-prototypes \
diff --git a/net-mgmt/bsnmpd/files/patch-configure.ac b/net-mgmt/bsnmpd/files/patch-configure.ac
index 53c80b421fc8..7e8154ce07d8 100644
--- a/net-mgmt/bsnmpd/files/patch-configure.ac
+++ b/net-mgmt/bsnmpd/files/patch-configure.ac
@@ -1,6 +1,6 @@
---- configure.ac.orig Mon Apr 25 15:49:28 2005
-+++ configure.ac Thu Sep 29 10:00:03 2005
-@@ -18,6 +18,8 @@
+--- configure.ac.orig Tue Oct 4 15:21:26 2005
++++ configure.ac Wed Oct 5 17:24:12 2005
+@@ -21,6 +21,8 @@
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
@@ -9,54 +9,3 @@
AC_PROG_CC
AC_PROG_CPP
AC_PROG_MAKE_SET
-@@ -74,6 +76,50 @@
-
- # check for getaddrinfo
- AC_CHECK_FUNCS(getaddrinfo)
-+
-+AC_CHECK_HEADER(stdint.h,
-+ AC_DEFINE(HAVE_STDINT_H))
-+AC_CHECK_HEADER(inttypes.h,
-+ [AC_DEFINE(HAVE_INTTYPES_H)
-+ ac_have_inttypes_h=yes])
-+AC_CACHE_CHECK([how to print quads],
-+ ac_cv_quad_fmt,
-+ [if test "$ac_have_inttypes_h" = "yes" ; then
-+ AC_EGREP_CPP(yes,
-+[
-+# include <inttypes.h>
-+# ifdef PRIu64
-+yes
-+# endif
-+],
-+ ac_cv_quad_fmt=PRIu64,
-+ AC_TRY_RUN(
-+[[
-+# include <stdio.h>
-+# include <stdlib.h>
-+# include <string.h>
-+int
-+main()
-+{
-+ char buf[100];
-+
-+ sprintf(buf, "%llx", 0x1234567887654321LLU);
-+ exit((strcmp(buf, "1234567887654321") == 0) ? 0 : 1);
-+}
-+]],
-+ ac_cv_quad_fmt='"ll"',
-+ ac_cv_quad_fmt='"q"',
-+ ac_cv_quad_fmt='"q"')
-+ fi ]))
-+
-+if test "$ac_cv_quad_fmt" = "PRIu64" ; then
-+ AC_DEFINE(QUADFMT, PRIu64)
-+ AC_DEFINE(QUADXFMT, PRIx64)
-+else
-+ AC_DEFINE_UNQUOTED(QUADFMT, ${ac_cv_quad_fmt}"u")
-+ AC_DEFINE_UNQUOTED(QUADXFMT, ${ac_cv_quad_fmt}"x")
-+fi
-+
-
- AC_CONFIG_FILES([
- Makefile:config/Makefile.pre:Makefile.in
diff --git a/net-mgmt/bsnmpd/files/patch-gensnmptree__gensnmptree.c b/net-mgmt/bsnmpd/files/patch-gensnmptree__gensnmptree.c
deleted file mode 100644
index 75ed34b47a0d..000000000000
--- a/net-mgmt/bsnmpd/files/patch-gensnmptree__gensnmptree.c
+++ /dev/null
@@ -1,12 +0,0 @@
---- gensnmptree/gensnmptree.c.orig Thu Sep 22 08:58:15 2005
-+++ gensnmptree/gensnmptree.c Thu Sep 22 08:59:03 2005
-@@ -595,7 +595,9 @@
-
- fprintf(fp, "#include <sys/types.h>\n");
- fprintf(fp, "#include <stdio.h>\n");
-+#ifdef HAVE_STDINT_H
- fprintf(fp, "#include <stdint.h>\n");
-+#endif
- if (localincs) {
- fprintf(fp, "#include \"asn1.h\"\n");
- fprintf(fp, "#include \"snmp.h\"\n");
diff --git a/net-mgmt/bsnmpd/files/patch-lib__asn1.c b/net-mgmt/bsnmpd/files/patch-lib__asn1.c
deleted file mode 100644
index fc20064dc337..000000000000
--- a/net-mgmt/bsnmpd/files/patch-lib__asn1.c
+++ /dev/null
@@ -1,14 +0,0 @@
---- lib/asn1.c.orig Thu Sep 22 09:02:07 2005
-+++ lib/asn1.c Thu Sep 22 09:03:46 2005
-@@ -35,7 +35,11 @@
- #include <stdlib.h>
- #include <stdarg.h>
- #include <string.h>
-+#ifdef HAVE_STDINT_H
- #include <stdint.h>
-+#elif defined(HAVE_INTTYPES_H)
-+#include <inttypes.h>
-+#endif
- #include <assert.h>
- #include "asn1.h"
-
diff --git a/net-mgmt/bsnmpd/files/patch-lib__asn1.h b/net-mgmt/bsnmpd/files/patch-lib__asn1.h
deleted file mode 100644
index 7ea606571d8f..000000000000
--- a/net-mgmt/bsnmpd/files/patch-lib__asn1.h
+++ /dev/null
@@ -1,13 +0,0 @@
---- lib/asn1.h.orig Tue Dec 2 18:52:37 2003
-+++ lib/asn1.h Wed Sep 21 09:53:04 2005
-@@ -183,4 +183,10 @@
- ASN_EXCEPT_ENDOFMIBVIEW = 0x02,
- };
-
-+#if !defined(__STDC_LIMIT_MACROS)
-+#define INT32_MIN (-0x7fffffff-1)
-+#define INT32_MAX 0x7fffffff
-+#define UINT32_MAX 0xffffffffU
-+#endif
-+
- #endif
diff --git a/net-mgmt/bsnmpd/files/patch-lib__snmp.c b/net-mgmt/bsnmpd/files/patch-lib__snmp.c
deleted file mode 100644
index 2861afd6a9d2..000000000000
--- a/net-mgmt/bsnmpd/files/patch-lib__snmp.c
+++ /dev/null
@@ -1,14 +0,0 @@
---- lib/snmp.c.orig Fri Sep 23 08:48:16 2005
-+++ lib/snmp.c Fri Sep 23 08:47:34 2005
-@@ -36,7 +36,11 @@
- #include <stdlib.h>
- #include <stddef.h>
- #include <stdarg.h>
-+#ifdef HAVE_STDINT_H
- #include <stdint.h>
-+#elif defined(HAVE_INTTYPES_H)
-+#include <inttypes.h>
-+#endif
- #include <string.h>
- #include <ctype.h>
- #include <netdb.h>
diff --git a/net-mgmt/bsnmpd/files/patch-lib__snmpagent.c b/net-mgmt/bsnmpd/files/patch-lib__snmpagent.c
deleted file mode 100644
index 9ebe9869afe2..000000000000
--- a/net-mgmt/bsnmpd/files/patch-lib__snmpagent.c
+++ /dev/null
@@ -1,14 +0,0 @@
---- lib/snmpagent.c.orig Thu Sep 22 09:06:25 2005
-+++ lib/snmpagent.c Thu Sep 22 09:07:19 2005
-@@ -36,7 +36,11 @@
- #include <stdlib.h>
- #include <stddef.h>
- #include <stdarg.h>
-+#ifdef HAVE_STDINT_H
- #include <stdint.h>
-+#elif defined(HAVE_INTTYPES_H)
-+#include <inttypes.h>
-+#endif
- #include <string.h>
-
- #include "asn1.h"
diff --git a/net-mgmt/bsnmpd/files/patch-lib__snmpclient.c b/net-mgmt/bsnmpd/files/patch-lib__snmpclient.c
deleted file mode 100644
index 163711937de7..000000000000
--- a/net-mgmt/bsnmpd/files/patch-lib__snmpclient.c
+++ /dev/null
@@ -1,14 +0,0 @@
---- lib/snmpclient.c.orig Thu Sep 22 09:07:57 2005
-+++ lib/snmpclient.c Thu Sep 22 09:08:38 2005
-@@ -48,7 +48,11 @@
- #include <unistd.h>
- #include <fcntl.h>
- #include <netdb.h>
-+#ifdef HAVE_STDINT_H
- #include <stdint.h>
-+#elif defined(HAVE_INTTYPES_H)
-+#include <inttypes.h>
-+#endif
- #include <limits.h>
- #ifdef HAVE_ERR_H
- #include <err.h>
diff --git a/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII.h b/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII.h
new file mode 100644
index 000000000000..fe25a711370a
--- /dev/null
+++ b/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII.h
@@ -0,0 +1,16 @@
+--- snmp_mibII/mibII.h Wed Oct 5 11:56:04 2005
++++ snmp_mibII/mibII.h Wed Oct 5 11:56:57 2005
+@@ -57,6 +57,13 @@
+ #include "mibII_tree.h"
+
+
++#ifndef SA_SIZE
++#define SA_SIZE(sa) \
++ ( (!(sa) || ((struct sockaddr *)(sa))->sa_len == 0) ? \
++ sizeof(long) : \
++ 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(long) - 1) ) )
++#endif
++
+ /*
+ * Interface list and flags.
+ */
diff --git a/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_ipaddr.c b/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_ipaddr.c
deleted file mode 100644
index 6cde906bd272..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_ipaddr.c
+++ /dev/null
@@ -1,15 +0,0 @@
---- snmp_mibII/mibII_ipaddr.c.orig Wed Sep 21 12:21:53 2005
-+++ snmp_mibII/mibII_ipaddr.c Wed Sep 21 12:18:56 2005
-@@ -88,8 +88,10 @@
- }
-
- bcast.s_addr = upd->addr.s_addr & upd->mask.s_addr;
-- if (!(upd->set & UPD_BCAST) || upd->bcast)
-- bcast.s_addr |= htonl(0xffffffff & ~ntohl(upd->mask.s_addr));
-+ if (!(upd->set & UPD_BCAST) || upd->bcast) {
-+ uint32_t tmp = ~ntohl(upd->mask.s_addr);
-+ bcast.s_addr |= htonl(0xffffffff & tmp);
-+ }
-
- if ((ifa = mib_create_ifa(upd->ifindex, upd->addr, upd->mask, bcast)) == NULL)
- return (SNMP_ERR_GENERR);
diff --git a/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_route.c b/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_route.c
new file mode 100644
index 000000000000..a47a29b556bb
--- /dev/null
+++ b/net-mgmt/bsnmpd/files/patch-snmp_mibII__mibII_route.c
@@ -0,0 +1,14 @@
+--- snmp_mibII/mibII_route.c.orig Wed Oct 5 14:18:53 2005
++++ snmp_mibII/mibII_route.c Wed Oct 5 14:18:16 2005
+@@ -30,7 +30,11 @@
+ *
+ * Routing table
+ */
++#ifdef HAVE_SYSTREE_H
+ #include <sys/tree.h>
++#else
++#include "tree.h"
++#endif
+ #include "mibII.h"
+ #include "mibII_oid.h"
+
diff --git a/net-mgmt/bsnmpd/files/patch-snmp_mibII__tree.h b/net-mgmt/bsnmpd/files/patch-snmp_mibII__tree.h
new file mode 100644
index 000000000000..5e41dc7aea77
--- /dev/null
+++ b/net-mgmt/bsnmpd/files/patch-snmp_mibII__tree.h
@@ -0,0 +1,682 @@
+--- snmp_mibII/tree.h.orig Wed Oct 5 16:43:43 2005
++++ snmp_mibII/tree.h Wed Oct 5 16:45:16 2005
+@@ -0,0 +1,679 @@
++/*-
++ * Copyright 2002 Niels Provos <provos@citi.umich.edu>
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++#ifndef _SYS_TREE_H_
++#define _SYS_TREE_H_
++
++/*
++ * This file defines data structures for different types of trees:
++ * splay trees and red-black trees.
++ *
++ * A splay tree is a self-organizing data structure. Every operation
++ * on the tree causes a splay to happen. The splay moves the requested
++ * node to the root of the tree and partly rebalances it.
++ *
++ * This has the benefit that request locality causes faster lookups as
++ * the requested nodes move to the top of the tree. On the other hand,
++ * every lookup causes memory writes.
++ *
++ * The Balance Theorem bounds the total access time for m operations
++ * and n inserts on an initially empty tree as O((m + n)lg n). The
++ * amortized cost for a sequence of m accesses to a splay tree is O(lg n);
++ *
++ * A red-black tree is a binary search tree with the node color as an
++ * extra attribute. It fulfills a set of conditions:
++ * - every search path from the root to a leaf consists of the
++ * same number of black nodes,
++ * - each red node (except for the root) has a black parent,
++ * - each leaf node is black.
++ *
++ * Every operation on a red-black tree is bounded as O(lg n).
++ * The maximum height of a red-black tree is 2lg (n+1).
++ */
++
++#define SPLAY_HEAD(name, type) \
++struct name { \
++ struct type *sph_root; /* root of the tree */ \
++}
++
++#define SPLAY_INITIALIZER(root) \
++ { NULL }
++
++#define SPLAY_INIT(root) do { \
++ (root)->sph_root = NULL; \
++} while (/*CONSTCOND*/ 0)
++
++#define SPLAY_ENTRY(type) \
++struct { \
++ struct type *spe_left; /* left element */ \
++ struct type *spe_right; /* right element */ \
++}
++
++#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
++#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
++#define SPLAY_ROOT(head) (head)->sph_root
++#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
++
++/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
++#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
++ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
++ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
++ (head)->sph_root = tmp; \
++} while (/*CONSTCOND*/ 0)
++
++#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
++ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
++ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
++ (head)->sph_root = tmp; \
++} while (/*CONSTCOND*/ 0)
++
++#define SPLAY_LINKLEFT(head, tmp, field) do { \
++ SPLAY_LEFT(tmp, field) = (head)->sph_root; \
++ tmp = (head)->sph_root; \
++ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
++} while (/*CONSTCOND*/ 0)
++
++#define SPLAY_LINKRIGHT(head, tmp, field) do { \
++ SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
++ tmp = (head)->sph_root; \
++ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
++} while (/*CONSTCOND*/ 0)
++
++#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
++ SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
++ SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
++ SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
++ SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
++} while (/*CONSTCOND*/ 0)
++
++/* Generates prototypes and inline functions */
++
++#define SPLAY_PROTOTYPE(name, type, field, cmp) \
++void name##_SPLAY(struct name *, struct type *); \
++void name##_SPLAY_MINMAX(struct name *, int); \
++struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
++struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
++ \
++/* Finds the node with the same key as elm */ \
++static __inline struct type * \
++name##_SPLAY_FIND(struct name *head, struct type *elm) \
++{ \
++ if (SPLAY_EMPTY(head)) \
++ return(NULL); \
++ name##_SPLAY(head, elm); \
++ if ((cmp)(elm, (head)->sph_root) == 0) \
++ return (head->sph_root); \
++ return (NULL); \
++} \
++ \
++static __inline struct type * \
++name##_SPLAY_NEXT(struct name *head, struct type *elm) \
++{ \
++ name##_SPLAY(head, elm); \
++ if (SPLAY_RIGHT(elm, field) != NULL) { \
++ elm = SPLAY_RIGHT(elm, field); \
++ while (SPLAY_LEFT(elm, field) != NULL) { \
++ elm = SPLAY_LEFT(elm, field); \
++ } \
++ } else \
++ elm = NULL; \
++ return (elm); \
++} \
++ \
++static __inline struct type * \
++name##_SPLAY_MIN_MAX(struct name *head, int val) \
++{ \
++ name##_SPLAY_MINMAX(head, val); \
++ return (SPLAY_ROOT(head)); \
++}
++
++/* Main splay operation.
++ * Moves node close to the key of elm to top
++ */
++#define SPLAY_GENERATE(name, type, field, cmp) \
++struct type * \
++name##_SPLAY_INSERT(struct name *head, struct type *elm) \
++{ \
++ if (SPLAY_EMPTY(head)) { \
++ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
++ } else { \
++ int __comp; \
++ name##_SPLAY(head, elm); \
++ __comp = (cmp)(elm, (head)->sph_root); \
++ if(__comp < 0) { \
++ SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
++ SPLAY_RIGHT(elm, field) = (head)->sph_root; \
++ SPLAY_LEFT((head)->sph_root, field) = NULL; \
++ } else if (__comp > 0) { \
++ SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
++ SPLAY_LEFT(elm, field) = (head)->sph_root; \
++ SPLAY_RIGHT((head)->sph_root, field) = NULL; \
++ } else \
++ return ((head)->sph_root); \
++ } \
++ (head)->sph_root = (elm); \
++ return (NULL); \
++} \
++ \
++struct type * \
++name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
++{ \
++ struct type *__tmp; \
++ if (SPLAY_EMPTY(head)) \
++ return (NULL); \
++ name##_SPLAY(head, elm); \
++ if ((cmp)(elm, (head)->sph_root) == 0) { \
++ if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
++ (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
++ } else { \
++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
++ (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
++ name##_SPLAY(head, elm); \
++ SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
++ } \
++ return (elm); \
++ } \
++ return (NULL); \
++} \
++ \
++void \
++name##_SPLAY(struct name *head, struct type *elm) \
++{ \
++ struct type __node, *__left, *__right, *__tmp; \
++ int __comp; \
++\
++ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
++ __left = __right = &__node; \
++\
++ while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
++ if (__comp < 0) { \
++ __tmp = SPLAY_LEFT((head)->sph_root, field); \
++ if (__tmp == NULL) \
++ break; \
++ if ((cmp)(elm, __tmp) < 0){ \
++ SPLAY_ROTATE_RIGHT(head, __tmp, field); \
++ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
++ break; \
++ } \
++ SPLAY_LINKLEFT(head, __right, field); \
++ } else if (__comp > 0) { \
++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
++ if (__tmp == NULL) \
++ break; \
++ if ((cmp)(elm, __tmp) > 0){ \
++ SPLAY_ROTATE_LEFT(head, __tmp, field); \
++ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
++ break; \
++ } \
++ SPLAY_LINKRIGHT(head, __left, field); \
++ } \
++ } \
++ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
++} \
++ \
++/* Splay with either the minimum or the maximum element \
++ * Used to find minimum or maximum element in tree. \
++ */ \
++void name##_SPLAY_MINMAX(struct name *head, int __comp) \
++{ \
++ struct type __node, *__left, *__right, *__tmp; \
++\
++ SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
++ __left = __right = &__node; \
++\
++ while (1) { \
++ if (__comp < 0) { \
++ __tmp = SPLAY_LEFT((head)->sph_root, field); \
++ if (__tmp == NULL) \
++ break; \
++ if (__comp < 0){ \
++ SPLAY_ROTATE_RIGHT(head, __tmp, field); \
++ if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
++ break; \
++ } \
++ SPLAY_LINKLEFT(head, __right, field); \
++ } else if (__comp > 0) { \
++ __tmp = SPLAY_RIGHT((head)->sph_root, field); \
++ if (__tmp == NULL) \
++ break; \
++ if (__comp > 0) { \
++ SPLAY_ROTATE_LEFT(head, __tmp, field); \
++ if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
++ break; \
++ } \
++ SPLAY_LINKRIGHT(head, __left, field); \
++ } \
++ } \
++ SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
++}
++
++#define SPLAY_NEGINF -1
++#define SPLAY_INF 1
++
++#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
++#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
++#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
++#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
++#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
++ : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
++#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
++ : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
++
++#define SPLAY_FOREACH(x, name, head) \
++ for ((x) = SPLAY_MIN(name, head); \
++ (x) != NULL; \
++ (x) = SPLAY_NEXT(name, head, x))
++
++/* Macros that define a red-black tree */
++#define RB_HEAD(name, type) \
++struct name { \
++ struct type *rbh_root; /* root of the tree */ \
++}
++
++#define RB_INITIALIZER(root) \
++ { NULL }
++
++#define RB_INIT(root) do { \
++ (root)->rbh_root = NULL; \
++} while (/*CONSTCOND*/ 0)
++
++#define RB_BLACK 0
++#define RB_RED 1
++#define RB_ENTRY(type) \
++struct { \
++ struct type *rbe_left; /* left element */ \
++ struct type *rbe_right; /* right element */ \
++ struct type *rbe_parent; /* parent element */ \
++ int rbe_color; /* node color */ \
++}
++
++#define RB_LEFT(elm, field) (elm)->field.rbe_left
++#define RB_RIGHT(elm, field) (elm)->field.rbe_right
++#define RB_PARENT(elm, field) (elm)->field.rbe_parent
++#define RB_COLOR(elm, field) (elm)->field.rbe_color
++#define RB_ROOT(head) (head)->rbh_root
++#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
++
++#define RB_SET(elm, parent, field) do { \
++ RB_PARENT(elm, field) = parent; \
++ RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
++ RB_COLOR(elm, field) = RB_RED; \
++} while (/*CONSTCOND*/ 0)
++
++#define RB_SET_BLACKRED(black, red, field) do { \
++ RB_COLOR(black, field) = RB_BLACK; \
++ RB_COLOR(red, field) = RB_RED; \
++} while (/*CONSTCOND*/ 0)
++
++#ifndef RB_AUGMENT
++#define RB_AUGMENT(x) do {} while (0)
++#endif
++
++#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
++ (tmp) = RB_RIGHT(elm, field); \
++ if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
++ RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
++ } \
++ RB_AUGMENT(elm); \
++ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
++ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
++ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
++ else \
++ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
++ } else \
++ (head)->rbh_root = (tmp); \
++ RB_LEFT(tmp, field) = (elm); \
++ RB_PARENT(elm, field) = (tmp); \
++ RB_AUGMENT(tmp); \
++ if ((RB_PARENT(tmp, field))) \
++ RB_AUGMENT(RB_PARENT(tmp, field)); \
++} while (/*CONSTCOND*/ 0)
++
++#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
++ (tmp) = RB_LEFT(elm, field); \
++ if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
++ RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
++ } \
++ RB_AUGMENT(elm); \
++ if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
++ if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
++ RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
++ else \
++ RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
++ } else \
++ (head)->rbh_root = (tmp); \
++ RB_RIGHT(tmp, field) = (elm); \
++ RB_PARENT(elm, field) = (tmp); \
++ RB_AUGMENT(tmp); \
++ if ((RB_PARENT(tmp, field))) \
++ RB_AUGMENT(RB_PARENT(tmp, field)); \
++} while (/*CONSTCOND*/ 0)
++
++/* Generates prototypes and inline functions */
++#define RB_PROTOTYPE(name, type, field, cmp) \
++void name##_RB_INSERT_COLOR(struct name *, struct type *); \
++void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
++struct type *name##_RB_REMOVE(struct name *, struct type *); \
++struct type *name##_RB_INSERT(struct name *, struct type *); \
++struct type *name##_RB_FIND(struct name *, struct type *); \
++struct type *name##_RB_NEXT(struct type *); \
++struct type *name##_RB_MINMAX(struct name *, int); \
++ \
++
++/* Main rb operation.
++ * Moves node close to the key of elm to top
++ */
++#define RB_GENERATE(name, type, field, cmp) \
++void \
++name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
++{ \
++ struct type *parent, *gparent, *tmp; \
++ while ((parent = RB_PARENT(elm, field)) != NULL && \
++ RB_COLOR(parent, field) == RB_RED) { \
++ gparent = RB_PARENT(parent, field); \
++ if (parent == RB_LEFT(gparent, field)) { \
++ tmp = RB_RIGHT(gparent, field); \
++ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
++ RB_COLOR(tmp, field) = RB_BLACK; \
++ RB_SET_BLACKRED(parent, gparent, field);\
++ elm = gparent; \
++ continue; \
++ } \
++ if (RB_RIGHT(parent, field) == elm) { \
++ RB_ROTATE_LEFT(head, parent, tmp, field);\
++ tmp = parent; \
++ parent = elm; \
++ elm = tmp; \
++ } \
++ RB_SET_BLACKRED(parent, gparent, field); \
++ RB_ROTATE_RIGHT(head, gparent, tmp, field); \
++ } else { \
++ tmp = RB_LEFT(gparent, field); \
++ if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
++ RB_COLOR(tmp, field) = RB_BLACK; \
++ RB_SET_BLACKRED(parent, gparent, field);\
++ elm = gparent; \
++ continue; \
++ } \
++ if (RB_LEFT(parent, field) == elm) { \
++ RB_ROTATE_RIGHT(head, parent, tmp, field);\
++ tmp = parent; \
++ parent = elm; \
++ elm = tmp; \
++ } \
++ RB_SET_BLACKRED(parent, gparent, field); \
++ RB_ROTATE_LEFT(head, gparent, tmp, field); \
++ } \
++ } \
++ RB_COLOR(head->rbh_root, field) = RB_BLACK; \
++} \
++ \
++void \
++name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
++{ \
++ struct type *tmp; \
++ while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
++ elm != RB_ROOT(head)) { \
++ if (RB_LEFT(parent, field) == elm) { \
++ tmp = RB_RIGHT(parent, field); \
++ if (RB_COLOR(tmp, field) == RB_RED) { \
++ RB_SET_BLACKRED(tmp, parent, field); \
++ RB_ROTATE_LEFT(head, parent, tmp, field);\
++ tmp = RB_RIGHT(parent, field); \
++ } \
++ if ((RB_LEFT(tmp, field) == NULL || \
++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
++ (RB_RIGHT(tmp, field) == NULL || \
++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
++ RB_COLOR(tmp, field) = RB_RED; \
++ elm = parent; \
++ parent = RB_PARENT(elm, field); \
++ } else { \
++ if (RB_RIGHT(tmp, field) == NULL || \
++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
++ struct type *oleft; \
++ if ((oleft = RB_LEFT(tmp, field)) \
++ != NULL) \
++ RB_COLOR(oleft, field) = RB_BLACK;\
++ RB_COLOR(tmp, field) = RB_RED; \
++ RB_ROTATE_RIGHT(head, tmp, oleft, field);\
++ tmp = RB_RIGHT(parent, field); \
++ } \
++ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
++ RB_COLOR(parent, field) = RB_BLACK; \
++ if (RB_RIGHT(tmp, field)) \
++ RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
++ RB_ROTATE_LEFT(head, parent, tmp, field);\
++ elm = RB_ROOT(head); \
++ break; \
++ } \
++ } else { \
++ tmp = RB_LEFT(parent, field); \
++ if (RB_COLOR(tmp, field) == RB_RED) { \
++ RB_SET_BLACKRED(tmp, parent, field); \
++ RB_ROTATE_RIGHT(head, parent, tmp, field);\
++ tmp = RB_LEFT(parent, field); \
++ } \
++ if ((RB_LEFT(tmp, field) == NULL || \
++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
++ (RB_RIGHT(tmp, field) == NULL || \
++ RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
++ RB_COLOR(tmp, field) = RB_RED; \
++ elm = parent; \
++ parent = RB_PARENT(elm, field); \
++ } else { \
++ if (RB_LEFT(tmp, field) == NULL || \
++ RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
++ struct type *oright; \
++ if ((oright = RB_RIGHT(tmp, field)) \
++ != NULL) \
++ RB_COLOR(oright, field) = RB_BLACK;\
++ RB_COLOR(tmp, field) = RB_RED; \
++ RB_ROTATE_LEFT(head, tmp, oright, field);\
++ tmp = RB_LEFT(parent, field); \
++ } \
++ RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
++ RB_COLOR(parent, field) = RB_BLACK; \
++ if (RB_LEFT(tmp, field)) \
++ RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
++ RB_ROTATE_RIGHT(head, parent, tmp, field);\
++ elm = RB_ROOT(head); \
++ break; \
++ } \
++ } \
++ } \
++ if (elm) \
++ RB_COLOR(elm, field) = RB_BLACK; \
++} \
++ \
++struct type * \
++name##_RB_REMOVE(struct name *head, struct type *elm) \
++{ \
++ struct type *child, *parent, *old = elm; \
++ int color; \
++ if (RB_LEFT(elm, field) == NULL) \
++ child = RB_RIGHT(elm, field); \
++ else if (RB_RIGHT(elm, field) == NULL) \
++ child = RB_LEFT(elm, field); \
++ else { \
++ struct type *left; \
++ elm = RB_RIGHT(elm, field); \
++ while ((left = RB_LEFT(elm, field)) != NULL) \
++ elm = left; \
++ child = RB_RIGHT(elm, field); \
++ parent = RB_PARENT(elm, field); \
++ color = RB_COLOR(elm, field); \
++ if (child) \
++ RB_PARENT(child, field) = parent; \
++ if (parent) { \
++ if (RB_LEFT(parent, field) == elm) \
++ RB_LEFT(parent, field) = child; \
++ else \
++ RB_RIGHT(parent, field) = child; \
++ RB_AUGMENT(parent); \
++ } else \
++ RB_ROOT(head) = child; \
++ if (RB_PARENT(elm, field) == old) \
++ parent = elm; \
++ (elm)->field = (old)->field; \
++ if (RB_PARENT(old, field)) { \
++ if (RB_LEFT(RB_PARENT(old, field), field) == old)\
++ RB_LEFT(RB_PARENT(old, field), field) = elm;\
++ else \
++ RB_RIGHT(RB_PARENT(old, field), field) = elm;\
++ RB_AUGMENT(RB_PARENT(old, field)); \
++ } else \
++ RB_ROOT(head) = elm; \
++ RB_PARENT(RB_LEFT(old, field), field) = elm; \
++ if (RB_RIGHT(old, field)) \
++ RB_PARENT(RB_RIGHT(old, field), field) = elm; \
++ if (parent) { \
++ left = parent; \
++ do { \
++ RB_AUGMENT(left); \
++ } while ((left = RB_PARENT(left, field)) != NULL); \
++ } \
++ goto color; \
++ } \
++ parent = RB_PARENT(elm, field); \
++ color = RB_COLOR(elm, field); \
++ if (child) \
++ RB_PARENT(child, field) = parent; \
++ if (parent) { \
++ if (RB_LEFT(parent, field) == elm) \
++ RB_LEFT(parent, field) = child; \
++ else \
++ RB_RIGHT(parent, field) = child; \
++ RB_AUGMENT(parent); \
++ } else \
++ RB_ROOT(head) = child; \
++color: \
++ if (color == RB_BLACK) \
++ name##_RB_REMOVE_COLOR(head, parent, child); \
++ return (old); \
++} \
++ \
++/* Inserts a node into the RB tree */ \
++struct type * \
++name##_RB_INSERT(struct name *head, struct type *elm) \
++{ \
++ struct type *tmp; \
++ struct type *parent = NULL; \
++ int comp = 0; \
++ tmp = RB_ROOT(head); \
++ while (tmp) { \
++ parent = tmp; \
++ comp = (cmp)(elm, parent); \
++ if (comp < 0) \
++ tmp = RB_LEFT(tmp, field); \
++ else if (comp > 0) \
++ tmp = RB_RIGHT(tmp, field); \
++ else \
++ return (tmp); \
++ } \
++ RB_SET(elm, parent, field); \
++ if (parent != NULL) { \
++ if (comp < 0) \
++ RB_LEFT(parent, field) = elm; \
++ else \
++ RB_RIGHT(parent, field) = elm; \
++ RB_AUGMENT(parent); \
++ } else \
++ RB_ROOT(head) = elm; \
++ name##_RB_INSERT_COLOR(head, elm); \
++ return (NULL); \
++} \
++ \
++/* Finds the node with the same key as elm */ \
++struct type * \
++name##_RB_FIND(struct name *head, struct type *elm) \
++{ \
++ struct type *tmp = RB_ROOT(head); \
++ int comp; \
++ while (tmp) { \
++ comp = cmp(elm, tmp); \
++ if (comp < 0) \
++ tmp = RB_LEFT(tmp, field); \
++ else if (comp > 0) \
++ tmp = RB_RIGHT(tmp, field); \
++ else \
++ return (tmp); \
++ } \
++ return (NULL); \
++} \
++ \
++/* ARGSUSED */ \
++struct type * \
++name##_RB_NEXT(struct type *elm) \
++{ \
++ if (RB_RIGHT(elm, field)) { \
++ elm = RB_RIGHT(elm, field); \
++ while (RB_LEFT(elm, field)) \
++ elm = RB_LEFT(elm, field); \
++ } else { \
++ if (RB_PARENT(elm, field) && \
++ (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
++ elm = RB_PARENT(elm, field); \
++ else { \
++ while (RB_PARENT(elm, field) && \
++ (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
++ elm = RB_PARENT(elm, field); \
++ elm = RB_PARENT(elm, field); \
++ } \
++ } \
++ return (elm); \
++} \
++ \
++struct type * \
++name##_RB_MINMAX(struct name *head, int val) \
++{ \
++ struct type *tmp = RB_ROOT(head); \
++ struct type *parent = NULL; \
++ while (tmp) { \
++ parent = tmp; \
++ if (val < 0) \
++ tmp = RB_LEFT(tmp, field); \
++ else \
++ tmp = RB_RIGHT(tmp, field); \
++ } \
++ return (parent); \
++}
++
++#define RB_NEGINF -1
++#define RB_INF 1
++
++#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
++#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
++#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
++#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
++#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
++#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
++
++#define RB_FOREACH(x, name, head) \
++ for ((x) = RB_MIN(name, head); \
++ (x) != NULL; \
++ (x) = name##_RB_NEXT(x))
++
++#endif /* _SYS_TREE_H_ */
diff --git a/net-mgmt/bsnmpd/files/patch-snmp_ntp__snmp_ntp.c b/net-mgmt/bsnmpd/files/patch-snmp_ntp__snmp_ntp.c
deleted file mode 100644
index 81db6376ba72..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmp_ntp__snmp_ntp.c
+++ /dev/null
@@ -1,48 +0,0 @@
---- snmp_ntp/snmp_ntp.c.orig Mon May 23 06:03:48 2005
-+++ snmp_ntp/snmp_ntp.c Mon Sep 26 12:50:42 2005
-@@ -40,7 +40,11 @@
- #include <ctype.h>
- #include <errno.h>
- #include <netdb.h>
-+#ifdef HAVE_STDINT_H
- #include <stdint.h>
-+#elif defined(HAVE_INTTYPES_H)
-+#include <inttypes.h>
-+#endif
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-@@ -360,6 +364,7 @@
- free(rpkt);
- return (-1);
- }
-+ return 0;
- }
-
- /*
-@@ -720,7 +725,7 @@
- {
- int r, n, error;
- struct addrinfo hints, *res0;
-- struct sockaddr_in *sin;
-+ struct sockaddr_in *sin_local;
-
- r = sscanf(val, "%hhd.%hhd.%hhd.%hhd%n",
- &ip[0], &ip[1], &ip[2], &ip[3], &n);
-@@ -743,11 +748,11 @@
- return (-1);
- }
-
-- sin = (struct sockaddr_in *)(void *)res0->ai_addr;
-- ip[3] = sin->sin_addr.s_addr >> 24;
-- ip[2] = sin->sin_addr.s_addr >> 16;
-- ip[1] = sin->sin_addr.s_addr >> 8;
-- ip[0] = sin->sin_addr.s_addr >> 0;
-+ sin_local = (struct sockaddr_in *)(void *)res0->ai_addr;
-+ ip[3] = sin_local->sin_addr.s_addr >> 24;
-+ ip[2] = sin_local->sin_addr.s_addr >> 16;
-+ ip[1] = sin_local->sin_addr.s_addr >> 8;
-+ ip[0] = sin_local->sin_addr.s_addr >> 0;
-
- freeaddrinfo(res0);
- return (0);
diff --git a/net-mgmt/bsnmpd/files/patch-snmpd.config b/net-mgmt/bsnmpd/files/patch-snmpd.config
new file mode 100644
index 000000000000..4050e480a603
--- /dev/null
+++ b/net-mgmt/bsnmpd/files/patch-snmpd.config
@@ -0,0 +1,14 @@
+--- snmpd/snmpd.config Fri Feb 25 14:50:43 2005
++++ snmpd/snmpd.config Wed Oct 5 10:57:30 2005
+@@ -83,7 +83,7 @@
+ #
+ # Netgraph module
+ #
+-begemotSnmpdModulePath."netgraph" = "/usr/local/lib/snmp_netgraph.so"
+-
+-%netgraph
+-begemotNgControlNodeName = "snmpd"
++#begemotSnmpdModulePath."netgraph" = "/usr/local/lib/snmp_netgraph.so"
++#
++#%netgraph
++#begemotNgControlNodeName = "snmpd"
diff --git a/net-mgmt/bsnmpd/files/patch-snmpd__config.c b/net-mgmt/bsnmpd/files/patch-snmpd__config.c
deleted file mode 100644
index e4ea1468e787..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmpd__config.c
+++ /dev/null
@@ -1,20 +0,0 @@
---- snmpd/config.c.orig Thu Sep 22 08:43:58 2005
-+++ snmpd/config.c Thu Sep 22 08:44:54 2005
-@@ -820,7 +820,7 @@
- while (token == '.') {
- if (gettoken() == TOK_NUM) {
- if (numval > ASN_MAXID)
-- report("subid too large %#"PRIx64, numval);
-+ report("subid too large %#"QUADXFMT, numval);
- if (oid->len == ASN_MAXOIDLEN)
- report("index too long");
- oid->subs[oid->len++] = numval;
-@@ -863,7 +863,7 @@
- if (token != TOK_NUM)
- report("bad INTEGER syntax");
- if (numval > 0x7fffffff)
-- report("INTEGER too large %"PRIu64, numval);
-+ report("INTEGER too large %"QUADFMT, numval);
-
- value->v.integer = numval;
- gettoken();
diff --git a/net-mgmt/bsnmpd/files/patch-snmpd__main.c b/net-mgmt/bsnmpd/files/patch-snmpd__main.c
deleted file mode 100644
index 99553c9e00f4..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmpd__main.c
+++ /dev/null
@@ -1,10 +0,0 @@
---- snmpd/main.c.orig Thu Sep 22 09:14:31 2005
-+++ snmpd/main.c Thu Sep 22 09:15:49 2005
-@@ -33,6 +33,7 @@
- #include <sys/param.h>
- #include <sys/un.h>
- #include <sys/ucred.h>
-+#include <sys/uio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stddef.h>
diff --git a/net-mgmt/bsnmpd/files/patch-snmpd__snmpd.config b/net-mgmt/bsnmpd/files/patch-snmpd__snmpd.config
deleted file mode 100644
index b7bc1ac7ed40..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmpd__snmpd.config
+++ /dev/null
@@ -1,14 +0,0 @@
---- snmpd/snmpd.config.orig Tue Sep 20 20:43:27 2005
-+++ snmpd/snmpd.config Tue Sep 20 20:43:38 2005
-@@ -82,11 +82,3 @@
- # Load MIB-2 module
- #
- begemotSnmpdModulePath."mibII" = "/usr/local/lib/snmp_mibII.so"
--
--#
--# Netgraph module
--#
--begemotSnmpdModulePath."netgraph" = "/usr/local/lib/snmp_netgraph.so"
--
--%netgraph
--begemotNgControlNodeName = "snmpd"
diff --git a/net-mgmt/bsnmpd/files/patch-snmpd__trap.c b/net-mgmt/bsnmpd/files/patch-snmpd__trap.c
deleted file mode 100644
index 23454e747812..000000000000
--- a/net-mgmt/bsnmpd/files/patch-snmpd__trap.c
+++ /dev/null
@@ -1,11 +0,0 @@
---- snmpd/trap.c.orig Wed Sep 21 11:42:50 2005
-+++ snmpd/trap.c Wed Sep 21 11:42:06 2005
-@@ -111,7 +111,7 @@
-
- if (connect(t->socket, (struct sockaddr *)&sa, sa.sin_len) == -1) {
- syslog(LOG_ERR, "connect(%s,%u): %m",
-- inet_ntoa(sa.sin_addr), ntohl(sa.sin_port));
-+ inet_ntoa(sa.sin_addr), ntohs(sa.sin_port));
- (void)close(t->socket);
- free(t);
- return (SNMP_ERR_GENERR);