[Python-modules-commits] [py-radix] 02/13: Import py-radix_0.9.7.orig.tar.gz

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Tue Jan 30 13:53:00 UTC 2018


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to annotated tag debian/0.9.7-1
in repository py-radix.

commit e9635643ff075b4d1b00ef674e05ab21cde8754a
Author: Aggelos Avgerinos <evaggelos.avgerinos at gmail.com>
Date:   Mon Jan 22 10:49:35 2018 +0200

    Import py-radix_0.9.7.orig.tar.gz
---
 .bumpversion.cfg                |    6 +
 .coveragerc                     |    8 +
 .gitignore                      |   53 ++
 .travis.yml                     |   30 ++
 ChangeLog                       |   78 ---
 LICENSE                         |   20 +-
 MANIFEST                        |    9 -
 MANIFEST.in                     |    3 +
 Makefile                        |   12 +
 PKG-INFO                        |   20 -
 README => README.rst            |   83 +++-
 TODO                            |   24 -
 appveyor.yml                    |   19 +
 inet_ntop.c                     |  201 --------
 py-radix.spec                   |   44 --
 radix.c                         |  675 --------------------------
 radix/__init__.py               |   39 ++
 radix/_radix.c                  | 1015 +++++++++++++++++++++++++++++++++++++++
 radix/_radix/radix.c            |  920 +++++++++++++++++++++++++++++++++++
 radix.h => radix/_radix/radix.h |  110 +++--
 radix/radix.py                  |  536 +++++++++++++++++++++
 radix_python.c                  |  988 -------------------------------------
 setup.cfg                       |    5 +
 setup.py                        |  103 ++--
 strlcpy.c                       |   51 --
 test.py                         |  353 --------------
 tests/__init__.py               |    0
 tests/data/radix-0.5-c_ext.pkl  |   21 +
 tests/data/radix-0.6-c_ext.pkl  |   21 +
 tests/data/radix-0.6-no_ext.pkl |   21 +
 tests/test_compat.py            |   47 ++
 tests/test_regression.py        |  539 +++++++++++++++++++++
 32 files changed, 3510 insertions(+), 2544 deletions(-)

