summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog209
-rw-r--r--debian/clean4
-rw-r--r--debian/compat1
-rw-r--r--debian/control61
-rw-r--r--debian/copyright181
-rw-r--r--debian/libmowgli-2-0.install1
-rw-r--r--debian/libmowgli-2-0.lintian-overrides1
-rw-r--r--debian/libmowgli-2-0.symbols349
-rw-r--r--debian/libmowgli-2-dev.docs2
-rw-r--r--debian/libmowgli-2-dev.examples2
-rw-r--r--debian/libmowgli-2-dev.install3
-rw-r--r--debian/patches/001-Disable_Makefile_silent_output.diff14
-rw-r--r--debian/patches/002-Make-Examples-Buildable-standalone.diff302
-rw-r--r--debian/patches/003-Fix-machine.h.diff11
-rw-r--r--debian/patches/004-No-openssl.diff15
-rw-r--r--debian/patches/series4
-rwxr-xr-xdebian/rules45
-rw-r--r--debian/source/format1
-rw-r--r--debian/watch4
-rw-r--r--src/libmowgli/core/Makefile32
-rw-r--r--src/libmowgli/core/alloc.c238
-rw-r--r--src/libmowgli/core/alloc.h38
-rw-r--r--src/libmowgli/core/allocation_policy.c70
-rw-r--r--src/libmowgli/core/allocation_policy.h44
-rw-r--r--src/libmowgli/core/allocator.c46
-rw-r--r--src/libmowgli/core/allocator.h29
-rw-r--r--src/libmowgli/core/assert.h60
-rw-r--r--src/libmowgli/core/bootstrap.c82
-rw-r--r--src/libmowgli/core/bootstrap.h29
-rw-r--r--src/libmowgli/core/heap.c374
-rw-r--r--src/libmowgli/core/heap.h48
-rw-r--r--src/libmowgli/core/iterator.h44
-rw-r--r--src/libmowgli/core/logger.c95
-rw-r--r--src/libmowgli/core/logger.h62
-rw-r--r--src/libmowgli/core/mowgli_string.c201
-rw-r--r--src/libmowgli/core/mowgli_string.h53
-rw-r--r--src/libmowgli/core/process.c123
-rw-r--r--src/libmowgli/core/process.h38
-rw-r--r--src/libmowgli/core/stdinc.h109
39 files changed, 1815 insertions, 1210 deletions
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index ce5599f..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,209 +0,0 @@
-libmowgli-2 (2.1.0-2) unstable; urgency=medium
-
- * Orphan.
-
- -- Andrej Shadura <andrewsh@debian.org> Tue, 24 Apr 2018 16:52:34 +0200
-
-libmowgli-2 (2.1.0-1) unstable; urgency=medium
-
- * New upstream release.
-
- -- Andrew Shadura <andrewsh@debian.org> Tue, 05 Jul 2016 15:42:56 +0200
-
-libmowgli-2 (2.0.0+git20140224.89982cf4-2) unstable; urgency=medium
-
- * Upload to unstable.
- * Update debian/watch.
-
- -- Andrew Shadura <andrewsh@debian.org> Tue, 05 Jul 2016 15:38:49 +0200
-
-libmowgli-2 (2.0.0+git20140224.89982cf4-1) experimental; urgency=medium
-
- * New upstream snapshot (Closes: #741518).
- * Refresh patches.
- * Update symbols file.
- * Update the home page URL (Closes: #747383).
- * Add pkg-config dependency (Closes: #747336).
-
- -- Andrew Shadura <andrewsh@debian.org> Wed, 18 Jun 2014 23:36:06 +0200
-
-libmowgli-2 (2.0.0-3) unstable; urgency=medium
-
- * Fix symbols, unbreak build on kFreeBSD.
- * Update the home page URL (Closes: #747383).
- * Add pkg-config dependency (Closes: #747336).
-
- -- Andrew Shadura <andrewsh@debian.org> Wed, 18 Jun 2014 23:41:26 +0200
-
-libmowgli-2 (2.0.0-2) unstable; urgency=medium
-
- * Add missing licenses to debian/copyright (Closes: #741436).
- * Fix build on unsupported architectures and Hurd (Closes: #745608).
-
- -- Andrew Shadura <andrewsh@debian.org> Tue, 17 Jun 2014 10:16:10 +0200
-
-libmowgli-2 (2.0.0-1) unstable; urgency=low
-
- * New major upstream release (Closes: #676964).
- * Update copyright file.
-
- -- Andrew Shadura <andrewsh@debian.org> Tue, 28 Jan 2014 15:45:25 +0100
-
-libmowgli (1.0.0-4) unstable; urgency=low
-
- * Update config.sub and config.guess on build (Closes: #727414).
- * Build-depend on autotools-dev to have fresh config.* files.
-
- -- Andrew Shadura <andrewsh@debian.org> Mon, 27 Jan 2014 19:54:50 +0100
-
-libmowgli (1.0.0-3) unstable; urgency=low
-
- * Fix arch-dependent files in -dev package (Closes: #670014).
-
- -- Andrew Shadura <andrewsh@debian.org> Wed, 23 Oct 2013 11:57:40 +0200
-
-libmowgli (1.0.0-2) unstable; urgency=low
-
- * Update Standards-Version to 3.9.4 (no changes).
- * Fix FTBFS with latest debhelper (Closes: #724183).
- * Fix arch-dependent files in -dev package (Closes: #670014).
-
- -- Andrew Shadura <andrewsh@debian.org> Tue, 22 Oct 2013 15:30:44 +0200
-
-libmowgli (1.0.0-1) unstable; urgency=low
-
- * New maintainer
- * New upstream release (Closes: #647748, #559181, #590064)
- * Switch to 3.0 (quilt) format, drop README.source
- * Bump Standards-Version to 3.9.3
- * Don't compress examples source code
- * Use dpkg-buildflags
- * Update Homepage field
- * Update copyright file
- * Update package descriptions
- * Update symbols file
- * Update watch file
- * Run autoreconf during build, stop using autotools-dev
- * Use debian/clean to clean up after build
- * Remove duplicate Section fields in debian/control
- * Update Vcs-* fields
- * Add lintian override for exception handling code calling exit(3)
- * Don't try to install make dependency bits along with examples
- * Add multiarch support:
- - raise debhelper compatibility level to 9
- - raise debhelper build-dependency to 9
- - add Pre-Depends to the binary package
- - change install files to use multiarch paths
- - use Multi-Arch: same for binary packages
- - strip multiarch paths from buildsys.mk installed
- along with examples
-
- -- Andrew O. Shadura <bugzilla@tut.by> Mon, 02 Apr 2012 15:04:06 +0200
-
-libmowgli (0.7.1-1) unstable; urgency=low
-
- * New upstream version
- * Update patch 001-Disable_Makefile_silent_output.diff
- Update 001-Disable_Makefile_silent_output.diff for
- current makefile
- * Remove 'a' from package description
- (Closes: #500944)
-
- -- Patrick Schoenfeld <schoenfeld@debian.org> Tue, 22 Feb 2011 16:21:44 +0100
-
-libmowgli (0.7.0-3) unstable; urgency=low
-
- * Upload to sid (Closes: #559181, #590064)
- * Update watch file
- * Update the Vcs-uris to reflection the migration git
- * Switch to debhelper 7
- * Switch to quilt as patch management system
- * Update Standards-Version, changes needed:
- + Update section of libmowgli2-dbg to 'debug'
- * Add missing misc:Depends in libmowgli-dev and libmowgli2-dbg control
- information
- * Remove Adam Cécile from uploaders
- * Fix watch file (again)
- (Closes: #486575)
-
- -- Patrick Schoenfeld <schoenfeld@debian.org> Tue, 22 Feb 2011 15:26:10 +0100
-
-libmowgli (0.7.0-2) experimental; urgency=low
-
- * Upload to experimental because lenny is frozen
- * Replace (C) with © because of its legal entitlement (in debian/copyright)
-
- -- Patrick Schoenfeld <schoenfeld@debian.org> Wed, 17 Sep 2008 16:21:14 +0200
-
-libmowgli (0.7.0-1) experimental; urgency=low
-
- * Upload to experimental because lenny is frozen
- * New upstream version
- * Updated maintainer email address
- * Adapt the packagename, because of the bumped SONAME
- * Remove 003-dont-call-exit-where-its-not-appropriate.dpatch because
- changes were applied upstream
- * Fix watch file, broken due to change in upstream site. Thanks to Tim Retout
- for the bug report and the patch.
- (Closes: #486575)
- * Fixed a spelling error in the long description of libmowgli2
- (application -> applications)
- * Remove introduction texts from descriptions that are not aimed at
- developers, because its not interesting for endusers
- * Fix indentation in debian/copyright
- * Update upstream homepage in debian/control and debian/changelog
- * Updated copyright file
- * Add debian/README.source to document patch handling for compliance
- with updated policy
- * Bump Standards-version to 3.8.0
-
- -- Patrick Schoenfeld <schoenfeld@debian.org> Wed, 17 Sep 2008 10:46:27 +0200
-
-libmowgli (0.6.1-1) unstable; urgency=low
-
- * New upstream release (Closes: #463604)
- * Added Vcs-Headers
- * Introducing William Pitcock as a new co-maintainer
- * Added a symbols file for dpkg-gensymbols to enable more relaxed
- dependencies for packages that depend on libmowgli
- * Added a patch (backport of changes in upstream mercurial repository) to
- fix the inappropriate call of exit in the library (Closes: #465740)
- * Reworked the copyright file to make licensing and copyright informations
- more clear and fix errors in old copyright file.
- * Changed order of dh_makeshlibs and dh_fixperms in debian/rules to avoid
- problems with permissions that occur under some conditions
- * Changed call to dh_makeshlibs so that it produces a versioned shlibs file
- * Some changes to the package descriptions so its more clear for what the
- different binary packages are used
-
- -- Patrick Schoenfeld <schoenfeld@in-medias-res.com> Thu, 10 Jan 2008 08:41:59 +0100
-
-libmowgli (0.6.0-1) unstable; urgency=low
-
- * New upstream release
- (Closes: #458410)
- * Removed patch for wrong SONAME (it was integrated upstream)
- * Updated Standards Version
-
- -- Patrick Schoenfeld <schoenfeld@in-medias-res.com> Mon, 31 Dec 2007 14:47:12 +0100
-
-libmowgli (0.5.0-3) unstable; urgency=low
-
- * Updated upstream domain, because the old domain seems not to be
- available any more (Closes: #450201)
- * Changed priority of libmowgli1-dbg to be extra to fix override disparity
-
- -- Patrick Schoenfeld <schoenfeld@in-medias-res.com> Thu, 08 Nov 2007 06:52:28 +0100
-
-libmowgli (0.5.0-2) unstable; urgency=low
-
- * Fixed issues with copyright file (Accidentally we stated that the library
- ilicensed under the terms of the BSD license)
-
- -- Patrick Schoenfeld <schoenfeld@in-medias-res.com> Wed, 24 Oct 2007 21:14:58 +0200
-
-libmowgli (0.5.0-1) unstable; urgency=low
-
- * Initial release (Closes: #444334, #447410).
-
- -- Patrick Schoenfeld <schoenfeld@in-medias-res.com> Wed, 10 Oct 2007 15:53:56 +0200
diff --git a/debian/clean b/debian/clean
deleted file mode 100644
index 92d8807..0000000
--- a/debian/clean
+++ /dev/null
@@ -1,4 +0,0 @@
-.deps src/.deps src/*/.deps src/*/*/.deps buildsys.mk config.log config.status extra.mk *.pc
-src/libmowgli/*/*.dep
-src/libmowgli/platform/autoconf.h
-config.sub config.guess configure config.rpath
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index ec63514..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-9
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 7828458..0000000
--- a/debian/control
+++ /dev/null
@@ -1,61 +0,0 @@
-Source: libmowgli-2
-Priority: optional
-Maintainer: Debian QA Group <packages@qa.debian.org>
-Build-Depends: debhelper (>= 9), dh-autoreconf, autotools-dev
-Standards-Version: 3.9.5
-Homepage: http://www.atheme.org/projects/libmowgli.html
-Vcs-Git: https://git.dgit.debian.org/libmowgli-2
-Vcs-Browser: https://browse.dgit.debian.org/libmowgli-2.git/
-Section: libs
-
-Package: libmowgli-2-dev
-Section: libdevel
-Architecture: any
-Depends:
- libmowgli-2-0 (= ${binary:Version}),
- ${misc:Depends},
- pkgconf | pkg-config
-Multi-Arch: same
-Description: high performance development framework for C (development)
- Mowgli is a development framework for C (like GLib), which provides high
- performance and highly flexible algorithms. It can be used as a supplement
- to GLib (to add additional functions (dictionaries, hashes), or replace some
- of the slow GLib list manipulation functions), or stand alone. It also
- provides a powerful hook system and convenient logging for your code, as well
- as high performance block allocator.
- .
- This package contains files needed for development with this library and code
- examples.
-
-Package: libmowgli-2-0
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Pre-Depends: ${misc:Pre-Depends}
-Multi-Arch: same
-Description: high performance development framework for C
- Mowgli is a development framework for C (like GLib), which provides high
- performance and highly flexible algorithms. It can be used as a supplement
- to GLib (to add additional functions (dictionaries, hashes), or replace some
- of the slow GLib list manipulation functions), or stand alone. It also
- provides a powerful hook system and convenient logging for your code, as well
- as high performance block allocator.
- .
- This package contains the shared library needed to run programs that use the
- mowgli library.
-
-Package: libmowgli-2-0-dbg
-Priority: extra
-Section: debug
-Architecture: any
-Depends: libmowgli-2-0 (= ${binary:Version}), ${misc:Depends}
-Multi-Arch: same
-Description: high performance development framework for C (debug)
- Mowgli is a development framework for C (like GLib), which provides high
- performance and highly flexible algorithms. It can be used as a supplement
- to GLib (to add additional functions (dictionaries, hashes), or replace some
- of the slow GLib list manipulation functions), or stand alone. It also
- provides a powerful hook system and convenient logging for your code, as well
- as high performance block allocator.
- .
- This package contains the debug symbols needed to create meaningful backtraces
- for applications that use the mowgli library.
diff --git a/debian/copyright b/debian/copyright
deleted file mode 100644
index 0eb2a30..0000000
--- a/debian/copyright
+++ /dev/null
@@ -1,181 +0,0 @@
-This package was debianized by:
- Patrick Schoenfeld <schoenfeld@in-medias-res.com>
- Adam Cécile (Le_Vert) <gandalf@le-vert.net>
-on Wed, 10 Oct 2007 13:15:01 +0200.
-
-It was downloaded from http://www.atheme.org/project/mowgli
-
-Copyright:
- © 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
- © 2007-2008 Jilles Tjoelker <jilles@stack.nl>
- © 2005-2006 Theo Julienne <terminal -at- atheme.org>
- © 2007 Pippijn van Steenhoven <pippijn -at- one09.net>
- © 2007 Giacomo Lozito <james -at- develia.org>
- © 1999-2007 Takuji Nishimura and Makoto Matsumoto
- © 2007 Jonathan Schleifer <js-buildsys@webkeks.org>
- © 2012 Elizabeth Myers <elizabeth -at- sporksmoo.net>
- © 2011 Andrew Wilcox <awilcox -at- wilcox-tech.com>
- © 2012-2013 Patrick McFarland <pmcfarland@adterrasperaspera.com>
- © 2012 Alex Iadicicco <alex -at- ajitek.net>
-
-License (for everything except the exceptions listed below):
- Atheme License (ISC derivate):
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice is present in all copies.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT OWNER
- 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) 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.
-
-On Debian systems, the complete text of the GNU Lesser General
-Public License version 2 can be found in `/usr/share/common-licenses/LGPL-2'.
-
-Files: src/libmowgli/ext/getopt_long.*
-License:
- Copyright (c) 2000 The NetBSD Foundation, Inc.
- All rights reserved.
- .
- This code is derived from software contributed to The NetBSD Foundation
- by Dieter Baron and Thomas Klausner.
- .
- 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 NETBSD FOUNDATION, INC. 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 THE FOUNDATION 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) 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.
-
-Files:
- src/libmowgli/platform/win32/socketpair.c
-Copyright:
- 2007, 2010 by Nathan C. Myers <ncm@cantrip.org>
-License:
- This code is Free Software. It may be copied freely, in original or
- modified form, subject only to the restrictions that (1) the author is
- relieved from all responsibilities for any use for any purpose, and (2)
- this copyright notice must be retained, unchanged, in its entirety. If
- for any reason the author might be held responsible for any consequences
- of copying or use, license is withheld.
-
-Files:
- src/libmowgli/container/patricia.*
- src/libmowgli/dns/dns_evloop_reslib.c
- src/examples/formattertest/formattertest.c
- src/examples/libevent-bench/bench.c
- src/examples/listsort/listsort.c
- src/examples/patriciatest/patriciatest.c
- src/examples/patriciatest2/patriciatest2.c
- src/examples/randomtest/randomtest.c
-Copyright:
- (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
- (c) 2007-2010 Jilles Tjoelker <jilles -at- stack.nl>
- (c) 2003 Niels Provos <provos@citi.umich.edu>
- (c) 1985, 1993 The Regents of the University of California. All rights reserved.
-License:
-
- Additional copyright for algorithm in randomtest.c:
- © 1999-2007 Takuji Nishimura and Makoto Matsumoto
-
- 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. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
- 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.
-
-Additional copyrights for dns_evloop_reslib.c:
- Portions Copyright (c) 1993 by Digital Equipment Corporation.
- Portions Copyright (c) 1996-1999 by Internet Software Consortium.
-with original license:
- 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.
-
-Additional copyright for mowgli_string.c:
- Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
-
-Files:
- src/examples/vio-udplistener/vio-udplistener.c
- src/examples/async_resolver/async_resolver.c
-License:
- Public domain
-
-Files:
- src/libmowgli/ext/proctitle.c
-Copyright:
- (c) 2000-2011, PostgreSQL Global Development Group
-License:
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose, without fee, and without a written agreement
- is hereby granted, provided that the above copyright notice and this
- paragraph and the following two paragraphs appear in all copies.
- .
- IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
- LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
- DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
- .
- THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
- PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
-The Debian packaging is :
- Copyright (c) 2007 Adam Cécile (Le_Vert) <gandalf@le-vert.net>
- Copyright (c) 2007 Patrick Schoenfeld <schoenfeld@in-medias-res.com>
- Copyright (c) 2012-2014 Andrew Shadura <andrewsh@debian.org>
-and is licensed under the GPL-2, see `/usr/share/common-licenses/GPL-2'.
diff --git a/debian/libmowgli-2-0.install b/debian/libmowgli-2-0.install
deleted file mode 100644
index 3ddde58..0000000
--- a/debian/libmowgli-2-0.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/*/lib*.so.*
diff --git a/debian/libmowgli-2-0.lintian-overrides b/debian/libmowgli-2-0.lintian-overrides
deleted file mode 100644
index 9ca7dde..0000000
--- a/debian/libmowgli-2-0.lintian-overrides
+++ /dev/null
@@ -1 +0,0 @@
-libmowgli-2-0 binary: shlib-calls-exit usr/lib/*/libmowgli-2.so.0.0.0
diff --git a/debian/libmowgli-2-0.symbols b/debian/libmowgli-2-0.symbols
deleted file mode 100644
index 74b9754..0000000
--- a/debian/libmowgli-2-0.symbols
+++ /dev/null
@@ -1,349 +0,0 @@
-libmowgli-2.so.0 libmowgli-2-0 #MINVER#
- (arch=linux-any)_mowgli_epoll_pollops@Base 2.0.0
- (arch=kfreebsd-any)_mowgli_kqueue_pollops@Base 2.0.0
- _mowgli_log_buf@Base 2.0.0+git20140224
- _mowgli_log_cb@Base 2.0.0+git20140224
- _mowgli_null_mutex_ops@Base 2.0.0
- _mowgli_null_pollops@Base 2.0.0
- _mowgli_poll_pollops@Base 2.0.0
- _mowgli_posix_mutex_ops@Base 2.0.0
- _mowgli_select_pollops@Base 2.0.0
- cacheline_size@Base 2.0.0+git20140224
- mowgli_alloc@Base 0.7.0
- mowgli_alloc_array@Base 0.7.0
- mowgli_alloc_array_using_policy@Base 2.0.0
- mowgli_alloc_using_policy@Base 2.0.0
- mowgli_allocation_policy_bootstrap@Base 2.0.0
- mowgli_allocation_policy_create@Base 0.7.0
- mowgli_allocation_policy_lookup@Base 0.7.0
- mowgli_allocator_bootstrap@Base 2.0.0
- mowgli_allocator_malloc@Base 0.7.0
- mowgli_allocator_set_policy@Base 0.7.0
- mowgli_allocator_set_policy_by_name@Base 0.7.0
- mowgli_argc@Base 2.0.0+git20140224
- mowgli_argstack_bootstrap@Base 2.0.0
- mowgli_argstack_create@Base 0.7.0
- mowgli_argstack_create_from_va_list@Base 0.7.0
- mowgli_argstack_pop_boolean@Base 0.7.0
- mowgli_argstack_pop_numeric@Base 0.7.0
- mowgli_argstack_pop_pointer@Base 0.7.0
- mowgli_argstack_pop_string@Base 0.7.0
- mowgli_argv@Base 2.0.0+git20140224
- mowgli_bitvector_bootstrap@Base 2.0.0
- mowgli_bitvector_combine@Base 0.7.0
- mowgli_bitvector_compare@Base 0.7.0
- mowgli_bitvector_create@Base 0.7.0
- mowgli_bitvector_get@Base 0.7.0
- mowgli_bitvector_set@Base 0.7.0
- mowgli_bitvector_xor@Base 0.7.0
- mowgli_cacheline_bootstrap@Base 2.0.0+git20140224
- mowgli_cacheline_size@Base 2.0.0+git20140224
- mowgli_config_file_free@Base 2.0.0
- mowgli_config_file_load@Base 2.0.0
- mowgli_dictionary_add@Base 0.7.0
- mowgli_dictionary_create@Base 0.7.0
- mowgli_dictionary_create_named@Base 0.7.0
- mowgli_dictionary_delete@Base 0.7.0
- mowgli_dictionary_destroy@Base 0.7.0
- mowgli_dictionary_find@Base 0.7.0
- mowgli_dictionary_foreach@Base 0.7.0
- mowgli_dictionary_foreach_cur@Base 0.7.0
- mowgli_dictionary_foreach_next@Base 0.7.0
- mowgli_dictionary_foreach_start@Base 0.7.0
- mowgli_dictionary_get_comparator_func@Base 0.7.0
- mowgli_dictionary_get_linear_index@Base 0.7.0
- mowgli_dictionary_link@Base 0.7.0
- mowgli_dictionary_retrieve@Base 0.7.0
- mowgli_dictionary_retune@Base 0.7.0
- mowgli_dictionary_search@Base 0.7.0
- mowgli_dictionary_set_comparator_func@Base 0.7.0
- mowgli_dictionary_size@Base 0.7.0
- mowgli_dictionary_stats@Base 0.7.0
- mowgli_dictionary_unlink_root@Base 0.7.0
- mowgli_dns_create@Base 2.0.0
- mowgli_dns_delete_query@Base 2.0.0
- mowgli_dns_destroy@Base 2.0.0
- mowgli_dns_dn_expand@Base 2.0.0
- mowgli_dns_dn_skipname@Base 2.0.0
- mowgli_dns_evloop_add_local_domain@Base 2.0.0
- mowgli_dns_evloop_delete_queries@Base 2.0.0
- mowgli_dns_evloop_destroy@Base 2.0.0
- mowgli_dns_evloop_gethost_byaddr@Base 2.0.0
- mowgli_dns_evloop_gethost_byname@Base 2.0.0
- mowgli_dns_evloop_init@Base 2.0.0
- mowgli_dns_evloop_resolver@Base 2.0.0
- mowgli_dns_evloop_restart@Base 2.0.0
- mowgli_dns_evloop_set_resolvconf@Base 2.0.0+git20140224
- mowgli_dns_gethost_byaddr@Base 2.0.0
- mowgli_dns_gethost_byname@Base 2.0.0
- mowgli_dns_init@Base 2.0.0
- mowgli_dns_ns_get16@Base 2.0.0
- mowgli_dns_ns_get32@Base 2.0.0
- mowgli_dns_ns_put16@Base 2.0.0
- mowgli_dns_ns_put32@Base 2.0.0
- mowgli_dns_res_mkquery@Base 2.0.0
- mowgli_dns_restart@Base 2.0.0
- mowgli_error_context_create@Base 0.7.0
- mowgli_error_context_destroy@Base 0.7.0
- mowgli_error_context_display@Base 0.7.0
- mowgli_error_context_display_with_error@Base 0.7.0
- mowgli_error_context_pop@Base 0.7.0
- mowgli_error_context_push@Base 0.7.0
- mowgli_eventloop_break@Base 2.0.0
- mowgli_eventloop_create@Base 2.0.0
- mowgli_eventloop_destroy@Base 2.0.0
- mowgli_eventloop_get_data@Base 2.0.0
- mowgli_eventloop_next_timer@Base 2.0.0
- mowgli_eventloop_run@Base 2.0.0
- mowgli_eventloop_run_once@Base 2.0.0
- mowgli_eventloop_run_timers@Base 2.0.0
- mowgli_eventloop_set_data@Base 2.0.0
- mowgli_eventloop_timeout_once@Base 2.0.0
- mowgli_eventloop_timers_only@Base 2.0.0
- mowgli_fnv_hash@Base 0.7.0
- mowgli_fnv_hash_string@Base 0.7.0
- mowgli_formatter_format@Base 0.7.0
- mowgli_formatter_format_from_argstack@Base 0.7.0
- mowgli_formatter_print@Base 0.7.0
- mowgli_free@Base 0.7.0
- mowgli_getopt@Base 2.0.0
- mowgli_getopt_long@Base 2.0.0
- mowgli_global_storage_bootstrap@Base 2.0.0
- mowgli_global_storage_free@Base 0.7.0
- mowgli_global_storage_get@Base 0.7.0
- mowgli_global_storage_put@Base 0.7.0
- mowgli_heap_alloc@Base 0.7.0
- mowgli_heap_create@Base 0.7.0
- mowgli_heap_create_full@Base 0.7.0
- mowgli_heap_destroy@Base 0.7.0
- mowgli_heap_free@Base 0.7.0
- mowgli_helper_create@Base 2.0.0
- mowgli_helper_destroy@Base 2.0.0
- mowgli_helper_set_read_cb@Base 2.0.0
- mowgli_helper_setup@Base 2.0.0
- mowgli_helper_spawn@Base 2.0.0
- mowgli_hook_associate@Base 0.7.0
- mowgli_hook_bootstrap@Base 2.0.0
- mowgli_hook_call@Base 0.7.0
- mowgli_hook_dissociate@Base 0.7.0
- mowgli_hook_register@Base 0.7.0
- mowgli_index_allocate@Base 1.0.0
- mowgli_index_append@Base 1.0.0
- mowgli_index_copy_append@Base 1.0.0
- mowgli_index_copy_insert@Base 1.0.0
- mowgli_index_copy_set@Base 1.0.0
- mowgli_index_count@Base 1.0.0
- mowgli_index_create@Base 1.0.0
- mowgli_index_delete@Base 1.0.0
- mowgli_index_destroy@Base 1.0.0
- mowgli_index_get@Base 1.0.0
- mowgli_index_init@Base 1.0.0
- mowgli_index_insert@Base 1.0.0
- mowgli_index_merge_append@Base 1.0.0
- mowgli_index_merge_insert@Base 1.0.0
- mowgli_index_move@Base 1.0.0
- mowgli_index_set@Base 1.0.0
- mowgli_index_sort@Base 1.0.0
- mowgli_init@Base 0.7.0
- mowgli_interface_bootstrap@Base 2.0.0+git20140224
- mowgli_interface_get@Base 2.0.0+git20140224
- mowgli_interface_register@Base 2.0.0+git20140224
- mowgli_interface_unregister@Base 2.0.0+git20140224
- mowgli_json_create_array@Base 2.0.0+git20140224
- mowgli_json_create_float@Base 2.0.0+git20140224
- mowgli_json_create_integer@Base 2.0.0+git20140224
- mowgli_json_create_object@Base 2.0.0+git20140224
- mowgli_json_create_string@Base 2.0.0+git20140224
- mowgli_json_create_string_n@Base 2.0.0+git20140224
- mowgli_json_decref@Base 2.0.0+git20140224
- mowgli_json_false@Base 2.0.0+git20140224
- mowgli_json_incref@Base 2.0.0+git20140224
- mowgli_json_null@Base 2.0.0+git20140224
- mowgli_json_parse_create@Base 2.0.0+git20140224
- mowgli_json_parse_data@Base 2.0.0+git20140224
- mowgli_json_parse_destroy@Base 2.0.0+git20140224
- mowgli_json_parse_error@Base 2.0.0+git20140224
- mowgli_json_parse_file@Base 2.0.0+git20140224
- mowgli_json_parse_more@Base 2.0.0+git20140224
- mowgli_json_parse_next@Base 2.0.0+git20140224
- mowgli_json_parse_reset@Base 2.0.0+git20140224
- mowgli_json_parse_string@Base 2.0.0+git20140224
- mowgli_json_serialize@Base 2.0.0+git20140224
- mowgli_json_serialize_to_string@Base 2.0.0+git20140224
- mowgli_json_true@Base 2.0.0+git20140224
- mowgli_linebuf_attach_to_eventloop@Base 2.0.0
- mowgli_linebuf_create@Base 2.0.0
- mowgli_linebuf_delim@Base 2.0.0+git20140224
- mowgli_linebuf_destroy@Base 2.0.0
- mowgli_linebuf_detach_from_eventloop@Base 2.0.0+git20140224
- mowgli_linebuf_setbuflen@Base 2.0.0
- mowgli_linebuf_shut_down@Base 2.0.0+git20140224
- mowgli_linebuf_write@Base 2.0.0
- mowgli_linebuf_writef@Base 2.0.0
- mowgli_list_concat@Base 0.7.0
- mowgli_list_create@Base 0.7.0
- mowgli_list_free@Base 0.7.0
- mowgli_list_reverse@Base 0.7.0
- mowgli_list_sort@Base 0.7.0
- mowgli_log_bootstrap@Base 2.0.0+git20140224
- mowgli_log_cb_default@Base 0.7.0
- mowgli_log_prefix_real@Base 2.0.0+git20140224
- mowgli_log_real@Base 0.7.0
- mowgli_log_set_cb@Base 0.7.0
- mowgli_memslice_bootstrap@Base 2.0.0
- mowgli_memslice_get_policy@Base 2.0.0
- mowgli_module_close@Base 0.7.0
- mowgli_module_open@Base 0.7.0
- mowgli_module_symbol@Base 0.7.0
- mowgli_mutex_create@Base 2.0.0
- mowgli_mutex_destroy@Base 2.0.0
- mowgli_mutex_init@Base 2.0.0
- mowgli_mutex_lock@Base 2.0.0
- mowgli_mutex_set_policy@Base 2.0.0
- mowgli_mutex_trylock@Base 2.0.0
- mowgli_mutex_uninit@Base 2.0.0
- mowgli_mutex_unlock@Base 2.0.0
- mowgli_node_add@Base 0.7.0
- mowgli_node_add_after@Base 0.7.0
- mowgli_node_add_before@Base 0.7.0
- mowgli_node_add_head@Base 0.7.0
- mowgli_node_bootstrap@Base 2.0.0
- mowgli_node_create@Base 0.7.0
- mowgli_node_delete@Base 0.7.0
- mowgli_node_find@Base 0.7.0
- mowgli_node_free@Base 0.7.0
- mowgli_node_index@Base 0.7.0
- mowgli_node_insert@Base 0.7.0
- mowgli_node_move@Base 0.7.0
- mowgli_node_nth@Base 0.7.0
- mowgli_node_nth_data@Base 0.7.0
- mowgli_object_class_bootstrap@Base 2.0.0+git20140224
- mowgli_object_class_check_cast@Base 0.7.0
- mowgli_object_class_destroy@Base 0.7.0
- mowgli_object_class_find_by_name@Base 0.7.0
- mowgli_object_class_init@Base 0.7.0
- mowgli_object_class_message_handler_attach@Base 0.7.0
- mowgli_object_class_message_handler_detach@Base 0.7.0
- mowgli_object_class_reinterpret_impl@Base 0.7.0
- mowgli_object_class_set_derivitive@Base 0.7.0
- mowgli_object_init@Base 0.7.0
- mowgli_object_init_from_class@Base 0.7.0
- mowgli_object_message_broadcast@Base 0.7.0
- mowgli_object_message_handler_attach@Base 0.7.0
- mowgli_object_message_handler_detach@Base 0.7.0
- mowgli_object_metadata_associate@Base 0.7.0
- mowgli_object_metadata_dissociate@Base 0.7.0
- mowgli_object_metadata_retrieve@Base 0.7.0
- mowgli_object_ref@Base 0.7.0
- mowgli_object_unref@Base 0.7.0
- mowgli_optarg@Base 2.0.0
- mowgli_opterr@Base 2.0.0
- mowgli_optind@Base 2.0.0
- mowgli_optopt@Base 2.0.0
- mowgli_optreset@Base 2.0.0
- mowgli_patricia_add@Base 0.7.0
- mowgli_patricia_create@Base 0.7.0
- mowgli_patricia_create_named@Base 0.7.0
- mowgli_patricia_delete@Base 0.7.0
- mowgli_patricia_destroy@Base 0.7.0
- mowgli_patricia_elem_add@Base 1.0.0
- mowgli_patricia_elem_delete@Base 1.0.0
- mowgli_patricia_elem_find@Base 1.0.0
- mowgli_patricia_elem_get_data@Base 1.0.0
- mowgli_patricia_elem_get_key@Base 1.0.0
- mowgli_patricia_elem_set_data@Base 1.0.0
- mowgli_patricia_foreach@Base 0.7.0
- mowgli_patricia_foreach_cur@Base 0.7.0
- mowgli_patricia_foreach_next@Base 0.7.0
- mowgli_patricia_foreach_start@Base 0.7.0
- mowgli_patricia_retrieve@Base 0.7.0
- mowgli_patricia_search@Base 0.7.0
- mowgli_patricia_shutdown@Base 2.0.0
- mowgli_patricia_size@Base 0.7.0
- mowgli_patricia_stats@Base 0.7.0
- mowgli_pollable_create@Base 2.0.0
- mowgli_pollable_destroy@Base 2.0.0
- mowgli_pollable_set_cloexec@Base 2.0.0+git20140224
- mowgli_pollable_set_nonblocking@Base 2.0.0
- mowgli_pollable_setselect@Base 2.0.0
- mowgli_pollable_trigger@Base 2.0.0+git20140224
- mowgli_process_clone@Base 2.0.0
- mowgli_process_kill@Base 2.0.0
- mowgli_process_spawn@Base 2.0.0
- mowgli_proctitle_get@Base 2.0.0
- mowgli_proctitle_init@Base 2.0.0
- mowgli_proctitle_set@Base 2.0.0
- mowgli_program_opts_consumer_bool@Base 2.0.0
- mowgli_program_opts_consumer_int@Base 2.0.0
- mowgli_program_opts_consumer_str@Base 2.0.0
- mowgli_program_opts_parse@Base 2.0.0
- mowgli_queue_bootstrap@Base 2.0.0
- mowgli_queue_destroy@Base 0.7.0
- mowgli_queue_find@Base 0.7.0
- mowgli_queue_head@Base 0.7.0
- mowgli_queue_length@Base 0.7.0
- mowgli_queue_pop_head@Base 0.7.0
- mowgli_queue_pop_tail@Base 0.7.0
- mowgli_queue_push@Base 0.7.0
- mowgli_queue_remove@Base 0.7.0
- mowgli_queue_remove_data@Base 0.7.0
- mowgli_queue_rewind@Base 0.7.0
- mowgli_queue_shift@Base 0.7.0
- mowgli_queue_skip@Base 0.7.0
- mowgli_queue_tail@Base 0.7.0
- mowgli_random_bootstrap@Base 2.0.0
- mowgli_random_create@Base 0.7.0
- mowgli_random_create_with_seed@Base 0.7.0
- mowgli_random_int@Base 0.7.0
- mowgli_random_int_ranged@Base 0.7.0
- mowgli_random_reseed@Base 0.7.0
- mowgli_signal_install_handler@Base 0.7.0
- mowgli_simple_eventloop_error_handler@Base 2.0.0
- mowgli_simple_eventloop_run_once@Base 2.0.0
- mowgli_simple_eventloop_timeout_once@Base 2.0.0
- mowgli_soft_assert_log@Base 1.0.0
- mowgli_strdup@Base 2.0.0
- mowgli_strdup_using_policy@Base 2.0.0
- mowgli_string_append@Base 0.7.0
- mowgli_string_append_char@Base 0.7.0
- mowgli_string_create@Base 0.7.0
- mowgli_string_destroy@Base 0.7.0
- mowgli_string_reset@Base 0.7.0
- mowgli_strlcat@Base 1.0.0
- mowgli_strlcpy@Base 1.0.0
- mowgli_strndup@Base 2.0.0+git20140224
- mowgli_strndup_using_policy@Base 2.0.0+git20140224
- mowgli_timer_add@Base 2.0.0
- mowgli_timer_add_once@Base 2.0.0
- mowgli_timer_destroy@Base 2.0.0
- mowgli_timer_find@Base 2.0.0
- mowgli_vio_create@Base 2.0.0
- mowgli_vio_default_accept@Base 2.0.0
- mowgli_vio_default_bind@Base 2.0.0
- mowgli_vio_default_close@Base 2.0.0
- mowgli_vio_default_connect@Base 2.0.0
- mowgli_vio_default_error@Base 2.0.0
- mowgli_vio_default_evops@Base 2.0.0+git20140224
- mowgli_vio_default_listen@Base 2.0.0
- mowgli_vio_default_ops@Base 2.0.0
- mowgli_vio_default_read@Base 2.0.0
- mowgli_vio_default_recvfrom@Base 2.0.0
- mowgli_vio_default_reuseaddr@Base 2.0.0+git20140224
- mowgli_vio_default_seek@Base 2.0.0
- mowgli_vio_default_sendto@Base 2.0.0
- mowgli_vio_default_socket@Base 2.0.0
- mowgli_vio_default_tell@Base 2.0.0
- mowgli_vio_default_write@Base 2.0.0
- mowgli_vio_destroy@Base 2.0.0
- mowgli_vio_err_errcode@Base 2.0.0
- mowgli_vio_err_sslerrcode@Base 2.0.0
- mowgli_vio_eventloop_attach@Base 2.0.0
- mowgli_vio_eventloop_detach@Base 2.0.0
- mowgli_vio_init@Base 2.0.0
- mowgli_vio_openssl_getsslcontext@Base 2.0.0
- mowgli_vio_openssl_getsslhandle@Base 2.0.0
- mowgli_vio_openssl_setssl@Base 2.0.0
- mowgli_vio_sockaddr_create@Base 2.0.0
- mowgli_vio_sockaddr_from_struct@Base 2.0.0
- mowgli_vio_sockaddr_info@Base 2.0.0
- mowgli_writef@Base 2.0.0
diff --git a/debian/libmowgli-2-dev.docs b/debian/libmowgli-2-dev.docs
deleted file mode 100644
index da6ffa7..0000000
--- a/debian/libmowgli-2-dev.docs
+++ /dev/null
@@ -1,2 +0,0 @@
-doc/BOOST
-README
diff --git a/debian/libmowgli-2-dev.examples b/debian/libmowgli-2-dev.examples
deleted file mode 100644
index b28d08f..0000000
--- a/debian/libmowgli-2-dev.examples
+++ /dev/null
@@ -1,2 +0,0 @@
-src/examples/*
-buildsys.mk
diff --git a/debian/libmowgli-2-dev.install b/debian/libmowgli-2-dev.install
deleted file mode 100644
index 7df81cd..0000000
--- a/debian/libmowgli-2-dev.install
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/include/*
-usr/lib/*/lib*.so
-usr/lib/*/pkgconfig/*
diff --git a/debian/patches/001-Disable_Makefile_silent_output.diff b/debian/patches/001-Disable_Makefile_silent_output.diff
deleted file mode 100644
index 7189358..0000000
--- a/debian/patches/001-Disable_Makefile_silent_output.diff
+++ /dev/null
@@ -1,14 +0,0 @@
-Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
-Description: Let's show what happens...
-
---- a/buildsys.mk.in
-+++ b/buildsys.mk.in
-@@ -102,7 +102,7 @@
-
- MO_FILES = ${LOCALES:.po=.mo}
-
--.SILENT:
-+#.SILENT:
- .SUFFIXES:
- .SUFFIXES: .beam .c .c.dep .cc .cc.dep .class .cxx .cxx.dep .d .erl .lib.o .java .mo .m .m.dep .mm .mm.dep .o .plugin.o .po .py .pyc .rc .S .S.dep .xpm
- .PHONY: all subdirs ${SUBDIRS} pre-depend depend install install-extra uninstall uninstall-extra clean distclean locales
diff --git a/debian/patches/002-Make-Examples-Buildable-standalone.diff b/debian/patches/002-Make-Examples-Buildable-standalone.diff
deleted file mode 100644
index 180f9b9..0000000
--- a/debian/patches/002-Make-Examples-Buildable-standalone.diff
+++ /dev/null
@@ -1,302 +0,0 @@
-Author: Adam Cécile (Le_Vert) <gandalf@le-vert.net>
-Description: This patch makes the examples build standalone.
-
---- a/src/examples/formattertest/formattertest.c
-+++ b/src/examples/formattertest/formattertest.c
-@@ -31,7 +31,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- int
- main(int argc, char *argv[])
---- a/src/examples/formattertest/Makefile
-+++ b/src/examples/formattertest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = formattertest${PROG_SUFFIX}
- SRCS = formattertest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/listsort/listsort.c
-+++ b/src/examples/listsort/listsort.c
-@@ -31,7 +31,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- #ifdef _WIN32
- # define strcasecmp _stricmp
---- a/src/examples/listsort/Makefile
-+++ b/src/examples/listsort/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = listsort${PROG_SUFFIX}
- SRCS = listsort.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/randomtest/Makefile
-+++ b/src/examples/randomtest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = randomtest${PROG_SUFFIX}
- SRCS = randomtest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/randomtest/randomtest.c
-+++ b/src/examples/randomtest/randomtest.c
-@@ -31,7 +31,7 @@
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- int
- main(int argc, char *argv[])
---- a/src/examples/async_resolver/async_resolver.c
-+++ b/src/examples/async_resolver/async_resolver.c
-@@ -1,6 +1,6 @@
- /* This code is in the public domain. */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- typedef struct
- {
---- a/src/examples/async_resolver/Makefile
-+++ b/src/examples/async_resolver/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = async_resolver${PROG_SUFFIX}
- SRCS = async_resolver.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/echoserver/echoserver.c
-+++ b/src/examples/echoserver/echoserver.c
-@@ -21,7 +21,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- mowgli_eventloop_t *base_eventloop;
- mowgli_eventloop_pollable_t *listener;
---- a/src/examples/echoserver/Makefile
-+++ b/src/examples/echoserver/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = echoserver${PROG_SUFFIX}
- SRCS = echoserver.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/helpertest/helpertest.c
-+++ b/src/examples/helpertest/helpertest.c
-@@ -21,7 +21,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- int helper_count = 0;
-
---- a/src/examples/helpertest/Makefile
-+++ b/src/examples/helpertest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = helpertest${PROG_SUFFIX}
- SRCS = helpertest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/libevent-bench/bench.c
-+++ b/src/examples/libevent-bench/bench.c
-@@ -76,7 +76,7 @@
- } \
- } while (0)
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- static int count, writes, fired;
- static mowgli_eventloop_t *base_eventloop;
---- a/src/examples/libevent-bench/Makefile
-+++ b/src/examples/libevent-bench/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = bench${PROG_SUFFIX}
- SRCS = bench.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/linetest/linetest.c
-+++ b/src/examples/linetest/linetest.c
-@@ -22,7 +22,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- mowgli_eventloop_t *base_eventloop;
- char buf[512];
---- a/src/examples/linetest/Makefile
-+++ b/src/examples/linetest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = linetest${PROG_SUFFIX}
- SRCS = linetest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/memslice-bench/Makefile
-+++ b/src/examples/memslice-bench/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = memslice-bench${PROG_SUFFIX}
- SRCS = memslice-bench.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/memslice-bench/memslice-bench.c
-+++ b/src/examples/memslice-bench/memslice-bench.c
-@@ -30,7 +30,7 @@
- } \
- } while (0)
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- mowgli_allocation_policy_t *memslice;
- mowgli_allocation_policy_t *sysmalloc;
---- a/src/examples/patriciatest2/Makefile
-+++ b/src/examples/patriciatest2/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = patriciatest2${PROG_SUFFIX}
- SRCS = patriciatest2.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/patriciatest2/patriciatest2.c
-+++ b/src/examples/patriciatest2/patriciatest2.c
-@@ -31,7 +31,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- #define TESTSIZE 10000
-
---- a/src/examples/patriciatest/Makefile
-+++ b/src/examples/patriciatest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = patriciatest${PROG_SUFFIX}
- SRCS = patriciatest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/patriciatest/patriciatest.c
-+++ b/src/examples/patriciatest/patriciatest.c
-@@ -31,7 +31,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- int errors = 0;
-
---- a/src/examples/timertest/Makefile
-+++ b/src/examples/timertest/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = timertest${PROG_SUFFIX}
- SRCS = timertest.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/timertest/timertest.c
-+++ b/src/examples/timertest/timertest.c
-@@ -21,7 +21,7 @@
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- mowgli_eventloop_t *eventloop;
-
---- a/src/examples/vio-udplistener/Makefile
-+++ b/src/examples/vio-udplistener/Makefile
-@@ -1,7 +1,7 @@
- PROG_NOINST = vio-udplistener${PROG_SUFFIX}
- SRCS = vio-udplistener.c
-
--include ../../../buildsys.mk
-+include ../buildsys.mk
-
- CPPFLAGS += -I../../libmowgli
- LIBS += -L../../libmowgli -lmowgli-2
---- a/src/examples/vio-udplistener/vio-udplistener.c
-+++ b/src/examples/vio-udplistener/vio-udplistener.c
-@@ -3,7 +3,7 @@
- * This example is public domain.
- */
-
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- #define BUFSIZE 2048
-
---- a/src/examples/Makefile
-+++ b/src/examples/Makefile
-@@ -1,2 +1,2 @@
- SUBDIRS = echoserver vio-udplistener async_resolver formattertest helpertest jsontest libevent-bench linetest listsort memslice-bench patriciatest patriciatest2 randomtest timertest
--include ../../buildsys.mk
-+include buildsys.mk
---- a/src/examples/jsontest/jsontest.c
-+++ b/src/examples/jsontest/jsontest.c
-@@ -1,4 +1,4 @@
--#include <mowgli.h>
-+#include <libmowgli-2/mowgli.h>
-
- void
- out_string(mowgli_json_output_t *out, const char *str, size_t len)
diff --git a/debian/patches/003-Fix-machine.h.diff b/debian/patches/003-Fix-machine.h.diff
deleted file mode 100644
index 4e3ffa4..0000000
--- a/debian/patches/003-Fix-machine.h.diff
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/libmowgli/platform/machine.h
-+++ b/src/libmowgli/platform/machine.h
-@@ -192,7 +192,7 @@
- # endif
- #endif
-
--#if defined __linux || defined __linux__
-+#if defined __linux || defined __linux__ || defined __FreeBSD_kernel__
- # define MOWGLI_OS_LINUX
- # define MOWGLI_OS linux
- # define MOWGLI_OS_THREADS_POSIX
diff --git a/debian/patches/004-No-openssl.diff b/debian/patches/004-No-openssl.diff
deleted file mode 100644
index 1a8cf7d..0000000
--- a/debian/patches/004-No-openssl.diff
+++ /dev/null
@@ -1,15 +0,0 @@
---- a/m4/ax_check_openssl.m4
-+++ b/m4/ax_check_openssl.m4
-@@ -42,9 +42,11 @@
- [root of the OpenSSL directory])],
- [
- case "$withval" in
-- "" | y | ye | yes | n | no)
-+ y | ye | yes)
- AC_MSG_ERROR([Invalid --with-openssl value])
- ;;
-+ "" | n | no) ssldirs=""
-+ ;;
- *) ssldirs="$withval"
- ;;
- esac
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index 7b4be3e..0000000
--- a/debian/patches/series
+++ /dev/null
@@ -1,4 +0,0 @@
-001-Disable_Makefile_silent_output.diff
-002-Make-Examples-Buildable-standalone.diff
-003-Fix-machine.h.diff
-004-No-openssl.diff
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 63b011e..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/make -f
-
-export CFLAGS := $(shell dpkg-buildflags --get CFLAGS) $(shell dpkg-buildflags --get CPPFLAGS)
-export CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
-export LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
-
-export ACLOCAL := aclocal -I m4
-
-export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
-
-%:
- dh $@ --with=autoreconf
-
-override_dh_auto_configure:
-ifneq "$(wildcard /usr/share/misc/config.sub)" ""
- cp -f /usr/share/misc/config.sub config.sub
-endif
-ifneq "$(wildcard /usr/share/misc/config.guess)" ""
- cp -f /usr/share/misc/config.guess config.guess
-endif
- dh_auto_configure -- SHELL=/bin/sh --with-openssl=no
-
-override_dh_auto_install:
- dh_auto_install
- # mkdir -p debian/libmowgli-2-0/usr/include/$(DEB_HOST_MULTIARCH)/libmowgli-2/platform
- # mv -f debian/tmp/usr/include/libmowgli-2/platform/autoconf.h debian/libmowgli-2-0/usr/include/$(DEB_HOST_MULTIARCH)/libmowgli-2/platform/autoconf.h
-
-override_dh_installexamples:
- sed -e 's,\(libdir = \$${prefix}/lib\)/.*$$,\1,' \
- -e 's,CFLAGS = .*$$,CFLAGS = ,' \
- -e 's,CPPFLAGS = .*$$,CPPFLAGS = ,' \
- -e 's,LDFLAGS = .*$$,LDFLAGS = ,' < buildsys.mk > buildsys.mk.new
- mv -f buildsys.mk.new buildsys.mk
- dh_installexamples -X.dep
-
-override_dh_compress:
- dh_compress -Xusr/share/doc/libmowgli-2-dev/examples
-
-override_dh_strip:
- dh_strip --dbg-package=libmowgli-2-0-dbg
-
-override_dh_auto_clean:
- [ ! -f buildsys.mk ] || dh_auto_clean
-
-.PHONY: override_dh_installexamples override_dh_compress override_dh_strip override_dh_auto_clean override_dh_auto_install override_dh_auto_configure
diff --git a/debian/source/format b/debian/source/format
deleted file mode 100644
index 163aaf8..0000000
--- a/debian/source/format
+++ /dev/null
@@ -1 +0,0 @@
-3.0 (quilt)
diff --git a/debian/watch b/debian/watch
deleted file mode 100644
index 49d58c0..0000000
--- a/debian/watch
+++ /dev/null
@@ -1,4 +0,0 @@
-version=4
-opts="mode=git" https://github.com/atheme/libmowgli-2.git \
-refs/tags/v([\d\.]+) debian uupdate
-
diff --git a/src/libmowgli/core/Makefile b/src/libmowgli/core/Makefile
new file mode 100644
index 0000000..08a5306
--- /dev/null
+++ b/src/libmowgli/core/Makefile
@@ -0,0 +1,32 @@
+include ../../../extra.mk
+
+STATIC_PIC_LIB_NOINST = ${LIBMOWGLI_SHARED_CORE}
+STATIC_LIB_NOINST = ${LIBMOWGLI_STATIC_CORE}
+
+SRCS = bootstrap.c \
+ alloc.c \
+ allocation_policy.c \
+ allocator.c \
+ heap.c \
+ logger.c \
+ mowgli_string.c \
+ process.c
+
+INCLUDES = bootstrap.h \
+ alloc.h \
+ allocation_policy.h \
+ allocator.h \
+ assert.h \
+ heap.h \
+ iterator.h \
+ logger.h \
+ mowgli_string.h \
+ stdinc.h \
+ process.h
+
+include ../../../buildsys.mk
+
+includesubdir = $(PACKAGE_NAME)/core
+
+CPPFLAGS += -I. -I.. -I../../.. -DMOWGLI_CORE
+
diff --git a/src/libmowgli/core/alloc.c b/src/libmowgli/core/alloc.c
new file mode 100644
index 0000000..e527973
--- /dev/null
+++ b/src/libmowgli/core/alloc.c
@@ -0,0 +1,238 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * alloc.c: Safe, portable implementations of malloc, calloc, and free.
+ *
+ * Copyright (c) 2007, 2012 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+/*
+ * bootstrapped allocators so that we can initialise without blowing up
+ */
+typedef struct
+{
+ mowgli_allocation_policy_t *allocator;
+} alloc_tag_t;
+
+static void *
+_mowgli_bootstrap_alloc(size_t size)
+{
+ return calloc(size, 1);
+}
+
+static void
+_mowgli_bootstrap_free(void *ptr)
+{
+ if (ptr)
+ free(ptr);
+}
+
+static mowgli_allocation_policy_t _mowgli_allocator_bootstrap =
+{
+ { 0 },
+ _mowgli_bootstrap_alloc,
+ _mowgli_bootstrap_free
+};
+
+static mowgli_allocation_policy_t *_mowgli_allocator = &_mowgli_allocator_bootstrap;
+
+/*
+ * \brief Allocates an array of data that contains "count" objects,
+ * of "size" size.
+ *
+ * Usually, this wraps calloc().
+ *
+ * \param size size of objects to allocate.
+ * \param count amount of objects to allocate.
+ *
+ * \return A pointer to a memory buffer.
+ */
+void *
+mowgli_alloc_array_using_policy(mowgli_allocation_policy_t *policy, size_t size, size_t count)
+{
+ size_t adj_size;
+ void *r;
+
+ return_val_if_fail(policy != NULL, NULL);
+
+ adj_size = (size * count) + sizeof(alloc_tag_t);
+
+ r = policy->allocate(adj_size);
+ ((alloc_tag_t *) r)->allocator = policy;
+
+ return (char *) r + sizeof(alloc_tag_t);
+}
+
+/*
+ * \brief Allocates an object of "size" size.
+ *
+ * This is the equivilant of calling mowgli_alloc_array(size, 1).
+ *
+ * \param size size of object to allocate.
+ *
+ * \return A pointer to a memory buffer.
+ */
+void *
+mowgli_alloc_using_policy(mowgli_allocation_policy_t *policy, size_t size)
+{
+ return mowgli_alloc_array_using_policy(policy, size, 1);
+}
+
+/*
+ * \brief Duplicater a string using mowgli_alloc() using a specific policy.
+ */
+char *
+mowgli_strdup_using_policy(mowgli_allocation_policy_t *policy, const char *in)
+{
+ char *out;
+ size_t len;
+
+ return_val_if_fail(in != NULL, NULL);
+
+ len = strlen(in) + 1;
+ out = mowgli_alloc_using_policy(policy, len);
+ mowgli_strlcpy(out, in, len);
+
+ return out;
+}
+
+/*
+ * \brief Duplicater a string using mowgli_alloc() using a specific policy.
+ */
+char *
+mowgli_strdup(const char *in)
+{
+ return mowgli_strdup_using_policy(_mowgli_allocator, in);
+}
+
+/*
+ * \brief Duplicate a string of a specified length using mowgli_alloc() using a specific policy.
+ */
+char *
+mowgli_strndup_using_policy(mowgli_allocation_policy_t *policy, const char *in, size_t size)
+{
+ char *out;
+ size_t len;
+
+ return_val_if_fail(in != NULL, NULL);
+
+ len = strlen(in) + 1;
+
+ if (size < len)
+ len = size;
+
+ out = mowgli_alloc_using_policy(policy, len);
+ mowgli_strlcpy(out, in, len);
+
+ return out;
+}
+
+/*
+ * \brief Duplicate a string of a specified length using mowgli_alloc() using a specific policy.
+ */
+char *
+mowgli_strndup(const char *in, size_t size)
+{
+ return mowgli_strndup_using_policy(_mowgli_allocator, in, size);
+}
+
+/*
+ * \brief Allocates an array of data that contains "count" objects,
+ * of "size" size.
+ *
+ * Usually, this wraps calloc().
+ *
+ * \param size size of objects to allocate.
+ * \param count amount of objects to allocate.
+ *
+ * \return A pointer to a memory buffer.
+ */
+void *
+mowgli_alloc_array(size_t size, size_t count)
+{
+ return mowgli_alloc_array_using_policy(_mowgli_allocator, size, count);
+}
+
+/*
+ * \brief Allocates an object of "size" size.
+ *
+ * This is the equivilant of calling mowgli_alloc_array(size, 1).
+ *
+ * \param size size of object to allocate.
+ *
+ * \return A pointer to a memory buffer.
+ */
+void *
+mowgli_alloc(size_t size)
+{
+ return mowgli_alloc_array_using_policy(_mowgli_allocator, size, 1);
+}
+
+/*
+ * \brief Frees an object back to the system memory pool.
+ *
+ * Wraps free protecting against common mistakes (reports an error instead).
+ *
+ * \param ptr pointer to object to free.
+ */
+void
+mowgli_free(void *ptr)
+{
+ alloc_tag_t *tag;
+
+ return_if_fail(ptr != NULL);
+
+ tag = (alloc_tag_t *) ((char *) ptr - sizeof(alloc_tag_t));
+ tag->allocator->deallocate(tag);
+}
+
+/*
+ * \brief Sets the mowgli.allocation_policy used by the allocation primitives.
+ *
+ * \param policy The mowgli_allocation_policy_t object to use.
+ */
+void
+mowgli_allocator_set_policy(mowgli_allocation_policy_t *policy)
+{
+ return_if_fail(policy != NULL);
+
+ _mowgli_allocator = policy;
+}
+
+/*
+ * \brief Sets the mowgli.allocation_policy used by the allocation primitives,
+ * when given a name.
+ *
+ * \param name The name of the policy to use.
+ */
+void
+mowgli_allocator_set_policy_by_name(const char *name)
+{
+ mowgli_allocation_policy_t *policy;
+
+ return_if_fail(name != NULL);
+
+ policy = mowgli_allocation_policy_lookup(name);
+
+ if (policy == NULL)
+ return;
+
+ mowgli_allocator_set_policy(policy);
+}
diff --git a/src/libmowgli/core/alloc.h b/src/libmowgli/core/alloc.h
new file mode 100644
index 0000000..ac0f2f9
--- /dev/null
+++ b/src/libmowgli/core/alloc.h
@@ -0,0 +1,38 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * alloc.h: Safe, portable implementations of malloc, calloc, and free.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_ALLOC_H__
+#define __MOWGLI_ALLOC_H__
+
+extern void *mowgli_alloc_array_using_policy(mowgli_allocation_policy_t *policy, size_t size, size_t count);
+extern void *mowgli_alloc_using_policy(mowgli_allocation_policy_t *policy, size_t size);
+extern char *mowgli_strdup_using_policy(mowgli_allocation_policy_t *policy, const char *in);
+extern char *mowgli_strndup_using_policy(mowgli_allocation_policy_t *policy, const char *in, size_t size);
+
+extern void *mowgli_alloc_array(size_t size, size_t count);
+extern void *mowgli_alloc(size_t size);
+extern char *mowgli_strdup(const char *in);
+extern char *mowgli_strndup(const char *in, size_t size);
+extern void mowgli_free(void *ptr);
+
+#endif
diff --git a/src/libmowgli/core/allocation_policy.c b/src/libmowgli/core/allocation_policy.c
new file mode 100644
index 0000000..dc66cb8
--- /dev/null
+++ b/src/libmowgli/core/allocation_policy.c
@@ -0,0 +1,70 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * allocation_policy.h: Allocation policy management.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+static mowgli_object_class_t klass;
+static mowgli_patricia_t *mowgli_allocation_policy_dict = NULL;
+
+static void
+_allocation_policy_key_canon(char *str)
+{ }
+
+void
+mowgli_allocation_policy_bootstrap(void)
+{
+ mowgli_allocation_policy_dict = mowgli_patricia_create(_allocation_policy_key_canon);
+
+ mowgli_object_class_init(&klass, "mowgli.allocation_policy", NULL, FALSE);
+}
+
+mowgli_allocation_policy_t *
+mowgli_allocation_policy_create(const char *name, mowgli_allocation_func_t allocator, mowgli_deallocation_func_t deallocator)
+{
+ mowgli_allocation_policy_t *policy;
+
+ if (mowgli_allocation_policy_dict == NULL)
+ mowgli_allocation_policy_dict = mowgli_patricia_create(_allocation_policy_key_canon);
+
+ if ((policy = mowgli_patricia_retrieve(mowgli_allocation_policy_dict, name)))
+ return policy;
+
+ policy = mowgli_alloc(sizeof(mowgli_allocation_policy_t));
+ mowgli_object_init_from_class(mowgli_object(policy), name, &klass);
+
+ policy->allocate = allocator;
+ policy->deallocate = deallocator;
+
+ mowgli_patricia_add(mowgli_allocation_policy_dict, name, policy);
+
+ return policy;
+}
+
+mowgli_allocation_policy_t *
+mowgli_allocation_policy_lookup(const char *name)
+{
+ if (mowgli_allocation_policy_dict == NULL)
+ mowgli_allocation_policy_dict = mowgli_patricia_create(_allocation_policy_key_canon);
+
+ return mowgli_patricia_retrieve(mowgli_allocation_policy_dict, name);
+}
diff --git a/src/libmowgli/core/allocation_policy.h b/src/libmowgli/core/allocation_policy.h
new file mode 100644
index 0000000..5d6be62
--- /dev/null
+++ b/src/libmowgli/core/allocation_policy.h
@@ -0,0 +1,44 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * allocation_policy.h: Allocation policy management.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_ALLOCATION_POLICY_H__
+#define __MOWGLI_ALLOCATION_POLICY_H__
+
+typedef void *(*mowgli_allocation_func_t)(size_t size);
+typedef void (*mowgli_deallocation_func_t)(void *ptr);
+
+typedef struct
+{
+ mowgli_object_t parent;
+ mowgli_allocation_func_t allocate;
+ mowgli_deallocation_func_t deallocate;
+} mowgli_allocation_policy_t;
+
+mowgli_allocation_policy_t *mowgli_allocation_policy_create(const char *name, mowgli_allocation_func_t allocator, mowgli_deallocation_func_t deallocator);
+mowgli_allocation_policy_t *mowgli_allocation_policy_lookup(const char *name);
+
+/* for mowgli_alloc, et. al */
+void mowgli_allocator_set_policy(mowgli_allocation_policy_t *policy);
+void mowgli_allocator_set_policy_by_name(const char *name);
+
+#endif
diff --git a/src/libmowgli/core/allocator.c b/src/libmowgli/core/allocator.c
new file mode 100644
index 0000000..6002bb0
--- /dev/null
+++ b/src/libmowgli/core/allocator.c
@@ -0,0 +1,46 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * allocator.h: Builtin allocation policies (mmap/malloc).
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+mowgli_allocation_policy_t *mowgli_allocator_malloc = NULL;
+
+static void *
+mowgli_allocator_func_malloc(size_t size)
+{
+ return calloc(size, 1);
+}
+
+static void
+mowgli_allocator_func_free(void *ptr)
+{
+ if (ptr)
+ free(ptr);
+}
+
+void
+mowgli_allocator_bootstrap(void)
+{
+ mowgli_allocator_malloc = mowgli_allocation_policy_create("malloc", mowgli_allocator_func_malloc,
+ mowgli_allocator_func_free);
+}
diff --git a/src/libmowgli/core/allocator.h b/src/libmowgli/core/allocator.h
new file mode 100644
index 0000000..c243fe2
--- /dev/null
+++ b/src/libmowgli/core/allocator.h
@@ -0,0 +1,29 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * allocator.h: Builtin allocation policies (mmap/malloc).
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_ALLOCATOR_H__
+#define __MOWGLI_ALLOCATOR_H__
+
+extern mowgli_allocation_policy_t *mowgli_allocator_malloc;
+
+#endif
diff --git a/src/libmowgli/core/assert.h b/src/libmowgli/core/assert.h
new file mode 100644
index 0000000..fce30a1
--- /dev/null
+++ b/src/libmowgli/core/assert.h
@@ -0,0 +1,60 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * assert.h: Assertions.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_ASSERT_H__
+#define __MOWGLI_ASSERT_H__
+
+#define _assert_msg(exp) "assertion '" #exp "' failed."
+
+#define soft_assert(exp) \
+ do \
+ { \
+ if (!(exp)) \
+ { \
+ mowgli_log_warning(_assert_msg(exp)); \
+ } \
+ } while (0)
+
+#define return_if_fail(exp) \
+ do \
+ { \
+ if (!(exp)) \
+ { \
+ mowgli_log_warning(_assert_msg(exp)); \
+ return; \
+ } \
+ } while (0)
+
+#define return_val_if_fail(exp, val) \
+ do \
+ { \
+ if (!(exp)) \
+ { \
+ mowgli_log_warning(_assert_msg(exp)); \
+ return (val); \
+ } \
+ } while (0)
+
+#define return_null_if_fail(exp) return_val_if_fail(exp, NULL)
+
+#endif
diff --git a/src/libmowgli/core/bootstrap.c b/src/libmowgli/core/bootstrap.c
new file mode 100644
index 0000000..4aecc98
--- /dev/null
+++ b/src/libmowgli/core/bootstrap.c
@@ -0,0 +1,82 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * bootstrap.c: Initialization of libmowgli.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+extern void mowgli_log_bootstrap(void);
+extern void mowgli_node_bootstrap(void);
+extern void mowgli_queue_bootstrap(void);
+extern void mowgli_object_class_bootstrap(void);
+extern void mowgli_argstack_bootstrap(void);
+extern void mowgli_bitvector_bootstrap(void);
+extern void mowgli_global_storage_bootstrap(void);
+extern void mowgli_hook_bootstrap(void);
+extern void mowgli_random_bootstrap(void);
+extern void mowgli_allocation_policy_bootstrap(void);
+extern void mowgli_allocator_bootstrap(void);
+extern void mowgli_memslice_bootstrap(void);
+extern void mowgli_cacheline_bootstrap(void);
+extern void mowgli_interface_bootstrap(void);
+
+/* TODO: rename to mowgli_bootstrap next time there is a LIB_MAJOR bump */
+MOWGLI_BOOTSTRAP_FUNC(mowgli_bootstrap_real)
+{
+ static bool bootstrapped = 0;
+
+ if (bootstrapped)
+ return;
+
+ /* initial bootstrap */
+ mowgli_log_bootstrap();
+ mowgli_node_bootstrap();
+ mowgli_queue_bootstrap();
+ mowgli_object_class_bootstrap();
+ mowgli_argstack_bootstrap();
+ mowgli_bitvector_bootstrap();
+ mowgli_global_storage_bootstrap();
+ mowgli_hook_bootstrap();
+ mowgli_random_bootstrap();
+ mowgli_allocation_policy_bootstrap();
+ mowgli_allocator_bootstrap();
+ mowgli_memslice_bootstrap();
+ mowgli_cacheline_bootstrap();
+ mowgli_interface_bootstrap();
+
+#ifdef _WIN32
+ extern void mowgli_winsock_bootstrap(void);
+
+ mowgli_winsock_bootstrap();
+#endif
+
+ /* now that we're bootstrapped, we can use a more optimised allocator
+ if one is available. */
+ mowgli_allocator_set_policy(mowgli_allocator_malloc);
+
+ bootstrapped = true;
+}
+
+void
+mowgli_init(void)
+{
+ mowgli_log("mowgli_init() is a deprecated function, provided only for backwards compatibility with Mowgli-1. You should remove it if you no longer support using Mowgli-1.");
+}
diff --git a/src/libmowgli/core/bootstrap.h b/src/libmowgli/core/bootstrap.h
new file mode 100644
index 0000000..36f46f4
--- /dev/null
+++ b/src/libmowgli/core/bootstrap.h
@@ -0,0 +1,29 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * bootstrap.c: Initialization of libmowgli.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_BOOTSTRAP_H__
+#define __MOWGLI_BOOTSTRAP_H__
+
+extern void mowgli_bootstrap(void);
+
+#endif
diff --git a/src/libmowgli/core/heap.c b/src/libmowgli/core/heap.c
new file mode 100644
index 0000000..b4fd9d9
--- /dev/null
+++ b/src/libmowgli/core/heap.c
@@ -0,0 +1,374 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * heap.c: Heap allocation.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ * Copyright (c) 2005-2006 Theo Julienne <terminal -at- atheme.org>
+ * Copyright (c) 2011 Andrew Wilcox <awilcox -at- wilcox-tech.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ *
+ * Legal note: code devised from claro.base.block module r288 (Pre MPL)
+ */
+
+#include "mowgli.h"
+
+#ifdef HAVE_MMAP
+# include <sys/mman.h>
+# if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+# define MAP_ANON MAP_ANONYMOUS
+# endif
+#endif
+
+/* A block of memory allocated to the allocator */
+struct mowgli_block_
+{
+ mowgli_node_t node;
+
+ /* link back to our heap */
+ mowgli_heap_t *heap;
+
+ /* pointer to the first item */
+ void *data;
+
+ /* singly linked list of free items */
+ void *first_free;
+
+ unsigned int num_allocated;
+};
+
+/* A pile of blocks */
+struct mowgli_heap_
+{
+ unsigned int elem_size;
+ unsigned int mowgli_heap_elems;
+ unsigned int free_elems;
+
+ unsigned int alloc_size;
+
+ unsigned int flags;
+
+ mowgli_list_t blocks; /* list of non-empty blocks */
+
+ mowgli_allocation_policy_t *allocator;
+ mowgli_boolean_t use_mmap;
+
+ mowgli_mutex_t mutex;
+
+ mowgli_block_t *empty_block; /* a single entirely free block, or NULL */
+};
+
+typedef struct mowgli_heap_elem_header_ mowgli_heap_elem_header_t;
+
+struct mowgli_heap_elem_header_
+{
+ union
+ {
+ mowgli_block_t *block; /* for allocated elems: block ptr */
+ mowgli_heap_elem_header_t *next;/* for free elems: next free */
+ } un;
+};
+
+/* expands a mowgli_heap_t by 1 block */
+static void
+mowgli_heap_expand(mowgli_heap_t *bh)
+{
+ mowgli_block_t *block = NULL;
+ void *blp = NULL;
+ mowgli_heap_elem_header_t *node, *prev;
+ char *offset;
+ unsigned int a;
+ size_t blp_size;
+
+ blp_size = sizeof(mowgli_block_t) + (bh->alloc_size * bh->mowgli_heap_elems);
+
+ if (bh->empty_block != NULL)
+ return;
+
+#if defined(HAVE_MMAP) && defined(MAP_ANON)
+
+ if (bh->use_mmap)
+ blp = mmap(NULL, sizeof(mowgli_block_t) + (bh->alloc_size * bh->mowgli_heap_elems),
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ else
+#elif defined(_WIN32)
+
+ if (bh->use_mmap)
+ {
+ blp = VirtualAlloc(NULL, sizeof(mowgli_block_t) + (bh->alloc_size * bh->mowgli_heap_elems),
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+ }
+ else
+#endif
+ {
+ if (bh->allocator)
+ blp = bh->allocator->allocate(blp_size);
+ else
+ blp = mowgli_alloc(blp_size);
+ }
+
+ block = (mowgli_block_t *) blp;
+
+ offset = (char *) blp + sizeof(mowgli_block_t);
+ block->data = offset;
+ block->heap = bh;
+
+ prev = NULL;
+
+ for (a = 0; a < bh->mowgli_heap_elems; a++)
+ {
+ node = (mowgli_heap_elem_header_t *) offset;
+ node->un.next = prev;
+ offset += bh->alloc_size;
+ prev = node;
+ }
+
+ block->first_free = prev;
+
+ bh->empty_block = block;
+ bh->free_elems += bh->mowgli_heap_elems;
+}
+
+/* shrinks a mowgli_heap_t by 1 block. */
+static void
+mowgli_heap_shrink(mowgli_heap_t *heap, mowgli_block_t *b)
+{
+ return_if_fail(b != NULL);
+
+ if (b == heap->empty_block)
+ heap->empty_block = NULL;
+ else
+ mowgli_node_delete(&b->node, &heap->blocks);
+
+#if defined(HAVE_MMAP)
+
+ if (heap->use_mmap)
+ munmap(b, sizeof(mowgli_block_t) + (heap->alloc_size * heap->mowgli_heap_elems));
+ else
+#elif defined(_WIN32)
+
+ if (heap->use_mmap)
+ VirtualFree(b, 0, MEM_RELEASE);
+ else
+#endif
+ if (heap->allocator)
+ heap->allocator->deallocate(b);
+ else
+ mowgli_free(b);
+
+ heap->free_elems -= heap->mowgli_heap_elems;
+}
+
+/* creates a new mowgli_heap_t */
+mowgli_heap_t *
+mowgli_heap_create_full(size_t elem_size, size_t mowgli_heap_elems, unsigned int flags, mowgli_allocation_policy_t *allocator)
+{
+ mowgli_heap_t *bh = mowgli_alloc(sizeof(mowgli_heap_t));
+ int numpages, pagesize;
+
+ bh->elem_size = elem_size;
+ bh->mowgli_heap_elems = mowgli_heap_elems;
+
+ /* at least 2, this avoids some silly special cases */
+ if (bh->mowgli_heap_elems < 2)
+ bh->mowgli_heap_elems = 2;
+
+ bh->free_elems = 0;
+
+ bh->alloc_size = bh->elem_size + sizeof(mowgli_heap_elem_header_t);
+
+ /* don't waste part of a page */
+ if (allocator == NULL)
+ {
+#ifdef HAVE_MMAP
+ pagesize = getpagesize();
+#else
+ pagesize = 4096;
+#endif
+ numpages = (sizeof(mowgli_block_t) + (bh->alloc_size * bh->mowgli_heap_elems) + pagesize - 1) / pagesize;
+ bh->mowgli_heap_elems = (numpages * pagesize - sizeof(mowgli_block_t)) / bh->alloc_size;
+ }
+
+ bh->flags = flags;
+
+ bh->allocator = allocator ? allocator : mowgli_allocator_malloc;
+
+#ifdef HAVE_MMAP
+ bh->use_mmap = allocator != NULL ? FALSE : TRUE;
+#endif
+
+ if (mowgli_mutex_init(&bh->mutex) != 0)
+ mowgli_log_fatal("heap mutex can't be created");
+
+ if (flags & BH_NOW)
+ {
+ mowgli_mutex_lock(&bh->mutex);
+ mowgli_heap_expand(bh);
+ mowgli_mutex_unlock(&bh->mutex);
+ }
+
+ return bh;
+}
+
+mowgli_heap_t *
+mowgli_heap_create(size_t elem_size, size_t mowgli_heap_elems, unsigned int flags)
+{
+ return mowgli_heap_create_full(elem_size, mowgli_heap_elems, flags, NULL);
+}
+
+/* completely frees a mowgli_heap_t and all blocks */
+void
+mowgli_heap_destroy(mowgli_heap_t *heap)
+{
+ mowgli_node_t *n, *tn;
+
+ MOWGLI_LIST_FOREACH_SAFE(n, tn, heap->blocks.head)
+ {
+ mowgli_heap_shrink(heap, n->data);
+ }
+
+ if (heap->empty_block)
+ mowgli_heap_shrink(heap, heap->empty_block);
+
+ mowgli_mutex_uninit(&heap->mutex);
+
+ /* everything related to heap has gone, time for itself */
+ mowgli_free(heap);
+}
+
+/* allocates a new item from a mowgli_heap_t */
+void *
+mowgli_heap_alloc(mowgli_heap_t *heap)
+{
+ mowgli_node_t *n;
+ mowgli_block_t *b;
+ mowgli_heap_elem_header_t *h;
+
+ if (mowgli_mutex_lock(&heap->mutex) != 0)
+ mowgli_log_fatal("heap mutex can't be locked");
+
+ /* no free space? */
+ if (heap->free_elems == 0)
+ {
+ mowgli_heap_expand(heap);
+
+ if (heap->free_elems == 0)
+ {
+ mowgli_mutex_unlock(&heap->mutex);
+ return NULL;
+ }
+ }
+
+ /* try a partially used block before using a fully free block */
+ n = heap->blocks.head;
+ b = n != NULL ? n->data : NULL;
+
+ if ((b == NULL) || (b->first_free == NULL))
+ b = heap->empty_block;
+
+ /* due to above check */
+ return_val_if_fail(b != NULL, NULL);
+
+ /* pull the first free node from the list */
+ h = b->first_free;
+ return_val_if_fail(h != NULL, NULL);
+
+ /* mark it as used */
+ b->first_free = h->un.next;
+ h->un.block = b;
+
+ /* keep count */
+ heap->free_elems--;
+ b->num_allocated++;
+
+ /* move it between the lists if needed */
+
+ /* note that a block has at least two items in it, so these cases
+ * cannot both occur in the same allocation */
+ if (b->num_allocated == 1)
+ {
+ heap->empty_block = NULL;
+ mowgli_node_add_head(b, &b->node, &heap->blocks);
+ }
+ else if (b->first_free == NULL)
+ {
+ /* move full blocks to the end of the list */
+ mowgli_node_delete(&b->node, &heap->blocks);
+ mowgli_node_add(b, &b->node, &heap->blocks);
+ }
+
+#ifdef HEAP_DEBUG
+
+ /* debug */
+ mowgli_log("mowgli_heap_alloc(heap = @%p) -> %p", heap, (char*) h + sizeof(mowgli_heap_elem_header_t));
+#endif
+
+ mowgli_mutex_unlock(&heap->mutex);
+
+ /* return pointer to it */
+ return (char *) h + sizeof(mowgli_heap_elem_header_t);
+}
+
+/* frees an item back to the mowgli_heap_t */
+void
+mowgli_heap_free(mowgli_heap_t *heap, void *data)
+{
+ mowgli_block_t *b;
+ mowgli_heap_elem_header_t *h;
+
+ if (mowgli_mutex_lock(&heap->mutex) != 0)
+ mowgli_log_fatal("heap mutex can't be locked");
+
+ h = (mowgli_heap_elem_header_t *) ((char *) data - sizeof(mowgli_heap_elem_header_t));
+ b = h->un.block;
+
+ return_if_fail(b->heap == heap);
+ return_if_fail(b->num_allocated > 0);
+
+ /* memset the element before returning it to the heap. */
+ memset(data, 0, b->heap->elem_size);
+
+ /* mark it as free */
+ h->un.next = b->first_free;
+ b->first_free = h;
+
+ /* keep count */
+ heap->free_elems++;
+ b->num_allocated--;
+#ifdef HEAP_DEBUG
+
+ /* debug */
+ mowgli_log("mowgli_heap_free(heap = @%p, data = %p)", heap, data);
+#endif
+
+ /* move it between the lists if needed */
+ if (b->num_allocated == 0)
+ {
+ if (heap->empty_block != NULL)
+ mowgli_heap_shrink(heap, heap->empty_block);
+
+ mowgli_node_delete(&b->node, &heap->blocks);
+ heap->empty_block = b;
+ }
+ else if (b->num_allocated == heap->mowgli_heap_elems - 1)
+ {
+ mowgli_node_delete(&b->node, &heap->blocks);
+ mowgli_node_add_head(b, &b->node, &heap->blocks);
+ }
+
+ mowgli_mutex_unlock(&heap->mutex);
+}
diff --git a/src/libmowgli/core/heap.h b/src/libmowgli/core/heap.h
new file mode 100644
index 0000000..e193983
--- /dev/null
+++ b/src/libmowgli/core/heap.h
@@ -0,0 +1,48 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * heap.h: Heap allocation.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ * Copyright (c) 2005-2006 Theo Julienne <terminal -at- atheme.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ *
+ * Legal note: code devised from claro.base.block module r288 (Pre MPL)
+ */
+
+#ifndef __MOWGLI_HEAP_H__
+#define __MOWGLI_HEAP_H__
+
+typedef struct mowgli_heap_ mowgli_heap_t;
+typedef struct mowgli_block_ mowgli_block_t;
+
+/* Flag for mowgli_heap_create */
+#define BH_DONTCARE 0
+
+#define BH_NOW 1
+#define BH_LAZY 0
+
+/* Functions for heaps */
+extern mowgli_heap_t *mowgli_heap_create(size_t elem_size, size_t mowgli_heap_elems, unsigned int flags);
+extern mowgli_heap_t *mowgli_heap_create_full(size_t elem_size, size_t mowgli_heap_elems, unsigned int flags, mowgli_allocation_policy_t *allocator);
+extern void mowgli_heap_destroy(mowgli_heap_t *heap);
+
+/* Functions for blocks */
+extern void *mowgli_heap_alloc(mowgli_heap_t *heap);
+extern void mowgli_heap_free(mowgli_heap_t *heap, void *data);
+
+#endif
diff --git a/src/libmowgli/core/iterator.h b/src/libmowgli/core/iterator.h
new file mode 100644
index 0000000..2eac7b4
--- /dev/null
+++ b/src/libmowgli/core/iterator.h
@@ -0,0 +1,44 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * iterator.h: Iterators.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_ITERATOR_H__
+#define __MOWGLI_ITERATOR_H__
+
+typedef struct _mowgli_iterator
+{
+ struct _mowgli_iterator *prev, *next;
+
+ void *data;
+} mowgli_iterator_t;
+
+/* The following are macros which can be used with iterators. */
+#define MOWGLI_ITER_FOREACH(n, head) \
+ for (n = (head); n; n = n->next)
+#define MOWGLI_ITER_FOREACH_NEXT(n, head) \
+ for (n = (head); n->next; n = n->next)
+#define MOWGLI_ITER_FOREACH_PREV(n, tail) \
+ for (n = (tail); n; n = n->prev)
+#define MOWGLI_ITER_FOREACH_SAFE(n, tn, head) \
+ for (n = (head), tn = n ? n->next : NULL; n != NULL; n = tn, tn = n ? n->next : NULL)
+
+#endif
diff --git a/src/libmowgli/core/logger.c b/src/libmowgli/core/logger.c
new file mode 100644
index 0000000..e334dd2
--- /dev/null
+++ b/src/libmowgli/core/logger.c
@@ -0,0 +1,95 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * logger.c: Event and debugging message logging.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+#define MOWGLI_LOG_BUF_SIZE 4096
+
+char _mowgli_log_buf[MOWGLI_LOG_BUF_SIZE];
+mowgli_log_cb_t _mowgli_log_cb;
+
+void
+mowgli_log_cb_default(const char *buf)
+{
+ fprintf(stderr, "%s\n", buf);
+}
+
+void
+mowgli_log_bootstrap()
+{
+ _mowgli_log_cb = mowgli_log_cb_default;
+}
+
+void
+mowgli_log_set_cb(mowgli_log_cb_t callback)
+{
+ return_if_fail(callback != NULL);
+
+ _mowgli_log_cb = callback;
+}
+
+void
+mowgli_log_prefix_real(const char *file, int line, const char *func, const char *prefix, const char *fmt, ...)
+{
+ int len = snprintf(_mowgli_log_buf, MOWGLI_LOG_BUF_SIZE, "(%s:%d %s): %s",
+ file, line, func, prefix);
+
+ char *buf = &_mowgli_log_buf[len];
+
+ va_list va;
+
+ va_start(va, fmt);
+ vsnprintf(buf, MOWGLI_LOG_BUF_SIZE - len, fmt, va);
+ va_end(va);
+
+ _mowgli_log_cb(_mowgli_log_buf);
+}
+
+/* TODO: remove next time there is a LIB_MAJOR bump */
+void
+mowgli_log_real(const char *file, int line, const char *func, const char *fmt, ...)
+{
+ int len = snprintf(_mowgli_log_buf, 4095, "(%s:%d %s): ", file, line,
+ func);
+
+ char *buf = &_mowgli_log_buf[len];
+
+ va_list va;
+
+ va_start(va, fmt);
+ vsnprintf(buf, 4095 - len, fmt, va);
+ va_end(va);
+
+ _mowgli_log_cb(_mowgli_log_buf);
+}
+
+/* TODO: remove next time there is a LIB_MAJOR bump */
+void
+mowgli_soft_assert_log(const char *asrt, const char *file, int line, const char *function)
+{
+ snprintf(_mowgli_log_buf, 4095,
+ "(%s:%d %s): critical: Assertion '%s' failed.", file, line,
+ function, asrt);
+
+ _mowgli_log_cb(_mowgli_log_buf);
+}
diff --git a/src/libmowgli/core/logger.h b/src/libmowgli/core/logger.h
new file mode 100644
index 0000000..5c875d1
--- /dev/null
+++ b/src/libmowgli/core/logger.h
@@ -0,0 +1,62 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * logger.h: Event and debugging message logging.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ * Copyright (c) 2013 Patrick McFarland <pmcfarland@adterrasperaspera.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_LOGGER_H__
+#define __MOWGLI_LOGGER_H__
+
+typedef void (*mowgli_log_cb_t)(const char *);
+
+extern void mowgli_log_set_cb(mowgli_log_cb_t callback);
+
+#define mowgli_log(...) \
+ mowgli_log_prefix("", __VA_ARGS__)
+
+#define mowgli_log_warning(...) \
+ mowgli_log_prefix("warning: ", __VA_ARGS__)
+
+#define mowgli_log_error(...) \
+ mowgli_log_prefix("error: ", __VA_ARGS__)
+
+#define mowgli_log_fatal(...) \
+ do \
+ { \
+ mowgli_log_prefix("fatal: ", __VA_ARGS__); \
+ abort(); \
+ } while (0)
+
+#define mowgli_log_prefix(prefix, ...) \
+ mowgli_log_prefix_real(__FILE__, __LINE__, _MOWGLI_FUNCNAME, prefix, __VA_ARGS__)
+
+extern MOWGLI_COLD(MOWGLI_PRINTF(void mowgli_log_prefix_real(const char *file,
+ int line, const char *func, const char *prefix, const char *fmt, ...), 5));
+
+#if defined MOWGLI_COMPILER_GCC_COMPAT
+# define _MOWGLI_FUNCNAME __PRETTY_FUNCTION__
+#elif defined MOWGLI_COMPILER_MSVC
+# define _MOWGLI_FUNCNAME __FUNCTION__
+#else
+# define _MOWGLI_FUNCNAME __func__
+#endif
+
+#endif
diff --git a/src/libmowgli/core/mowgli_string.c b/src/libmowgli/core/mowgli_string.c
new file mode 100644
index 0000000..455a12c
--- /dev/null
+++ b/src/libmowgli/core/mowgli_string.c
@@ -0,0 +1,201 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * mowgli_string.c: Immutable string buffers with cheap manipulation.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ * Copyright (c) 2007 Pippijn van Steenhoven <pippijn -at- one09.net>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+mowgli_string_t *
+mowgli_string_create(void)
+{
+ mowgli_string_t *self = mowgli_alloc(sizeof(mowgli_string_t));
+
+ self->size = 64;
+ self->pos = 0;
+ self->str = mowgli_alloc(self->size);
+
+ self->append = &mowgli_string_append;
+ self->append_char = &mowgli_string_append_char;
+ self->reset = &mowgli_string_reset;
+ self->destroy = &mowgli_string_destroy;
+
+ return self;
+}
+
+void
+mowgli_string_reset(mowgli_string_t *self)
+{
+ return_if_fail(self != NULL);
+
+ self->str[0] = self->pos = 0;
+}
+
+void
+mowgli_string_destroy(mowgli_string_t *self)
+{
+ return_if_fail(self != NULL);
+
+ mowgli_free(self->str);
+ mowgli_free(self);
+}
+
+void
+mowgli_string_append(mowgli_string_t *self, const char *src, size_t n)
+{
+ if (self->size - self->pos <= n)
+ {
+ char *new_ptr;
+
+ self->size = MAX(self->size * 2, self->pos + n + 8);
+
+ new_ptr = mowgli_alloc(self->size);
+ mowgli_strlcpy(new_ptr, self->str, self->size);
+
+ mowgli_free(self->str);
+ self->str = new_ptr;
+ }
+
+ memcpy(self->str + self->pos, src, n);
+ self->pos += n;
+ self->str[self->pos] = 0;
+}
+
+void
+mowgli_string_append_char(mowgli_string_t *self, const char c)
+{
+ if (self->size - self->pos <= 1)
+ {
+ char *new_ptr;
+
+ self->size = MAX(self->size * 2, self->pos + 9);
+
+ new_ptr = mowgli_alloc(self->size);
+ mowgli_strlcpy(new_ptr, self->str, self->size);
+
+ mowgli_free(self->str);
+ self->str = new_ptr;
+ }
+
+ self->str[self->pos++] = c;
+ self->str[self->pos] = 0;
+}
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.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.
+ */
+
+size_t
+mowgli_strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ {
+ d++;
+ }
+
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return dlen + strlen(s);
+
+ while (*s != '\0')
+ {
+ if (n != 1)
+ {
+ *d++ = *s;
+ n--;
+ }
+
+ s++;
+ }
+
+ *d = '\0';
+
+ return dlen + (s - src);/* count does not include NUL */
+}
+
+size_t
+mowgli_strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0)
+ while (--n != 0)
+ {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+
+ if (n == 0)
+ {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+
+ while (*s++)
+ { }
+ }
+
+ return s - src - 1; /* count does not include NUL */
+}
+
+ssize_t
+mowgli_writef(mowgli_descriptor_t fd, const char *fmt, ...)
+{
+ size_t len;
+ va_list va;
+ char buf[16384];
+
+ return_val_if_fail(fmt != NULL, -1);
+
+ va_start(va, fmt);
+ len = vsnprintf(buf, sizeof buf, fmt, va);
+ va_end(va);
+
+#ifdef _WIN32
+ return send(fd, buf, len, 0);
+#else
+ return write(fd, buf, len);
+#endif
+}
diff --git a/src/libmowgli/core/mowgli_string.h b/src/libmowgli/core/mowgli_string.h
new file mode 100644
index 0000000..9652b4c
--- /dev/null
+++ b/src/libmowgli/core/mowgli_string.h
@@ -0,0 +1,53 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * mowgli_string.h: Immutable string buffers with cheap manipulation.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ * Copyright (c) 2007 Pippijn van Steenhoven <pippijn -at- one09.net>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_STRING_H__
+#define __MOWGLI_STRING_H__
+
+typedef struct mowgli_string_
+{
+ char *str;
+ size_t pos;
+ size_t size;
+
+ void (*reset)(struct mowgli_string_ *self);
+
+ void (*append)(struct mowgli_string_ *self, const char *src, size_t n);
+
+ void (*append_char)(struct mowgli_string_ *self, const char c);
+
+ void (*destroy)(struct mowgli_string_ *self);
+} mowgli_string_t;
+
+extern mowgli_string_t *mowgli_string_create(void);
+extern void mowgli_string_reset(mowgli_string_t *self);
+extern void mowgli_string_destroy(mowgli_string_t *self);
+extern void mowgli_string_append(mowgli_string_t *self, const char *src, size_t n);
+extern void mowgli_string_append_char(mowgli_string_t *self, const char c);
+
+extern size_t mowgli_strlcat(char *dest, const char *src, size_t count);
+extern size_t mowgli_strlcpy(char *dest, const char *src, size_t count);
+extern ssize_t mowgli_writef(mowgli_descriptor_t fd, const char *fmt, ...);
+
+#endif
diff --git a/src/libmowgli/core/process.c b/src/libmowgli/core/process.c
new file mode 100644
index 0000000..9d6c8b4
--- /dev/null
+++ b/src/libmowgli/core/process.c
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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.
+ */
+
+#include "mowgli.h"
+
+typedef struct
+{
+ char *path;
+ char **argv;
+} mowgli_process_execv_req_t;
+
+static void
+mowgli_process_cloned_execv(mowgli_process_execv_req_t *execv_req)
+{
+#ifndef _WIN32
+ return_if_fail(execv_req != NULL);
+ return_if_fail(execv_req->path != NULL);
+ return_if_fail(execv_req->argv != NULL);
+
+ /* Do best to set proctitle if below hack don't work */
+ mowgli_proctitle_set("%s", execv_req->argv[0]);
+ execv(execv_req->path, execv_req->argv);
+
+ mowgli_free(execv_req->argv);
+ mowgli_free(execv_req->path);
+ mowgli_free(execv_req);
+#else
+# warning implement me :(
+#endif
+}
+
+mowgli_process_t *
+mowgli_process_clone(mowgli_process_start_fn_t start_fn, const char *procname, void *userdata)
+{
+#ifndef _WIN32
+ mowgli_process_t *out;
+
+ return_val_if_fail(start_fn != NULL, NULL);
+
+ out = mowgli_alloc(sizeof(mowgli_process_t));
+ out->userdata = userdata;
+
+ out->pid = fork();
+
+ switch (out->pid)
+ {
+ default:
+ break;
+
+ case 0:
+
+ /* Do our best to set this... */
+ mowgli_proctitle_set("%s", procname);
+ start_fn(out->userdata);
+ _exit(255);
+
+ return NULL;
+ break;
+
+ case -1:
+ mowgli_free(out);
+ return NULL;
+ break;
+ }
+
+ return out;
+#else
+# warning implement me :(
+ return NULL;
+#endif
+}
+
+mowgli_process_t *
+mowgli_process_spawn(const char *path, char *const argv[])
+{
+ size_t i;
+ mowgli_process_execv_req_t *req;
+
+ return_val_if_fail(path != NULL, NULL);
+ return_val_if_fail(argv != NULL, NULL);
+
+ req = mowgli_alloc(sizeof(mowgli_process_execv_req_t));
+ req->path = mowgli_strdup(path);
+
+ for (i = 0; argv[i] != NULL; i++)
+ ;
+
+ req->argv = mowgli_alloc_array(sizeof(char *), i + 1);
+
+ for (i = 0; argv[i] != NULL; i++)
+ req->argv[i] = argv[i];
+
+ return mowgli_process_clone((mowgli_process_start_fn_t) mowgli_process_cloned_execv, req->argv[0], req);
+}
+
+void
+mowgli_process_kill(mowgli_process_t *process)
+{
+#ifndef _WIN32
+ return_if_fail(process != NULL);
+
+ kill(process->pid, SIGKILL);
+#else
+# warning implement me :(
+#endif
+}
diff --git a/src/libmowgli/core/process.h b/src/libmowgli/core/process.h
new file mode 100644
index 0000000..c2fdcf1
--- /dev/null
+++ b/src/libmowgli/core/process.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 William Pitcock <nenolod@dereferenced.org>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_PROCESS_H__
+#define __MOWGLI_PROCESS_H__
+
+typedef void (*mowgli_process_start_fn_t)(void *data);
+
+typedef pid_t mowgli_process_id_t;
+
+typedef struct
+{
+ mowgli_process_id_t pid;
+ void *userdata;
+} mowgli_process_t;
+
+extern mowgli_process_t *mowgli_process_clone(mowgli_process_start_fn_t start_fn, const char *proctitle, void *userdata);
+extern mowgli_process_t *mowgli_process_spawn(const char *path, char *const argv[]);
+extern void mowgli_process_kill(mowgli_process_t *process);
+
+#endif
diff --git a/src/libmowgli/core/stdinc.h b/src/libmowgli/core/stdinc.h
new file mode 100644
index 0000000..e1410a5
--- /dev/null
+++ b/src/libmowgli/core/stdinc.h
@@ -0,0 +1,109 @@
+/*
+ * libmowgli: A collection of useful routines for programming.
+ * stdinc.h: Pulls in the base system includes for libmowgli.
+ *
+ * Copyright (c) 2007 William Pitcock <nenolod -at- sacredspiral.co.uk>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice is present in all copies.
+ *
+ * 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 __MOWGLI_STDINC_H__
+#define __MOWGLI_STDINC_H__
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <signal.h>
+#include <time.h>
+#include <errno.h>
+#include <setjmp.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <limits.h>
+
+/* socket stuff */
+#ifndef _WIN32
+# include <netdb.h>
+# include <netinet/in.h>
+# include <unistd.h>
+# include <grp.h>
+# include <sys/time.h>
+# include <sys/wait.h>
+# include <sys/resource.h>
+# include <sys/socket.h>
+# include <fcntl.h>
+# include <arpa/inet.h>
+# include <libgen.h>
+# include <dirent.h>
+#else
+# define WINVER 0x0501
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# include <winsock2.h>
+# include <ws2tcpip.h>
+# include <sys/timeb.h>
+# include <direct.h>
+# include <io.h>
+# include <process.h>
+# include <fcntl.h>
+# include "platform/win32/win32_stdinc.h"
+#endif
+
+#ifdef _MSC_VER
+# pragma warning (disable: 4996)
+#endif
+
+#ifdef FALSE
+# undef FALSE
+#endif
+
+#ifdef TRUE
+# undef TRUE
+#endif
+
+typedef enum {FALSE, TRUE} mowgli_boolean_t;
+
+/* Macros for min/max. */
+#ifndef MIN
+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#ifndef MAX
+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+/* OpenSSL stuff */
+#ifdef HAVE_OPENSSL
+# if defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# ifdef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
+# undef DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
+# define DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER
+# endif
+# endif
+# include <openssl/rand.h>
+# include <openssl/ssl.h>
+# include <openssl/err.h>
+#endif
+
+#endif