diff --git a/.bumpversion.cfg b/.bumpversion.cfg
new file mode 100644
index 0000000..cad6759
--- /dev/null
+++ b/.bumpversion.cfg
@@ -0,0 +1,6 @@
+[bumpversion]
+files = setup.py radix/__init__.py
+commit = True
+tag = True
+current_version = 0.9.7
+
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..9f73555
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,8 @@
+# .coveragerc to control coverage.py
+[run]
+branch = True
+source = .
+
+[report]
+omit =
+  setup.py
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..414b218
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,53 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+bin/
+build/
+develop-eggs/
+dist/
+eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.cache
+nosetests.xml
+coverage.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
+
+# Rope
+.ropeproject
+
+# Django stuff:
+*.log
+*.pot
+
+# Sphinx documentation
+docs/_build/
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d45719c
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,30 @@
+language: python
+
+sudo: false
+
+python:
+  - "pypy"
+  - "2.6"
+  - "2.7"
+  - "3.3"
+  - "3.4"
+  - "3.5"
+
+env:
+  - RADIX_NO_EXT=true
+  - RADIX_NO_EXT=false
+
+matrix:
+  exclude:
+    - python: "pypy"  # pypy will always build without extension
+      env: RADIX_NO_EXT=false
+
+install:
+  - pip install coveralls 
+  - python setup.py install
+
+script:
+  - python setup.py nosetests
+
+after_success:
+  - coveralls
diff --git a/ChangeLog b/ChangeLog
deleted file mode 100644
index 712617e..0000000
--- a/ChangeLog
+++ /dev/null
@@ -1,78 +0,0 @@
-20071218
- - (djm) Implement pickle protocol via __reduce__ and __setstate__, inspired
-   by wrapper from Erik Curiel (ecuriel AT kefta.com)
- - (djm) Crank version number to 0.5
- - (djm) Make this compile on Python 2.4, which lacks Py_ssize_t
-
-20071010
-- (djm) fix for Windows platforms: WSAStartup was not called, resulting
-  in failures inside getaddrinfo. Report from harpreet.sawhney AT gmail.com
-
-20060808
- - (djm) Support for Win32 (AF_INET6 is still broken though)
-
-20060628
- - (djm) Add RPM spec file
- - (djm) Hygene fixes: be more strict with types, use Python memory
-   allocators instead of libc malloc/free
-
-20050425
- - (djm) Fix bug that could corrupt some prefixes; reported by 
-   siganos AT cs.ucr.edu
- - (djm) Delete semicolons from EOL in test.py
- - (djm) Release py-radix-0.4
-
-20041123
- - (djm) Use RFC3849 IPv6 prefixes in documentation
- - (djm) Some stupid platforms still lack strl*, so avoid their use
- - (djm) Allow mixing of IPv4 and IPv6 prefixes in the same tree by keeping 
-   separate trees in the RadixObject for each AF
- - (djm) Release beta version: py-radix-0.3
-
-20041122
- - (djm) Raise a RuntimeWarning and abort iteration if the tree changes while
-   we are iterating over it
- - (djm) Add new regress tests: nodes() on an empty tree, iterate on an 
-   empty tree, modify tree while iterating, add/delete/check lots of prefixes
- - (djm) order and tidy regress test function names
- - (djm) Don't need to use a callback to do Radix.nodes(), so don't use one
- - (djm) Avoid callback for tree deletes too
- - (djm) GC unusued args to newRadixNodeObject
- - (djm) KNF and GC radix.h
- - (djm) unifdef radix.c
- - (djm) KNF radix.c (more remains)
- - (djm) Kill asserts() in radix.c, more KNF (starting to be readable now)
- - (djm) Implement Radix.prefixes() returning a list of prefix strings
- - (djm) Allow Radix methods to accept separate prefix lengths. E.g. 
-    method("xx.xx.xx.xx", yy)
- - (djm) Support keyword arguments for Radix methods. E.g. 
-   tree.add(network="127.0.0.1", masklen=32)
- - (djm) scrub off address bits past masklen, E.g. so tree.add("10.0.0.255/24")
-   creates an idential object to tree.add("10.0.0.0/24")
- - (djm) Regress tests for bad addresses and insane mask lengths
- - (djm) Support for binary packed addresses in Radix methods and a RadixNode
-    member
-
-20041121
- - (djm) Fix a bug: forgot to set the exception type when trying to get 
-   RadixNode members that don't exist
- - (djm) Prepare for Radix.method(address, masklen) by extending radix API
- - (djm) Add regression tests (not yet integrated with build)
- - (djm) Always allocate user objects in RadixNode
- - (djm) API change: don't allow creation of arbirtary members in RadixNode.
-   Instead, provide a data dict for storage of user-specified state. This 
-   avoid all of the introspection breakage of providing our get/setattr 
-   functions
- - (djm) Add RadixNode docstring
- - (djm) Add iterator support
- - (djm) Flesh out setup.py and add correct URL
- - (djm) Raise an exception when trying to mix V4 and V6 addresses in a single 
-   tree (rather than continuing and returning confusing results). Hopefully 
-   this will be fixed in the future
- - (djm) Release alpha version: py-radix-0.2
-
-20041118
- - (djm) Start the changelog
- - (djm) Release alpha version: py-radix-0.1
-
-$Id: ChangeLog,v 1.39 2007/12/18 02:49:01 djm Exp $
diff --git a/LICENSE b/LICENSE
index 6228d38..9b55be4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,22 @@
-The Python binding code is subject to this license:
+The latest (post-2014) Python code is subject to this license:
+
+/*
+ * Copyright (c) 2014 Michael J. Schultz <mjschultz at gmail.com>
+ *
+ * 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.
+ */
+
+The original (pre-2014) Python binding code is subject to this license:
 
 /*
  * Copyright (c) 2004 Damien Miller <djm at mindrot.org>
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index 07e9299..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,9 +0,0 @@
-ChangeLog
-LICENSE
-PKG-INFO
-README
-TODO
-radix.c
-radix.h
-radix_python.c
-setup.py
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..500c43f
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include LICENSE
+include README.rst
+include radix/_radix/*
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2c31db2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,12 @@
+bumpversion:
+	pip install bumpversion
+
+major minor patch: bumpversion
+	bumpversion $@
+	@echo "push via \`git push origin master --tags\`"
+
+clean:
+	find . -name '*.py[co]' -delete
+	find . -name '__pycache__' -delete
+	find . -name '*.so' -delete
+	rm -rf build/ dist/ *.egg *.egg-info/
diff --git a/PKG-INFO b/PKG-INFO
deleted file mode 100644
index ee55130..0000000
--- a/PKG-INFO
+++ /dev/null
@@ -1,20 +0,0 @@
-Metadata-Version: 1.0
-Name: py-radix
-Version: 0.5
-Summary: Radix tree for storage and retrieval of network prefixes
-Home-page: http://www.mindrot.org/py-radix.html
-Author: Damien Miller
-Author-email: djm at mindrot.org
-License: BSD
-Download-URL: http://www2.mindrot.org/files/py-radix/
-Description: py-radix is an implementation of a radix tree data structure 
-             for the storage and retrieval of IPv4 and IPv6 network prefixes.
-	     The radix tree is the data structure most commonly used for 
-	     routing table lookups. It efficiently stores network prefixes of 
-	     varying lengths and allows fast lookups of containing networks.
-Keywords: radix,tree,python,routing
-Classifier: Intended Audience :: Developers
-Classifier: License :: OSI Approved :: BSD License
-Classifier: Natural Language :: English
-Classifier: Programming Language :: Python
-Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README b/README.rst
similarity index 53%
rename from README
rename to README.rst
index 3a99e30..b95be3e 100644
--- a/README
+++ b/README.rst
@@ -1,26 +1,47 @@
-py-radix is an implementation of a radix tree data structure for the storage 
-and retrieval of IPv4 and IPv6 network prefixes.
+py-radix
+========
 
-The radix tree is the data structure most commonly used for routing table 
-lookups. It efficiently stores network prefixes of varying lengths and 
-allows fast lookups of containing networks.
+.. image:: https://pypip.in/v/py-radix/badge.png
+   :target: https://pypi.python.org/pypi/py-radix
 
-To install, use the standard Python distutils incantation:
+.. image:: https://travis-ci.org/mjschultz/py-radix.svg?branch=master
+   :target: https://travis-ci.org/mjschultz/py-radix
+
+.. image:: https://coveralls.io/repos/mjschultz/py-radix/badge.png?branch=master
+   :target: https://coveralls.io/r/mjschultz/py-radix?branch=master
+
+.. image:: https://pypip.in/d/py-radix/badge.png
+   :target: https://pypi.python.org/pypi/py-radix
+
+py-radix implements the radix tree data structure for the storage and
+retrieval of IPv4 and IPv6 network prefixes.
+
+The radix tree is commonly used for routing table lookups. It efficiently
+stores network prefixes of varying lengths and allows fast lookups of
+containing networks.
+
+Installation
+------------
+
+Installation is a breeze via pip: ::
+
+    pip install py-radix
+
+Or with the standard Python distutils incantation: ::
 
 	python setup.py build
 	python setup.py install
 
-Regression tests are in the test.py file.
+The C extension will be built for supported python versions. If you do not
+want the C extension, set the environment variable ``RADIX_NO_EXT=1``.
 
-py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
-implementation is taken (and modified) from MRTd and is subject to a 4-term 
-BSD license. See the LICENSE file for details.
+Tests are in the ``tests/`` directory and can be run with
+``python setup.py nosetests``.
 
-Please report bugs to Damien Miller <djm at mindrot.org>. Please check the TODO
-file first, in case your problem is something I already know about (please
-send patches!)
+Usage
+-----
 
-A simple example that demonstrates most of the features:
+A simple example that demonstrates most of the features: ::
 
 	import radix
 
@@ -60,6 +81,15 @@ A simple example that demonstrates most of the features:
 	# that contains the search term (routing-style lookup)
 	rnode = rtree.search_best("10.123.45.6")
 
+	# Worst-search will return the shortest matching prefix
+	# that contains the search term (inverse routing-style lookup)
+	rnode = rtree.search_worst("10.123.45.6")
+
+	# Covered search will return all prefixes inside the given
+	# search term, as a list (including the search term itself,
+	# if present in the tree)
+	rnodes = rtree.search_covered("10.123.0.0/16")
+
 	# There are a couple of implicit members of a RadixNode:
 	print rnode.network	# -> "10.0.0.0"
 	print rnode.prefix	# -> "10.0.0.0/8"
@@ -74,7 +104,7 @@ A simple example that demonstrates most of the features:
 	# Use the nodes() method to return all RadixNodes created
 	nodes = rtree.nodes()
 	for rnode in nodes:
-  		print rnode.prefix
+		print rnode.prefix
 
 	# The prefixes() method will return all the prefixes (as a
 	# list of strings) that have been entered
@@ -90,4 +120,25 @@ A simple example that demonstrates most of the features:
   		print rnode.prefix
 
 
-$Id: README,v 1.12 2004/11/24 20:46:18 djm Exp $
+License
+-------
+
+py-radix is licensed under a ISC/BSD licence. The underlying radix tree 
+implementation is taken (and modified) from MRTd and is subject to a 4-term 
+BSD license. See the LICENSE file for details.
+
+Contributing
+------------
+
+Please report bugs via GitHub at https://github.com/mjschultz/py-radix/issues.
+Code changes can be contributed through a pull request on GitHub or emailed
+directly to me <mjschultz at gmail.com>.
+
+The main portions of the directory tree are as follows: ::
+
+    .
+    ├── radix/*.py      # Pure Python code
+    ├── radix/_radix.c  # C extension code (compatible with pure python code)
+    ├── radix/_radix/*  # C extension code (compatible with pure python code)
+    ├── tests/          # Tests (regression and unit)
+    └── setup.py        # Standard setup.py for installation/testing/etc.
diff --git a/TODO b/TODO
deleted file mode 100644
index 83bb387..0000000
--- a/TODO
+++ /dev/null
@@ -1,24 +0,0 @@
-Fix bug(?) on Win32: getaddrinfo doesn't seem to parse IPv6 addresses
-
-- Maybe Extend Radix methods to accept (network, mask) (contiguous masks only)
-
-- tree.delete(RadixNode)
-
-tree.copy()
-
-more KNF
-
-tree.search_all_containing(network) -> [ network, network ] (sorted by prefix)
-(use search_best2 internally)
-
-tree.search_containing(network) -> RadixNode or None
- Find the prefix containing 'network', not including an exact match. 
-
-tree.num_prefixes()
-
-dict-like interface:
-	tree[addr] = user_object
-
-"blur" prefix - reduce masklen
-
-$Id: TODO,v 1.24 2007/12/18 00:53:53 djm Exp $
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..d2cd1e8
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,19 @@
+environment:
+  matrix:
+    - PYTHON: "C:\\Python27"
+    - PYTHON: "C:\\Python33"
+    - PYTHON: "C:\\Python34"
+    - PYTHON: "C:\\Python35"
+    - PYTHON: "C:\\Python27-x64"
+    - PYTHON: "C:\\Python33-x64"
+    - PYTHON: "C:\\Python34-x64"
+    - PYTHON: "C:\\Python35-x64"
+
+install:
+  # We need wheel installed to build wheels
+  - "%PYTHON%\\python.exe setup.py install"
+
+build: off
+
+test_script:
+  - "%PYTHON%\\python.exe setup.py test"
diff --git a/inet_ntop.c b/inet_ntop.c
deleted file mode 100644
index d3db3ce..0000000
--- a/inet_ntop.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/*	$OpenBSD: inet_ntop.c,v 1.7 2005/08/06 20:30:03 espie Exp $	*/
-
-/* Copyright (c) 1996 by Internet Software Consortium.
- *
- * 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM 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.
- */
-
-#include "radix.h"
-#include <sys/types.h>
-#include <string.h>
-#include <errno.h>
-#include <stdio.h>
-
-#ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT EINVAL
-#endif
-#ifndef IN6ADDRSZ
-# define IN6ADDRSZ 16
-#endif
-#ifndef INT16SZ
-# define INT16SZ 2
-#endif
-
-/*
- * WARNING: Don't even consider trying to compile this on a system where
- * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
- */
-
-static const char *inet_ntop4(const u_char *src, char *dst, size_t size);
-static const char *inet_ntop6(const u_char *src, char *dst, size_t size);
-
-/* char *
- * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
- * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
- * author:
- *	Paul Vixie, 1996.
- */
-const char *
-inet_ntop(int af, const void *src, char *dst, size_t size)
-{
-	switch (af) {
-	case AF_INET:
-		return (inet_ntop4(src, dst, size));
-	case AF_INET6:
-		return (inet_ntop6(src, dst, size));
-	default:
-		errno = EAFNOSUPPORT;
-		return (NULL);
-	}
-	/* NOTREACHED */
-}
-
-/* const char *
- * inet_ntop4(src, dst, size)
- *	format an IPv4 address, more or less like inet_ntoa()
- * return:
- *	`dst' (as a const)
- * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop4(const u_char *src, char *dst, size_t size)
-{
-	static const char fmt[] = "%u.%u.%u.%u";
-	char tmp[sizeof "255.255.255.255"];
-	int l;
-
-	l = snprintf(tmp, size, fmt, src[0], src[1], src[2], src[3]);
-	if (l <= 0 || (unsigned)l >= size) {
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
-
-/* const char *
- * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
- * author:
- *	Paul Vixie, 1996.
- */
-static const char *
-inet_ntop6(const u_char *src, char *dst, size_t size)
-{
-	/*
-	 * Note that int32_t and int16_t need only be "at least" large enough
-	 * to contain a value of the specified size.  On some systems, like
-	 * Crays, there is no such thing as an integer variable with 16 bits.
-	 * Keep this in mind if you think this function should have been coded
-	 * to use pointer overlays.  All the world's not a VAX.
-	 */
-	char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-	char *tp, *ep;
-	struct { int base, len; } best, cur;
-	u_int words[IN6ADDRSZ / INT16SZ];
-	int i;
-	int advance;
-
-	/*
-	 * Preprocess:
-	 *	Copy the input (bytewise) array into a wordwise array.
-	 *	Find the longest run of 0x00's in src[] for :: shorthanding.
-	 */
-	memset(words, '\0', sizeof words);
-	for (i = 0; i < IN6ADDRSZ; i++)
-		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
-	best.base = -1;
-	cur.base = -1;
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) {
-		if (words[i] == 0) {
-			if (cur.base == -1)
-				cur.base = i, cur.len = 1;
-			else
-				cur.len++;
-		} else {
-			if (cur.base != -1) {
-				if (best.base == -1 || cur.len > best.len)
-					best = cur;
-				cur.base = -1;
-			}
-		}
-	}
-	if (cur.base != -1) {
-		if (best.base == -1 || cur.len > best.len)
-			best = cur;
-	}
-	if (best.base != -1 && best.len < 2)
-		best.base = -1;
-
-	/*
-	 * Format the result.
-	 */
-	tp = tmp;
-	ep = tmp + sizeof(tmp);
-	for (i = 0; i < (IN6ADDRSZ / INT16SZ) && tp < ep; i++) {
-		/* Are we inside the best run of 0x00's? */
-		if (best.base != -1 && i >= best.base &&
-		    i < (best.base + best.len)) {
-			if (i == best.base) {
-				if (tp + 1 >= ep)
-					return (NULL);
-				*tp++ = ':';
-			}
-			continue;
-		}
-		/* Are we following an initial run of 0x00s or any real hex? */
-		if (i != 0) {
-			if (tp + 1 >= ep)
-				return (NULL);
-			*tp++ = ':';
-		}
-		/* Is this address an encapsulated IPv4? */
-		if (i == 6 && best.base == 0 &&
-		    (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
-			if (!inet_ntop4(src+12, tp, (size_t)(ep - tp)))
-				return (NULL);
-			tp += strlen(tp);
-			break;
-		}
-		advance = snprintf(tp, ep - tp, "%x", words[i]);
-		if (advance <= 0 || advance >= ep - tp)
-			return (NULL);
-		tp += advance;
-	}
-	/* Was it a trailing run of 0x00's? */
-	if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) {
-		if (tp + 1 >= ep)
-			return (NULL);
-		*tp++ = ':';
-	}
-	if (tp + 1 >= ep)
-		return (NULL);
-	*tp++ = '\0';
-
-	/*
-	 * Check for overflow, copy, and we're done.
-	 */
-	if ((size_t)(tp - tmp) > size) {
-		errno = ENOSPC;
-		return (NULL);
-	}
-	strlcpy(dst, tmp, size);
-	return (dst);
-}
diff --git a/py-radix.spec b/py-radix.spec
deleted file mode 100644
index a6d41b3..0000000
--- a/py-radix.spec
+++ /dev/null
@@ -1,44 +0,0 @@
-Name: py-radix
-Summary: Radix tree data structure for Python
-Version: 0.5
-Release: 1
-Source0: http://www2.mindrot.org/files/py-radix/py-radix-%{version}.tar.gz
-License: BSD
-Group: Development/Libraries
-BuildRoot: %{_tmppath}/%{name}-buildroot
-Requires: %{__python}
-BuildRequires: python-devel, gcc
-Url: http://www.mindrot.org/py-radix.html
-
-%description
-py-radix is an implementation of a radix tree for Python, which 
-supports storage and lookups of IPv4 and IPv6 networks. 
-
-The radix tree (a.k.a Patricia tree) is the data structure most 
-commonly used for routing table lookups. It efficiently stores 
-network prefixes of varying lengths and allows fast lookups of 
-containing networks. py-radix's implementation is built solely 
-for networks (the data structure itself is more general). 
-
-%prep
-%setup
-
-%build
-%{__python} setup.py build
-
-%install
-%{__python} setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
-sed -e 's|/[^/]*$||' INSTALLED_FILES | grep "site-packages/" | \
-    sort | uniq | awk '{ print "%attr(755,root,root) %dir " $1}' > INSTALLED_DIRS
-cat INSTALLED_FILES INSTALLED_DIRS > INSTALLED_OBJECTS
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files -f INSTALLED_OBJECTS
-%defattr(-,root,root)
-%doc LICENSE README TODO ChangeLog
-
-%changelog
-* Wed Jun 28 2006 Damien Miller <djm at mindrot.org>
-- Build RPM
diff --git a/radix.c b/radix.c
deleted file mode 100644
index fbb4244..0000000
--- a/radix.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright (c) 1999-2000
- *
- * The Regents of the University of Michigan ("The Regents") and
- * Merit Network, Inc. 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.
- *
- * 3. All advertising materials mentioning features or use of
- * this software must display the following acknowledgement:
- *
- *   This product includes software developed by the University of
- *   Michigan, Merit Network, Inc., and their contributors.
- *
- * 4. Neither the name of the University, Merit Network, nor the
- * names of their contributors may be used to endorse or
- * promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "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 TH E REGENTS
- * OR CONTRIBUTORS 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) HO WEVER 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.
- */
-/*
- * Portions Copyright (c) 2004,2005 Damien Miller <djm at mindrot.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.
- */
-
-#include "Python.h"
-
-#include <sys/types.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "radix.h"
-
-/* $Id: radix.c,v 1.17 2007/10/24 06:04:31 djm Exp $ */
-
-/*
- * Originally from MRT include/defs.h
- * $MRTId: defs.h,v 1.1.1.1 2000/08/14 18:46:10 labovit Exp $
- */
-#define BIT_TEST(f, b)  ((f) & (b))
-
-/*
- * Originally from MRT include/mrt.h
- * $MRTId: mrt.h,v 1.1.1.1 2000/08/14 18:46:10 labovit Exp $
- */
-#define prefix_tochar(prefix)		((char *)&(prefix)->add)
-#define prefix_touchar(prefix)		((u_char *)&(prefix)->add)
-
-/*
- * Originally from MRT lib/mrt/prefix.c
- * $MRTId: prefix.c,v 1.1.1.1 2000/08/14 18:46:11 labovit Exp $
- */
-
-static int
-comp_with_mask(u_char *addr, u_char *dest, u_int mask)
-{
-	if (memcmp(addr, dest, mask / 8) == 0) {
-		u_int n = mask / 8;
-		u_int m = ((~0) << (8 - (mask % 8)));
-
-		if (mask % 8 == 0 || (addr[n] & m) == (dest[n] & m))
-			return (1);
-	}
-	return (0);
-}
-
-static prefix_t 
-*New_Prefix2(int family, void *dest, int bitlen, prefix_t *prefix)
-{
-	int dynamic_allocated = 0;
-	int default_bitlen = 32;
-
-	if (family == AF_INET6) {
-		default_bitlen = 128;
-		if (prefix == NULL) {
-			if ((prefix = PyMem_Malloc(sizeof(*prefix))) == NULL)
-				return (NULL);
-			memset(prefix, '\0', sizeof(*prefix));
-			dynamic_allocated++;
-		}
-		memcpy(&prefix->add.sin6, dest, 16);
-	} else if (family == AF_INET) {
-		if (prefix == NULL) {
-			if ((prefix = PyMem_Malloc(sizeof(*prefix))) == NULL)
-				return (NULL);
-			memset(prefix, '\0', sizeof(*prefix));
-			dynamic_allocated++;
-		}
-		memcpy(&prefix->add.sin, dest, 4);
-	} else
-		return (NULL);
-
-	prefix->bitlen = (bitlen >= 0) ? bitlen : default_bitlen;
-	prefix->family = family;
-	prefix->ref_count = 0;
-	if (dynamic_allocated)
-		prefix->ref_count++;
-	return (prefix);
-}
-
-
-static prefix_t 
-*Ref_Prefix(prefix_t *prefix)
-{
-	if (prefix == NULL)
-		return (NULL);
-	if (prefix->ref_count == 0) {
-		/* make a copy in case of a static prefix */
-		return (New_Prefix2(prefix->family, &prefix->add,
-		    prefix->bitlen, NULL));
-	}
-	prefix->ref_count++;
-	return (prefix);
-}
-
-
-void
-Deref_Prefix(prefix_t *prefix)
-{
-	if (prefix == NULL)
-		return;
-	prefix->ref_count--;
-	if (prefix->ref_count <= 0) {
-		PyMem_Free(prefix);
-		return;
-	}
-}
-
-/*
- * Originally from MRT lib/radix/radix.c
- * $MRTId: radix.c,v 1.1.1.1 2000/08/14 18:46:13 labovit Exp $
- */
-
-/* these routines support continuous mask only */
-
-radix_tree_t
-*New_Radix(void)
-{
-	radix_tree_t *radix;
-
-	if ((radix = PyMem_Malloc(sizeof(*radix))) == NULL)
-		return (NULL);
-	memset(radix, '\0', sizeof(*radix));
-
-	radix->maxbits = 128;
-	radix->head = NULL;
-	radix->num_active_node = 0;
-	return (radix);
-}
-
-/*
- * if func is supplied, it will be called as func(node->data)
- * before deleting the node
- */
-static void
-Clear_Radix(radix_tree_t *radix, rdx_cb_t func, void *cbctx)
-{
-	if (radix->head) {
-		radix_node_t *Xstack[RADIX_MAXBITS + 1];
-		radix_node_t **Xsp = Xstack;
-		radix_node_t *Xrn = radix->head;
-
-		while (Xrn) {
-			radix_node_t *l = Xrn->l;
-			radix_node_t *r = Xrn->r;
-
-			if (Xrn->prefix) {
-				Deref_Prefix(Xrn->prefix);
-				if (Xrn->data && func)
-					func(Xrn, cbctx);
-			}
-			PyMem_Free(Xrn);
-			radix->num_active_node--;
-
-			if (l) {
-				if (r)
-					*Xsp++ = r;
-				Xrn = l;
-			} else if (r) {
-				Xrn = r;
-			} else if (Xsp != Xstack) {
-				Xrn = *(--Xsp);
-			} else {
-				Xrn = (radix_node_t *) 0;
-			}
-		}
-	}
... 5384 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/py-radix.git



More information about the Python-modules-commits mailing list