changeset 2603:3c52a573889a

Merge branch 'stable'
author Mark Brand <mabrand@mabrand.nl>
date Wed, 13 Jun 2012 19:11:14 +0200
parents a7251453b7ff (diff) 5fa39b653154 (current diff)
children 0b271dd82312
files src/libpaper.mk
diffstat 257 files changed, 16014 insertions(+), 1543 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Wed Jun 13 02:35:57 2012 -0700
+++ b/.gitignore	Wed Jun 13 19:11:14 2012 +0200
@@ -1,3 +1,4 @@
+/settings.mk
 /usr/
 /log/
 /pkg
--- a/Makefile	Wed Jun 13 02:35:57 2012 -0700
+++ b/Makefile	Wed Jun 13 19:11:14 2012 +0200
@@ -13,6 +13,9 @@
 LIBTOOLIZE := $(shell glibtoolize --help >/dev/null 2>&1 && echo g)libtoolize
 PATCH      := $(shell gpatch --help >/dev/null 2>&1 && echo g)patch
 SED        := $(shell gsed --help >/dev/null 2>&1 && echo g)sed
+WGET       := wget --no-check-certificate \
+                   --user-agent=$(shell wget --version | \
+                   $(SED) -n 's,GNU \(Wget\) \([0-9.]*\).*,\1/\2,p')
 
 REQUIREMENTS := autoconf automake bash bison bzip2 cmake flex \
                 gcc intltoolize $(LIBTOOL) $(LIBTOOLIZE) \
@@ -61,13 +64,25 @@
 DOWNLOAD_PKG_ARCHIVE = \
     mkdir -p '$(PKG_DIR)' && \
     $(if $($(1)_URL_2), \
-        ( wget -T 30 -t 3 --no-check-certificate -O- '$($(1)_URL)' || wget --no-check-certificate -O- '$($(1)_URL_2)' ), \
-        wget --no-check-certificate -O- '$($(1)_URL)') \
+        ( $(WGET) -T 30 -t 3 -O- '$($(1)_URL)' || $(WGET) -O- '$($(1)_URL_2)' ), \
+        $(WGET) -O- '$($(1)_URL)') \
     $(if $($(1)_FIX_GZIP), \
         | gzip -d | gzip -9n, \
         ) \
     > '$(PKG_DIR)/$($(1)_FILE)'
 
+ifeq ($(IGNORE_SETTINGS),yes)
+    $(info [ignore settings.mk])
+else ifeq ($(wildcard $(PWD)/settings.mk),$(PWD)/settings.mk)
+    include $(PWD)/settings.mk
+else
+    $(info [create settings.mk])
+    $(shell { \
+        echo '#JOBS = $(JOBS)'; \
+        echo '#PKGS ='; \
+    } >'$(PWD)/settings.mk')
+endif
+
 .PHONY: all
 all: $(PKGS)
 
--- a/index.html	Wed Jun 13 02:35:57 2012 -0700
+++ b/index.html	Wed Jun 13 19:11:14 2012 +0200
@@ -914,6 +914,16 @@
         <td id="agg-website"><a href="http://www.antigrain.com/">Anti-Grain Geometry</a></td>
     </tr>
     <tr>
+        <td id="apr-util-package">apr-util</td>
+        <td id="apr-util-version">1.3.10</td>
+        <td id="apr-util-website"><a href="http://apr.apache.org/">APR-util</a></td>
+    </tr>
+    <tr>
+        <td id="apr-package">apr</td>
+        <td id="apr-version">1.4.2</td>
+        <td id="apr-website"><a href="http://apr.apache.org/">APR</a></td>
+    </tr>
+    <tr>
         <td id="atk-package">atk</td>
         <td id="atk-version">2.2.0</td>
         <td id="atk-website"><a href="http://www.gtk.org/">ATK</a></td>
@@ -974,6 +984,11 @@
         <td id="cgal-website"><a href="http://www.cgal.org/">cgal</a></td>
     </tr>
     <tr>
+        <td id="cminpack-package">cminpack</td>
+        <td id="cminpack-version">1.2.0</td>
+        <td id="cminpack-website"><a href="http://devernay.free.fr/hacks/cminpack/cminpack.html">cminpack</a></td>
+    </tr>
+    <tr>
         <td id="cppunit-package">cppunit</td>
         <td id="cppunit-version">1.12.1</td>
         <td id="cppunit-website"><a href="http://apps.sourceforge.net/mediawiki/cppunit/">CppUnit</a></td>
@@ -985,12 +1000,12 @@
     </tr>
     <tr>
         <td id="curl-package">curl</td>
-        <td id="curl-version">7.25.0</td>
+        <td id="curl-version">7.26.0</td>
         <td id="curl-website"><a href="http://curl.haxx.se/libcurl/">cURL</a></td>
     </tr>
     <tr>
         <td id="dbus-package">dbus</td>
-        <td id="dbus-version">1.5.12</td>
+        <td id="dbus-version">1.6.0</td>
         <td id="dbus-website"><a href="http://dbus.freedesktop.org/">dbus</a></td>
     </tr>
     <tr>
@@ -1010,7 +1025,7 @@
     </tr>
     <tr>
         <td id="exiv2-package">exiv2</td>
-        <td id="exiv2-version">0.22</td>
+        <td id="exiv2-version">0.23</td>
         <td id="exiv2-website"><a href="http://www.exiv2.org/">Exiv2</a></td>
     </tr>
     <tr>
@@ -1025,12 +1040,12 @@
     </tr>
     <tr>
         <td id="ffmpeg-package">ffmpeg</td>
-        <td id="ffmpeg-version">0.10.2</td>
+        <td id="ffmpeg-version">0.11.1</td>
         <td id="ffmpeg-website"><a href="http://www.ffmpeg.org/">ffmpeg</a></td>
     </tr>
     <tr>
         <td id="fftw-package">fftw</td>
-        <td id="fftw-version">3.3.1</td>
+        <td id="fftw-version">3.3.2</td>
         <td id="fftw-website"><a href="http://www.fftw.org/">fftw</a></td>
     </tr>
     <tr>
@@ -1085,7 +1100,7 @@
     </tr>
     <tr>
         <td id="gc-package">gc</td>
-        <td id="gc-version">7.1</td>
+        <td id="gc-version">7.2b</td>
         <td id="gc-website"><a href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">gc</a></td>
     </tr>
     <tr>
@@ -1095,7 +1110,7 @@
     </tr>
     <tr>
         <td id="gcc-gmp-package">gcc-gmp</td>
-        <td id="gcc-gmp-version">5.0.4</td>
+        <td id="gcc-gmp-version">5.0.5</td>
         <td id="gcc-gmp-website"><a href="http://www.gmplib.org/">GMP for GCC</a></td>
     </tr>
     <tr>
@@ -1115,12 +1130,12 @@
     </tr>
     <tr>
         <td id="gdal-package">gdal</td>
-        <td id="gdal-version">1.9.0</td>
+        <td id="gdal-version">1.9.1</td>
         <td id="gdal-website"><a href="http://www.gdal.org/">GDAL</a></td>
     </tr>
     <tr>
         <td id="gdb-package">gdb</td>
-        <td id="gdb-version">7.4</td>
+        <td id="gdb-version">7.4.1</td>
         <td id="gdb-website"><a href="http://www.gnu.org/software/gdb/">gdb</a></td>
     </tr>
     <tr>
@@ -1130,7 +1145,7 @@
     </tr>
     <tr>
         <td id="geos-package">geos</td>
-        <td id="geos-version">3.3.2</td>
+        <td id="geos-version">3.3.4</td>
         <td id="geos-website"><a href="http://trac.osgeo.org/geos/">GEOS</a></td>
     </tr>
     <tr>
@@ -1140,7 +1155,7 @@
     </tr>
     <tr>
         <td id="giflib-package">giflib</td>
-        <td id="giflib-version">4.1.6</td>
+        <td id="giflib-version">4.2.0</td>
         <td id="giflib-website"><a href="http://sourceforge.net/projects/libungif/">giflib</a></td>
     </tr>
     <tr>
@@ -1160,17 +1175,17 @@
     </tr>
     <tr>
         <td id="gmp-package">gmp</td>
-        <td id="gmp-version">5.0.4</td>
+        <td id="gmp-version">5.0.5</td>
         <td id="gmp-website"><a href="http://www.gmplib.org/">GMP</a></td>
     </tr>
     <tr>
         <td id="gnutls-package">gnutls</td>
-        <td id="gnutls-version">3.0.17</td>
+        <td id="gnutls-version">3.0.20</td>
         <td id="gnutls-website"><a href="http://www.gnu.org/software/gnutls/">GnuTLS</a></td>
     </tr>
     <tr>
         <td id="graphicsmagick-package">graphicsmagick</td>
-        <td id="graphicsmagick-version">1.3.14</td>
+        <td id="graphicsmagick-version">1.3.15</td>
         <td id="graphicsmagick-website"><a href="http://www.graphicsmagick.org/">GraphicsMagick</a></td>
     </tr>
     <tr>
@@ -1180,7 +1195,7 @@
     </tr>
     <tr>
         <td id="gsoap-package">gsoap</td>
-        <td id="gsoap-version">2.8.8</td>
+        <td id="gsoap-version">2.8.9</td>
         <td id="gsoap-website"><a href="http://gsoap2.sourceforge.net/">gSOAP</a></td>
     </tr>
     <tr>
@@ -1239,6 +1254,11 @@
         <td id="guile-website"><a href="http://www.gnu.org/software/guile/">GNU Guile</a></td>
     </tr>
     <tr>
+        <td id="hunspell-package">hunspell</td>
+        <td id="hunspell-version">1.3.2</td>
+        <td id="hunspell-website"><a href="http://hunspell.sourceforge.net/">Hunspell</a></td>
+    </tr>
+    <tr>
         <td id="id3lib-package">id3lib</td>
         <td id="id3lib-version">3.8.3</td>
         <td id="id3lib-website"><a href="http://id3lib.sourceforge.net/">id3lib</a></td>
@@ -1289,6 +1309,11 @@
         <td id="lcms1-website"><a href="http://www.littlecms.com/">lcms1</a></td>
     </tr>
     <tr>
+        <td id="levmar-package">levmar</td>
+        <td id="levmar-version">2.6</td>
+        <td id="levmar-website"><a href="http://www.ics.forth.gr/~lourakis/levmar">levmar</a></td>
+    </tr>
+    <tr>
         <td id="libarchive-package">libarchive</td>
         <td id="libarchive-version">3.0.3</td>
         <td id="libarchive-website"><a href="http://code.google.com/p/libarchive/">Libarchive</a></td>
@@ -1310,12 +1335,17 @@
     </tr>
     <tr>
         <td id="libevent-package">libevent</td>
-        <td id="libevent-version">2.0.18</td>
+        <td id="libevent-version">2.0.19</td>
         <td id="libevent-website"><a href="http://libevent.org/">libevent</a></td>
     </tr>
     <tr>
+        <td id="libf2c-package">libf2c</td>
+        <td id="libf2c-version">1</td>
+        <td id="libf2c-website"><a href="http://www.netlib.org/f2c/">libf2c</a></td>
+    </tr>
+    <tr>
         <td id="libffi-package">libffi</td>
-        <td id="libffi-version">3.0.10</td>
+        <td id="libffi-version">3.0.11</td>
         <td id="libffi-website"><a href="http://sourceware.org/libffi/">libffi</a></td>
     </tr>
     <tr>
@@ -1324,13 +1354,23 @@
         <td id="libgcrypt-website"><a href="ftp://ftp.gnupg.org/gcrypt/libgcrypt/">libgcrypt</a></td>
     </tr>
     <tr>
+        <td id="libgda-package">libgda</td>
+        <td id="libgda-version">4.2.13</td>
+        <td id="libgda-website"><a href="http://www.gnome-db.org/">libgda</a></td>
+    </tr>
+    <tr>
+        <td id="libgdamm-package">libgdamm</td>
+        <td id="libgdamm-version">4.1.3</td>
+        <td id="libgdamm-website"><a href="https://launchpad.net/libgdamm">libgdamm</a></td>
+    </tr>
+    <tr>
         <td id="libgee-package">libgee</td>
         <td id="libgee-version">0.5.0</td>
         <td id="libgee-website"><a href="http://live.gnome.org/Libgee">libgee</a></td>
     </tr>
     <tr>
         <td id="libgeotiff-package">libgeotiff</td>
-        <td id="libgeotiff-version">1.3.0</td>
+        <td id="libgeotiff-version">1.4.0</td>
         <td id="libgeotiff-website"><a href="http://trac.osgeo.org/geotiff/">GeoTiff</a></td>
     </tr>
     <tr>
@@ -1350,7 +1390,7 @@
     </tr>
     <tr>
         <td id="libgsasl-package">libgsasl</td>
-        <td id="libgsasl-version">1.6.1</td>
+        <td id="libgsasl-version">1.8.0</td>
         <td id="libgsasl-website"><a href="http://www.gnu.org/software/gsasl/">Libgsasl</a></td>
     </tr>
     <tr>
@@ -1380,7 +1420,7 @@
     </tr>
     <tr>
         <td id="libidn-package">libidn</td>
-        <td id="libidn-version">1.24</td>
+        <td id="libidn-version">1.25</td>
         <td id="libidn-website"><a href="http://www.gnu.org/software/libidn/">Libidn</a></td>
     </tr>
     <tr>
@@ -1409,6 +1449,11 @@
         <td id="libmng-website"><a href="http://www.libmng.com/">libmng</a></td>
     </tr>
     <tr>
+        <td id="libmodplug-package">libmodplug</td>
+        <td id="libmodplug-version">0.8.8.4</td>
+        <td id="libmodplug-website"><a href="http://modplug-xmms.sourceforge.net/">libmodplug</a></td>
+    </tr>
+    <tr>
         <td id="libntlm-package">libntlm</td>
         <td id="libntlm-version">1.3</td>
         <td id="libntlm-website"><a href="http://www.nongnu.org/libntlm/">Libntlm</a></td>
@@ -1435,7 +1480,7 @@
     </tr>
     <tr>
         <td id="libpaper-package">libpaper</td>
-        <td id="libpaper-version">1.1.24+nmu1</td>
+        <td id="libpaper-version">1.1.24+nmu2</td>
         <td id="libpaper-website"><a href="http://packages.debian.org/unstable/libpaper1">libpaper</a></td>
     </tr>
     <tr>
@@ -1445,8 +1490,13 @@
     </tr>
     <tr>
         <td id="librsvg-package">librsvg</td>
-        <td id="librsvg-version">2.36.0</td>
+        <td id="librsvg-version">2.36.1</td>
         <td id="librsvg-website"><a href="http://librsvg.sourceforge.net/">librsvg</a></td>
+	</tr>
+    <tr>
+        <td id="librtmp-package">librtmp</td>
+        <td id="librtmp-version">2.4</td>
+        <td id="librtmp-website"><a href="http://rtmpdump.mplayerhq.hu/">librtmp</a></td>
     </tr>
     <tr>
         <td id="libsamplerate-package">libsamplerate</td>
@@ -1455,7 +1505,7 @@
     </tr>
     <tr>
         <td id="libshout-package">libshout</td>
-        <td id="libshout-version">2.2.2</td>
+        <td id="libshout-version">2.3.0</td>
         <td id="libshout-website"><a href="http://www.icecast.org/">libshout</a></td>
     </tr>
     <tr>
@@ -1470,7 +1520,7 @@
     </tr>
     <tr>
         <td id="libssh2-package">libssh2</td>
-        <td id="libssh2-version">1.4.0</td>
+        <td id="libssh2-version">1.4.2</td>
         <td id="libssh2-website"><a href="http://www.libssh2.org">libssh2</a></td>
     </tr>
     <tr>
@@ -1490,7 +1540,7 @@
     </tr>
     <tr>
         <td id="libvpx-package">libvpx</td>
-        <td id="libvpx-version">1.0.0</td>
+        <td id="libvpx-version">1.1.0</td>
         <td id="libvpx-website"><a href="http://code.google.com/p/webm/">vpx</a></td>
     </tr>
     <tr>
@@ -1514,8 +1564,13 @@
         <td id="llvm-website"><a href="http://llvm.org/">llvm</a></td>
     </tr>
     <tr>
+        <td id="log4cxx-package">log4cxx</td>
+        <td id="log4cxx-version">0.10.0</td>
+        <td id="log4cxx-website"><a href="http://logging.apache.org/log4cxx/">log4cxx</a></td>
+    </tr>
+    <tr>
         <td id="lua-package">lua</td>
-        <td id="lua-version">5.1.4</td>
+        <td id="lua-version">5.2.0</td>
         <td id="lua-website"><a href="http://www.lua.org/">Lua</a></td>
     </tr>
     <tr>
@@ -1529,6 +1584,11 @@
         <td id="matio-website"><a href="http://sourceforge.net/projects/matio/">matio</a></td>
     </tr>
     <tr>
+        <td id="mdbtools-package">mdbtools</td>
+        <td id="mdbtools-version">0.6pre1</td>
+        <td id="mdbtools-website"><a href="http://sourceforge.net/projects/mdbtools/">mdbtools</a></td>
+    </tr>
+    <tr>
         <td id="mingw-utils-package">mingw-utils</td>
         <td id="mingw-utils-version">0.4-1</td>
         <td id="mingw-utils-website"><a href="http://www.mingw.org/">MinGW Utilities</a></td>
@@ -1545,7 +1605,7 @@
     </tr>
     <tr>
         <td id="muparser-package">muparser</td>
-        <td id="muparser-version">1.34</td>
+        <td id="muparser-version">2.2.2</td>
         <td id="muparser-website"><a href="http://muparser.sourceforge.net/">muParser</a></td>
     </tr>
     <tr>
@@ -1554,6 +1614,11 @@
         <td id="mxml-website"><a href="http://www.minixml.org/">Mini-XML</a></td>
     </tr>
     <tr>
+        <td id="ncurses-package">ncurses</td>
+        <td id="ncurses-version">5.9</td>
+        <td id="ncurses-website"><a href="http://www.gnu.org/software/ncurses/">Ncurses</a></td>
+    </tr>
+    <tr>
         <td id="nettle-package">nettle</td>
         <td id="nettle-version">2.4</td>
         <td id="nettle-website"><a href="http://www.lysator.liu.se/~nisse/nettle/">nettle</a></td>
@@ -1575,7 +1640,7 @@
     </tr>
     <tr>
         <td id="openal-package">openal</td>
-        <td id="openal-version">1.13</td>
+        <td id="openal-version">1.14</td>
         <td id="openal-website"><a href="http://kcat.strangesoft.net/openal.html">openal</a></td>
     </tr>
     <tr>
@@ -1600,7 +1665,7 @@
     </tr>
     <tr>
         <td id="openssl-package">openssl</td>
-        <td id="openssl-version">1.0.1</td>
+        <td id="openssl-version">1.0.1c</td>
         <td id="openssl-website"><a href="http://www.openssl.org/">openssl</a></td>
     </tr>
     <tr>
@@ -1625,7 +1690,7 @@
     </tr>
     <tr>
         <td id="pdflib_lite-package">pdflib_lite</td>
-        <td id="pdflib_lite-version">7.0.5</td>
+        <td id="pdflib_lite-version">7.0.5p3</td>
         <td id="pdflib_lite-website"><a href="http://www.pdflib.com/download/free-software/pdflib-lite-7/">PDFlib Lite</a></td>
     </tr>
     <tr>
@@ -1640,7 +1705,7 @@
     </tr>
     <tr>
         <td id="pixman-package">pixman</td>
-        <td id="pixman-version">0.25.2</td>
+        <td id="pixman-version">0.25.6</td>
         <td id="pixman-website"><a href="http://cairographics.org/">pixman</a></td>
     </tr>
     <tr>
@@ -1659,6 +1724,11 @@
         <td id="poco-website"><a href="http://pocoproject.org/">POCO C++ Libraries</a></td>
     </tr>
     <tr>
+        <td id="poppler-package">poppler</td>
+        <td id="poppler-version">0.18.4</td>
+        <td id="poppler-website"><a href="http://poppler.freedesktop.org/">poppler</a></td>
+    </tr>
+    <tr>
         <td id="popt-package">popt</td>
         <td id="popt-version">1.16</td>
         <td id="popt-website"><a href="http://freshmeat.net/projects/popt/">popt</a></td>
@@ -1670,7 +1740,7 @@
     </tr>
     <tr>
         <td id="postgresql-package">postgresql</td>
-        <td id="postgresql-version">9.1.3</td>
+        <td id="postgresql-version">9.1.4</td>
         <td id="postgresql-website"><a href="http://www.postgresql.org/">PostgreSQL</a></td>
     </tr>
     <tr>
@@ -1680,20 +1750,30 @@
     </tr>
     <tr>
         <td id="pthreads-package">pthreads</td>
-        <td id="pthreads-version">2-8-0</td>
+        <td id="pthreads-version">2-9-1</td>
         <td id="pthreads-website"><a href="http://sourceware.org/pthreads-win32/">Pthreads-w32</a></td>
     </tr>
     <tr>
+        <td id="qdbm-package">qdbm</td>
+        <td id="qdbm-version">1.8.78</td>
+        <td id="qdbm-website"><a href="http://fallabs.com/qdbm/">QDBM</a></td>
+    </tr>
+    <tr>
         <td id="qjson-package">qjson</td>
         <td id="qjson-version">0.7.1</td>
         <td id="qjson-website"><a href="http://qjson.sourceforge.net/">QJson</a></td>
     </tr>
     <tr>
         <td id="qt-package">qt</td>
-        <td id="qt-version">4.8.1</td>
+        <td id="qt-version">4.8.2</td>
         <td id="qt-website"><a href="http://qt.nokia.com/">Qt</a></td>
     </tr>
     <tr>
+        <td id="qwt-package">qwt</td>
+        <td id="qwt-version">6.0.1</td>
+        <td id="qwt-website"><a href="http://qwt.sourceforge.net/">Qwt</a></td>
+    </tr>
+    <tr>
         <td id="qwtplot3d-package">qwtplot3d</td>
         <td id="qwtplot3d-version">0.2.7</td>
         <td id="qwtplot3d-website"><a href="http://qwtplot3d.sourceforge.net/">QwtPlot3D</a></td>
@@ -1744,18 +1824,23 @@
         <td id="smpeg-website"><a href="http://icculus.org/smpeg/">smpeg</a></td>
     </tr>
     <tr>
+        <td id="sox-package">sox</td>
+        <td id="sox-version">14.4.0</td>
+        <td id="sox-website"><a href="http://sox.sourceforge.net/">SoX</a></td>
+    </tr>
+    <tr>
         <td id="speex-package">speex</td>
         <td id="speex-version">1.2rc1</td>
         <td id="speex-website"><a href="http://www.speex.org/">Speex</a></td>
     </tr>
     <tr>
         <td id="sqlite-package">sqlite</td>
-        <td id="sqlite-version">3071100</td>
+        <td id="sqlite-version">3071300</td>
         <td id="sqlite-website"><a href="http://www.sqlite.org/">SQLite</a></td>
     </tr>
     <tr>
         <td id="suitesparse-package">suitesparse</td>
-        <td id="suitesparse-version">3.7.0</td>
+        <td id="suitesparse-version">4.0.0</td>
         <td id="suitesparse-website"><a href="http://www.cise.ufl.edu/research/sparse/SuiteSparse/">SuiteSparse</a></td>
     </tr>
     <tr>
@@ -1765,7 +1850,7 @@
     </tr>
     <tr>
         <td id="taglib-package">taglib</td>
-        <td id="taglib-version">1.7.1</td>
+        <td id="taglib-version">1.7.2</td>
         <td id="taglib-website"><a href="http://developer.kde.org/~wheeler/taglib.html">TagLib</a></td>
     </tr>
     <tr>
@@ -1800,7 +1885,7 @@
     </tr>
     <tr>
         <td id="vorbis-package">vorbis</td>
-        <td id="vorbis-version">1.3.2</td>
+        <td id="vorbis-version">1.3.3</td>
         <td id="vorbis-website"><a href="http://www.vorbis.com/">Vorbis</a></td>
     </tr>
     <tr>
@@ -1840,12 +1925,12 @@
     </tr>
     <tr>
         <td id="xine-lib-package">xine-lib</td>
-        <td id="xine-lib-version">1.1.20.1</td>
+        <td id="xine-lib-version">1.1.21</td>
         <td id="xine-lib-website"><a href="http://www.xine-project.org/">xine-lib</a></td>
     </tr>
     <tr>
         <td id="xmlwrapp-package">xmlwrapp</td>
-        <td id="xmlwrapp-version">0.6.2</td>
+        <td id="xmlwrapp-version">0.6.3</td>
         <td id="xmlwrapp-website"><a href="http://sourceforge.net/projects/xmlwrapp/">xmlwrapp</a></td>
     </tr>
     <tr>
@@ -1860,7 +1945,7 @@
     </tr>
     <tr>
         <td id="zlib-package">zlib</td>
-        <td id="zlib-version">1.2.6</td>
+        <td id="zlib-version">1.2.7</td>
         <td id="zlib-website"><a href="http://zlib.net/">zlib</a></td>
     </tr>
     <tr>
@@ -2058,6 +2143,7 @@
             <tr><td><code>make</code></td>      <td>&rarr;</td><td><code>$(MAKE)</code></td></tr>
             <tr><td><code>patch</code></td>     <td>&rarr;</td><td><code>$(PATCH)</code></td></tr>
             <tr><td><code>sed</code></td>       <td>&rarr;</td><td><code>$(SED)</code></td></tr>
+            <tr><td><code>wget</code></td>      <td>&rarr;</td><td><code>$(WGET)</code></td></tr>
         </table>
     </li>
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/agg-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,27 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 2617d6a743ad197dc7ae0278a9c7015cc7dff61f Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 12 Jun 2012 17:05:49 +0200
+Subject: [PATCH] automake 1.12 compatibility fix
+
+---
+ configure.in |    1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/configure.in b/configure.in
+index fceca82..317e17b 100644
+--- a/configure.in
++++ b/configure.in
+@@ -8,7 +8,6 @@ dnl Checks for programs.
+ AC_PROG_CC
+ AC_PROG_CXX
+ AC_ISC_POSIX
+-AM_C_PROTOTYPES
+ if test "x$U" != "x"; then
+   AC_MSG_ERROR(Compiler not ANSI compliant)
+ fi
+-- 
+1.7.10.4
+
--- a/src/agg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/agg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.antigrain.com/download/index.html' | \
+    $(WGET) -q -O- 'http://www.antigrain.com/download/index.html' | \
     $(SED) -n 's,.*<A href="http://www.antigrain.com/agg-\([0-9.]*\).tar.gz".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/apr-util.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := apr-util
+$(PKG)_IGNORE   := 1.4.1
+$(PKG)_CHECKSUM := f5aaf15542209fee479679299dc4cb1ac0924a59
+$(PKG)_SUBDIR   := apr-util-$($(PKG)_VERSION)
+$(PKG)_FILE     := apr-util-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://mirror.apache-kr.org/apr/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://archive.apache.org/dist/apr/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc apr expat libiconv
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://apr.apache.org/download.cgi' | \
+    grep 'aprutil1.*best' |
+    $(SED) -n 's,.*APR-util \([0-9.]*\).*,\1,p'
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --enable-static \
+        --without-pgsql \
+        --without-sqlite2 \
+        --without-sqlite3 \
+        --with-apr='$(PREFIX)/$(TARGET)' \
+        CFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/apu-1-config' '$(PREFIX)/bin/$(TARGET)-apu-1-config'
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/apr.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := apr
+$(PKG)_IGNORE   := 1.4.6
+$(PKG)_CHECKSUM := d48324efb0280749a5d7ccbb053d68545c568b4b
+$(PKG)_SUBDIR   := apr-$($(PKG)_VERSION)
+$(PKG)_FILE     := apr-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://mirror.apache-kr.org/apr/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://archive.apache.org/dist/apr/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://apr.apache.org/download.cgi' | \
+    grep 'apr1.*best' |
+    $(SED) -n 's,.*APR \([0-9.]*\).*,\1,p'
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --enable-static \
+        ac_cv_sizeof_off_t=4 \
+        ac_cv_sizeof_pid_t=4 \
+        ac_cv_sizeof_size_t=4 \
+        ac_cv_sizeof_ssize_t=4 \
+        CFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/apr-1-config' '$(PREFIX)/bin/$(TARGET)-apr-1-config'
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/atk-1-DllMain.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,12 @@
+diff -uNr atk-2.2.0-orig/atk/atkobject.c atk-2.2.0/atk/atkobject.c
+--- atk-2.2.0-orig/atk/atkobject.c	2011-09-19 19:06:54.000000000 +0200
++++ atk-2.2.0/atk/atkobject.c	2012-04-14 20:26:12.763814596 +0200
+@@ -366,7 +366,7 @@
+ static HMODULE atk_dll;
+ 
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++atk_DllMain (HINSTANCE hinstDLL,
+ 	 DWORD     fdwReason,
+ 	 LPVOID    lpvReserved)
+ {
--- a/src/atk.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/atk.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := atk
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3f4daf31f99b6e0c12ce9675400f2f02dbf1b820
+$(PKG)_CHECKSUM := b9808b77c7905eb46fc2b64587ef93beab37470a
 $(PKG)_SUBDIR   := atk-$($(PKG)_VERSION)
-$(PKG)_FILE     := atk-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := atk-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/atk/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib gettext
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/atk/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/atk/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=ATK_\\([0-9]*_[0-9]*[02468]_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
@@ -18,7 +18,6 @@
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i 's,DllMain,static _disabled_DllMain,' '$(1)/atk/atkobject.c'
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --disable-shared \
--- a/src/atkmm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/atkmm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := atkmm
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 9ca44756821f4d431c554e1cf8184989bb25ce12
+$(PKG)_CHECKSUM := 2af04a30dd1f6250d3d35f616bbc34c264b7b327
 $(PKG)_SUBDIR   := atkmm-$($(PKG)_VERSION)
-$(PKG)_FILE     := atkmm-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := atkmm-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/atkmm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc atk glibmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/atkmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/atkmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/aubio.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/aubio.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc fftw libsamplerate libsndfile
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.aubio.org/download' | \
+    $(WGET) -q -O- 'http://www.aubio.org/download' | \
     $(SED) -n 's,.*aubio-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/binutils.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/binutils.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/binutils/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/binutils/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="binutils-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^2\.1' | \
     head -1
--- a/src/boost.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/boost.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib bzip2 expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.boost.org/users/download/' | \
+    $(WGET) -q -O- 'http://www.boost.org/users/download/' | \
     $(SED) -n 's,.*/boost/\([0-9][^"/]*\)/".*,\1,p' | \
     grep -v beta | \
     head -1
--- a/src/bzip2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/bzip2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.bzip.org/downloads.html' | \
+    $(WGET) -q -O- 'http://www.bzip.org/downloads.html' | \
     grep 'bzip2-' | \
     $(SED) -n 's,.*bzip2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cairo-1-DllMain.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,18 @@
+diff -uNr cairo-1.10.2-orig/src/cairo-system.c cairo-1.10.2/src/cairo-system.c
+--- cairo-1.10.2-orig/src/cairo-system.c	2010-06-18 13:47:14.000000000 +0200
++++ cairo-1.10.2/src/cairo-system.c	2012-04-14 22:01:27.848928137 +0200
+@@ -70,12 +70,12 @@
+ 
+ /* declare to avoid "no previous prototype for 'DllMain'" warning */
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++cairo_DllMain (HINSTANCE hinstDLL,
+          DWORD     fdwReason,
+          LPVOID    lpvReserved);
+ 
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++cairo_DllMain (HINSTANCE hinstDLL,
+          DWORD     fdwReason,
+          LPVOID    lpvReserved)
+ {
--- a/src/cairo.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/cairo.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib libpng fontconfig freetype pixman
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
     $(SED) -n 's,.*"cairo-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/cairomm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/cairomm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc cairo libsigc++
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/releases/?C=M;O=D' | \
     $(SED) -n 's,.*"cairomm-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^1\.8\.' | \
     head -1
--- a/src/cgal.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/cgal.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc boost gmp mpfr qt
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://gforge.inria.fr/frs/?group_id=52' | \
+    $(WGET) -q -O- 'https://gforge.inria.fr/frs/?group_id=52' | \
     grep 'CGAL-' | \
     $(SED) -n 's,.*CGAL-\([0-9][^>a-z]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cminpack.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,27 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := cminpack
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 7ac79d8623d0bc6c95c61e0c364ca9e38e8a13ca
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://devernay.free.fr/hacks/cminpack/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://devernay.free.fr/hacks/cminpack/cminpack.html' | \
+    $(SED) -n 's,.*cminpack-\([0-9.]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && cmake \
+        -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
+    $(MAKE) -C '$(1)' -j $(JOBS)
+
+    $(INSTALL) -d                         '$(PREFIX)/$(TARGET)/lib'
+    $(INSTALL) -m644 '$(1)/libcminpack.a' '$(PREFIX)/$(TARGET)/lib/'
+    $(INSTALL) -d                         '$(PREFIX)/$(TARGET)/include'
+    $(INSTALL) -m644 '$(1)/cminpack.h'    '$(PREFIX)/$(TARGET)/include/'
+endef
--- a/src/cppunit.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/cppunit.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/cppunit/files/cppunit/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/cppunit/files/cppunit/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/cunit.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/cunit.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/cunit/files/CUnit/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/cunit/files/CUnit/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/curl-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/curl-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -5,29 +5,105 @@
 http://github.com/bagder/curl
 Also contains MXE specific fixes.
 
-From ee69c33117cf616c19e9cd288f08eb4c91bf190d Mon Sep 17 00:00:00 2001
-From: Volker Grabsch <vog@notjusthosting.com>
-Date: Fri, 28 Oct 2011 13:48:04 +0200
-Subject: [PATCH] static linking for MXE
+From 07bcce2b2d7b51f2b7aadba8c842cc4b6ca70bb8 Mon Sep 17 00:00:00 2001
+From: Yang Tse <yangsita@gmail.com>
+Date: Fri, 25 May 2012 23:59:38 +0200
+Subject: [PATCH] Fix libcurl.pc and curl-config generation for static MingW*
+ cross builds
 
+(cherry picked from commit a379a4c1637cfe266bfa95c2c878f9cc06ce2f6a)
 ---
- include/curl/curlbuild.h.in |    3 +++
- 1 files changed, 3 insertions(+), 0 deletions(-)
+ configure.ac   |    3 +++
+ curl-config.in |   12 +++++++++---
+ libcurl.pc.in  |    4 ++--
+ 3 files changed, 14 insertions(+), 5 deletions(-)
 
-diff --git a/include/curl/curlbuild.h.in b/include/curl/curlbuild.h.in
-index fe348f4..c428273 100644
---- a/include/curl/curlbuild.h.in
-+++ b/include/curl/curlbuild.h.in
-@@ -111,6 +111,9 @@
- /*  EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY  */
- /* ================================================================ */
+diff --git a/configure.ac b/configure.ac
+index 2300c8c..db40f18 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -240,6 +240,7 @@ AM_CONDITIONAL(MIMPURE, test x$mimpure = xyes)
+ AC_MSG_CHECKING([if we need BUILDING_LIBCURL])
+ use_cppflag_building_libcurl="no"
+ use_cppflag_curl_staticlib="no"
++CPPFLAG_CURL_STATICLIB=""
+ case $host in
+   *-*-mingw*)
+     AC_MSG_RESULT(yes)
+@@ -249,6 +250,7 @@ case $host in
+     then
+       AC_MSG_RESULT(yes)
+       use_cppflag_curl_staticlib="yes"
++      CPPFLAG_CURL_STATICLIB="-DCURL_STATICLIB"
+     else
+       AC_MSG_RESULT(no)
+     fi
+@@ -259,6 +261,7 @@ case $host in
+ esac
+ AM_CONDITIONAL(USE_CPPFLAG_BUILDING_LIBCURL, test x$use_cppflag_building_libcurl = xyes)
+ AM_CONDITIONAL(USE_CPPFLAG_CURL_STATICLIB, test x$use_cppflag_curl_staticlib = xyes)
++AC_SUBST(CPPFLAG_CURL_STATICLIB)
  
-+/* Configure process defines this to 1 when static linking is requested. */
-+#undef CURL_STATICLIB
-+
- /* Configure process defines this to 1 when it finds out that system  */
- /* header file ws2tcpip.h must be included by the external interface. */
- #undef CURL_PULL_WS2TCPIP_H
+ # Determine whether all dependent libraries must be specified when linking
+ if test "X$enable_shared" = "Xyes" -a "X$link_all_deplibs" = "Xno"
+diff --git a/curl-config.in b/curl-config.in
+index 3d02a03..a3ca8b5 100644
+--- a/curl-config.in
++++ b/curl-config.in
+@@ -6,7 +6,7 @@
+ #                            | (__| |_| |  _ <| |___
+ #                             \___|\___/|_| \_\_____|
+ #
+-# Copyright (C) 2001 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
++# Copyright (C) 2001 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ #
+ # This software is licensed as described in the file COPYING, which
+ # you should have received as part of this distribution. The terms
+@@ -24,6 +24,7 @@
+ prefix=@prefix@
+ exec_prefix=@exec_prefix@
+ includedir=@includedir@
++cppflag_curl_staticlib=@CPPFLAG_CURL_STATICLIB@
+ 
+ usage()
+ {
+@@ -128,10 +129,15 @@ while test $# -gt 0; do
+ 	;;
+ 
+     --cflags)
++        if test "X$cppflag_curl_staticlib" = "X-DCURL_STATICLIB"; then
++          CPPFLAG_CURL_STATICLIB="-DCURL_STATICLIB "
++        else
++          CPPFLAG_CURL_STATICLIB=""
++        fi
+        	if test "X@includedir@" = "X/usr/include"; then
+-          echo ""
++          echo "$(CPPFLAG_CURL_STATICLIB)"
+         else
+-          echo "-I@includedir@"
++          echo "$(CPPFLAG_CURL_STATICLIB)-I@includedir@"
+         fi
+        	;;
+ 
+diff --git a/libcurl.pc.in b/libcurl.pc.in
+index 2ba9c39..6e878c5 100644
+--- a/libcurl.pc.in
++++ b/libcurl.pc.in
+@@ -5,7 +5,7 @@
+ #                            | (__| |_| |  _ <| |___
+ #                             \___|\___/|_| \_\_____|
+ #
+-# Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
++# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ #
+ # This software is licensed as described in the file COPYING, which
+ # you should have received as part of this distribution. The terms
+@@ -36,4 +36,4 @@ Description: Library to transfer files with ftp, http, etc.
+ Version: @CURLVERSION@
+ Libs: -L${libdir} -lcurl @LIBS@
+ Libs.private: @LIBCURL_LIBS@ @LIBS@
+-Cflags: -I${includedir}
++Cflags: -I${includedir} @CPPFLAG_CURL_STATICLIB@
 -- 
-1.7.8.3
+1.7.9.2
 
--- a/src/curl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/curl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := curl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := f6016a24051d98806ca3ddf754592701cb66e00c
+$(PKG)_CHECKSUM := c2e62eaace2407d377bf544d1f808aea6dddf64c
 $(PKG)_SUBDIR   := curl-$($(PKG)_VERSION)
 $(PKG)_FILE     := curl-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://curl.haxx.se/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gnutls libidn libssh2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://curl.haxx.se/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://curl.haxx.se/download/?C=M;O=D' | \
     $(SED) -n 's,.*curl-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/dbus.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/dbus.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := dbus
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3140ea452337d664dbe6d30f0d990c756d101694
+$(PKG)_CHECKSUM := 9bfc971ff4cafa2741050d53a98cc7bfdc56880a
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://$(PKG).freedesktop.org/releases/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/dbus/dbus/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/dbus/dbus/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '^1\.[01234]\.' | \
     head -1
--- a/src/dcmtk.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/dcmtk.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc openssl tiff libpng libxml2 zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://dicom.offis.de/dcmtk.php.en' | \
+    $(WGET) -q -O- 'http://dicom.offis.de/dcmtk.php.en' | \
     $(SED) -n 's,.*/dcmtk-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/devil.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/devil.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freeglut zlib openexr jpeg jasper lcms libmng libpng tiff sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://openil.svn.sourceforge.net/viewvc/openil/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://openil.svn.sourceforge.net/viewvc/openil/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="release-\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- a/src/eigen.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/eigen.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://eigen.tuxfamily.org/index.php?title=Main_Page#Download' | \
+    $(WGET) -q -O- 'http://eigen.tuxfamily.org/index.php?title=Main_Page#Download' | \
     grep 'eigen/get/' | \
     $(SED) -n 's,.*eigen/get/\(2[^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/exiv2-r2619.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://dev.exiv2.org/projects/exiv2/repository/revisions/2619
-
-Index: trunk/src/epsimage.cpp
-===================================================================
---- trunk/src/epsimage.cpp	(revision 2618)
-+++ trunk/src/epsimage.cpp	(revision 2619)
-@@ -393,6 +393,7 @@
-         unsigned int depth = 0;
-         const unsigned int maxDepth = UINT_MAX;
-         bool illustrator8 = false;
-+        bool corelDraw = false;
-         bool implicitPage = false;
-         bool implicitPageTrailer = false;
-         bool inDefaultsPreviewPrologSetup = false;
-@@ -547,6 +548,8 @@
-                 posAi7ThumbnailEndData = startPos;
-             } else if (posEndComments == posEndEps && line == "%%EndComments") {
-                 posEndComments = startPos;
-+            } else if (inDefaultsPreviewPrologSetup && startsWith(line, "%%BeginResource: procset wCorel")) {
-+                corelDraw = true;
-             } else if (line == "%%EndPreview") {
-                 inDefaultsPreviewPrologSetup = false;
-             } else if (line == "%%EndDefaults") {
-@@ -922,6 +925,10 @@
-                             writeTemp(*tempIo, "%%BeginPageSetup" + lineEnding);
-                         }
-                         writeTemp(*tempIo, "%Exiv2BeginXMP: Before %%EndPageSetup" + lineEnding);
-+                        if (corelDraw) {
-+                            writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
-+                            writeTemp(*tempIo, "@rs" + lineEnding);
-+                        }
-                         if (posBeginPhotoshop != posEndEps) {
-                             writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
-                             writeTemp(*tempIo, "%begin_xml_code" + lineEnding);
-@@ -953,6 +960,10 @@
-                             writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by Photoshop." + lineEnding);
-                             writeTemp(*tempIo, "%end_xml_code" + lineEnding);
-                         }
-+                        if (corelDraw) {
-+                            writeTemp(*tempIo, "%Exiv2Notice: The following line is needed by CorelDRAW." + lineEnding);
-+                            writeTemp(*tempIo, "@sv" + lineEnding);
-+                        }
-                         writeTemp(*tempIo, "%Exiv2EndXMP" + lineEnding);
-                         if (line != "%%EndPageSetup") {
-                             writeTemp(*tempIo, "%%EndPageSetup" + lineEnding);
--- a/src/exiv2-r2646.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://dev.exiv2.org/projects/exiv2/repository/revisions/2646
-
-Index: trunk/src/jpgimage.cpp
-===================================================================
---- trunk/src/jpgimage.cpp	(revision 2645)
-+++ trunk/src/jpgimage.cpp	(revision 2646)
-@@ -86,10 +86,21 @@
-     const char     JpegBase::xmpId_[]  = "http://ns.adobe.com/xap/1.0/\0";
- 
-     const char     Photoshop::ps3Id_[] = "Photoshop 3.0\0";
--    const char     Photoshop::bimId_[] = "8BIM";
-+    const char*    Photoshop::irbId_[] = {"8BIM", "AgHg", "DCSR", "PHUT"};
-     const uint16_t Photoshop::iptc_    = 0x0404;
-     const uint16_t Photoshop::preview_ = 0x040c;
- 
-+    bool Photoshop::isIrb(const byte* pPsData,
-+                          long        sizePsData)
-+    {
-+        if (sizePsData < 4) return false;
-+        for (size_t i = 0; i < (sizeof irbId_) / (sizeof *irbId_); i++) {
-+            assert(strlen(irbId_[i]) == 4);
-+            if (memcmp(pPsData, irbId_[i], 4) == 0) return true;
-+        }
-+        return false;
-+    }
-+
-     bool Photoshop::valid(const byte* pPsData,
-                           long        sizePsData)
-     {
-@@ -126,8 +137,7 @@
-         std::cerr << "Photoshop::locateIrb: ";
- #endif
-         // Data should follow Photoshop format, if not exit
--        while (   position <= sizePsData - 12
--               && memcmp(pPsData + position, Photoshop::bimId_, 4) == 0) {
-+        while (position <= sizePsData - 12 && isIrb(pPsData + position, 4)) {
-             const byte *hrd = pPsData + position;
-             position += 4;
-             uint16_t type = getUShort(pPsData + position, bigEndian);
-@@ -237,7 +247,7 @@
-         DataBuf rawIptc = IptcParser::encode(iptcData);
-         if (rawIptc.size_ > 0) {
-             byte tmpBuf[12];
--            std::memcpy(tmpBuf, Photoshop::bimId_, 4);
-+            std::memcpy(tmpBuf, Photoshop::irbId_[0], 4);
-             us2Data(tmpBuf + 4, iptc_, bigEndian);
-             tmpBuf[6] = 0;
-             tmpBuf[7] = 0;
-Index: trunk/src/jpgimage.hpp
-===================================================================
---- trunk/src/jpgimage.hpp	(revision 2645)
-+++ trunk/src/jpgimage.hpp	(revision 2646)
-@@ -64,11 +64,21 @@
-     struct EXIV2API Photoshop {
-         // Todo: Public for now
-         static const char     ps3Id_[]; //!< %Photoshop marker
--        static const char     bimId_[]; //!< %Photoshop marker
-+        static const char*    irbId_[]; //!< %Photoshop IRB markers
-         static const uint16_t iptc_;    //!< %Photoshop IPTC marker
-         static const uint16_t preview_; //!< %Photoshop preview marker
- 
-         /*!
-+          @brief Checks an IRB
-+
-+          @param pPsData        Existing IRB buffer
-+          @param sizePsData     Size of the IRB buffer
-+          @return true  if the IRB marker is known and the buffer is big enough to check this;<BR>
-+                  false otherwise
-+        */
-+        static bool isIrb(const byte* pPsData,
-+                          long        sizePsData);
-+        /*!
-           @brief Validates all IRBs
- 
-           @param pPsData        Existing IRB buffer
-Index: trunk/src/psdimage.cpp
-===================================================================
---- trunk/src/psdimage.cpp	(revision 2645)
-+++ trunk/src/psdimage.cpp	(revision 2646)
-@@ -39,6 +39,7 @@
- # include "exv_conf.h"
- #endif
- #include "psdimage.hpp"
-+#include "jpgimage.hpp"
- #include "image.hpp"
- #include "basicio.hpp"
- #include "error.hpp"
-@@ -56,11 +57,9 @@
- //       Extend this helper to a proper class with all required functionality,
- //       then move it here or into a separate file?
- 
--const uint32_t kPhotoshopResourceType = 0x3842494d; // '8BIM'
--
- //! @cond IGNORE
- struct PhotoshopResourceBlock {
--    uint32_t      resourceType;       // always kPhotoshopResourceType
-+    uint32_t      resourceType;       // one of the markers in Photoshop::irbId_[]
-     uint16_t      resourceId;
-     unsigned char resourceName[2];    // Pascal string (length byte + characters), padded to an even size -- this assumes the empty string
-     uint32_t      resourceDataSize;
-@@ -215,14 +214,11 @@
-                 throw Error(3, "Photoshop");
-             }
- 
--            // read resource type and ID
--            uint32_t resourceType = getULong(buf, bigEndian);
--            uint16_t resourceId = getUShort(buf + 4, bigEndian);
--
--            if (resourceType != kPhotoshopResourceType)
-+            if (!Photoshop::isIrb(buf, 4))
-             {
-                 break; // bad resource type
-             }
-+            uint16_t resourceId = getUShort(buf + 4, bigEndian);
-             uint32_t resourceNameLength = buf[6] & ~1;
- 
-             // skip the resource name, plus any padding
-@@ -447,7 +443,8 @@
-             // read resource type and ID
-             uint32_t resourceType = getULong(buf, bigEndian);
- 
--            if (resourceType != kPhotoshopResourceType) {
-+            if (!Photoshop::isIrb(buf, 4))
-+            {
-                 throw Error(3, "Photoshop"); // bad resource type
-             }
-             uint16_t resourceId = getUShort(buf + 4, bigEndian);
-@@ -493,11 +490,12 @@
-                 && resourceId != kPhotoshopResourceID_ExifInfo
-                 && resourceId != kPhotoshopResourceID_XMPPacket) {
- #ifdef DEBUG
-+                std::cerr << std::hex << "copy : resourceType: " << resourceType << "\n";
-                 std::cerr << std::hex << "copy : resourceId: " << resourceId << "\n";
-                 std::cerr << std::dec;
- #endif
-                 // Copy resource block to new PSD file
--                ul2Data(buf, kPhotoshopResourceType, bigEndian);
-+                ul2Data(buf, resourceType, bigEndian);
-                 if (outIo.write(buf, 4) != 4) throw Error(21);
-                 us2Data(buf, resourceId, bigEndian);
-                 if (outIo.write(buf, 2) != 2) throw Error(21);
-@@ -577,8 +575,7 @@
-                 std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_IPTC_NAA << "\n";
-                 std::cerr << std::dec << "Writing IPTC_NAA: size: " << rawIptc.size_ << "\n";
- #endif
--                ul2Data(buf, kPhotoshopResourceType, bigEndian);
--                if (out.write(buf, 4) != 4) throw Error(21);
-+                if (out.write(reinterpret_cast<const byte*>(Photoshop::irbId_[0]), 4) != 4) throw Error(21);
-                 us2Data(buf, kPhotoshopResourceID_IPTC_NAA, bigEndian);
-                 if (out.write(buf, 2) != 2) throw Error(21);
-                 us2Data(buf, 0, bigEndian);                      // NULL resource name
-@@ -618,8 +615,7 @@
-                 std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_ExifInfo << "\n";
-                 std::cerr << std::dec << "Writing ExifInfo: size: " << blob.size() << "\n";
- #endif
--                ul2Data(buf, kPhotoshopResourceType, bigEndian);
--                if (out.write(buf, 4) != 4) throw Error(21);
-+                if (out.write(reinterpret_cast<const byte*>(Photoshop::irbId_[0]), 4) != 4) throw Error(21);
-                 us2Data(buf, kPhotoshopResourceID_ExifInfo, bigEndian);
-                 if (out.write(buf, 2) != 2) throw Error(21);
-                 us2Data(buf, 0, bigEndian);                      // NULL resource name
-@@ -663,8 +659,7 @@
-             std::cerr << std::hex << "write: resourceId: " << kPhotoshopResourceID_XMPPacket << "\n";
-             std::cerr << std::dec << "Writing XMPPacket: size: " << xmpPacket.size() << "\n";
- #endif
--            ul2Data(buf, kPhotoshopResourceType, bigEndian);
--            if (out.write(buf, 4) != 4) throw Error(21);
-+            if (out.write(reinterpret_cast<const byte*>(Photoshop::irbId_[0]), 4) != 4) throw Error(21);
-             us2Data(buf, kPhotoshopResourceID_XMPPacket, bigEndian);
-             if (out.write(buf, 2) != 2) throw Error(21);
-             us2Data(buf, 0, bigEndian);                      // NULL resource name
--- a/src/exiv2-r2650.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://dev.exiv2.org/projects/exiv2/repository/revisions/2650
-
-Index: trunk/src/jpgimage.cpp
-===================================================================
---- trunk/src/jpgimage.cpp	(revision 2649)
-+++ trunk/src/jpgimage.cpp	(revision 2650)
-@@ -87,6 +87,7 @@ namespace Exiv2 {
- 
-     const char     Photoshop::ps3Id_[] = "Photoshop 3.0\0";
-     const char*    Photoshop::irbId_[] = {"8BIM", "AgHg", "DCSR", "PHUT"};
-+    const char     Photoshop::bimId_[] = "8BIM"; // deprecated
-     const uint16_t Photoshop::iptc_    = 0x0404;
-     const uint16_t Photoshop::preview_ = 0x040c;
- 
-Index: trunk/src/jpgimage.hpp
-===================================================================
---- trunk/src/jpgimage.hpp	(revision 2649)
-+++ trunk/src/jpgimage.hpp	(revision 2650)
-@@ -65,6 +65,7 @@ namespace Exiv2 {
-         // Todo: Public for now
-         static const char     ps3Id_[]; //!< %Photoshop marker
-         static const char*    irbId_[]; //!< %Photoshop IRB markers
-+        static const char     bimId_[]; //!< %Photoshop IRB marker (deprecated)
-         static const uint16_t iptc_;    //!< %Photoshop IPTC marker
-         static const uint16_t preview_; //!< %Photoshop preview marker
- 
--- a/src/exiv2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/exiv2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := exiv2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 35211d853a986fe1b008fca14db090726e8dcce3
+$(PKG)_CHECKSUM := 5f342bf642477526f41add11d6ee7787cdcd639f
 $(PKG)_SUBDIR   := exiv2-$($(PKG)_VERSION)
 $(PKG)_FILE     := exiv2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.exiv2.org/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libiconv zlib expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.exiv2.org/download.html' | \
+    $(WGET) -q -O- 'http://www.exiv2.org/download.html' | \
     grep 'href="exiv2-' | \
     $(SED) -n 's,.*exiv2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/expat.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/expat.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/expat/files/expat/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/expat/files/expat/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/faad2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/faad2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/faac/files/faad2-src/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/faac/files/faad2-src/' | \
     $(SED) -n 's,.*faad2-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/ffmpeg-1-pkgconfig.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch adds a libswresample dependency to libavfilter.pc, and a libavfilter
-dependency to libavdevice.pc. Both issues have patches upstream, so this patch
-can be dropped for the next FFmpeg version.
-
---- ffmpeg-0.10/configure.orig	2012-03-09 21:18:38.403806202 +0100
-+++ ffmpeg-0.10/configure	2012-03-09 21:19:37.175808737 +0100
-@@ -3749,8 +3749,8 @@
- pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBM"
- pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
--pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
--pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
-+pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION, libavfilter = $LIBAVFILTER_VERSION"
-+pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libswresample = $LIBSWRESAMPLE_VERSION"
- pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
- pkgconfig_generate libswresample "FFmpeg audio rescaling library" "$LIBSWRESAMPLE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"
--- a/src/ffmpeg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/ffmpeg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := ffmpeg
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 743f44a71f93b14c9b26ca2424b0da8457cef4be
+$(PKG)_CHECKSUM := bf01742be60c2e6280371fc4189d5d28933f1a56
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://www.ffmpeg.org/releases/$($(PKG)_FILE)
@@ -11,12 +11,13 @@
 $(PKG)_DEPS     := gcc bzip2 lame libvpx opencore-amr sdl speex theora vorbis x264 xvidcore zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ffmpeg.org/download.html' | \
+    $(WGET) -q -O- 'http://www.ffmpeg.org/download.html' | \
     $(SED) -n 's,.*ffmpeg-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    '$(SED)' -i "s^[-]lvpx^`'$(TARGET)'-pkg-config --libs-only-l vpx`^g;" $(1)/configure
     cd '$(1)' && ./configure \
         --cross-prefix='$(TARGET)'- \
         --enable-cross-compile \
--- a/src/fftw.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/fftw.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := fftw
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3fecc492f576503a6a509d2073bd82b3fe0aef13
+$(PKG)_CHECKSUM := 11a8c31186ff5a7d686a79a3f21b2530888e0dc2
 $(PKG)_SUBDIR   := fftw-$($(PKG)_VERSION)
 $(PKG)_FILE     := fftw-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.fftw.org/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.fftw.org/download.html' | \
+    $(WGET) -q -O- 'http://www.fftw.org/download.html' | \
     $(SED) -n 's,.*fftw-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v alpha | \
     grep -v beta | \
@@ -20,6 +20,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
@@ -29,6 +30,7 @@
 
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
@@ -38,6 +40,7 @@
 
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --enable-threads \
--- a/src/file.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/file.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libgnurx
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.astron.com/pub/file/' | \
+    $(WGET) -q -O- 'ftp://ftp.astron.com/pub/file/' | \
     grep 'file-' | \
     $(SED) -n 's,.*file-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
--- a/src/flac.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/flac.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv ogg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://flac.cvs.sourceforge.net/viewvc/flac/flac/' | \
+    $(WGET) -q -O- 'http://flac.cvs.sourceforge.net/viewvc/flac/flac/' | \
     grep '<option>FLAC_RELEASE_' | \
     $(SED) -n 's,.*FLAC_RELEASE_\([0-9][0-9_]*\)__.*,\1,p' | \
     $(SED) 's,_,.,g' | \
--- a/src/fltk.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/fltk.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg libpng pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.fltk.org/' | \
+    $(WGET) -q -O- 'http://www.fltk.org/' | \
     $(SED) -n 's,.*>v\([0-9][^<]*\)<.*,\1,p' | \
     grep -v '^1\.1\.' | \
     head -1
--- a/src/fontconfig.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/fontconfig.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://fontconfig.org/release/' | \
+    $(WGET) -q -O- 'http://fontconfig.org/release/' | \
     $(SED) -n 's,.*fontconfig-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
--- a/src/freeglut.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/freeglut.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeglut/files/freeglut/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeglut/files/freeglut/' | \
     $(SED) -n 's,.*freeglut-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/freeimage.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/freeimage.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeimage/files/Source Distribution/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeimage/files/Source Distribution/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/freetds.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/freetds.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -14,7 +14,7 @@
     echo $(freetds_VERSION)
 endef
 define $(PKG)_UPDATE_orig
-    wget -q -O- 'http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/' | \
+    $(WGET) -q -O- 'http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/' | \
     grep '<option>R' | \
     $(SED) -n 's,.*R\([0-9][0-9_]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
--- a/src/freetype.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/freetype.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freetype/files/freetype2/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freetype/files/freetype2/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/fribidi.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/fribidi.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://fribidi.org/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://fribidi.org/download/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="fribidi-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/ftgl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/ftgl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/ftgl/files/FTGL Source/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/ftgl/files/FTGL Source/' | \
     $(SED) -n 's,.*<tr title="\([0-9][^"]*\)".*,\1,p' | \
     head -1
 endef
--- a/src/gc.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gc.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gc
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := e84cba5d18f4ea5ed4e5fd3f1dc6a46bc190ff6f
-$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_CHECKSUM := 042b551d9e313557c8919375c669ae484237cf3e
+$(PKG)_SUBDIR   := $(PKG)-7.2
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.hpl.hp.com/personal/Hans_Boehm/$(PKG)/$(PKG)_source/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/?C=M;O=D' | \
     grep '<a href="gc-' | \
     $(SED) -n 's,.*<a href="gc-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v 'alpha' | \
@@ -20,6 +20,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --enable-threads=win32 \
--- a/src/gcc-mpc.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gcc-mpc.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \
+    $(WGET) -q -O- 'https://gforge.inria.fr/scm/viewvc.php/tags/?root=mpc&sortby=date' | \
     $(SED) -n 's,.*<a name="\([0-9][^"]*\)".*,\1,p' | \
     head -1
 endef
--- a/src/gcc.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gcc.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := mingwrt w32api binutils gcc-gmp gcc-mpc gcc-mpfr
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/gcc/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="gcc-\([0-9][^"]*\)/".*,\1,p' | \
     grep -v '^4\.[543]\.' | \
     head -1
--- a/src/gd.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gd.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -15,7 +15,7 @@
     echo $(gd_VERSION)
 endef
 define $(PKG)_UPDATE_orig
-    wget -q -O- 'http://www.libgd.org/releases/' | \
+    $(WGET) -q -O- 'http://www.libgd.org/releases/' | \
     $(SED) -n 's,.*gd-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdal-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,54 @@
+This file is part of MXE.
+See index.html for further information.
+
+Taken from http://trac.osgeo.org/gdal/changeset/24491?format=diff&new=24491
+
+Index: gdal/frmts/gif/gifdataset.cpp
+===================================================================
+--- gdal/frmts/gif/gifdataset.cpp	(revision 23621)
++++ gdal/frmts/gif/gifdataset.cpp	(revision 24491)
+@@ -471,4 +471,26 @@
+ 
+ /************************************************************************/
++/*                        GDALPrintGifError()                           */
++/************************************************************************/
++
++static void GDALPrintGifError(const char* pszMsg)
++{
++/* GIFLIB_MAJOR is only defined in libgif >= 4.2.0 */
++/* libgif 4.2.0 has retired PrintGifError() and added GifErrorString() */
++#if defined(GIFLIB_MAJOR) && defined(GIFLIB_MINOR) && \
++        ((GIFLIB_MAJOR == 4 && GIFLIB_MINOR >= 2) || GIFLIB_MAJOR > 4)
++    /* Static string actually, hence the const char* cast */
++    const char* pszGIFLIBError = (const char*) GifErrorString();
++    if (pszGIFLIBError == NULL)
++        pszGIFLIBError = "Unknown error";
++    CPLError( CE_Failure, CPLE_AppDefined,
++              "%s. GIFLib Error : %s", pszMsg, pszGIFLIBError );
++#else
++    PrintGifError();
++    CPLError( CE_Failure, CPLE_AppDefined, "%s", pszMsg );
++#endif
++}
++
++/************************************************************************/
+ /*                             CreateCopy()                             */
+ /************************************************************************/
+@@ -597,7 +619,5 @@
+     {
+         FreeMapObject(psGifCT);
+-        PrintGifError();
+-        CPLError( CE_Failure, CPLE_AppDefined, 
+-                  "Error writing gif file." );
++        GDALPrintGifError("Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
+@@ -623,7 +643,5 @@
+     if (EGifPutImageDesc(hGifFile, 0, 0, nXSize, nYSize, bInterlace, NULL) == GIF_ERROR )
+     {
+-        PrintGifError();
+-        CPLError( CE_Failure, CPLE_AppDefined, 
+-                  "Error writing gif file." );
++        GDALPrintGifError("Error writing gif file.");
+         EGifCloseFile(hGifFile);
+         VSIFCloseL( fp );
--- a/src/gdal.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gdal.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := gdal
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := e2eaaf0fba39137b40c0d3069ac41dfb6f3c76db
+$(PKG)_CHECKSUM := c1eae556398ff7b9332afe9d3022dcd931130808
 $(PKG)_SUBDIR   := gdal-$($(PKG)_VERSION)
 $(PKG)_FILE     := gdal-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/gdal/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib libpng tiff libgeotiff jpeg jasper giflib expat sqlite curl geos postgresql gta
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/gdal/wiki/DownloadSource' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/gdal/wiki/DownloadSource' | \
     $(SED) -n 's,.*gdal-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -20,6 +20,7 @@
     # The option '--without-threads' means native win32 threading without pthread.
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-bsb \
@@ -65,7 +66,6 @@
         --without-ingres \
         --without-dods-root \
         --without-dwgdirect \
-        --without-dwg-plt \
         --without-idb \
         --without-sde \
         --without-epsilon \
@@ -73,7 +73,6 @@
         --without-php \
         --without-ruby \
         --without-python \
-        --without-macosx-framework \
         LIBS="-ljpeg -lsecur32 `'$(TARGET)-pkg-config' --libs openssl libtiff-4`"
     $(MAKE) -C '$(1)'       -j 1 lib-target
     $(MAKE) -C '$(1)'       -j 1 install-lib
--- a/src/gdb-2-fix-makeinfo.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://sourceware.org/bugzilla/show_bug.cgi?id=13638
-
-===================================================================
-RCS file: /cvs/src/src/gdb/configure,v
-retrieving revision 1.335.2.2
-retrieving revision 1.335.2.3
-diff -u -r1.335.2.2 -r1.335.2.3
---- src/gdb/configure	2012/02/21 22:03:47	1.335.2.2
-+++ src/gdb/configure	2012/02/21 22:07:40	1.335.2.3
-@@ -995,6 +995,8 @@
- LIBS
- CPPFLAGS
- CPP
-+MAKEINFO
-+MAKEINFOFLAGS
- YACC
- YFLAGS
- XMKMF'
-@@ -1696,6 +1698,9 @@
-   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
-               you have headers in a nonstandard directory <include dir>
-   CPP         C preprocessor
-+  MAKEINFO    Parent configure detects if it is of sufficient version.
-+  MAKEINFOFLAGS
-+              Parameters for MAKEINFO.
-   YACC        The `Yet Another C Compiler' implementation to use. Defaults to
-               the first program found out of: `bison -y', `byacc', `yacc'.
-   YFLAGS      The list of arguments that will be passed by default to $YACC.
-@@ -7158,59 +7163,9 @@
- 
- 
- 
--# Do we have a single-tree copy of texinfo?  Even if we do, we can't
--# rely on it - libiberty is built before texinfo.
--# Extract the first word of "makeinfo", so it can be a program name with args.
--set dummy makeinfo; ac_word=$2
--{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
--$as_echo_n "checking for $ac_word... " >&6; }
--if test "${ac_cv_prog_MAKEINFO+set}" = set; then :
--  $as_echo_n "(cached) " >&6
--else
--  if test -n "$MAKEINFO"; then
--  ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
--else
--as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
--for as_dir in $PATH
--do
--  IFS=$as_save_IFS
--  test -z "$as_dir" && as_dir=.
--    for ac_exec_ext in '' $ac_executable_extensions; do
--  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
--    ac_cv_prog_MAKEINFO="makeinfo"
--    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
--    break 2
--  fi
--done
--  done
--IFS=$as_save_IFS
--
--fi
--fi
--MAKEINFO=$ac_cv_prog_MAKEINFO
--if test -n "$MAKEINFO"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKEINFO" >&5
--$as_echo "$MAKEINFO" >&6; }
--else
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
--$as_echo "no" >&6; }
--fi
--
--
--if test "x$MAKEINFO" = "x"; then
--  as_fn_error "makeinfo is required for compilation" "$LINENO" 5
--else
--  case "$MAKEINFO" in
--    */missing\ makeinfo*)
--      as_fn_error "makeinfo is required for compilation" "$LINENO" 5
--      ;;
--  esac
--fi
--
-+# We never need to detect it in this sub-configure.
-+# But preserve it for config.status --recheck.
- 
--# --split-size=5000000 may be already in $MAKEINFO from parent configure.
--# Re-running configure in gdb/ would lose it so ensure it stays present.
--MAKEINFOFLAGS=${MAKEINFOFLAGS---split-size=5000000}
- 
- 
- MAKEINFO_EXTRA_FLAGS=""
--- a/src/gdb.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gdb.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -2,7 +2,7 @@
 # See index.html for further information.
 
 PKG             := gdb
-$(PKG)_CHECKSUM := 43a3ee582eae4d69c2babea4f8700b7bec8e37fa
+$(PKG)_CHECKSUM := 1b0f8c3778d4b10c8d2be6922ac01a9900e8116c
 $(PKG)_SUBDIR   := gdb-$($(PKG)_VERSION)
 $(PKG)_FILE     := gdb-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE)
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc expat libiconv zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/gdb/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/gdb/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="gdb-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v '^7\.3a' | \
     sort -r | \
--- a/src/gdk-pixbuf-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gdk-pixbuf-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -27,7 +27,7 @@
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gdkpixbuf_DllMain (HINSTANCE hinstDLL,
           DWORD     fdwReason,
           LPVOID    lpvReserved)
  {
--- a/src/gdk-pixbuf.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gdk-pixbuf.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libpng jpeg tiff jasper libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gdk-pixbuf/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gdk-pixbuf/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
--- a/src/geos.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/geos.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := geos
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 942b0bbc61a059bd5269fddd4c0b44a508670cb3
+$(PKG)_CHECKSUM := 2ec4be729c851460daf89d0d2ab785be5ef4c5c5
 $(PKG)_SUBDIR   := geos-$($(PKG)_VERSION)
 $(PKG)_FILE     := geos-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://download.osgeo.org/geos/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://geos.refractions.net/' | \
+    $(WGET) -q -O- 'http://geos.refractions.net/' | \
     $(SED) -n 's,.*geos-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -19,9 +19,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
-        --prefix='$(PREFIX)/$(TARGET)' \
-        --disable-swig
+        --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
 
     '$(TARGET)-gcc' \
--- a/src/gettext.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gettext.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gnu.org/software/gettext/' | \
+    $(WGET) -q -O- 'http://www.gnu.org/software/gettext/' | \
     grep 'gettext-' | \
     $(SED) -n 's,.*gettext-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/giflib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/giflib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := giflib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 22680f604ec92065f04caf00b1c180ba74fb8562
+$(PKG)_CHECKSUM := bc942711f75de7d8539f79be34d69c0d53c381c1
 $(PKG)_SUBDIR   := giflib-$($(PKG)_VERSION)
 $(PKG)_FILE     := giflib-$($(PKG)_VERSION).tar.bz2
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/giflib/giflib-4.x/giflib-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/giflib/giflib-4.x/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/giflib/files/giflib 4.x/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/giflib/files/giflib 4.x/' | \
     $(SED) -n 's,.*/giflib-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
@@ -18,8 +18,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
-        --prefix='$(PREFIX)/$(TARGET)' \
         --without-x \
         CPPFLAGS='-D_OPEN_BINARY'
     $(MAKE) -C '$(1)/lib' -j '$(JOBS)' install
--- a/src/glew.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/glew.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/glew/files/glew/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/glew/files/glew/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/glib-2-DllMain.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,59 @@
+diff -uNr glib-2.28.8-orig/gio/giomodule.c glib/gio/giomodule.c
+--- glib-2.28.8-orig/gio/giomodule.c	2011-01-05 22:44:06.000000000 +0100
++++ glib/gio/giomodule.c	2011-11-23 21:04:43.867004895 +0100
+@@ -489,10 +489,8 @@
+ 
+ static HMODULE gio_dll = NULL;
+ 
+-#ifdef DLL_EXPORT
+-
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++gio_DllMain (HINSTANCE hinstDLL,
+ 	 DWORD     fdwReason,
+ 	 LPVOID    lpvReserved)
+ {
+@@ -502,8 +500,6 @@
+   return TRUE;
+ }
+ 
+-#endif
+-
+ #undef GIO_MODULE_DIR
+ 
+ /* GIO_MODULE_DIR is used only in code called just once,
+diff -uNr glib-2.28.8-orig/glib/gutils.c glib/glib/gutils.c
+--- glib-2.28.8-orig/glib/gutils.c	2011-06-06 01:18:49.000000000 +0200
++++ glib/glib/gutils.c	2011-11-23 21:05:07.822988144 +0100
+@@ -144,10 +144,8 @@
+ 
+ static HMODULE glib_dll = NULL;
+ 
+-#ifdef DLL_EXPORT
+-
+ BOOL WINAPI
+-DllMain (HINSTANCE hinstDLL,
++glib_DllMain (HINSTANCE hinstDLL,
+ 	 DWORD     fdwReason,
+ 	 LPVOID    lpvReserved)
+ {
+@@ -157,8 +155,6 @@
+   return TRUE;
+ }
+ 
+-#endif
+-
+ gchar *
+ _glib_get_dll_directory (void)
+ {
+@@ -166,10 +162,8 @@
+   gchar *p;
+   wchar_t wc_fn[MAX_PATH];
+ 
+-#ifdef DLL_EXPORT
+   if (glib_dll == NULL)
+     return NULL;
+-#endif
+ 
+   /* This code is different from that in
+    * g_win32_get_package_installation_directory_of_module() in that
--- a/src/glib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/glib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := glib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 20cd63705a8805260da0320c65b979233f2e3c18
+$(PKG)_CHECKSUM := 9b11968fedf4da45bcd10c4a8c50012d41b3af50
 $(PKG)_SUBDIR   := glib-$($(PKG)_VERSION)
-$(PKG)_FILE     := glib-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := glib-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/glib/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gettext pcre libiconv zlib dbus
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/glib/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/glib/refs/tags' | \
     $(SED) -n "s,.*tag/?id=\([0-9]\+\.[0-9]*[02468]\.[^']*\).*,\1,p" | \
     head -1
 endef
--- a/src/glibmm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/glibmm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := glibmm
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := d15bc0fed7dea6fec73746370653687f74e02592
+$(PKG)_CHECKSUM := bd1962c7de710036875a8b6d7ab7b5e5e50fb7af
 $(PKG)_SUBDIR   := glibmm-$($(PKG)_VERSION)
-$(PKG)_FILE     := glibmm-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := glibmm-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/glibmm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libsigc++
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/glibmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/glibmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     head -1
--- a/src/gmp.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gmp.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := gmp
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := ea4ea7c3f10436ef5ae7a75b3fad163a8b86edc0
+$(PKG)_CHECKSUM := 12a662456033e21aed3e318aef4177f4000afe3b
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gmplib.org/pub/$(PKG)-$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gmplib.org/' | \
+    $(WGET) -q -O- 'http://www.gmplib.org/' | \
     grep '<a href="' | \
     $(SED) -n 's,.*gmp-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v '^4\.' | \
@@ -21,6 +21,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && CC_FOR_BUILD=gcc ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
         --enable-cxx \
--- a/src/gnutls-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gnutls-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -3,11 +3,14 @@
 
 Contains ad hoc patches for cross building.
 
-From 6e89465f1e792f5d527708544cce1ef92ae4669b Mon Sep 17 00:00:00 2001
-From: MXE
+From 1f08b1e9d6f6a03e0fe5e62aef85aa1021014953 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 28 Oct 2011 09:23:41 +0200
-Subject: [PATCH 1/2] add missing static library linking
+Subject: [PATCH 1/5] add missing static library linking
 
+---
+ lib/gnutls.pc.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/lib/gnutls.pc.in b/lib/gnutls.pc.in
 index c45f8f3..57d0dbb 100644
@@ -25,11 +28,14 @@
 1.7.9.2
 
 
-From aa11a6f645ce93f80fbffd7e72c6964bdfd68542 Mon Sep 17 00:00:00 2001
-From: MXE
+From bbf2330693746cc45a3df65cba253ce44a353ac3 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 24 Nov 2011 15:06:06 +0100
-Subject: [PATCH 2/2] disable doc and test (MXE specific)
+Subject: [PATCH 2/5] disable doc and test (mingw-cross-env specific)
 
+---
+ Makefile.am |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/Makefile.am b/Makefile.am
 index 0afe4bd..da7436a 100644
@@ -47,3 +53,87 @@
 -- 
 1.7.9.2
 
+
+From 5ee5355a9b34821b99f3f2fa83eb8435ccb45702 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Tue, 3 Apr 2012 13:58:42 +0200
+Subject: [PATCH 3/5] Revert "make dist will also make lzip compressed
+ tarball"
+
+This reverts commit 97ac1bc58274f651338444693bd75441ba12f46f.
+---
+ configure.ac |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index f826704..bb4d044 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -25,7 +25,7 @@ AC_INIT([GnuTLS], [3.0.20], [bug-gnutls@gnu.org])
+ AC_CONFIG_AUX_DIR([build-aux])
+ AC_CONFIG_MACRO_DIR([m4])
+ 
+-AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz dist-lzip -Wall -Werror -Wno-override])
++AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
+ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+ AM_CONFIG_HEADER(config.h)
+ 
+-- 
+1.7.9.2
+
+
+From 7f22baaa57d160a22b49d25b8fa4024b754aedcd Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 6 Jun 2012 09:57:24 +0200
+Subject: [PATCH 4/5] AM_PROG_AR for automake 1.12 compatibility
+
+Taken from
+http://lists.gnu.org/archive/html/automake/2012-05/msg00014.html
+---
+ configure.ac |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index bb4d044..4c9c13a 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -37,6 +37,7 @@ dnl Checks for programs.
+ AC_PROG_CC
+ AM_PROG_AS
+ AC_PROG_CXX
++m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+ gl_EARLY
+ 
+ # For includes/gnutls/gnutls.h.in.
+-- 
+1.7.9.2
+
+
+From da583995c66f2df7cac31435d1609754a6853d07 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Wed, 6 Jun 2012 10:09:48 +0200
+Subject: [PATCH 5/5] add missing include wincrypt.h
+
+taken from
+http://lists.gnu.org/archive/html/gnutls-devel/2012-06/msg00001.html
+---
+ lib/gnutls_x509.c |    3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/lib/gnutls_x509.c b/lib/gnutls_x509.c
+index 71e0d69..130d75c 100644
+--- a/lib/gnutls_x509.c
++++ b/lib/gnutls_x509.c
+@@ -42,6 +42,9 @@
+ #include "x509/x509_int.h"
+ #include <gnutls_str_array.h>
+ #include "read-file.h"
++#if defined _WIN32 || defined __WIN32__
++#include <wincrypt.h>
++#endif
+ 
+ /*
+  * some x509 certificate parsing functions.
+-- 
+1.7.9.2
+
--- a/src/gnutls.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gnutls.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -2,7 +2,7 @@
 # See index.html for further information.
 
 PKG             := gnutls
-$(PKG)_CHECKSUM := 2e2adc41e0c75d8170fdca5955bd007ae93ceada
+$(PKG)_CHECKSUM := 0c65f6a1e669c0fe85ddb2d645078b3bce9d1518
 $(PKG)_SUBDIR   := gnutls-$($(PKG)_VERSION)
 $(PKG)_FILE     := gnutls-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnutls.org/pub/gnutls/$($(PKG)_FILE)
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc nettle zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gnutls.git;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>gnutls_\([0-9]*_[0-9]*[02468]_[^<]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
@@ -27,6 +27,7 @@
     # Value taken from http://msdn.microsoft.com/en-us/library/windows/desktop/ms737530%28v=vs.85%29.aspx
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --enable-static \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
--- a/src/graphicsmagick.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/graphicsmagick.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := graphicsmagick
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 7ef5711a18da0a3b6b143548a2a7822597ea416d
+$(PKG)_CHECKSUM := 59ab01a1a8a12b26955c64bb2b660b6283855204
 $(PKG)_SUBDIR   := GraphicsMagick-$($(PKG)_VERSION)
 $(PKG)_FILE     := GraphicsMagick-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc pthreads libtool zlib bzip2 jpeg jasper lcms1 libpng tiff freetype libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
@@ -20,6 +20,7 @@
     cd '$(1)' && autoconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-modules \
--- a/src/gsl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gsl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>[^0-9>]*\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/gsoap.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gsoap.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := gsoap
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 011b507e667d7bb76e30fc8a31055e8cf323311d
+$(PKG)_CHECKSUM := 61ac88f1fd3f5f3a93358577c634302760d31640
 $(PKG)_SUBDIR   := gsoap-$(call SHORT_PKG_VERSION,$(PKG))
 $(PKG)_FILE     := gsoap_$($(PKG)_VERSION).zip
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/gsoap2/gSOAP/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gnutls libgcrypt libntlm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/gsoap2/files/gSOAP/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/gsoap2/files/gSOAP/' | \
     $(SED) -n 's,.*gsoap_\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
 endef
--- a/src/gst-plugins-base.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gst-plugins-base.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libxml2 gstreamer liboil pango ogg vorbis theora
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-base/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-base/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
--- a/src/gst-plugins-good.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gst-plugins-good.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libxml2 gstreamer gst-plugins-base liboil libshout cairo flac gtk2 jpeg libpng speex taglib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-good/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gst-plugins-good/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
--- a/src/gstreamer.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gstreamer.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/gstreamer/gstreamer/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/gstreamer/gstreamer/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
--- a/src/gta.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gta.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib bzip2 xz
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gta.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gta.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>libgta-\([0-9.]*\)<.*,\1,p' | \
     head -1
--- a/src/gtk2-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtk2-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -18,7 +18,7 @@
  
  int __stdcall
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gdk_DllMain (HINSTANCE hinstDLL,
  	 DWORD     dwReason,
  	 LPVOID    reserved)
  {
@@ -31,7 +31,7 @@
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++gtk_DllMain (HINSTANCE hinstDLL,
  	 DWORD     fdwReason,
  	 LPVOID    lpvReserved)
  {
--- a/src/gtk2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtk2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gettext libpng jpeg tiff jasper glib atk pango cairo gdk-pixbuf
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtk+/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtk+/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
--- a/src/gtkglext.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtkglext.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtkglext/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtkglext/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '1\.1\.' | \
--- a/src/gtkglextmm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtkglextmm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtkglext gtkmm2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtkglextmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtkglextmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '1\.1\.' | \
--- a/src/gtkmm2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtkmm2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2 libsigc++ pangomm cairomm atkmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtkmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtkmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     grep -v '^2\.9' | \
--- a/src/gtksourceview.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtksourceview.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtk2 libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/gtksourceview/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/gtksourceview/refs/tags' | \
     $(SED) -n 's,.*>GTKSOURCEVIEW_\([0-9]\+_[0-9]*[02468]_[^<]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     grep -v '^2\.9[0-9]\.' | \
--- a/src/gtksourceviewmm2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/gtksourceviewmm2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtkmm2 gtksourceview
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/cgit/gtksourceviewmm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/cgit/gtksourceviewmm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=gtksourceviewmm-\\([0-9][^']*\\)'.*,\\1,p" | \
     grep -v '^2\.9[0-9]\.' | \
--- a/src/guile.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/guile.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libtool gmp libiconv gettext libunistring gc libffi readline
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>[^0-9>]*\([0-9][^< ]*\)\.<.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hunspell-test.cpp	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,37 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <hunspell.hxx>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    std::ofstream dic ("hunspell-test.dic");
+    dic << "2\nHello\nWorld";
+    dic.close();
+    std::ofstream aff ("hunspell-test.aff");
+    aff << "SET UTF-8\nTRY loredWH\nMAXDIFF 1";
+    aff.close();
+    Hunspell h("hunspell-test.aff", "hunspell-test.dic");
+
+    if (h.spell("Hello") == 0)
+    {
+        std::cerr << "Error: hunspell marked correct word as wrong" << std::endl;
+    }
+    if (h.spell("wrld") != 0)
+    {
+        std::cerr << "Error: hunspell marked wrong word as correct" << std::endl;
+    }
+
+    char ** result;
+    int n = h.suggest(&result, "ell");
+    for (int i = 0; i < n; i++) std::cout << result[i];
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hunspell.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,36 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := hunspell
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 902c76d2b55a22610e2227abc4fd26cbe606a51c
+$(PKG)_SUBDIR   := hunspell-$($(PKG)_VERSION)
+$(PKG)_FILE     := hunspell-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/hunspell/Hunspell/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc libiconv gettext readline pthreads
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/hunspell/files/Hunspell/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # Note: the configure file doesn't pick up pdcurses, so "ui" is disabled
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --enable-static \
+        --disable-shared \
+        --with-warnings \
+        --without-ui \
+        --with-readline \
+        --prefix='$(PREFIX)/$(TARGET)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+
+
+    # Test
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-hunspell.exe' \
+        `'$(TARGET)-pkg-config' hunspell --cflags --libs`
+endef
--- a/src/id3lib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/id3lib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/id3lib/files/id3lib/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/id3lib/files/id3lib/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/ilmbase.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/ilmbase.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openexr.com/downloads.html' | \
+    $(WGET) -q -O- 'http://www.openexr.com/downloads.html' | \
     grep 'ilmbase-' | \
     $(SED) -n 's,.*ilmbase-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/imagemagick.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/imagemagick.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc bzip2 ffmpeg fftw freetype jasper jpeg lcms libpng libtool openexr pthreads tiff
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.imagemagick.org/' | \
+    $(WGET) -q -O- 'http://www.imagemagick.org/' | \
     $(SED) -n 's,.*<p>The current release is ImageMagick \([0-9][^<]*\).</p>.*,\1,p' | \
     head -1
 endef
--- a/src/jasper.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/jasper.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ece.uvic.ca/~mdadams/jasper/' | \
+    $(WGET) -q -O- 'http://www.ece.uvic.ca/~mdadams/jasper/' | \
     grep 'jasper-' | \
     $(SED) -n 's,.*jasper-\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
--- a/src/jpeg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/jpeg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.ijg.org/' | \
+    $(WGET) -q -O- 'http://www.ijg.org/' | \
     $(SED) -n 's,.*jpegsrc\.v\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/json-c.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/json-c.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://oss.metaparadigm.com/json-c/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://oss.metaparadigm.com/json-c/?C=M;O=D' | \
     $(SED) -n 's,.*json-c-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/lame.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lame.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lame/files/lame/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lame/files/lame/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lapack-test.f	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,10 @@
+*
+* This file is part of MXE.
+* See index.html for further information.
+*
+      INTEGER MAJOR, MINOR, PATCH
+*
+      CALL ILAVER ( MAJOR,MINOR, PATCH )
+      WRITE(*,*) "LAPACK ",MAJOR,".",MINOR,".",PATCH
+*
+      END
--- a/src/lapack.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lapack.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -2,7 +2,7 @@
 # See index.html for further information.
 
 PKG             := lapack
-$(PKG)_IGNORE   :=
+$(PKG)_IGNORE   := 3.4.1
 $(PKG)_CHECKSUM := 910109a931524f8dcc2734ce23fe927b00ca199f
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tgz
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.netlib.org/lapack/' | \
+    $(WGET) -q -O- 'http://www.netlib.org/lapack/' | \
     $(SED) -n 's_.*>LAPACK, version \([0-9]\.[0-9]\.[0-9]\).*_\1_ip' | \
     head -1
 endef
@@ -20,6 +20,12 @@
     cd '$(1)' && cmake \
         -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
         -DCMAKE_AR='$(PREFIX)/bin/$(TARGET)-ar' \
+        -DCMAKE_RANLIB='$(PREFIX)/bin/$(TARGET)-ranlib' \
         .
     $(MAKE) -C '$(1)/SRC' -j '$(JOBS)' install
+
+    '$(TARGET)-gfortran' \
+        -W -Wall -Werror -pedantic \
+        '$(2).f' -o '$(PREFIX)/$(TARGET)/bin/test-lapack.exe' \
+        -llapack
 endef
--- a/src/lcms.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lcms.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/lcms1.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lcms1.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/lcms/files/lcms/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     grep '^1\.' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/levmar.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,25 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := levmar
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 118bd20b55ab828d875f1b752cb5e1238258950b
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tgz
+$(PKG)_URL      := http://www.ics.forth.gr/~lourakis/$(PKG)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc lapack blas libf2c
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- "http://www.ics.forth.gr/~lourakis/levmar/"  | \
+    $(SED) -n 's_.*Latest:.*levmar-\([0-9]\.[0-9]\).*_\1_ip' | \
+    head -1;
+endef
+
+define $(PKG)_BUILD
+    $(MAKE) -C '$(1)' -j '$(JOBS)' liblevmar.a \
+        CC=$(TARGET)-gcc \
+        AR=$(TARGET)-ar \
+        RANLIB=$(TARGET)-ranlib
+    $(INSTALL) -m644 '$(1)/levmar.h'    '$(PREFIX)/$(TARGET)/include/'
+    $(INSTALL) -m644 '$(1)/liblevmar.a' '$(PREFIX)/$(TARGET)/lib/'
+endef
--- a/src/libarchive.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libarchive.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc bzip2 libiconv libxml2 openssl xz zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/libarchive/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/libarchive/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libarchive-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libass.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libass.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freetype fontconfig fribidi
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/libass/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/libass/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libass-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libcroco.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libcroco.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libcroco/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libcroco/refs/tags' | \
     $(SED) -n 's,.*<a[^>]*>LIBCROCO_\([0-9][0-9_]*\)<.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     head -1
--- a/src/libdnet.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libdnet.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc winpcap
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libdnet/files/libdnet/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libdnet/files/libdnet/' | \
     $(SED) -n 's,.*/libdnet-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libevent.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libevent.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libevent
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2a2cc87ce1945f43dfa5a5f9575fef3d14a8f57a
+$(PKG)_CHECKSUM := 28c109190345ce5469add8cf3f45c5dd57fe2a85
 $(PKG)_SUBDIR   := libevent-$($(PKG)_VERSION)-stable
 $(PKG)_FILE     := libevent-$($(PKG)_VERSION)-stable.tar.gz
 $(PKG)_URL      := https://github.com/downloads/$(PKG)/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libevent.org/' | \
+    $(WGET) -q -O- 'http://libevent.org/' | \
     grep 'libevent-' | \
     $(SED) -n 's,.*libevent-\([0-9][^>]*\)-stable\.tar.*,\1,p' | \
     head -1
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= defexec_DATA=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libf2c-1.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,59 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -ur libf2c.orig/makefile.u libf2c/makefile.u
+--- libf2c.orig/makefile.u	2012-05-04 01:39:36.000000000 +1000
++++ libf2c/makefile.u	2012-05-04 01:45:30.000000000 +1000
+@@ -20,7 +20,7 @@
+ # compile, then strip unnecessary symbols
+ .c.o:
+ 	$(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c
+-	ld -r -x -o $*.xxx $*.o
++	$(LD) -r -x -o $*.xxx $*.o
+ 	mv $*.xxx $*.o
+ ## Under Solaris (and other systems that do not understand ld -x),
+ ## omit -x in the ld line above.
+@@ -72,8 +72,8 @@
+ all: f2c.h signal1.h sysdep1.h libf2c.a
+
+ libf2c.a: $(OFILES)
+-	ar r libf2c.a $?
+-	-ranlib libf2c.a
++	$(AR) r libf2c.a $?
++	-$(RANLIB) libf2c.a
+
+ ## Shared-library variant: the following rule works on Linux
+ ## systems.  Details are system-dependent.  Under Linux, -fPIC
+@@ -123,7 +123,7 @@
+
+ install: libf2c.a
+ 	cp libf2c.a $(LIBDIR)
+-	-ranlib $(LIBDIR)/libf2c.a
++	-$(RANLIB) $(LIBDIR)/libf2c.a
+
+ clean:
+ 	rm -f libf2c.a *.o arith.h signal1.h sysdep1.h
+@@ -182,12 +182,6 @@
+ xwsne.o:	lio.h
+ xwsne.o:	fmt.h
+
+-arith.h: arithchk.c
+-	$(CC) $(CFLAGS) -DNO_FPINIT arithchk.c -lm ||\
+-	 $(CC) -DNO_LONG_LONG $(CFLAGS) -DNO_FPINIT arithchk.c -lm
+-	./a.out >arith.h
+-	rm -f a.out arithchk.o
+-
+ check:
+ 	xsum Notice README abort_.c arithchk.c backspac.c c_abs.c c_cos.c \
+ 	c_div.c c_exp.c c_log.c c_sin.c c_sqrt.c cabs.c close.c comptry.bat \
+
+diff -urN tmp-libf2c.orig/arith.h tmp-libf2c/arith.h
+--- tmp-libf2c.orig/arith.h	1970-01-01 10:00:00.000000000 +1000
++++ tmp-libf2c/arith.h	2012-05-04 01:16:16.000000000 +1000
+@@ -0,0 +1,5 @@
++#define IEEE_8087
++#define Arith_Kind_ASL 1
++#define Double_Align
++#define QNaN0 0x0
++#define QNaN1 0xfff80000
++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libf2c.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,25 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libf2c
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := f71066b41695738dec2261de71eaf02a1aaffe8b
+$(PKG)_SUBDIR   :=
+$(PKG)_FILE     := $(PKG).zip
+$(PKG)_URL      := http://www.netlib.org/f2c/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    echo 1
+endef
+
+define $(PKG)_BUILD
+    $(MAKE) -C '$(1)' -j '$(JOBS)' -f makefile.u \
+        CC=$(TARGET)-gcc \
+        AR=$(TARGET)-ar \
+        LD=$(TARGET)-ld \
+        RANLIB=$(TARGET)-ranlib \
+        CFLAGS='-O -DUSE_CLOCK'
+    $(INSTALL) -m644 '$(1)/libf2c.a' '$(PREFIX)/$(TARGET)/lib'
+    $(INSTALL) -m644 '$(1)/f2c.h'    '$(PREFIX)/$(TARGET)/include'
+endef
--- a/src/libffi.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libffi.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libffi
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 97abf70e6a6d315d9259d58ac463663051d471e1
+$(PKG)_CHECKSUM := bff6a6c886f90ad5e30dee0b46676e8e0297d81d
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://sourceware.org/pub/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q --no-check-certificate -O- 'https://github.com/atgreen/libffi/tags' | \
+    $(WGET) -q -O- 'https://github.com/atgreen/libffi/tags' | \
     grep '<a href="/atgreen/libffi/tarball/' | \
     $(SED) -n 's,.*href="/atgreen/libffi/tarball/v\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgcrypt-test.c	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,32 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <stdio.h>
+#include <gcrypt.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    if (!gcry_check_version (GCRYPT_VERSION)) {
+        fputs ("libgcrypt version mismatch\n", stderr);
+        exit (2);
+    }
+
+    gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
+    gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0);
+    gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
+    gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
+
+    if (!gcry_control (GCRYCTL_INITIALIZATION_FINISHED_P)) {
+       fputs ("libgcrypt has not been initialized\n", stderr);
+       abort ();
+    }
+
+    printf("gcrypt version: %s", GCRYPT_VERSION );
+
+    return 0;
+}
--- a/src/libgcrypt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgcrypt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libgpg_error
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgcrypt/' | \
+    $(WGET) -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgcrypt/' | \
     $(SED) -n 's,.*libgcrypt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v '^1\.4\.' | \
     tail -1
@@ -24,4 +24,10 @@
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-gpg-error-prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    ln -sf '$(PREFIX)/$(TARGET)/bin/libgcrypt-config' '$(PREFIX)/bin/$(TARGET)-libgcrypt-config'
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libgcrypt.exe' \
+        `$(TARGET)-libgcrypt-config --cflags --libs`
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgda.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,34 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# LibGDA
+PKG             := libgda
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 61d0b498202b780750633cc2e957c40325d6c705
+$(PKG)_SUBDIR   := libgda-$($(PKG)_VERSION)
+$(PKG)_FILE     := libgda-$($(PKG)_VERSION).tar.xz
+$(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libgda/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib libxml2 mdbtools postgresql
+
+define $(PKG)_UPDATE
+    echo 'TODO: Updates for package libgda need to be fixed.' >&2;
+    echo $(libgda_VERSION)
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-shared \
+        --disable-gtk-doc \
+        --without-bdb \
+        --with-mdb \
+        --without-oracle \
+        --without-mysql \
+        --without-firebird \
+        --without-java \
+        --enable-binreloc \
+        --disable-crypto
+    $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgdamm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,28 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# libgdamm
+PKG             := libgdamm
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := f6126d7b46720e3ea4f3d49e03add2e52da233be
+$(PKG)_SUBDIR   := libgdamm-$($(PKG)_VERSION)
+$(PKG)_FILE     := libgdamm-$($(PKG)_VERSION).tar.xz
+$(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libgdamm/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc libgda glibmm
+
+define $(PKG)_UPDATE
+    echo 'TODO: Updates for package libgdamm need to be fixed.' >&2;
+    echo $(libgdamm_VERSION)
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        CXX='$(TARGET)-c++' \
+        PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config' \
+        MAKE=$(MAKE)
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+endef
--- a/src/libgee.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgee.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libgee/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libgee/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=LIBGEE_\\([0-9]*_[0-9]*_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
--- a/src/libgeotiff.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgeotiff.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := libgeotiff
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := b8cde5014cf82fe4683fa35fc81a5ea8d64b940f
+$(PKG)_CHECKSUM := 4c6f405869826bb7d9f35f1d69167e3b44a57ef0
 $(PKG)_SUBDIR   := libgeotiff-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgeotiff-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/geotiff/libgeotiff/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg tiff proj
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/geotiff/' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/geotiff/' | \
     $(SED) -n 's,.*libgeotiff-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libgnurx.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgnurx.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/Other/UserContributed/regex/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/Other/UserContributed/regex/' | \
     grep 'mingw-regex-' | \
     $(SED) -n 's,.*mingw-regex-\([0-9\.]*\).*,\1,p' | \
     sort | \
--- a/src/libgpg_error.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgpg_error.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/' | \
+    $(WGET) -q -O- 'ftp://ftp.gnupg.org/gcrypt/libgpg-error/' | \
     $(SED) -n 's,.*libgpg-error-\([1-9]\.[1-9][0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
--- a/src/libgsasl-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgsasl-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -13,7 +13,7 @@
 index 7fec454..d9b62cd 100644
 --- a/gl/memxor.c
 +++ b/gl/memxor.c
-@@ -23,7 +23,7 @@
+@@ -22,7 +22,7 @@
  #include "memxor.h"
  
  void *
--- a/src/libgsasl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgsasl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libgsasl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2942886514f14801193e505fc5367330d5c6b7de
+$(PKG)_CHECKSUM := 08fd5dfdd3d88154cf06cb0759a732790c47b4f7
 $(PKG)_SUBDIR   := libgsasl-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgsasl-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.gnu.org/gnu/gsasl/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libiconv libidn libntlm libgcrypt nettle
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gsasl.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=gsasl.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9]*\.[0-9]*[02468]\.[^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libgsf.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libgsf.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib bzip2 glib libxml2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libgsf/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libgsf/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=LIBGSF_\\([0-9]*_[0-9]*[02468]_[^<]*\\)'.*,\\1,p" | \
     $(SED) 's,_,.,g' | \
--- a/src/libharu.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libharu.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib libpng
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libharu.org/files/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://libharu.org/files/?C=M;O=D' | \
     $(SED) -n 's,.*libharu-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v 'rc' | \
     head -1
--- a/src/libical.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libical.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -9,7 +9,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/freeassociation/files/$(PKG)/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/freeassociation/files/$(PKG)/' | \
     $(SED) -n 's,.*/$(PKG)-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libiconv.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libiconv.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.gnu.org/software/libiconv/' | \
+    $(WGET) -q -O- 'http://www.gnu.org/software/libiconv/' | \
     grep 'libiconv-' | \
     $(SED) -n 's,.*libiconv-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/libidn.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libidn.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libidn
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 4251c108966375ede4df15d76a1bd9a4440f44ee
+$(PKG)_CHECKSUM := 92e64fd5a6428bda6ade2c3cde475b76455cd7dd
 $(PKG)_SUBDIR   := libidn-$($(PKG)_VERSION)
 $(PKG)_FILE     := libidn-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/libidn/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc gettext libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libidn.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libircclient.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libircclient.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libircclient/files/libircclient/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libircclient/files/libircclient/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/liblo.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/liblo.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/liblo/files/liblo/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/liblo/files/liblo/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libmad.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libmad.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mad/files/libmad/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mad/files/libmad/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libmikmod.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libmikmod.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://mikmod.raphnet.net/' | \
+    $(WGET) -q -O- 'http://mikmod.raphnet.net/' | \
     $(SED) -n 's,.*libmikmod-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libmng.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libmng.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg lcms1
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libmng/files/libmng-devel/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libmng/files/libmng-devel/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libmodplug-test.c	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,17 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <modplug.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    ModPlug_Settings settings;
+    ModPlug_GetSettings(&settings);
+    ModPlug_SetSettings(&settings);
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libmodplug.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,31 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# libmodplug
+PKG             := libmodplug
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := df4deffe542b501070ccb0aee37d875ebb0c9e22
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/modplug-xmms/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/modplug-xmms/files/libmodplug/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --disable-shared \
+        --enable-static \
+        --prefix='$(PREFIX)/$(TARGET)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+
+    '$(TARGET)-gcc' \
+        -W -Wall -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-libmodplug.exe' \
+        `'$(TARGET)-pkg-config' libmodplug --cflags --libs`
+endef
--- a/src/libntlm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libntlm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libntlm.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=libntlm.git;a=tags' | \
     grep '<a class="list subject"' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/liboauth.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/liboauth.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc curl openssl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://liboauth.sourceforge.net/' | \
+    $(WGET) -q -O- 'http://liboauth.sourceforge.net/' | \
     $(SED) -n 's,.*liboauth-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libodbc++.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libodbc++.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libodbcxx.svn.sourceforge.net/viewvc/libodbcxx/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://libodbcxx.svn.sourceforge.net/viewvc/libodbcxx/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="libodbc++-\([0-9][^"]*\)".*,\1,p' | \
     head -1
--- a/src/liboil.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/liboil.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cgit.freedesktop.org/liboil/refs/tags' | \
+    $(WGET) -q -O- 'http://cgit.freedesktop.org/liboil/refs/tags' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=[^0-9]*\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
 endef
--- a/src/libpano13.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libpano13.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff libpng zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/api/file/index/project-id/96188/rss?path=/libpano13' | \
+    $(WGET) -q -O- 'http://sourceforge.net/api/file/index/project-id/96188/rss?path=/libpano13' | \
     $(SED) -n 's,.*libpano13-\([0-9].*\)\.tar.*,\1,p' | \
     tail -1
 endef
--- a/src/libpaper.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libpaper.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := libpaper
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1f7a810a433a5a68b099aa92777cc2d0b3d03b42
+$(PKG)_CHECKSUM := 40f16453d7752bf5e3c9e74515650eb37edbb3fe
 $(PKG)_SUBDIR   := libpaper-$($(PKG)_VERSION)
 $(PKG)_FILE     := libpaper_$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.debian.org/debian/pool/main/libp/$(PKG)/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://packages.debian.org/unstable/source/libpaper' | \
+    $(WGET) -q -O- 'http://packages.debian.org/unstable/source/libpaper' | \
     $(SED) -n 's,.*libpaper_\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -19,6 +19,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
--- a/src/libpng.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libpng.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng/libpng;a=tags' | \
+    $(WGET) -q -O- 'http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng/libpng;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<]*\)<.*,\1,p' | \
     grep -v alpha | \
--- a/src/librsvg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/librsvg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := librsvg
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 11a2dc00c813da13532d7f16a822b414201e8b1b
+$(PKG)_CHECKSUM := 1084015373e90ff8fccbae4b27ee778bbdf14d40
 $(PKG)_SUBDIR   := librsvg-$($(PKG)_VERSION)
 $(PKG)_FILE     := librsvg-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/GNOME/sources/librsvg/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc glib libgsf cairo pango gtk2 libcroco
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/librsvg/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/librsvg/refs/tags' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp-1-v2.4.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,2699 @@
+From 272a91d06d71c2a326996f62797ed9ab42f69859 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Wed, 30 Jun 2010 22:34:59 +0000
+Subject: [PATCH 01/34] zlib dependency is only when CRYPTO is enabled
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@536 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile          |    9 +++++----
+ librtmp/hashswf.c |    4 ++--
+ 2 files changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 7470eb4..c7767b4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -11,9 +11,10 @@ SYS=posix
+ CRYPTO=OPENSSL
+ #CRYPTO=POLARSSL
+ #CRYPTO=GNUTLS
+-LIB_GNUTLS=-lgnutls -lgcrypt
+-LIB_OPENSSL=-lssl -lcrypto
+-LIB_POLARSSL=-lpolarssl
++LIBZ=-lz
++LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
++LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+ DEF_=-DNO_CRYPTO
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+@@ -33,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=$(CRYPTO_LIB) -lz $(LIBS_$(SYS)) $(XLIBS)
++LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_mingw=
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 06d2bbb..277f21c 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -66,10 +66,10 @@
+ extern void RTMP_TLS_Init();
+ extern TLS_CTX RTMP_TLS_ctx;
+ 
+-#endif /* CRYPTO */
+-
+ #include <zlib.h>
+ 
++#endif /* CRYPTO */
++
+ #define	AGENT	"Mozilla/5.0"
+ 
+ HTTPResult
+-- 
+1.7.10.4
+
+
+From 6556b9f9328acb1199dc1cc3f22fa82c86b51c8a Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 1 Jul 2010 12:00:43 +0000
+Subject: [PATCH 02/34] Fix typo
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@537 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c7767b4..1fcdd78 100644
+--- a/Makefile
++++ b/Makefile
+@@ -13,7 +13,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_OPENSSL=-lssl -lcrypto$ (LIBZ)
++LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+ DEF_=-DNO_CRYPTO
+-- 
+1.7.10.4
+
+
+From 8a5901c8a74280c898deb4ebf1a2f5d6f68bce42 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 3 Jul 2010 10:25:48 +0000
+Subject: [PATCH 03/34] Document the escape coding used for special characters
+ in values
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@538 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/librtmp.3 |   11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index 055b52b..a5a7558 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -57,14 +57,19 @@ The session handle is freed using
+ .BR RTMP_Free ().
+ 
+ All data is transferred using FLV format. The basic session requires
+-an RTMP URL. Additional options may be specified by appending
+-space-separated key=value pairs to the URL. The RTMP URL format
+-is of the form
++an RTMP URL.  The RTMP URL format is of the form
+ .nf
+   rtmp[t][e|s]://hostname[:port][/app[/playpath]]
+ .fi
+ 
+ Plain rtmp, as well as tunneled and encrypted sessions are supported.
++
++Additional options may be specified by appending space-separated
++key=value pairs to the URL. Special characters in values may need
++to be escaped to prevent misinterpretation by the option parser.
++The escape encoding uses a backslash followed by two hexadecimal digits
++representing the ASCII value of the character. E.g., spaces must
++be escaped as \fB\\20\fP and backslashes must be escaped as \fB\\5c\fP.
+ .SH OPTIONS
+ .SS "Network Parameters"
+ These options define how to connect to the media server.
+-- 
+1.7.10.4
+
+
+From c41568f57bec297581e8508a7e6a3d1e470dc81d Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 3 Jul 2010 10:28:57 +0000
+Subject: [PATCH 04/34] Update from prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@539 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/librtmp.3      |    2 +-
+ librtmp/librtmp.3.html |   13 +++++++++----
+ 2 files changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index a5a7558..66197d5 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -1,4 +1,4 @@
+-.TH LIBRTMP 3 "2010-05-29" "RTMPDump v2.2e"
++.TH LIBRTMP 3 "2010-07-03" "RTMPDump v2.3"
+ .\" Copyright 2010 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+diff --git a/librtmp/librtmp.3.html b/librtmp/librtmp.3.html
+index daf636f..e5e6f4b 100644
+--- a/librtmp/librtmp.3.html
++++ b/librtmp/librtmp.3.html
+@@ -6,7 +6,7 @@
+ <tr><td>LIBRTMP(3)<td align="center"><td align="right">LIBRTMP(3)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-29<td align="right">LIBRTMP(3)
++<tr><td>RTMPDump v2.3<td align="center">2010-07-03<td align="right">LIBRTMP(3)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+ <!-- Copyright 2010 Howard Chu.
+@@ -75,14 +75,19 @@ The session handle is freed using
+ <b>RTMP_Free</b>().
+ <p>
+ All data is transferred using FLV format. The basic session requires
+-an RTMP URL. Additional options may be specified by appending
+-space-separated key=value pairs to the URL. The RTMP URL format
+-is of the form
++an RTMP URL.  The RTMP URL format is of the form
+ <pre>
+   rtmp[t][e|s]://hostname[:port][/app[/playpath]]
+ </pre>
+ <p>
+ Plain rtmp, as well as tunneled and encrypted sessions are supported.
++<p>
++Additional options may be specified by appending space-separated
++key=value pairs to the URL. Special characters in values may need
++to be escaped to prevent misinterpretation by the option parser.
++The escape encoding uses a backslash followed by two hexadecimal digits
++representing the ASCII value of the character. E.g., spaces must
++be escaped as <b>\20</b> and backslashes must be escaped as <b>\5c</b>.
+ </ul>
+ 
+ <h3>OPTIONS</h3><ul>
+-- 
+1.7.10.4
+
+
+From f1c4f0ed07659cbeae4ffaa78ca8cce7500afa58 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:07:39 +0000
+Subject: [PATCH 05/34] Hide strtime()
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@541 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 277f21c..23e754b 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -435,7 +435,7 @@ make_unix_time(char *s)
+ /* Convert a Unix time to a network time string
+  * Weekday, DD-MMM-YYYY HH:MM:SS GMT
+  */
+-void
++static void
+ strtime(time_t * t, char *s)
+ {
+   struct tm *tm;
+-- 
+1.7.10.4
+
+
+From da78eba764eda23fb3bf9aa91bd6c5fee1839932 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:16:55 +0000
+Subject: [PATCH 06/34] Remove obsolete XBOX defs
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@542 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp_sys.h |   11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 0874cbe..6a3f215 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -24,17 +24,14 @@
+ 
+ #ifdef _WIN32
+ 
+-#ifdef _XBOX
+-#include <xtl.h>
+-#include <winsockx.h>
++#include <winsock2.h>
++#include <ws2tcpip.h>
++
++#ifdef _MSC_VER	/* MSVC */
+ #define snprintf _snprintf
+ #define strcasecmp stricmp
+ #define strncasecmp strnicmp
+ #define vsnprintf _vsnprintf
+-
+-#else /* !_XBOX */
+-#include <winsock2.h>
+-#include <ws2tcpip.h>
+ #endif
+ 
+ #define GetSockError()	WSAGetLastError()
+-- 
+1.7.10.4
+
+
+From eef87483b92036a1631c98c9c85dc3cae66411ee Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 5 Jul 2010 20:17:16 +0000
+Subject: [PATCH 07/34] Update XBOX/XBMC support
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@543 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 23e754b..3c56b69 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -466,7 +466,7 @@ RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
+ 
+   date[0] = '\0';
+ #ifdef _WIN32
+-#ifdef _XBOX
++#ifdef XBMC4XBOX
+   hpre.av_val = "Q:";
+   hpre.av_len = 2;
+   home.av_val = "\\UserData";
+-- 
+1.7.10.4
+
+
+From 24f7e724fc10d737a0f14c7741711b6b542c9d45 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 8 Jul 2010 10:38:33 +0000
+Subject: [PATCH 08/34] Don't link explicitly against static library
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@544 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |   27 +++++++++++++--------------
+ 1 file changed, 13 insertions(+), 14 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1fcdd78..741e438 100644
+--- a/Makefile
++++ b/Makefile
+@@ -34,7 +34,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=$(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_mingw=
+@@ -48,9 +48,11 @@ EXT_posix=
+ EXT_mingw=.exe
+ EXT=$(EXT_$(SYS))
+ 
+-all:	$(LIBRTMP) progs
++PROGS=rtmpdump rtmpgw rtmpsrv rtmpsuck
+ 
+-progs:	rtmpdump rtmpgw rtmpsrv rtmpsuck
++all:	$(LIBRTMP) $(PROGS)
++
++$(PROGS): $(LIBRTMP)
+ 
+ install:	progs
+ 	-mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
+@@ -69,20 +71,17 @@ FORCE:
+ $(LIBRTMP): FORCE
+ 	@cd librtmp; $(MAKE) all
+ 
+-# note: $^ is GNU Make's equivalent to BSD $>
+-# we use both since either make will ignore the one it doesn't recognize
+-
+-rtmpdump: rtmpdump.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(LIBS)
++rtmpdump: rtmpdump.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o $(LIBS)
+ 
+-rtmpsrv: rtmpsrv.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpsrv: rtmpsrv.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+-rtmpsuck: rtmpsuck.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpsuck: rtmpsuck.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+-rtmpgw: rtmpgw.o thread.o $(LIBRTMP)
+-	$(CC) $(LDFLAGS) $^ $> -o $@$(EXT) $(SLIBS)
++rtmpgw: rtmpgw.o thread.o
++	$(CC) $(LDFLAGS) -o $@$(EXT) $@.o thread.o $(SLIBS)
+ 
+ rtmpgw.o: rtmpgw.c $(INCRTMP) Makefile
+ rtmpdump.o: rtmpdump.c $(INCRTMP) Makefile
+-- 
+1.7.10.4
+
+
+From 5a3d6003a9745595583015c5b3b24e7bea818790 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 8 Jul 2010 11:11:47 +0000
+Subject: [PATCH 09/34] Fix install target
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@545 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 741e438..75628dd 100644
+--- a/Makefile
++++ b/Makefile
+@@ -54,7 +54,7 @@ all:	$(LIBRTMP) $(PROGS)
+ 
+ $(PROGS): $(LIBRTMP)
+ 
+-install:	progs
++install:	$(PROGS)
+ 	-mkdir -p $(BINDIR) $(SBINDIR) $(MANDIR)/man1 $(MANDIR)/man8
+ 	cp rtmpdump$(EXT) $(BINDIR)
+ 	cp rtmpgw$(EXT) rtmpsrv$(EXT) rtmpsuck$(EXT) $(SBINDIR)
+-- 
+1.7.10.4
+
+
+From 2340f0e27cd21d624d5f915fc42182750be6fca6 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 12 Jul 2010 08:20:04 +0000
+Subject: [PATCH 10/34] MacOSX/Darwin shared library flags
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@546 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile         |    3 +++
+ README           |    6 +++++-
+ librtmp/Makefile |   11 ++++++++++-
+ 3 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 75628dd..fda3c74 100644
+--- a/Makefile
++++ b/Makefile
+@@ -33,10 +33,12 @@ SBINDIR=$(DESTDIR)$(sbindir)
+ MANDIR=$(DESTDIR)$(mandir)
+ 
+ LIBS_posix=
++LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
++THREADLIB_darwin=-lpthread
+ THREADLIB_mingw=
+ THREADLIB=$(THREADLIB_$(SYS))
+ SLIBS=$(THREADLIB) $(LIBS)
+@@ -45,6 +47,7 @@ LIBRTMP=librtmp/librtmp.a
+ INCRTMP=librtmp/rtmp_sys.h librtmp/rtmp.h librtmp/log.h librtmp/amf.h
+ 
+ EXT_posix=
++EXT_darwin=
+ EXT_mingw=.exe
+ EXT=$(EXT_$(SYS))
+ 
+diff --git a/README b/README
+index 6607a1d..5689853 100644
+--- a/README
++++ b/README
+@@ -10,7 +10,11 @@ To compile type "make" with SYS=<platform name>, e.g.
+ 
+   $ make SYS=posix
+ 
+-for Linux, MacOSX, Unix, etc. or
++for Linux, Unix, etc. or
++
++  $ make SYS=darwin
++
++for MacOSX or
+ 
+   $ make SYS=mingw
+ 
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 6774db7..2fd5869 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -17,6 +17,7 @@ REQ_GNUTLS=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
++LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+@@ -26,9 +27,16 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+ SO_posix=so.0
++SO_darwin=so.0
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
++SO_LDFLAGS_posix=-shared -Wl,-soname,$@
++SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
++	-headerpad_max_install_names
++SO_LDFLAGS_mingw=
++SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
++
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+@@ -40,6 +48,7 @@ SO_INST=$(SOINST_$(SHARED))
+ DEF=-DRTMPDUMP_VERSION=\"$(VERSION)\" $(CRYPTO_DEF) $(XDEF)
+ OPT=-O2
+ CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
++LDFLAGS=$(XLDFLAGS)
+ 
+ incdir=$(prefix)/include/librtmp
+ bindir=$(prefix)/bin
+@@ -61,7 +70,7 @@ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+ 
+ librtmp.$(SO_EXT): $(OBJS)
+-	$(CC) -shared -Wl,-soname,$@ $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
++	$(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
+ 	ln -sf $@ librtmp.so
+ 
+ log.o: log.c log.h Makefile
+-- 
+1.7.10.4
+
+
+From 13798268e10fc8c56eecf5fce297375f7fca1526 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 9 Aug 2010 21:46:31 +0000
+Subject: [PATCH 11/34] Fixes for Darwin - use dylib, not bundle for shared
+ lib
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@547 400ebc74-4327-4243-bc38-086b20814532
+---
+ Makefile         |    2 +-
+ librtmp/Makefile |   17 +++++++++++------
+ 2 files changed, 12 insertions(+), 7 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index fda3c74..c322e9a 100644
+--- a/Makefile
++++ b/Makefile
+@@ -35,7 +35,7 @@ MANDIR=$(DESTDIR)$(mandir)
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=-L librtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_darwin=-lpthread
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 2fd5869..a4bf67e 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -26,13 +26,14 @@ CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
+ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+-SO_posix=so.0
+-SO_darwin=so.0
++SO_VERSION=0
++SO_posix=so.$(SO_VERSION)
++SO_darwin=$(SO_VERSION).dylib
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+-SO_LDFLAGS_darwin=-bundle -flat_namespace -undefined suppress -fno-common \
++SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+ SO_LDFLAGS_mingw=
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+@@ -92,9 +93,13 @@ install_base:	librtmp.a librtmp.pc
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+ 	cp librtmp.3 $(MANDIR)/man3
+ 
+-install_so.0:	librtmp.so.0
+-	cp librtmp.so.0 $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.so.0 librtmp.so
++install_so.$(SO_VERSION):	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(LIBDIR)
++	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
++
++install_$(SO_VERSION).dylib:	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(LIBDIR)
++	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
+ 
+ install_dll:	librtmp.dll
+ 	cp librtmp.dll $(BINDIR)
+-- 
+1.7.10.4
+
+
+From eb806247dc8eab25d8a675a4f633d3feaf2b2045 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 10 Aug 2010 06:41:50 +0000
+Subject: [PATCH 12/34] More dynlib tweaks
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@548 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile |   48 ++++++++++++++++++++++++++----------------------
+ 1 file changed, 26 insertions(+), 22 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index a4bf67e..6a1b08b 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -2,6 +2,15 @@ VERSION=v2.3
+ 
+ prefix=/usr/local
+ 
++incdir=$(prefix)/include/librtmp
++bindir=$(prefix)/bin
++libdir=$(prefix)/lib
++mandir=$(prefix)/man
++BINDIR=$(DESTDIR)$(bindir)
++INCDIR=$(DESTDIR)$(incdir)
++LIBDIR=$(DESTDIR)$(libdir)
++MANDIR=$(DESTDIR)$(mandir)
++
+ CC=$(CROSS_COMPILE)gcc
+ LD=$(CROSS_COMPILE)ld
+ AR=$(CROSS_COMPILE)ar
+@@ -27,11 +36,20 @@ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+ SO_VERSION=0
+-SO_posix=so.$(SO_VERSION)
+-SO_darwin=$(SO_VERSION).dylib
++SOX_posix=so
++SOX_darwin=dylib
++SOX_mingw=so	# useless
++SOX=$(SOX_$(SYS))
++SO_posix=$(SOX).$(SO_VERSION)
++SO_darwin=$(SO_VERSION).$(SOX)
+ SO_mingw=dll
+ SO_EXT=$(SO_$(SYS))
+ 
++SODIR_posix=$(LIBDIR)
++SODIR_darwin=$(LIBDIR)
++SODIR_mingw=$(BINDIR)
++SODIR=$(SODIR_$(SYS))
++
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+@@ -41,7 +59,7 @@ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+-SOINST_yes=install_$(SO_EXT)
++SOINST_yes=install_so
+ SO_DEF=$(SODEF_$(SHARED))
+ SO_LIB=$(SOLIB_$(SHARED))
+ SO_INST=$(SOINST_$(SHARED))
+@@ -51,28 +69,20 @@ OPT=-O2
+ CFLAGS=-Wall $(XCFLAGS) $(INC) $(DEF) $(OPT) $(SO_DEF)
+ LDFLAGS=$(XLDFLAGS)
+ 
+-incdir=$(prefix)/include/librtmp
+-bindir=$(prefix)/bin
+-libdir=$(prefix)/lib
+-mandir=$(prefix)/man
+-BINDIR=$(DESTDIR)$(bindir)
+-INCDIR=$(DESTDIR)$(incdir)
+-LIBDIR=$(DESTDIR)$(libdir)
+-MANDIR=$(DESTDIR)$(mandir)
+ 
+ OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
+ 
+ all:	librtmp.a $(SO_LIB)
+ 
+ clean:
+-	rm -f *.o *.a *.so *.$(SO_EXT)
++	rm -f *.o *.a *.$(SOX) *.$(SO_EXT)
+ 
+ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+ 
+ librtmp.$(SO_EXT): $(OBJS)
+ 	$(CC) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $> $(CRYPTO_LIB)
+-	ln -sf $@ librtmp.so
++	ln -sf $@ librtmp.$(SOX)
+ 
+ log.o: log.c log.h Makefile
+ rtmp.o: rtmp.c rtmp.h rtmp_sys.h handshake.h dh.h log.h amf.h Makefile
+@@ -93,13 +103,7 @@ install_base:	librtmp.a librtmp.pc
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+ 	cp librtmp.3 $(MANDIR)/man3
+ 
+-install_so.$(SO_VERSION):	librtmp.$(SO_EXT)
+-	cp librtmp.$(SO_EXT) $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.so
+-
+-install_$(SO_VERSION).dylib:	librtmp.$(SO_EXT)
+-	cp librtmp.$(SO_EXT) $(LIBDIR)
+-	cd $(LIBDIR); ln -sf librtmp.$(SO_EXT) librtmp.dylib
++install_so:	librtmp.$(SO_EXT)
++	cp librtmp.$(SO_EXT) $(SODIR)
++	cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX)
+ 
+-install_dll:	librtmp.dll
+-	cp librtmp.dll $(BINDIR)
+-- 
+1.7.10.4
+
+
+From 08bdebed5423602d195fa981b3f2663e62820677 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 13 Aug 2010 20:05:35 +0000
+Subject: [PATCH 13/34] Substitute libdir in pkgconfig file
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@549 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    3 ++-
+ librtmp/librtmp.pc.in |    2 +-
+ 2 files changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 6a1b08b..7cba62a 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -91,7 +91,8 @@ hashswf.o: hashswf.c http.h rtmp.h rtmp_sys.h Makefile
+ parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
+ 
+ librtmp.pc: librtmp.pc.in Makefile
+-	sed -e "s;@prefix@;$(prefix);" -e "s;@VERSION@;$(VERSION);" \
++	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
++		-e "s;@VERSION@;$(VERSION);" \
+ 		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index d58e269..70bd268 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -1,6 +1,6 @@
+ prefix=@prefix@
+ exec_prefix=${prefix}
+-libdir=${exec_prefix}/lib
++libdir=@libdir@
+ incdir=${prefix}/include
+ 
+ Name: librtmp
+-- 
+1.7.10.4
+
+
+From 59ca19036ed45667b08d98f09e4d4a7a727b77b3 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 13 Aug 2010 20:34:58 +0000
+Subject: [PATCH 14/34] Less case-sensitive check for Content-length: header
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@550 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index f152648..5c678fd 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3664,11 +3664,15 @@ HTTP_read(RTMP *r, int fill)
+     return -1;
+   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
+     return -1;
+-  ptr = strstr(r->m_sb.sb_start, "Content-Length:");
++  ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
++  while ((ptr = strstr(ptr, "Content-"))) {
++    if (!strncasecmp(ptr+8, "length:", 7)) break;
++    ptr += 8;
++  }
+   if (!ptr)
+     return -1;
+   hlen = atoi(ptr+16);
+-  ptr = strstr(ptr, "\r\n\r\n");
++  ptr = strstr(ptr+16, "\r\n\r\n");
+   if (!ptr)
+     return -1;
+   ptr += 4;
+-- 
+1.7.10.4
+
+
+From 8afb3681407a0a83dcb1fec449b83854da440738 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 8 Oct 2010 07:45:54 +0000
+Subject: [PATCH 15/34] Log error message for unsupported SWF Verification
+ types
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@551 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5c678fd..3e4e00a 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2789,11 +2789,17 @@ HandleCtrl(RTMP *r, const RTMPPacket *packet)
+   if (nType == 0x1A)
+     {
+       RTMP_Log(RTMP_LOGDEBUG, "%s, SWFVerification ping received: ", __FUNCTION__);
++      if (packet->m_nBodySize > 2 && packet->m_body[2] > 0x01)
++	{
++	  RTMP_Log(RTMP_LOGERROR,
++            "%s: SWFVerification Type %d request not supported! Patches welcome...",
++	    __FUNCTION__, packet->m_body[2]);
++	}
+ #ifdef CRYPTO
+       /*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+       /* respond with HMAC SHA256 of decompressed SWF, key is the 30byte player key, also the last 30 bytes of the server handshake are applied */
+-      if (r->Link.SWFSize)
++      else if (r->Link.SWFSize)
+ 	{
+ 	  RTMP_SendCtrl(r, 0x1B, 0, 0);
+ 	}
+-- 
+1.7.10.4
+
+
+From 9ca7e22d94c6e07e8ef05acbf636809a5914f50c Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 26 Oct 2010 23:51:10 +0000
+Subject: [PATCH 16/34] Timeout fix from Antti Ajanki
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@552 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    3 +++
+ rtmpdump.c     |    2 +-
+ 2 files changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 3e4e00a..db882dc 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1019,6 +1019,9 @@ RTMP_ToggleStream(RTMP *r)
+ 
+   if (!r->m_pausing)
+     {
++      if (RTMP_IsTimedout(r) && r->m_read.status == RTMP_READ_EOF)
++        r->m_read.status = 0;
++
+       res = RTMP_SendPause(r, TRUE, r->m_pauseStamp);
+       if (!res)
+ 	return res;
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 7aa19ab..c1cd95b 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -583,7 +583,7 @@ Download(RTMP * rtmp,		// connected RTMP object
+ #endif
+ 
+     }
+-  while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp));
++  while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp) && !RTMP_IsTimedout(rtmp));
+   free(buffer);
+   if (nRead < 0)
+     nRead = rtmp->m_read.status;
+-- 
+1.7.10.4
+
+
+From 1379a2c0d22f238d97970a7e7420287a9bd794de Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 24 Dec 2010 22:35:35 +0000
+Subject: [PATCH 17/34] Fix infinite loop on Error/Close
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@554 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index db882dc..e6e8ed8 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3395,10 +3395,10 @@ RTMP_Close(RTMP *r)
+     {
+       if (r->m_stream_id > 0)
+         {
+-          if ((r->Link.protocol & RTMP_FEATURE_WRITE))
+-	    SendFCUnpublish(r);
+ 	  i = r->m_stream_id;
+ 	  r->m_stream_id = 0;
++          if ((r->Link.protocol & RTMP_FEATURE_WRITE))
++	    SendFCUnpublish(r);
+ 	  SendDeleteStream(r, i);
+ 	}
+       if (r->m_clientID.av_val)
+-- 
+1.7.10.4
+
+
+From 8c713f4c5c8e72369b48d15772e19d1c9ebd5a19 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Fri, 25 Feb 2011 05:51:40 +0000
+Subject: [PATCH 18/34] Fix FLV timestamps during resume
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@557 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index e6e8ed8..e2925a7 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -4083,7 +4083,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  /* grab first timestamp and see if it needs fixing */
+ 	  nTimeStamp = AMF_DecodeInt24(packetBody + 4);
+ 	  nTimeStamp |= (packetBody[7] << 24);
+-	  delta = packet.m_nTimeStamp - nTimeStamp;
++	  delta = packet.m_nTimeStamp - nTimeStamp + r->m_read.nResumeTS;
+ 
+ 	  while (pos + 11 < nPacketLen)
+ 	    {
+-- 
+1.7.10.4
+
+
+From bca1ef01727cac659f7ac171c791490efe4e48d6 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 10 Mar 2011 14:30:06 +0000
+Subject: [PATCH 19/34] Add Libs.private to pkgconfig for Windows
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@558 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    6 ++++--
+ librtmp/librtmp.pc.in |    1 +
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 7cba62a..87618af 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -31,7 +31,8 @@ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+-CRYPTO_LIB=$(LIB_$(CRYPTO)) $(LIBS_$(SYS))
++PRIVATE_LIBS=$(LIBS_$(SYS))
++CRYPTO_LIB=$(LIB_$(CRYPTO)) $(PRIVATE_LIBS)
+ CRYPTO_REQ=$(REQ_$(CRYPTO))
+ CRYPTO_DEF=$(DEF_$(CRYPTO))
+ 
+@@ -93,7 +94,8 @@ parseurl.o: parseurl.c rtmp.h rtmp_sys.h log.h Makefile
+ librtmp.pc: librtmp.pc.in Makefile
+ 	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
+ 		-e "s;@VERSION@;$(VERSION);" \
+-		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" librtmp.pc.in > $@
++		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
++		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+ 
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index 70bd268..5933ca1 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -9,4 +9,5 @@ Version: @VERSION@
+ Requires: @CRYPTO_REQ@
+ URL: http://rtmpdump.mplayerhq.hu
+ Libs: -L${libdir} -lrtmp -lz
++Libs.private; @PRIVATE_LIBS@
+ Cflags: -I${incdir}
+-- 
+1.7.10.4
+
+
+From 25447a0f675cc6e9eefc8eb420ad3a2725be8ab1 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 10 Mar 2011 14:33:32 +0000
+Subject: [PATCH 20/34] Fix typos in prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@559 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/Makefile      |    2 +-
+ librtmp/librtmp.pc.in |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 87618af..1ea31a0 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -95,7 +95,7 @@ librtmp.pc: librtmp.pc.in Makefile
+ 	sed -e "s;@prefix@;$(prefix);" -e "s;@libdir@;$(libdir);" \
+ 		-e "s;@VERSION@;$(VERSION);" \
+ 		-e "s;@CRYPTO_REQ@;$(CRYPTO_REQ);" \
+-		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS));" librtmp.pc.in > $@
++		-e "s;@PRIVATE_LIBS@;$(PRIVATE_LIBS);" librtmp.pc.in > $@
+ 
+ install:	install_base $(SO_INST)
+ 
+diff --git a/librtmp/librtmp.pc.in b/librtmp/librtmp.pc.in
+index 5933ca1..a82beca 100644
+--- a/librtmp/librtmp.pc.in
++++ b/librtmp/librtmp.pc.in
+@@ -9,5 +9,5 @@ Version: @VERSION@
+ Requires: @CRYPTO_REQ@
+ URL: http://rtmpdump.mplayerhq.hu
+ Libs: -L${libdir} -lrtmp -lz
+-Libs.private; @PRIVATE_LIBS@
++Libs.private: @PRIVATE_LIBS@
+ Cflags: -I${incdir}
+-- 
+1.7.10.4
+
+
+From 0a219ffeeb0094111fd00c509fce3ddd6eba2de2 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Mon, 14 Mar 2011 06:48:09 +0000
+Subject: [PATCH 21/34] Bump up play command buffer sizes
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@560 400ebc74-4327-4243-bc38-086b20814532
+---
+ rtmpsrv.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f2af85b..4d5699f 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -266,7 +266,7 @@ static int
+ SendPlayStart(RTMP *r)
+ {
+   RTMPPacket packet;
+-  char pbuf[384], *pend = pbuf+sizeof(pbuf);
++  char pbuf[512], *pend = pbuf+sizeof(pbuf);
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+@@ -298,7 +298,7 @@ static int
+ SendPlayStop(RTMP *r)
+ {
+   RTMPPacket packet;
+-  char pbuf[384], *pend = pbuf+sizeof(pbuf);
++  char pbuf[512], *pend = pbuf+sizeof(pbuf);
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-- 
+1.7.10.4
+
+
+From a1bcab1da064cca8a534d26970333220b57a72f0 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Wed, 16 Mar 2011 12:11:21 +0000
+Subject: [PATCH 22/34] Fix rtmpt read hangs
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@561 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |   17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index e2925a7..3042c7f 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -877,7 +877,13 @@ RTMP_Connect1(RTMP *r, RTMPPacket *cp)
+       r->m_clientID.av_val = NULL;
+       r->m_clientID.av_len = 0;
+       HTTP_Post(r, RTMPT_OPEN, "", 1);
+-      HTTP_read(r, 1);
++      if (HTTP_read(r, 1) != 0)
++	{
++	  r->m_msgCounter = 0;
++	  RTMP_Log(RTMP_LOGDEBUG, "%s, Could not connect for handshake", __FUNCTION__);
++	  RTMP_Close(r);
++	  return 0;
++	}
+       r->m_msgCounter = 0;
+     }
+   RTMP_Log(RTMP_LOGDEBUG, "%s, ... connected, handshaking", __FUNCTION__);
+@@ -1284,7 +1290,12 @@ ReadN(RTMP *r, char *buffer, int n)
+ 		      return 0;
+ 		    }
+ 		}
+-	      HTTP_read(r, 0);
++	      if (HTTP_read(r, 0) == -1)
++		{
++		  RTMP_Log(RTMP_LOGDEBUG, "%s, No valid HTTP response found", __FUNCTION__);
++		  RTMP_Close(r);
++		  return 0;
++		}
+ 	    }
+ 	  if (r->m_resplen && !r->m_sb.sb_size)
+ 	    RTMPSockBuf_Fill(&r->m_sb);
+@@ -3670,7 +3681,7 @@ HTTP_read(RTMP *r, int fill)
+   if (fill)
+     RTMPSockBuf_Fill(&r->m_sb);
+   if (r->m_sb.sb_size < 144)
+-    return -1;
++    return -2;
+   if (strncmp(r->m_sb.sb_start, "HTTP/1.1 200 ", 13))
+     return -1;
+   ptr = r->m_sb.sb_start + sizeof("HTTP/1.1 200");
+-- 
+1.7.10.4
+
+
+From aa2825fbb1d1f70652d558a730baed28149ebbdd Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Sat, 19 Mar 2011 23:32:53 +0000
+Subject: [PATCH 23/34] Drop back on the handshake version, avoid rtmpe 9
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@562 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/handshake.h |    6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 958579a..d4d2913 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -400,8 +400,10 @@ HandShake(RTMP * r, int FP9HandShake)
+       /* set version to at least 9.0.115.0 */
+       if (encrypted)
+ 	{
+-	  clientsig[4] = 128;
+-	  clientsig[6] = 3;
++/* 	  clientsig[4] = 128;
++	  clientsig[6] = 3; */
++	  clientsig[4] = 0x7c;
++	  clientsig[6] = 0x2;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From ac1843db901184bef349615e3b67d7d2fcebdb7f Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Tue, 22 Mar 2011 15:13:18 +0000
+Subject: [PATCH 24/34] Fix prev commit
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@563 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/handshake.h |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index d4d2913..b172dbf 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -402,8 +402,8 @@ HandShake(RTMP * r, int FP9HandShake)
+ 	{
+ /* 	  clientsig[4] = 128;
+ 	  clientsig[6] = 3; */
+-	  clientsig[4] = 0x7c;
+-	  clientsig[6] = 0x2;
++	  clientsig[4] = 9;
++	  clientsig[6] = 0x7c;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From 495e1e64106f10a7a1c15f0e2f870a02aa90605c Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:07:31 +0000
+Subject: [PATCH 25/34] Handle Play.PublishNotify like Play.Start
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@566 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 3042c7f..286b6ae 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2282,6 +2282,8 @@ static const AVal av_NetStream_Play_Complete = AVC("NetStream.Play.Complete");
+ static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
+ static const AVal av_NetStream_Seek_Notify = AVC("NetStream.Seek.Notify");
+ static const AVal av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify");
++static const AVal av_NetStream_Play_PublishNotify =
++AVC("NetStream.Play.PublishNotify");
+ static const AVal av_NetStream_Play_UnpublishNotify =
+ AVC("NetStream.Play.UnpublishNotify");
+ static const AVal av_NetStream_Publish_Start = AVC("NetStream.Publish.Start");
+@@ -2449,7 +2451,8 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 	  RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
+ 	}
+ 
+-      else if (AVMATCH(&code, &av_NetStream_Play_Start))
++      else if (AVMATCH(&code, &av_NetStream_Play_Start)
++           || AVMATCH(&code, &av_NetStream_Play_PublishNotify))
+ 	{
+ 	  int i;
+ 	  r->m_bPlaying = TRUE;
+-- 
+1.7.10.4
+
+
+From 041cf3f2c927b26dc4b27b5e802fbb89362ea3e2 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:11:13 +0000
+Subject: [PATCH 26/34] Handle multiple sessions at once (ugly)
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@567 400ebc74-4327-4243-bc38-086b20814532
+---
+ rtmpsuck.c |   13 ++++++++-----
+ 1 file changed, 8 insertions(+), 5 deletions(-)
+
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index ce6d879..3293e8b 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -718,15 +718,15 @@ controlServerThread(void *unused)
+   TFRET();
+ }
+ 
+-void doServe(STREAMING_SERVER * server,	// server socket and state (our listening socket)
+-  int sockfd	// client connection socket
+-  )
++TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+ {
++  STREAMING_SERVER *server = arg;
+   RTMPPacket pc = { 0 }, ps = { 0 };
+   RTMPChunk rk = { 0 };
+   char *buf = NULL;
+   unsigned int buflen = 131072;
+   int paused = FALSE;
++  int sockfd = server->socket;
+ 
+   // timeout for http requests
+   fd_set rfds;
+@@ -990,7 +990,7 @@ quit:
+   if (server->state == STREAMING_IN_PROGRESS)
+     server->state = STREAMING_ACCEPTING;
+ 
+-  return;
++  TFRET();
+ }
+ 
+ TFTYPE
+@@ -1003,6 +1003,7 @@ serverThread(void *arg)
+     {
+       struct sockaddr_in addr;
+       socklen_t addrlen = sizeof(struct sockaddr_in);
++      STREAMING_SERVER *srv2 = malloc(sizeof(STREAMING_SERVER));
+       int sockfd =
+ 	accept(server->socket, (struct sockaddr *) &addr, &addrlen);
+ 
+@@ -1020,8 +1021,10 @@ serverThread(void *arg)
+ 	  RTMP_Log(RTMP_LOGDEBUG, "%s: accepted connection from %s\n", __FUNCTION__,
+ 	      inet_ntoa(addr.sin_addr));
+ #endif
++	  *srv2 = *server;
++	  srv2->socket = sockfd;
+ 	  /* Create a new thread and transfer the control to that */
+-	  doServe(server, sockfd);
++	  ThreadCreate(doServe, srv2);
+ 	  RTMP_Log(RTMP_LOGDEBUG, "%s: processed request\n", __FUNCTION__);
+ 	}
+       else
+-- 
+1.7.10.4
+
+
+From 6155179b296f9749f713bb9bf47e9ca1fdb1a201 Mon Sep 17 00:00:00 2001
+From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
+Date: Thu, 7 Apr 2011 19:33:28 +0000
+Subject: [PATCH 27/34] Use symbolic constants for packet types. From Peter
+ Miller @ opensource.org.au
+
+git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@568 400ebc74-4327-4243-bc38-086b20814532
+---
+ librtmp/rtmp.c |  132 ++++++++++++++++++++++++++++++--------------------------
+ librtmp/rtmp.h |   26 +++++++++--
+ rtmpsrv.c      |    8 ++--
+ rtmpsuck.c     |  112 ++++++++++++++++++++++++++---------------------
+ 4 files changed, 161 insertions(+), 117 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 286b6ae..5ef3ae9 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1103,32 +1103,32 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+   int bHasMediaPacket = 0;
+   switch (packet->m_packetType)
+     {
+-    case 0x01:
++    case RTMP_PACKET_TYPE_CHUNK_SIZE:
+       /* chunk size */
+       HandleChangeChunkSize(r, packet);
+       break;
+ 
+-    case 0x03:
++    case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
+       /* bytes read report */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: bytes read report", __FUNCTION__);
+       break;
+ 
+-    case 0x04:
++    case RTMP_PACKET_TYPE_CONTROL:
+       /* ctrl */
+       HandleCtrl(r, packet);
+       break;
+ 
+-    case 0x05:
++    case RTMP_PACKET_TYPE_SERVER_BW:
+       /* server bw */
+       HandleServerBW(r, packet);
+       break;
+ 
+-    case 0x06:
++    case RTMP_PACKET_TYPE_CLIENT_BW:
+       /* client bw */
+       HandleClientBW(r, packet);
+       break;
+ 
+-    case 0x08:
++    case RTMP_PACKET_TYPE_AUDIO:
+       /* audio data */
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize); */
+       HandleAudio(r, packet);
+@@ -1139,7 +1139,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	r->m_mediaStamp = packet->m_nTimeStamp;
+       break;
+ 
+-    case 0x09:
++    case RTMP_PACKET_TYPE_VIDEO:
+       /* video data */
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize); */
+       HandleVideo(r, packet);
+@@ -1150,19 +1150,22 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	r->m_mediaStamp = packet->m_nTimeStamp;
+       break;
+ 
+-    case 0x0F:			/* flex stream send */
++    case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
++      /* flex stream send */
+       RTMP_Log(RTMP_LOGDEBUG,
+ 	  "%s, flex stream send, size %lu bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+-    case 0x10:			/* flex shared object */
++    case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
++      /* flex shared object */
+       RTMP_Log(RTMP_LOGDEBUG,
+ 	  "%s, flex shared object, size %lu bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+-    case 0x11:			/* flex message */
++    case RTMP_PACKET_TYPE_FLEX_MESSAGE:
++      /* flex message */
+       {
+ 	RTMP_Log(RTMP_LOGDEBUG,
+ 	    "%s, flex message, size %lu bytes, not fully supported",
+@@ -1185,7 +1188,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	  bHasMediaPacket = 2;
+ 	break;
+       }
+-    case 0x12:
++    case RTMP_PACKET_TYPE_INFO:
+       /* metadata (notify) */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+@@ -1193,12 +1196,12 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	bHasMediaPacket = 1;
+       break;
+ 
+-    case 0x13:
++    case RTMP_PACKET_TYPE_SHARED_OBJECT:
+       RTMP_Log(RTMP_LOGDEBUG, "%s, shared object, not supported, ignoring",
+ 	  __FUNCTION__);
+       break;
+ 
+-    case 0x14:
++    case RTMP_PACKET_TYPE_INVOKE:
+       /* invoke */
+       RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+@@ -1208,7 +1211,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 	bHasMediaPacket = 2;
+       break;
+ 
+-    case 0x16:
++    case RTMP_PACKET_TYPE_FLASH_VIDEO:
+       {
+ 	/* go through FLV packets and handle metadata packets */
+ 	unsigned int pos = 0;
+@@ -1448,7 +1451,7 @@ SendConnectPacket(RTMP *r, RTMPPacket *cp)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1559,7 +1562,7 @@ SendBGHasStream(RTMP *r, double dId, AVal *playpath)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1591,7 +1594,7 @@ RTMP_SendCreateStream(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1617,7 +1620,7 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   char *enc;
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1649,7 +1652,7 @@ SendReleaseStream(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1679,7 +1682,7 @@ SendFCPublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1709,7 +1712,7 @@ SendFCUnpublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1741,7 +1744,7 @@ SendPublish(RTMP *r)
+ 
+   packet.m_nChannel = 0x04;	/* source channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1776,7 +1779,7 @@ SendDeleteStream(RTMP *r, double dStreamId)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1805,7 +1808,7 @@ RTMP_SendPause(RTMP *r, int DoPause, int iTime)
+ 
+   packet.m_nChannel = 0x08;	/* video channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* invoke */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1842,7 +1845,7 @@ RTMP_SendSeek(RTMP *r, int iTime)
+ 
+   packet.m_nChannel = 0x08;	/* video channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* invoke */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1870,7 +1873,7 @@ RTMP_SendServerBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x05;	/* Server BW */
++  packet.m_packetType = RTMP_PACKET_TYPE_SERVER_BW;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1890,7 +1893,7 @@ RTMP_SendClientBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x06;	/* Client BW */
++  packet.m_packetType = RTMP_PACKET_TYPE_CLIENT_BW;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1911,7 +1914,7 @@ SendBytesReceived(RTMP *r)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x03;	/* bytes in */
++  packet.m_packetType = RTMP_PACKET_TYPE_BYTES_READ_REPORT;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1937,7 +1940,7 @@ SendCheckBW(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;	/* RTMP_GetTime(); */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1965,7 +1968,7 @@ SendCheckBWResult(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter;	/* temp inc value. till we figure it out. */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -1994,7 +1997,7 @@ SendPong(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0x16 * r->m_nBWCheckCounter;	/* temp inc value. till we figure it out. */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -2021,7 +2024,7 @@ SendPlay(RTMP *r)
+ 
+   packet.m_nChannel = 0x08;	/* we make 8 our stream channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;	/*0x01000000; */
+   packet.m_hasAbsTimestamp = 0;
+@@ -2089,7 +2092,7 @@ SendPlaylist(RTMP *r)
+ 
+   packet.m_nChannel = 0x08;	/* we make 8 our stream channel */
+   packet.m_headerType = RTMP_PACKET_SIZE_LARGE;
+-  packet.m_packetType = 0x14;	/* INVOKE */
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = r->m_stream_id;	/*0x01000000; */
+   packet.m_hasAbsTimestamp = 0;
+@@ -2127,7 +2130,7 @@ SendSecureTokenResponse(RTMP *r, AVal *resp)
+ 
+   packet.m_nChannel = 0x03;	/* control channel (invoke) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x14;
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -2174,7 +2177,7 @@ RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime)
+ 
+   packet.m_nChannel = 0x02;	/* control channel (ping) */
+   packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
+-  packet.m_packetType = 0x04;	/* ctrl */
++  packet.m_packetType = RTMP_PACKET_TYPE_CONTROL;
+   packet.m_nTimeStamp = 0;	/* RTMP_GetTime(); */
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -3372,7 +3375,7 @@ RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue)
+     }
+ 
+   /* we invoked a remote method */
+-  if (packet->m_packetType == 0x14)
++  if (packet->m_packetType == RTMP_PACKET_TYPE_INVOKE)
+     {
+       AVal method;
+       char *ptr;
+@@ -3748,8 +3751,8 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       char *packetBody = packet.m_body;
+       unsigned int nPacketLen = packet.m_nBodySize;
+ 
+-      /* Return -3 if this was completed nicely with invoke message
+-       * Play.Stop or Play.Complete
++      /* Return RTMP_READ_COMPLETE if this was completed nicely with
++       * invoke message Play.Stop or Play.Complete
+        */
+       if (rtnGetNextMediaPacket == 2)
+ 	{
+@@ -3760,17 +3763,17 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  break;
+ 	}
+ 
+-      r->m_read.dataType |= (((packet.m_packetType == 0x08) << 2) |
+-			     (packet.m_packetType == 0x09));
++      r->m_read.dataType |= (((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO) << 2) |
++			     (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO));
+ 
+-      if (packet.m_packetType == 0x09 && nPacketLen <= 5)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
+ 	{
+ 	  RTMP_Log(RTMP_LOGDEBUG, "ignoring too small video packet: size: %d",
+ 	      nPacketLen);
+ 	  ret = RTMP_READ_IGNORE;
+ 	  break;
+ 	}
+-      if (packet.m_packetType == 0x08 && nPacketLen <= 1)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
+ 	{
+ 	  RTMP_Log(RTMP_LOGDEBUG, "ignoring too small audio packet: size: %d",
+ 	      nPacketLen);
+@@ -3787,7 +3790,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
+ 	  packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
+ 	  packet.m_hasAbsTimestamp);
+-      if (packet.m_packetType == 0x09)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_VIDEO)
+ 	RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ #endif
+ 
+@@ -3797,7 +3800,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  if (packet.m_nTimeStamp == 0)
+ 	    {
+ 	      if (r->m_read.nMetaHeaderSize > 0
+-		  && packet.m_packetType == 0x12)
++		  && packet.m_packetType == RTMP_PACKET_TYPE_INFO)
+ 		{
+ 		  AMFObject metaObj;
+ 		  int nRes =
+@@ -3858,7 +3861,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 		   * in the first FLV stream chunk and we have to compare
+ 		   * it and filter it out !!
+ 		   */
+-		  if (packet.m_packetType == 0x16)
++		  if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 		    {
+ 		      /* basically we have to find the keyframe with the
+ 		       * correct TS being nResumeTS
+@@ -3970,7 +3973,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	   * (seeking might put us somewhere before it)
+ 	   */
+ 	  if (!(r->m_read.flags & RTMP_READ_GOTKF) &&
+-	  	packet.m_packetType != 0x16)
++	  	packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	    {
+ 	      RTMP_Log(RTMP_LOGWARNING,
+ 		  "Stream does not start with requested frame, ignoring data... ");
+@@ -3983,7 +3986,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	    }
+ 	  /* ok, do the same for FLV streams */
+ 	  if (!(r->m_read.flags & RTMP_READ_GOTFLVK) &&
+-	  	packet.m_packetType == 0x16)
++	  	packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	    {
+ 	      RTMP_Log(RTMP_LOGWARNING,
+ 		  "Stream does not start with requested FLV frame, ignoring data... ");
+@@ -4002,9 +4005,11 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	   * the preceding if clause)
+ 	   */
+ 	  if (!(r->m_read.flags & RTMP_READ_NO_IGNORE) &&
+-	  	packet.m_packetType != 0x16)
+-	    {			/* exclude type 0x16 (FLV) since it can
+-				 * contain several FLV packets */
++	  	packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
++	    {
++              /* exclude type RTMP_PACKET_TYPE_FLASH_VIDEO since it can
++               * contain several FLV packets
++               */
+ 	      if (packet.m_nTimeStamp == 0)
+ 		{
+ 		  ret = RTMP_READ_IGNORE;
+@@ -4020,9 +4025,10 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 
+       /* calculate packet size and allocate slop buffer if necessary */
+       size = nPacketLen +
+-	((packet.m_packetType == 0x08 || packet.m_packetType == 0x09
+-	  || packet.m_packetType == 0x12) ? 11 : 0) +
+-	(packet.m_packetType != 0x16 ? 4 : 0);
++	((packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet.m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0) +
++	(packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO ? 4 : 0);
+ 
+       if (size + 4 > buflen)
+ 	{
+@@ -4048,8 +4054,9 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 
+       /* audio (0x08), video (0x09) or metadata (0x12) packets :
+        * construct 11 byte header then add rtmp packet's data */
+-      if (packet.m_packetType == 0x08 || packet.m_packetType == 0x09
+-	  || packet.m_packetType == 0x12)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet.m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet.m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	{
+ 	  nTimeStamp = r->m_read.nResumeTS + packet.m_nTimeStamp;
+ 	  prevTagSize = 11 + nPacketLen;
+@@ -4059,7 +4066,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	  ptr = AMF_EncodeInt24(ptr, pend, nPacketLen);
+ 
+ #if 0
+-	    if(packet.m_packetType == 0x09) { /* video */
++	    if(packet.m_packetType == RTMP_PACKET_TYPE_VIDEO) {
+ 
+ 	     /* H264 fix: */
+ 	     if((packetBody[0] & 0x0f) == 7) { /* CodecId = H264 */
+@@ -4089,7 +4096,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+       len = nPacketLen;
+ 
+       /* correct tagSize and obtain timestamp if we have an FLV stream */
+-      if (packet.m_packetType == 0x16)
++      if (packet.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  unsigned int pos = 0;
+ 	  int delta;
+@@ -4167,7 +4174,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 	}
+       ptr += len;
+ 
+-      if (packet.m_packetType != 0x16)
++      if (packet.m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  /* FLV tag packets contain their own prevTagSize */
+ 	  AMF_EncodeInt32(ptr, pend, prevTagSize);
+@@ -4352,11 +4359,12 @@ RTMP_Write(RTMP *r, const char *buf, int size)
+ 	  buf += 3;
+ 	  s2 -= 11;
+ 
+-	  if (((pkt->m_packetType == 0x08 || pkt->m_packetType == 0x09) &&
+-	    !pkt->m_nTimeStamp) || pkt->m_packetType == 0x12)
++	  if (((pkt->m_packetType == RTMP_PACKET_TYPE_AUDIO
++                || pkt->m_packetType == RTMP_PACKET_TYPE_VIDEO) &&
++            !pkt->m_nTimeStamp) || pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	    {
+ 	      pkt->m_headerType = RTMP_PACKET_SIZE_LARGE;
+-	      if (pkt->m_packetType == 0x12)
++	      if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 		pkt->m_nBodySize += 16;
+ 	    }
+ 	  else
+@@ -4371,7 +4379,7 @@ RTMP_Write(RTMP *r, const char *buf, int size)
+ 	    }
+ 	  enc = pkt->m_body;
+ 	  pend = enc + pkt->m_nBodySize;
+-	  if (pkt->m_packetType == 0x12)
++	  if (pkt->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	    {
+ 	      enc = AMF_EncodeString(enc, pend, &av_setDataFrame);
+ 	      pkt->m_nBytesRead = enc - pkt->m_body;
+diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h
+index de0b795..1ece207 100644
+--- a/librtmp/rtmp.h
++++ b/librtmp/rtmp.h
+@@ -71,9 +71,29 @@ extern "C"
+ 
+   uint32_t RTMP_GetTime(void);
+ 
+-#define RTMP_PACKET_TYPE_AUDIO 0x08
+-#define RTMP_PACKET_TYPE_VIDEO 0x09
+-#define RTMP_PACKET_TYPE_INFO  0x12
++/*      RTMP_PACKET_TYPE_...                0x00 */
++#define RTMP_PACKET_TYPE_CHUNK_SIZE         0x01
++/*      RTMP_PACKET_TYPE_...                0x02 */
++#define RTMP_PACKET_TYPE_BYTES_READ_REPORT  0x03
++#define RTMP_PACKET_TYPE_CONTROL            0x04
++#define RTMP_PACKET_TYPE_SERVER_BW          0x05
++#define RTMP_PACKET_TYPE_CLIENT_BW          0x06
++/*      RTMP_PACKET_TYPE_...                0x07 */
++#define RTMP_PACKET_TYPE_AUDIO              0x08
++#define RTMP_PACKET_TYPE_VIDEO              0x09
++/*      RTMP_PACKET_TYPE_...                0x0A */
++/*      RTMP_PACKET_TYPE_...                0x0B */
++/*      RTMP_PACKET_TYPE_...                0x0C */
++/*      RTMP_PACKET_TYPE_...                0x0D */
++/*      RTMP_PACKET_TYPE_...                0x0E */
++#define RTMP_PACKET_TYPE_FLEX_STREAM_SEND   0x0F
++#define RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT 0x10
++#define RTMP_PACKET_TYPE_FLEX_MESSAGE       0x11
++#define RTMP_PACKET_TYPE_INFO               0x12
++#define RTMP_PACKET_TYPE_SHARED_OBJECT      0x13
++#define RTMP_PACKET_TYPE_INVOKE             0x14
++/*      RTMP_PACKET_TYPE_...                0x15 */
++#define RTMP_PACKET_TYPE_FLASH_VIDEO        0x16
+ 
+ #define RTMP_MAX_HEADER_SIZE 18
+ 
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 4d5699f..f1b6c66 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -175,7 +175,7 @@ SendConnectResult(RTMP *r, double txn)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -236,7 +236,7 @@ SendResultNumber(RTMP *r, double txn, double ID)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -270,7 +270,7 @@ SendPlayStart(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+@@ -302,7 +302,7 @@ SendPlayStop(RTMP *r)
+ 
+   packet.m_nChannel = 0x03;     // control channel (invoke)
+   packet.m_headerType = 1; /* RTMP_PACKET_SIZE_MEDIUM; */
+-  packet.m_packetType = 0x14;   // INVOKE
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
+   packet.m_nTimeStamp = 0;
+   packet.m_nInfoField2 = 0;
+   packet.m_hasAbsTimestamp = 0;
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index 3293e8b..661e64b 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -461,67 +461,71 @@ ServePacket(STREAMING_SERVER *server, int which, RTMPPacket *packet)
+ 
+   switch (packet->m_packetType)
+     {
+-    case 0x01:
++    case RTMP_PACKET_TYPE_CHUNK_SIZE:
+       // chunk size
+ //      HandleChangeChunkSize(r, packet);
+       break;
+ 
+-    case 0x03:
++    case RTMP_PACKET_TYPE_BYTES_READ_REPORT:
+       // bytes read report
+       break;
+ 
+-    case 0x04:
++    case RTMP_PACKET_TYPE_CONTROL:
+       // ctrl
+ //      HandleCtrl(r, packet);
+       break;
+ 
+-    case 0x05:
++    case RTMP_PACKET_TYPE_SERVER_BW:
+       // server bw
+ //      HandleServerBW(r, packet);
+       break;
+ 
+-    case 0x06:
++    case RTMP_PACKET_TYPE_CLIENT_BW:
+       // client bw
+  //     HandleClientBW(r, packet);
+       break;
+ 
+-    case 0x08:
++    case RTMP_PACKET_TYPE_AUDIO:
+       // audio data
+       //RTMP_Log(RTMP_LOGDEBUG, "%s, received: audio %lu bytes", __FUNCTION__, packet.m_nBodySize);
+       break;
+ 
+-    case 0x09:
++    case RTMP_PACKET_TYPE_VIDEO:
+       // video data
+       //RTMP_Log(RTMP_LOGDEBUG, "%s, received: video %lu bytes", __FUNCTION__, packet.m_nBodySize);
+       break;
+ 
+-    case 0x0F:			// flex stream send
++    case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
++      // flex stream send
+       break;
+ 
+-    case 0x10:			// flex shared object
++    case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
++      // flex shared object
+       break;
+ 
+-    case 0x11:			// flex message
++    case RTMP_PACKET_TYPE_FLEX_MESSAGE:
++      // flex message
+       {
+ 	ret = ServeInvoke(server, which, packet, packet->m_body + 1);
+ 	break;
+       }
+-    case 0x12:
++    case RTMP_PACKET_TYPE_INFO:
+       // metadata (notify)
+       break;
+ 
+-    case 0x13:
++    case RTMP_PACKET_TYPE_SHARED_OBJECT:
+       /* shared object */
+       break;
+ 
+-    case 0x14:
++    case RTMP_PACKET_TYPE_INVOKE:
+       // invoke
+       ret = ServeInvoke(server, which, packet, packet->m_body);
+       break;
+ 
+-    case 0x16:
++    case RTMP_PACKET_TYPE_FLASH_VIDEO:
+       /* flv */
+ 	break;
++
+     default:
+       RTMP_Log(RTMP_LOGDEBUG, "%s, unknown packet type received: 0x%02x", __FUNCTION__,
+ 	  packet->m_packetType);
+@@ -547,21 +551,21 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+       unsigned int nPacketLen = packet->m_nBodySize;
+ 
+       // skip video info/command packets
+-      if (packet->m_packetType == 0x09 &&
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO &&
+ 	  nPacketLen == 2 && ((*packetBody & 0xf0) == 0x50))
+ 	{
+ 	  ret = 0;
+ 	  break;
+ 	}
+ 
+-      if (packet->m_packetType == 0x09 && nPacketLen <= 5)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO && nPacketLen <= 5)
+ 	{
+ 	  RTMP_Log(RTMP_LOGWARNING, "ignoring too small video packet: size: %d",
+ 	      nPacketLen);
+ 	  ret = 0;
+ 	  break;
+ 	}
+-      if (packet->m_packetType == 0x08 && nPacketLen <= 1)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO && nPacketLen <= 1)
+ 	{
+ 	  RTMP_Log(RTMP_LOGWARNING, "ignoring too small audio packet: size: %d",
+ 	      nPacketLen);
+@@ -571,19 +575,22 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ #ifdef _DEBUG
+       RTMP_Log(RTMP_LOGDEBUG, "type: %02X, size: %d, TS: %d ms", packet->m_packetType,
+ 	  nPacketLen, packet->m_nTimeStamp);
+-      if (packet->m_packetType == 0x09)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_VIDEO)
+ 	RTMP_Log(RTMP_LOGDEBUG, "frametype: %02X", (*packetBody & 0xf0));
+ #endif
+ 
+       // calculate packet size and reallocate buffer if necessary
+       unsigned int size = nPacketLen
+ 	+
+-	((packet->m_packetType == 0x08 || packet->m_packetType == 0x09
+-	  || packet->m_packetType == 0x12) ? 11 : 0) + (packet->m_packetType !=
+-						       0x16 ? 4 : 0);
++	((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet->m_packetType == RTMP_PACKET_TYPE_INFO) ? 11 : 0)
++        + (packet->m_packetType != 0x16 ? 4 : 0);
+ 
+       if (size + 4 > len)
+-	{			// the extra 4 is for the case of an FLV stream without a last prevTagSize (we need extra 4 bytes to append it)
++	{
++          /* The extra 4 is for the case of an FLV stream without a last
++           * prevTagSize (we need extra 4 bytes to append it).  */
+ 	  *buf = (char *) realloc(*buf, size + 4);
+ 	  if (*buf == 0)
+ 	    {
+@@ -594,13 +601,15 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	}
+       char *ptr = *buf, *pend = ptr + size+4;
+ 
+-      // audio (0x08), video (0x09) or metadata (0x12) packets :
+-      // construct 11 byte header then add rtmp packet's data
+-      if (packet->m_packetType == 0x08 || packet->m_packetType == 0x09
+-	  || packet->m_packetType == 0x12)
++      /* audio (RTMP_PACKET_TYPE_AUDIO), video (RTMP_PACKET_TYPE_VIDEO)
++       * or metadata (RTMP_PACKET_TYPE_INFO) packets: construct 11 byte
++       * header then add rtmp packet's data.  */
++      if (packet->m_packetType == RTMP_PACKET_TYPE_AUDIO
++          || packet->m_packetType == RTMP_PACKET_TYPE_VIDEO
++	  || packet->m_packetType == RTMP_PACKET_TYPE_INFO)
+ 	{
+ 	  // set data type
+-	  //*dataType |= (((packet->m_packetType == 0x08)<<2)|(packet->m_packetType == 0x09));
++	  //*dataType |= (((packet->m_packetType == RTMP_PACKET_TYPE_AUDIO)<<2)|(packet->m_packetType == RTMP_PACKET_TYPE_VIDEO));
+ 
+ 	  (*nTimeStamp) = packet->m_nTimeStamp;
+ 	  prevTagSize = 11 + nPacketLen;
+@@ -619,7 +628,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+       unsigned int len = nPacketLen;
+ 
+       // correct tagSize and obtain timestamp if we have an FLV stream
+-      if (packet->m_packetType == 0x16)
++      if (packet->m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{
+ 	  unsigned int pos = 0;
+ 
+@@ -629,8 +638,11 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	      *nTimeStamp = AMF_DecodeInt24(packetBody + pos + 4);
+ 	      *nTimeStamp |= (packetBody[pos + 7] << 24);
+ 
+-	      // set data type
+-	      //*dataType |= (((*(packetBody+pos) == 0x08)<<2)|(*(packetBody+pos) == 0x09));
++#if 0
++	      /* set data type */
++	      *dataType |= (((*(packetBody+pos) == RTMP_PACKET_TYPE_AUDIO) << 2)
++                            | (*(packetBody+pos) == RTMP_PACKET_TYPE_VIDEO));
++#endif
+ 
+ 	      if (pos + 11 + dataSize + 4 > nPacketLen)
+ 		{
+@@ -680,7 +692,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 	}
+       ptr += len;
+ 
+-      if (packet->m_packetType != 0x16)
++      if (packet->m_packetType != RTMP_PACKET_TYPE_FLASH_VIDEO)
+ 	{			// FLV tag packets contain their own prevTagSize
+ 	  AMF_EncodeInt32(ptr, pend, prevTagSize);
+ 	  //ptr += 4;
+@@ -828,7 +840,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+             if (RTMPPacket_IsReady(&ps))
+               {
+                 /* change chunk size */
+-                if (ps.m_packetType == 0x01)
++                if (ps.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
+                   {
+                     if (ps.m_nBodySize >= 4)
+                       {
+@@ -839,7 +851,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       }
+                   }
+                 /* bytes received */
+-                else if (ps.m_packetType == 0x03)
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_BYTES_READ_REPORT)
+                   {
+                     if (ps.m_nBodySize >= 4)
+                       {
+@@ -849,7 +861,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       }
+                   }
+                 /* ctrl */
+-                else if (ps.m_packetType == 0x04)
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_CONTROL)
+                   {
+                     short nType = AMF_DecodeInt16(ps.m_body);
+                     /* UpdateBufferMS */
+@@ -875,13 +887,16 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                           }
+                       }
+                   }
+-                else if (ps.m_packetType == 0x11 || ps.m_packetType == 0x14)
+-                  if (ServePacket(server, 0, &ps) && server->f_cur)
+-                    {
+-                      fclose(server->f_cur->f_file);
+-                      server->f_cur->f_file = NULL;
+-                      server->f_cur = NULL;
+-                    }
++                else if (ps.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE
++                         || ps.m_packetType == RTMP_PACKET_TYPE_INVOKE)
++                  {
++                    if (ServePacket(server, 0, &ps) && server->f_cur)
++                      {
++                        fclose(server->f_cur->f_file);
++                        server->f_cur->f_file = NULL;
++                        server->f_cur = NULL;
++                      }
++                  }
+                 RTMP_SendPacket(&server->rc, &ps, FALSE);
+                 RTMPPacket_Free(&ps);
+                 break;
+@@ -902,7 +917,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                       server->rc.m_pausing = 0;
+                     }
+                   /* change chunk size */
+-                  if (pc.m_packetType == 0x01)
++                  if (pc.m_packetType == RTMP_PACKET_TYPE_CHUNK_SIZE)
+                     {
+                       if (pc.m_nBodySize >= 4)
+                         {
+@@ -912,7 +927,7 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+                           server->rs.m_outChunkSize = server->rc.m_inChunkSize;
+                         }
+                     }
+-                  else if (pc.m_packetType == 0x04)
++                  else if (pc.m_packetType == RTMP_PACKET_TYPE_CONTROL)
+                     {
+                       short nType = AMF_DecodeInt16(pc.m_body);
+                       /* SWFverification */
+@@ -929,17 +944,18 @@ TFTYPE doServe(void *arg)	// server socket and state (our listening socket)
+ #endif
+                     }
+                   else if (server->f_cur && (
+-                       pc.m_packetType == 0x08 ||
+-                       pc.m_packetType == 0x09 ||
+-                       pc.m_packetType == 0x12 ||
+-                       pc.m_packetType == 0x16) &&
++                       pc.m_packetType == RTMP_PACKET_TYPE_AUDIO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_VIDEO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_INFO ||
++                       pc.m_packetType == RTMP_PACKET_TYPE_FLASH_VIDEO) &&
+                        RTMP_ClientPacket(&server->rc, &pc))
+                     {
+                       int len = WriteStream(&buf, &buflen, &server->stamp, &pc);
+                       if (len > 0 && fwrite(buf, 1, len, server->f_cur->f_file) != len)
+                         goto cleanup;
+                     }
+-                  else if ( pc.m_packetType == 0x11 || pc.m_packetType == 0x14)
++                  else if (pc.m_packetType == RTMP_PACKET_TYPE_FLEX_MESSAGE ||
++                           pc.m_packetType == RTMP_PACKET_TYPE_INVOKE)
+                     {
+                       if (ServePacket(server, 1, &pc) && server->f_cur)
+                         {
+-- 
+1.7.10.4
+
+
+From e09abc08504988e5c286ffc9c92da3ba76f95a20 Mon Sep 17 00:00:00 2001
+From: Compn <tempn@twmi.rr.com>
+Date: Tue, 5 Jul 2011 09:48:23 -0400
+Subject: [PATCH 28/34] add -shared to mingw ldflags, fixes compilation error
+ patch by Martin Storsjo
+
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 1ea31a0..785e869 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -54,7 +54,7 @@ SODIR=$(SODIR_$(SYS))
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+-SO_LDFLAGS_mingw=
++SO_LDFLAGS_mingw=-shared
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
+ SHARED=yes
+-- 
+1.7.10.4
+
+
+From 0e9b4917c1163227c48cd83e081aa972ed7d3111 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 14:41:11 -0700
+Subject: [PATCH 29/34] Revert "Drop back on the handshake version, avoid
+ rtmpe 9"
+
+This reverts commit aa2825fbb1d1f70652d558a730baed28149ebbdd.
+
+Conflicts:
+
+	librtmp/handshake.h
+---
+ librtmp/handshake.h |    6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index b172dbf..958579a 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -400,10 +400,8 @@ HandShake(RTMP * r, int FP9HandShake)
+       /* set version to at least 9.0.115.0 */
+       if (encrypted)
+ 	{
+-/* 	  clientsig[4] = 128;
+-	  clientsig[6] = 3; */
+-	  clientsig[4] = 9;
+-	  clientsig[6] = 0x7c;
++	  clientsig[4] = 128;
++	  clientsig[6] = 3;
+ 	}
+       else
+         {
+-- 
+1.7.10.4
+
+
+From d1f14b147e03aa17c968b96d6573320410a5252c Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 16:12:39 -0700
+Subject: [PATCH 30/34] Add RTMPE type 9 handshake signature
+
+---
+ librtmp/handshake.h |  349 +++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 336 insertions(+), 13 deletions(-)
+
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 958579a..98bf3c8 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -358,6 +358,337 @@ static void rtmpe8_sig(uint8_t *in, uint8_t *out, int keyid)
+   out[7] = v1;
+ }
+ 
++/* RTMPE type 9 uses Blowfish on the regular signature
++ * http://en.wikipedia.org/wiki/Blowfish_(cipher)
++ */
++#define	BF_ROUNDS	16
++typedef struct bf_key {
++	uint32_t s[4][256];
++	uint32_t p[BF_ROUNDS+2];
++} bf_key;
++
++static const uint32_t bf_sinit[][256] = {
++
++  /* S-Box 0 */
++  { 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
++    0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
++    0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
++    0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
++    0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
++    0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
++    0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
++    0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
++    0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
++    0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
++    0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
++    0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
++    0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
++    0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
++    0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
++    0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
++    0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
++    0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
++    0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
++    0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
++    0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
++    0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
++    0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
++    0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
++    0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
++    0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
++    0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
++    0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
++    0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
++    0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
++    0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
++    0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
++    0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
++    0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
++    0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
++    0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
++    0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
++    0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
++    0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
++    0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
++    0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
++    0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
++    0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a, },
++
++  /* S-Box 1 */
++  { 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
++    0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
++    0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
++    0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
++    0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
++    0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
++    0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
++    0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
++    0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
++    0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
++    0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
++    0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
++    0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
++    0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
++    0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
++    0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
++    0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
++    0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
++    0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
++    0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
++    0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
++    0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
++    0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
++    0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
++    0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
++    0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
++    0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
++    0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
++    0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
++    0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
++    0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
++    0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
++    0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
++    0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
++    0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
++    0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
++    0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
++    0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
++    0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
++    0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
++    0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
++    0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
++    0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7, },
++
++  /* S-Box 2 */
++  { 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
++    0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
++    0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
++    0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
++    0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
++    0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
++    0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
++    0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
++    0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
++    0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
++    0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
++    0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
++    0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
++    0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
++    0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
++    0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
++    0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
++    0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
++    0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
++    0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
++    0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
++    0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
++    0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
++    0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
++    0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
++    0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
++    0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
++    0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
++    0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
++    0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
++    0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
++    0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
++    0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
++    0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
++    0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
++    0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
++    0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
++    0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
++    0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
++    0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
++    0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
++    0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
++    0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0, },
++
++  /* S-Box 3 */
++  { 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
++    0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
++    0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
++    0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
++    0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
++    0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
++    0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
++    0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
++    0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
++    0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
++    0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
++    0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
++    0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
++    0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
++    0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
++    0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
++    0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
++    0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
++    0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
++    0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
++    0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
++    0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
++    0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
++    0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
++    0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
++    0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
++    0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
++    0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
++    0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
++    0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
++    0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
++    0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
++    0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
++    0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
++    0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
++    0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
++    0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
++    0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
++    0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
++    0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
++    0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
++    0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
++    0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6, },
++};
++
++static const uint32_t bf_pinit[] = {
++  /* P-Box */
++  0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
++  0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
++  0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
++};
++
++#define KEYBYTES	24
++
++static const unsigned char rtmpe9_keys[16][KEYBYTES] = {
++ { 0x79, 0x34, 0x77, 0x4c, 0x67, 0xd1, 0x38, 0x3a, 0xdf, 0xb3, 0x56, 0xbe,
++   0x8b, 0x7b, 0xd0, 0x24, 0x38, 0xe0, 0x73, 0x58, 0x41, 0x5d, 0x69, 0x67, },
++ { 0x46, 0xf6, 0xb4, 0xcc, 0x01, 0x93, 0xe3, 0xa1, 0x9e, 0x7d, 0x3c, 0x65,
++   0x55, 0x86, 0xfd, 0x09, 0x8f, 0xf7, 0xb3, 0xc4, 0x6f, 0x41, 0xca, 0x5c, },
++ { 0x1a, 0xe7, 0xe2, 0xf3, 0xf9, 0x14, 0x79, 0x94, 0xc0, 0xd3, 0x97, 0x43,
++   0x08, 0x7b, 0xb3, 0x84, 0x43, 0x2f, 0x9d, 0x84, 0x3f, 0x21, 0x01, 0x9b, },
++ { 0xd3, 0xe3, 0x54, 0xb0, 0xf7, 0x1d, 0xf6, 0x2b, 0x5a, 0x43, 0x4d, 0x04,
++   0x83, 0x64, 0x3e, 0x0d, 0x59, 0x2f, 0x61, 0xcb, 0xb1, 0x6a, 0x59, 0x0d, },
++ { 0xc8, 0xc1, 0xe9, 0xb8, 0x16, 0x56, 0x99, 0x21, 0x7b, 0x5b, 0x36, 0xb7,
++   0xb5, 0x9b, 0xdf, 0x06, 0x49, 0x2c, 0x97, 0xf5, 0x95, 0x48, 0x85, 0x7e, },
++ { 0xeb, 0xe5, 0xe6, 0x2e, 0xa4, 0xba, 0xd4, 0x2c, 0xf2, 0x16, 0xe0, 0x8f,
++   0x66, 0x23, 0xa9, 0x43, 0x41, 0xce, 0x38, 0x14, 0x84, 0x95, 0x00, 0x53, },
++ { 0x66, 0xdb, 0x90, 0xf0, 0x3b, 0x4f, 0xf5, 0x6f, 0xe4, 0x9c, 0x20, 0x89,
++   0x35, 0x5e, 0xd2, 0xb2, 0xc3, 0x9e, 0x9f, 0x7f, 0x63, 0xb2, 0x28, 0x81, },
++ { 0xbb, 0x20, 0xac, 0xed, 0x2a, 0x04, 0x6a, 0x19, 0x94, 0x98, 0x9b, 0xc8,
++   0xff, 0xcd, 0x93, 0xef, 0xc6, 0x0d, 0x56, 0xa7, 0xeb, 0x13, 0xd9, 0x30, },
++ { 0xbc, 0xf2, 0x43, 0x82, 0x09, 0x40, 0x8a, 0x87, 0x25, 0x43, 0x6d, 0xe6,
++   0xbb, 0xa4, 0xb9, 0x44, 0x58, 0x3f, 0x21, 0x7c, 0x99, 0xbb, 0x3f, 0x24, },
++ { 0xec, 0x1a, 0xaa, 0xcd, 0xce, 0xbd, 0x53, 0x11, 0xd2, 0xfb, 0x83, 0xb6,
++   0xc3, 0xba, 0xab, 0x4f, 0x62, 0x79, 0xe8, 0x65, 0xa9, 0x92, 0x28, 0x76, },
++ { 0xc6, 0x0c, 0x30, 0x03, 0x91, 0x18, 0x2d, 0x7b, 0x79, 0xda, 0xe1, 0xd5,
++   0x64, 0x77, 0x9a, 0x12, 0xc5, 0xb1, 0xd7, 0x91, 0x4f, 0x96, 0x4c, 0xa3, },
++ { 0xd7, 0x7c, 0x2a, 0xbf, 0xa6, 0xe7, 0x85, 0x7c, 0x45, 0xad, 0xff, 0x12,
++   0x94, 0xd8, 0xde, 0xa4, 0x5c, 0x3d, 0x79, 0xa4, 0x44, 0x02, 0x5d, 0x22, },
++ { 0x16, 0x19, 0x0d, 0x81, 0x6a, 0x4c, 0xc7, 0xf8, 0xb8, 0xf9, 0x4e, 0xcd,
++   0x2c, 0x9e, 0x90, 0x84, 0xb2, 0x08, 0x25, 0x60, 0xe1, 0x1e, 0xae, 0x18, },
++ { 0xe9, 0x7c, 0x58, 0x26, 0x1b, 0x51, 0x9e, 0x49, 0x82, 0x60, 0x61, 0xfc,
++   0xa0, 0xa0, 0x1b, 0xcd, 0xf5, 0x05, 0xd6, 0xa6, 0x6d, 0x07, 0x88, 0xa3, },
++ { 0x2b, 0x97, 0x11, 0x8b, 0xd9, 0x4e, 0xd9, 0xdf, 0x20, 0xe3, 0x9c, 0x10,
++   0xe6, 0xa1, 0x35, 0x21, 0x11, 0xf9, 0x13, 0x0d, 0x0b, 0x24, 0x65, 0xb2, },
++ { 0x53, 0x6a, 0x4c, 0x54, 0xac, 0x8b, 0x9b, 0xb8, 0x97, 0x29, 0xfc, 0x60,
++   0x2c, 0x5b, 0x3a, 0x85, 0x68, 0xb5, 0xaa, 0x6a, 0x44, 0xcd, 0x3f, 0xa7, },
++};
++
++#define	BF_ENC(X,S) \
++	(((S[0][X>>24] + S[1][X>>16 & 0xff]) ^ S[2][(X>>8) & 0xff]) + S[3][X & 0xff])
++
++static void bf_enc(uint32_t *x, bf_key *key)
++{
++  uint32_t  Xl;
++  uint32_t  Xr;
++  uint32_t  temp;
++  int	i;
++
++  Xl = x[0];
++  Xr = x[1];
++
++  for (i = 0; i < BF_ROUNDS; ++i) {
++    Xl ^= key->p[i];
++    Xr ^= BF_ENC(Xl,key->s);
++
++    temp = Xl;
++    Xl = Xr;
++    Xr = temp;
++  }
++
++  Xl ^= key->p[BF_ROUNDS];
++  Xr ^= key->p[BF_ROUNDS + 1];
++
++  x[0] = Xr;
++  x[1] = Xl;
++}
++
++static void bf_setkey(const unsigned char *kp, int keybytes, bf_key *key)
++{
++  int          i;
++  int          j;
++  int          k;
++  uint32_t  data;
++  uint32_t  d[2];
++
++  memcpy(key->p, bf_pinit, sizeof(key->p));
++  memcpy(key->s, bf_sinit, sizeof(key->s));
++
++  j = 0;
++  for (i = 0; i < BF_ROUNDS + 2; ++i) {
++    data = 0x00000000;
++	for (k = 0; k < 4; ++k) {
++	  data = (data << 8) | kp[j];
++	  j = j + 1;
++	  if (j >= keybytes) {
++	    j = 0;
++	  }
++	}
++	key->p[i] ^= data;
++  }
++
++  d[0] = 0x00000000;
++  d[1] = 0x00000000;
++
++  for (i = 0; i < BF_ROUNDS + 2; i += 2) {
++    bf_enc(d, key);
++
++	key->p[i] = d[0];
++	key->p[i + 1] = d[1];
++  }
++
++  for (i = 0; i < 4; ++i) {
++	for (j = 0; j < 256; j += 2) {
++
++	  bf_enc(d, key);
++
++	  key->s[i][j] = d[0];
++	  key->s[i][j + 1] = d[1];
++	}
++  }
++}
++
++static void rtmpe9_sig(uint8_t *in, uint8_t *out, int keyid)
++{
++  uint32_t d[2];
++  bf_key key;
++
++  bf_setkey(rtmpe9_keys[keyid], KEYBYTES, &key);
++
++  /* input is little-endian */
++  d[0] = in[0] | (in[1] << 8) | (in[2] << 16) | (in[3] << 24);
++  d[1] = in[4] | (in[5] << 8) | (in[6] << 16) | (in[7] << 24);
++  bf_enc(d, &key);
++  out[0] = d[0] & 0xff;
++  out[1] = (d[0] >> 8) & 0xff;
++  out[2] = (d[0] >> 16) & 0xff;
++  out[3] = (d[0] >> 24) & 0xff;
++  out[4] = d[1] & 0xff;
++  out[5] = (d[1] >> 8) & 0xff;
++  out[6] = (d[1] >> 16) & 0xff;
++  out[7] = (d[1] >> 24) & 0xff;
++}
++
+ static int
+ HandShake(RTMP * r, int FP9HandShake)
+ {
+@@ -605,8 +936,7 @@ HandShake(RTMP * r, int FP9HandShake)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+ 	  uint8_t *dptr = digestResp;
+ 	  uint8_t *sig = signatureResp;
+@@ -615,7 +945,6 @@ HandShake(RTMP * r, int FP9HandShake)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Client signature calculated:", __FUNCTION__);
+       RTMP_LogHex(RTMP_LOGDEBUG, signatureResp, SHA256_DIGEST_LENGTH);
+     }
+@@ -680,7 +1009,6 @@ HandShake(RTMP * r, int FP9HandShake)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+       else if (type == 9)
+         {
+ 	  uint8_t *dptr = digest;
+@@ -690,7 +1018,6 @@ HandShake(RTMP * r, int FP9HandShake)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Signature calculated:", __FUNCTION__);
+       RTMP_LogHex(RTMP_LOGDEBUG, signature, SHA256_DIGEST_LENGTH);
+       if (memcmp
+@@ -964,8 +1291,7 @@ SHandShake(RTMP * r)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+ 	  uint8_t *dptr = digestResp;
+ 	  uint8_t *sig = signatureResp;
+@@ -974,7 +1300,6 @@ SHandShake(RTMP * r)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+ 
+       /* some info output */
+       RTMP_Log(RTMP_LOGDEBUG,
+@@ -1030,17 +1355,15 @@ SHandShake(RTMP * r)
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+ 	    rtmpe8_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+-#if 0
+-      else if (type == 9))
++      else if (type == 9)
+         {
+-	  uint8_t *dptr = digestResp;
+-	  uint8_t *sig = signatureResp;
++	  uint8_t *dptr = digest;
++	  uint8_t *sig = signature;
+ 	  /* encrypt signatureResp */
+           for (i=0; i<SHA256_DIGEST_LENGTH; i+=8)
+             rtmpe9_sig(sig+i, sig+i, dptr[i] % 15);
+         }
+ #endif
+-#endif
+ 
+       /* show some information */
+       RTMP_Log(RTMP_LOGDEBUG, "%s: Digest key: ", __FUNCTION__);
+-- 
+1.7.10.4
+
+
+From be0590a86af80df528e3556b86f110ad4b5cbb27 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 16:41:28 -0700
+Subject: [PATCH 31/34] Add LIB_RTMP macro
+
+Allows changing to static linking on the cmd line
+---
+ Makefile |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index c322e9a..1597be8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -35,7 +35,8 @@ MANDIR=$(DESTDIR)$(mandir)
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIBS=-Llibrtmp -lrtmp $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
++LIB_RTMP=-Llibrtmp -lrtmp
++LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
+ 
+ THREADLIB_posix=-lpthread
+ THREADLIB_darwin=-lpthread
+-- 
+1.7.10.4
+
+
+From 4028a5aa7f72cac44a62b4aac596ff3c82e6e019 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:19:25 -0700
+Subject: [PATCH 32/34] Additional credit for RTMPE 9 keys
+
+---
+ README |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/README b/README
+index 5689853..865c6c4 100644
+--- a/README
++++ b/README
+@@ -1,7 +1,8 @@
+-RTMP Dump v2.3
++RTMP Dump v2.4
+ (C) 2009 Andrej Stepanchuk
+-(C) 2009-2010 Howard Chu
++(C) 2009-2011 Howard Chu
+ (C) 2010 2a665470ced7adb7156fcef47f8199a6371c117b8a79e399a2771e0b36384090
++(C) 2011 33ae1ce77301f4b4494faaa5f609f3c48b9dcf82
+ License: GPLv2
+ librtmp license: LGPLv2.1
+ http://rtmpdump.mplayerhq.hu/
+-- 
+1.7.10.4
+
+
+From 3121324046e4ca1934e7e28293fc8326475d5053 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:22:43 -0700
+Subject: [PATCH 33/34] Version bump
+
+---
+ Makefile         |    2 +-
+ librtmp/Makefile |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 1597be8..6ef5742 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,4 +1,4 @@
+-VERSION=v2.3
++VERSION=v2.4
+ 
+ prefix=/usr/local
+ 
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 785e869..d61e7a4 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -1,4 +1,4 @@
+-VERSION=v2.3
++VERSION=v2.4
+ 
+ prefix=/usr/local
+ 
+-- 
+1.7.10.4
+
+
+From c28f1bab7822de97353849e7787b59e50bbb1428 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@symas.com>
+Date: Mon, 11 Jul 2011 17:24:33 -0700
+Subject: [PATCH 34/34] v2.4 changes
+
+---
+ ChangeLog |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index f57c580..fb2319f 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,9 +1,12 @@
+ RTMPDump
+ Copyright 2008-2009 Andrej Stepanchuk; Distributed under the GPL v2
+-Copyright 2009-2010 Howard Chu
++Copyright 2009-2011 Howard Chu
+ Copyright 2009 The Flvstreamer Team
+ http://rtmpdump.mplayerhq.hu/
+ 
++11 July 2011, v2.4
++- add RTMPE type 9 handshake support
++
+ 30 June 2010, v2.3
+ - fix RC4 cleanup for GnuTLS/gcrypt
+ - declare RTMP_Write buf as const
+-- 
+1.7.10.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp-2-master.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,2356 @@
+From dc762e41a090b5c238bd7daedab13def69eb140b Mon Sep 17 00:00:00 2001
+From: toine512 <toine512@gmail.com>
+Date: Thu, 21 Jul 2011 17:10:13 -0700
+Subject: [PATCH 01/33] Squashed commit of the following:
+
+commit 84b160fdc8e6aaff9b5b214d90e8f002cc4185dd
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 23:09:26 2011 +0200
+
+    Updates man .. again
+
+commit 717c562b844595f5b24da268a5f5203d921ebc89
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 21:00:44 2011 +0200
+
+    More updates in man files, regenerating HTML files needed
+
+commit 8196cf03b2ff7b9483166302bf79a0760fed2772
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:42:41 2011 +0200
+
+    Updates ChangeLog
+
+commit 7a6931cffd0ffd2d0997ffed2bd7609e9a043387
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:37:40 2011 +0200
+
+    Updates man files, regenerating HTML files is needed
+
+commit 1cb67af20bb4085b87123299956c6b4d2d2b1484
+Author: toine512 <toine512@gmail.com>
+Date:   Wed Jul 20 20:03:16 2011 +0200
+
+    Implements Justin.tv support (NetStream.Authenticate.UsherToken)
+---
+ ChangeLog         |    3 +++
+ librtmp/librtmp.3 |    7 +++++--
+ librtmp/rtmp.c    |   44 ++++++++++++++++++++++++++++++++++++++++++++
+ librtmp/rtmp.h    |    2 ++
+ rtmpdump.1        |    9 +++++++--
+ rtmpdump.c        |   11 +++++++++--
+ rtmpgw.8          |    9 +++++++--
+ rtmpgw.c          |   11 +++++++++--
+ rtmpsrv.c         |    1 +
+ 9 files changed, 87 insertions(+), 10 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index fb2319f..c3b1a14 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -4,6 +4,9 @@ Copyright 2009-2011 Howard Chu
+ Copyright 2009 The Flvstreamer Team
+ http://rtmpdump.mplayerhq.hu/
+ 
++20 July 2011
++- add NetStream.Authenticate.UsherToken for Justin.tv
++
+ 11 July 2011, v2.4
+ - add RTMPE type 9 handshake support
+ 
+diff --git a/librtmp/librtmp.3 b/librtmp/librtmp.3
+index 66197d5..7c424aa 100644
+--- a/librtmp/librtmp.3
++++ b/librtmp/librtmp.3
+@@ -1,5 +1,5 @@
+-.TH LIBRTMP 3 "2010-07-03" "RTMPDump v2.3"
+-.\" Copyright 2010 Howard Chu.
++.TH LIBRTMP 3 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ librtmp \- RTMPDump Real-Time Messaging Protocol API
+@@ -161,6 +161,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++.BI jtv= JSON
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ .BI swfVfy= 0|1
+ If the value is 1 or TRUE, the SWF player is retrieved from the
+ specified
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5ef3ae9..adcff1f 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -96,6 +96,7 @@ static int SendDeleteStream(RTMP *r, double dStreamId);
+ static int SendFCSubscribe(RTMP *r, AVal *subscribepath);
+ static int SendPlay(RTMP *r);
+ static int SendBytesReceived(RTMP *r);
++static int SendUsherToken(RTMP *r, AVal *usherToken);
+ 
+ #if 0				/* unused */
+ static int SendBGHasStream(RTMP *r, double dId, AVal *playpath);
+@@ -335,6 +336,7 @@ RTMP_SetupStream(RTMP *r,
+ 		 uint32_t swfSize,
+ 		 AVal *flashVer,
+ 		 AVal *subscribepath,
++		 AVal *usherToken,
+ 		 int dStart,
+ 		 int dStop, int bLiveStream, long int timeout)
+ {
+@@ -355,6 +357,8 @@ RTMP_SetupStream(RTMP *r,
+     RTMP_Log(RTMP_LOGDEBUG, "auth     : %s", auth->av_val);
+   if (subscribepath && subscribepath->av_val)
+     RTMP_Log(RTMP_LOGDEBUG, "subscribepath : %s", subscribepath->av_val);
++  if (usherToken && usherToken->av_val)
++    RTMP_Log(RTMP_LOGDEBUG, "NetStream.Authenticate.UsherToken : %s", usherToken->av_val);
+   if (flashVer && flashVer->av_val)
+     RTMP_Log(RTMP_LOGDEBUG, "flashVer : %s", flashVer->av_val);
+   if (dStart > 0)
+@@ -420,6 +424,8 @@ RTMP_SetupStream(RTMP *r,
+     r->Link.flashVer = RTMP_DefaultFlashVer;
+   if (subscribepath && subscribepath->av_len)
+     r->Link.subscribepath = *subscribepath;
++  if (usherToken && usherToken->av_len)
++    r->Link.usherToken = *usherToken;
+   r->Link.seekTime = dStart;
+   r->Link.stopTime = dStop;
+   if (bLiveStream)
+@@ -477,6 +483,8 @@ static struct urlopt {
+   	"Stream is live, no seeking possible" },
+   { AVC("subscribe"), OFF(Link.subscribepath), OPT_STR, 0,
+   	"Stream to subscribe to" },
++  { AVC("jtv"), OFF(Link.usherToken),          OPT_STR, 0,
++  	"Justin.tv authentication token" },
+   { AVC("token"),     OFF(Link.token),	       OPT_STR, 0,
+   	"Key for SecureToken response" },
+   { AVC("swfVfy"),    OFF(Link.lFlags),        OPT_BOOL, RTMP_LF_SWFV,
+@@ -1641,6 +1649,39 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   return RTMP_SendPacket(r, &packet, TRUE);
+ }
+ 
++//Justin.tv specific authentication
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken"); //SAVC() isn't suitable for that
++
++static int
++SendUsherToken(RTMP *r, AVal *usherToken)
++{
++  RTMPPacket packet;
++  char pbuf[1024], *pend = pbuf + sizeof(pbuf);
++  char *enc;
++  packet.m_nChannel = 0x03;	/* control channel (invoke) */
++  packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
++  packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
++  packet.m_nTimeStamp = 0;
++  packet.m_nInfoField2 = 0;
++  packet.m_hasAbsTimestamp = 0;
++  packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
++
++  RTMP_Log(RTMP_LOGDEBUG, "UsherToken: %s", usherToken->av_val);
++  enc = packet.m_body;
++  enc = AMF_EncodeString(enc, pend, &av_NetStream_Authenticate_UsherToken);
++  enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
++  *enc++ = AMF_NULL;
++  enc = AMF_EncodeString(enc, pend, usherToken);
++
++  if (!enc)
++    return FALSE;
++
++  packet.m_nBodySize = enc - packet.m_body;
++
++  return RTMP_SendPacket(r, &packet, FALSE);
++}
++/******************************************/
++
+ SAVC(releaseStream);
+ 
+ static int
+@@ -2364,6 +2405,9 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 
+ 	  if (!(r->Link.protocol & RTMP_FEATURE_WRITE))
+ 	    {
++	      /* Authenticate on Justin.tv legacy servers before sending FCSubscribe */
++	      if (r->Link.usherToken.av_len)
++	        SendUsherToken(r, &r->Link.usherToken);
+ 	      /* Send the FCSubscribe if live stream or if subscribepath is set */
+ 	      if (r->Link.subscribepath.av_len)
+ 	        SendFCSubscribe(r, &r->Link.subscribepath);
+diff --git a/librtmp/rtmp.h b/librtmp/rtmp.h
+index 1ece207..6b2ae5b 100644
+--- a/librtmp/rtmp.h
++++ b/librtmp/rtmp.h
+@@ -155,6 +155,7 @@ extern "C"
+     AVal auth;
+     AVal flashVer;
+     AVal subscribepath;
++    AVal usherToken;
+     AVal token;
+     AMFObject extras;
+     int edepth;
+@@ -297,6 +298,7 @@ extern "C"
+ 			uint32_t swfSize,
+ 			AVal *flashVer,
+ 			AVal *subscribepath,
++			AVal *usherToken,
+ 			int dStart,
+ 			int dStop, int bLiveStream, long int timeout);
+ 
+diff --git a/rtmpdump.1 b/rtmpdump.1
+index 2395de9..0d9de8d 100644
+--- a/rtmpdump.1
++++ b/rtmpdump.1
+@@ -1,5 +1,5 @@
+-.TH RTMPDUMP 1 "2010-05-02" "RTMPDump v2.2e"
+-.\" Copyright 2010 Howard Chu.
++.TH RTMPDUMP 1 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ rtmpdump \- RTMP streaming media client
+@@ -51,6 +51,8 @@ rtmpdump \- RTMP streaming media client
+ [\c
+ .BI \-T \ key\fR]
+ [\c
++.BI \-j \ JSON\fR]
++[\c
+ .BI \-w \ swfHash\fR]
+ [\c
+ .BI \-x \ swfSize\fR]
+@@ -210,6 +212,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++\fB\-\-jtv		\-j\fP\ \fIJSON\fP
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ \fB\-\-swfhash		\-w\fP\ \fIhexstring\fP
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+ the server uses SWF Verification, but see the
+diff --git a/rtmpdump.c b/rtmpdump.c
+index c1cd95b..ec1de85 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -692,6 +692,8 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
+ 	  RTMP_LogPrintf
++	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
++	  RTMP_LogPrintf
+ 	    ("--hashes|-#             Display progress with hashes, not with the byte counter\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n",
+@@ -738,6 +740,7 @@ main(int argc, char **argv)
+   AVal hostname = { 0, 0 };
+   AVal playpath = { 0, 0 };
+   AVal subscribepath = { 0, 0 };
++  AVal usherToken = { 0, 0 }; //Justin.tv auth token
+   int port = -1;
+   int protocol = RTMP_PROTOCOL_UNDEFINED;
+   int retries = 0;
+@@ -839,12 +842,13 @@ main(int argc, char **argv)
+     {"debug", 0, NULL, 'z'},
+     {"quiet", 0, NULL, 'q'},
+     {"verbose", 0, NULL, 'V'},
++    {"jtv", 1, NULL, 'j'},
+     {0, 0, 0, 0}
+   };
+ 
+   while ((opt =
+ 	  getopt_long(argc, argv,
+-		      "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#",
++		      "hVveqzr:s:t:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:",
+ 		      longopts, NULL)) != -1)
+     {
+       switch (opt)
+@@ -1051,6 +1055,9 @@ main(int argc, char **argv)
+ 	case 'S':
+ 	  STR2AVAL(sockshost, optarg);
+ 	  break;
++    case 'j':
++      STR2AVAL(usherToken, optarg);
++      break;
+ 	default:
+ 	  RTMP_LogPrintf("unknown option: %c\n", opt);
+ 	  usage(argv[0]);
+@@ -1167,7 +1174,7 @@ main(int argc, char **argv)
+ 
+   RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
+ 		   &tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
+-		   &flashVer, &subscribepath, dSeek, dStopOffset, bLiveStream, timeout);
++		   &flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
+ 
+   /* Try to keep the stream moving if it pauses on us */
+   if (!bLiveStream && !(protocol & RTMP_FEATURE_HTTP))
+diff --git a/rtmpgw.8 b/rtmpgw.8
+index 197a2d6..0a231b4 100644
+--- a/rtmpgw.8
++++ b/rtmpgw.8
+@@ -1,5 +1,5 @@
+-.TH RTMPGW 8 "2010-05-02" "RTMPDump v2.2e"
+-.\" Copyright 2010 Howard Chu.
++.TH RTMPGW 8 "2011-07-20" "RTMPDump v2.4"
++.\" Copyright 2011 Howard Chu.
+ .\" Copying permitted according to the GNU General Public License V2.
+ .SH NAME
+ rtmpgw \- RTMP streaming media gateway
+@@ -50,6 +50,8 @@ rtmpgw \- RTMP streaming media gateway
+ [\c
+ .BI \-T \ key\fR]
+ [\c
++.BI \-j \ JSON\fR]
++[\c
+ .BI \-w \ swfHash\fR]
+ [\c
+ .BI \-x \ swfSize\fR]
+@@ -193,6 +195,9 @@ These options handle additional authentication requests from the server.
+ Key for SecureToken response, used if the server requires SecureToken
+ authentication.
+ .TP
++\fB\-\-jtv		\-j\fP\ \fIJSON\fP
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++.TP
+ \fB\-\-swfhash		\-w\fP\ \fIhexstring\fP
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+ the server uses SWF Verification, but see the
+diff --git a/rtmpgw.c b/rtmpgw.c
+index 10a99e8..ce7319a 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -95,6 +95,7 @@ typedef struct
+   AVal flashVer;
+   AVal token;
+   AVal subscribepath;
++  AVal usherToken; //Justin.tv auth token
+   AVal sockshost;
+   AMFObject extras;
+   int edepth;
+@@ -552,7 +553,7 @@ void processTCPrequest(STREAMING_SERVER * server,	// server socket and state (ou
+   RTMP_Init(&rtmp);
+   RTMP_SetBufferMS(&rtmp, req.bufferTime);
+   RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost,
+-		   &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, dSeek, req.dStopOffset,
++		   &req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset,
+ 		   req.bLiveStream, req.timeout);
+   /* backward compatibility, we always sent this as true before */
+   if (req.auth.av_len)
+@@ -953,6 +954,9 @@ ParseOption(char opt, char *arg, RTMP_REQUEST * req)
+     case 'z':
+       RTMP_debuglevel = RTMP_LOGALL;
+       break;
++    case 'j':
++      STR2AVAL(req->usherToken, arg);
++      break;
+     default:
+       RTMP_LogPrintf("unknown option: %c, arg: %s\n", opt, arg);
+       return FALSE;
+@@ -1023,6 +1027,7 @@ main(int argc, char **argv)
+     {"debug", 0, NULL, 'z'},
+     {"quiet", 0, NULL, 'q'},
+     {"verbose", 0, NULL, 'V'},
++    {"jtv", 1, NULL, 'j'},
+     {0, 0, 0, 0}
+   };
+ 
+@@ -1035,7 +1040,7 @@ main(int argc, char **argv)
+ 
+   while ((opt =
+ 	  getopt_long(argc, argv,
+-		      "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:", longopts,
++		      "hvqVzr:s:t:p:a:f:u:n:c:l:y:m:d:D:A:B:T:g:w:x:W:X:S:j:", longopts,
+ 		      NULL)) != -1)
+     {
+       switch (opt)
+@@ -1095,6 +1100,8 @@ main(int argc, char **argv)
+ 	    ("--stop|-B num           Stop at num seconds into stream\n");
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
++      RTMP_LogPrintf
++	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
+ 	     defaultRTMPRequest.bufferTime);
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f1b6c66..cf52bfa 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -116,6 +116,7 @@ typedef struct
+   AVal swfHash;
+   AVal flashVer;
+   AVal subscribepath;
++  AVal usherToken;
+   uint32_t swfSize;
+ 
+   uint32_t dStartOffset;
+-- 
+1.7.10.4
+
+
+From a2fb387404cb0da99cf439d58478fff701398700 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 21 Jul 2011 17:31:14 -0700
+Subject: [PATCH 02/33] Regenerate HTML docs, minor tweaks
+
+---
+ librtmp/librtmp.3.html |   10 ++++++++--
+ librtmp/rtmp.c         |    6 +++---
+ rtmpdump.1.html        |   11 +++++++++--
+ rtmpdump.c             |    6 +++---
+ rtmpgw.8.html          |   11 +++++++++--
+ rtmpgw.c               |    2 +-
+ rtmpsrv.c              |    1 -
+ 7 files changed, 33 insertions(+), 14 deletions(-)
+
+diff --git a/librtmp/librtmp.3.html b/librtmp/librtmp.3.html
+index e5e6f4b..6f59851 100644
+--- a/librtmp/librtmp.3.html
++++ b/librtmp/librtmp.3.html
+@@ -6,10 +6,10 @@
+ <tr><td>LIBRTMP(3)<td align="center"><td align="right">LIBRTMP(3)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.3<td align="center">2010-07-03<td align="right">LIBRTMP(3)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">LIBRTMP(3)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -238,6 +238,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>jtv=</b><i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>swfVfy=</b><i>0|1</i>
+ <dd>
+ If the value is 1 or TRUE, the SWF player is retrieved from the
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index adcff1f..8d76164 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -484,7 +484,7 @@ static struct urlopt {
+   { AVC("subscribe"), OFF(Link.subscribepath), OPT_STR, 0,
+   	"Stream to subscribe to" },
+   { AVC("jtv"), OFF(Link.usherToken),          OPT_STR, 0,
+-  	"Justin.tv authentication token" },
++	"Justin.tv authentication token" },
+   { AVC("token"),     OFF(Link.token),	       OPT_STR, 0,
+   	"Key for SecureToken response" },
+   { AVC("swfVfy"),    OFF(Link.lFlags),        OPT_BOOL, RTMP_LF_SWFV,
+@@ -1649,8 +1649,8 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
+   return RTMP_SendPacket(r, &packet, TRUE);
+ }
+ 
+-//Justin.tv specific authentication
+-static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken"); //SAVC() isn't suitable for that
++/* Justin.tv specific authentication */
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken");
+ 
+ static int
+ SendUsherToken(RTMP *r, AVal *usherToken)
+diff --git a/rtmpdump.1.html b/rtmpdump.1.html
+index 7f17636..826f722 100644
+--- a/rtmpdump.1.html
++++ b/rtmpdump.1.html
+@@ -6,10 +6,10 @@
+ <tr><td>RTMPDUMP(1)<td align="center"><td align="right">RTMPDUMP(1)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-02<td align="right">RTMPDUMP(1)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">RTMPDUMP(1)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -42,6 +42,7 @@ rtmpdump &minus; RTMP streaming media client
+ [<b>&minus;b</b><i>&nbsp;buffer</i>]
+ [<b>&minus;m</b><i>&nbsp;timeout</i>]
+ [<b>&minus;T</b><i>&nbsp;key</i>]
++[<b>&minus;j</b><i>&nbsp;JSON</i>]
+ [<b>&minus;w</b><i>&nbsp;swfHash</i>]
+ [<b>&minus;x</b><i>&nbsp;swfSize</i>]
+ [<b>&minus;W</b><i>&nbsp;swfUrl</i>]
+@@ -275,6 +276,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>&minus;&minus;jtv		&minus;j</b>&nbsp;<i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>&minus;&minus;swfhash		&minus;w</b>&nbsp;<i>hexstring</i>
+ <dd>
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+diff --git a/rtmpdump.c b/rtmpdump.c
+index ec1de85..89c053a 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1055,9 +1055,9 @@ main(int argc, char **argv)
+ 	case 'S':
+ 	  STR2AVAL(sockshost, optarg);
+ 	  break;
+-    case 'j':
+-      STR2AVAL(usherToken, optarg);
+-      break;
++	case 'j':
++	  STR2AVAL(usherToken, optarg);
++	  break;
+ 	default:
+ 	  RTMP_LogPrintf("unknown option: %c\n", opt);
+ 	  usage(argv[0]);
+diff --git a/rtmpgw.8.html b/rtmpgw.8.html
+index 58b8f35..68d6734 100644
+--- a/rtmpgw.8.html
++++ b/rtmpgw.8.html
+@@ -6,10 +6,10 @@
+ <tr><td>RTMPGW(8)<td align="center"><td align="right">RTMPGW(8)
+ </thead>
+ <tfoot>
+-<tr><td>RTMPDump v2.2e<td align="center">2010-05-02<td align="right">RTMPGW(8)
++<tr><td>RTMPDump v2.4<td align="center">2011-07-20<td align="right">RTMPGW(8)
+ </tfoot>
+ <tbody><tr><td colspan="3"><br><br><ul>
+-<!-- Copyright 2010 Howard Chu.
++<!-- Copyright 2011 Howard Chu.
+  Copying permitted according to the GNU General Public License V2.-->
+ </ul>
+ 
+@@ -41,6 +41,7 @@ rtmpgw &minus; RTMP streaming media gateway
+ [<b>&minus;b</b><i>&nbsp;buffer</i>]
+ [<b>&minus;m</b><i>&nbsp;timeout</i>]
+ [<b>&minus;T</b><i>&nbsp;key</i>]
++[<b>&minus;j</b><i>&nbsp;JSON</i>]
+ [<b>&minus;w</b><i>&nbsp;swfHash</i>]
+ [<b>&minus;x</b><i>&nbsp;swfSize</i>]
+ [<b>&minus;W</b><i>&nbsp;swfUrl</i>]
+@@ -249,6 +250,12 @@ authentication.
+ </dl>
+ <p>
+ <dl compact><dt>
++<b>&minus;&minus;jtv		&minus;j</b>&nbsp;<i>JSON</i>
++<dd>
++JSON token used by legacy Justin.tv servers. Invokes NetStream.Authenticate.UsherToken
++</dl>
++<p>
++<dl compact><dt>
+ <b>&minus;&minus;swfhash		&minus;w</b>&nbsp;<i>hexstring</i>
+ <dd>
+ SHA256 hash of the decompressed SWF file. This option may be needed if
+diff --git a/rtmpgw.c b/rtmpgw.c
+index ce7319a..733e105 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -1100,7 +1100,7 @@ main(int argc, char **argv)
+ 	    ("--stop|-B num           Stop at num seconds into stream\n");
+ 	  RTMP_LogPrintf
+ 	    ("--token|-T key          Key for SecureToken response\n");
+-      RTMP_LogPrintf
++	  RTMP_LogPrintf
+ 	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+ 	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index cf52bfa..f1b6c66 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -116,7 +116,6 @@ typedef struct
+   AVal swfHash;
+   AVal flashVer;
+   AVal subscribepath;
+-  AVal usherToken;
+   uint32_t swfSize;
+ 
+   uint32_t dStartOffset;
+-- 
+1.7.10.4
+
+
+From ed99ad05b34031fac74230760c77d4d1a6a9e706 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:29:58 +0300
+Subject: [PATCH 03/33] Remove the generated pkg-config file on make clean
+
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index d61e7a4..c95c8a6 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -76,7 +76,7 @@ OBJS=rtmp.o log.o amf.o hashswf.o parseurl.o
+ all:	librtmp.a $(SO_LIB)
+ 
+ clean:
+-	rm -f *.o *.a *.$(SOX) *.$(SO_EXT)
++	rm -f *.o *.a *.$(SOX) *.$(SO_EXT) librtmp.pc
+ 
+ librtmp.a: $(OBJS)
+ 	$(AR) rs $@ $?
+-- 
+1.7.10.4
+
+
+From 749018b7c7c4e0090ea17c104dc094ab74326c08 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:30:00 +0300
+Subject: [PATCH 04/33] Create the SODIR, too
+
+When SYS=mingw, this differs from LIBDIR.
+---
+ librtmp/Makefile |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index c95c8a6..aa4a339 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -100,7 +100,7 @@ librtmp.pc: librtmp.pc.in Makefile
+ install:	install_base $(SO_INST)
+ 
+ install_base:	librtmp.a librtmp.pc
+-	-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3
++	-mkdir -p $(INCDIR) $(LIBDIR)/pkgconfig $(MANDIR)/man3 $(SODIR)
+ 	cp amf.h http.h log.h rtmp.h $(INCDIR)
+ 	cp librtmp.a $(LIBDIR)
+ 	cp librtmp.pc $(LIBDIR)/pkgconfig
+-- 
+1.7.10.4
+
+
+From 9931c44867d157621ae10cf489ba336091dfab6b Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Sat, 30 Apr 2011 14:30:01 +0300
+Subject: [PATCH 05/33] Generate and install an import lib for the built DLL
+
+---
+ librtmp/Makefile |    8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index aa4a339..b88baf4 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -54,9 +54,14 @@ SODIR=$(SODIR_$(SYS))
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+ SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+ 	-headerpad_max_install_names
+-SO_LDFLAGS_mingw=-shared
++SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
++INSTALL_IMPLIB_posix=
++INSTALL_IMPLIB_darwin=
++INSTALL_IMPLIB_mingw=cp librtmp.dll.a $(LIBDIR)
++INSTALL_IMPLIB=$(INSTALL_IMPLIB_$(SYS))
++
+ SHARED=yes
+ SODEF_yes=-fPIC
+ SOLIB_yes=librtmp.$(SO_EXT)
+@@ -108,5 +113,6 @@ install_base:	librtmp.a librtmp.pc
+ 
+ install_so:	librtmp.$(SO_EXT)
+ 	cp librtmp.$(SO_EXT) $(SODIR)
++	$(INSTALL_IMPLIB)
+ 	cd $(SODIR); ln -sf librtmp.$(SO_EXT) librtmp.$(SOX)
+ 
+-- 
+1.7.10.4
+
+
+From 060206d121657d7e45c01ac022dd071c877b4caa Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Fri, 15 Jul 2011 13:46:02 +0300
+Subject: [PATCH 06/33] Check the return value from RTMP_SendBytesReceived()
+
+This avoids double frees in RTMP_Close(), if the
+RTMP_SendBytesReceived() call failed, which earlier led
+to RTMP_ReadPacket() writing back an already freed buffer
+(freed by RTMP_Close() within WriteN()) into m_vecChannelsIn.
+---
+ librtmp/rtmp.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 8d76164..f85cd83 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1338,7 +1338,8 @@ ReadN(RTMP *r, char *buffer, int n)
+ 	  r->m_nBytesIn += nRead;
+ 	  if (r->m_bSendCounter
+ 	      && r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
+-	    SendBytesReceived(r);
++	    if (!SendBytesReceived(r))
++	        return FALSE;
+ 	}
+       /*RTMP_Log(RTMP_LOGDEBUG, "%s: %d bytes\n", __FUNCTION__, nBytes); */
+ #ifdef _DEBUG
+-- 
+1.7.10.4
+
+
+From 159a06ebe6d82ef20f2c77c497d55af00d2e0b78 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Fri, 15 Jul 2011 13:46:03 +0300
+Subject: [PATCH 07/33] Don't try to close an already closed socket
+
+This could happen if WriteN() (called within SendBytesReceived())
+failed.
+---
+ librtmp/rtmp.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index f85cd83..df2cb27 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -3626,7 +3626,9 @@ RTMPSockBuf_Close(RTMPSockBuf *sb)
+       sb->sb_ssl = NULL;
+     }
+ #endif
+-  return closesocket(sb->sb_socket);
++  if (sb->sb_socket != -1)
++      return closesocket(sb->sb_socket);
++  return 0;
+ }
+ 
+ #define HEX2BIN(a)	(((a)&0x40)?((a)&0xf)+9:((a)&0xf))
+-- 
+1.7.10.4
+
+
+From 530d02fccf24f98e2e318418b2fa3e3420056fda Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Fri, 22 Jul 2011 18:04:05 -0700
+Subject: [PATCH 08/33] Fix MDH_free() for PolarSSL
+
+Reported by Reijo Tomperi <aggro80@users.sourceforge.net>
+---
+ librtmp/dh.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index 8e285a6..efef0fd 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -53,7 +53,7 @@ typedef struct MDH {
+ } MDH;
+ 
+ #define MDH_new()	calloc(1,sizeof(MDH))
+-#define MDH_free(vp)	{MDH *dh = vp; dhm_free(&dh->ctx); MP_free(dh->p); MP_free(dh->g); MP_free(dh->pub_key); MP_free(dh->priv_key); free(dh);}
++#define MDH_free(vp)	{MDH *_dh = vp; dhm_free(&_dh->ctx); MP_free(_dh->p); MP_free(_dh->g); MP_free(_dh->pub_key); MP_free(_dh->priv_key); free(_dh);}
+ 
+ static int MDH_generate_key(MDH *dh)
+ {
+-- 
+1.7.10.4
+
+
+From b627335dc37fd5265ac6d23a441ee2d89ab503c8 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Fri, 22 Jul 2011 18:06:27 -0700
+Subject: [PATCH 09/33] Plug potential memleak
+
+Reported by Reijo Tomperi <aggro80@users.sourceforge.net>
+---
+ rtmpdump.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 89c053a..e506fa9 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -444,7 +444,7 @@ Download(RTMP * rtmp,		// connected RTMP object
+ {
+   int32_t now, lastUpdate;
+   int bufferSize = 64 * 1024;
+-  char *buffer = (char *) malloc(bufferSize);
++  char *buffer;
+   int nRead = 0;
+   off_t size = ftello(file);
+   unsigned long lastPercent = 0;
+@@ -505,6 +505,8 @@ Download(RTMP * rtmp,		// connected RTMP object
+   rtmp->m_read.nMetaHeaderSize = nMetaHeaderSize;
+   rtmp->m_read.nInitialFrameSize = nInitialFrameSize;
+ 
++  buffer = (char *) malloc(bufferSize);
++
+   now = RTMP_GetTime();
+   lastUpdate = now - 1000;
+   do
+-- 
+1.7.10.4
+
+
+From ec422962d58b8e0d9bfcf0af6e450e0e349947da Mon Sep 17 00:00:00 2001
+From: "Scott D. Davilla" <davilla@xbmc.org>
+Date: Fri, 29 Jul 2011 11:26:35 -0700
+Subject: [PATCH 10/33] Darwin dylib updates
+
+Bring in line with current practice for Darwin dynamic libs
+---
+ librtmp/Makefile |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index b88baf4..a0125f1 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -52,8 +52,8 @@ SODIR_mingw=$(BINDIR)
+ SODIR=$(SODIR_$(SYS))
+ 
+ SO_LDFLAGS_posix=-shared -Wl,-soname,$@
+-SO_LDFLAGS_darwin=-dynamiclib -flat_namespace -undefined suppress -fno-common \
+-	-headerpad_max_install_names
++SO_LDFLAGS_darwin=-dynamiclib -twolevel_namespace -undefined dynamic_lookup \
++	-fno-common -headerpad_max_install_names -install_name $(libdir)/$@
+ SO_LDFLAGS_mingw=-shared -Wl,--out-implib,librtmp.dll.a
+ SO_LDFLAGS=$(SO_LDFLAGS_$(SYS))
+ 
+-- 
+1.7.10.4
+
+
+From 024d201c36e1b40f4f4d473e87d405e1b411230f Mon Sep 17 00:00:00 2001
+From: KSV <faltuvisitor@yahoo.co.in>
+Date: Sun, 31 Jul 2011 12:33:46 -0700
+Subject: [PATCH 11/33] Justin.TV usherToken detection
+
+---
+ rtmpsrv.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 59 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index f1b6c66..805ce0d 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -95,6 +95,7 @@ STREAMING_SERVER *rtmpServer = 0;	// server structure pointer
+ 
+ STREAMING_SERVER *startStreaming(const char *address, int port);
+ void stopStreaming(STREAMING_SERVER * server);
++char *strreplace(char *srcstr, int srclen, char *orig, char *repl);
+ 
+ typedef struct
+ {
+@@ -261,6 +262,7 @@ static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
+ static const AVal av_Stopped_playing = AVC("Stopped playing");
+ SAVC(details);
+ SAVC(clientid);
++static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken");
+ 
+ static int
+ SendPlayStart(RTMP *r)
+@@ -575,6 +577,13 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+     {
+       SendResultNumber(r, txn, 10.0);
+     }
++  else if (AVMATCH(&method, &av_NetStream_Authenticate_UsherToken))
++    {
++      AMFObjectProperty *prop = AMF_GetProp(&obj, NULL, 3);
++      AMFProp_GetString(prop, &r->Link.usherToken);
++      prop->p_vu.p_aval.av_len = 0;
++      prop->p_vu.p_aval.av_val = NULL;
++    }
+   else if (AVMATCH(&method, &av_play))
+     {
+       char *file, *p, *q, *cmd, *ptr;
+@@ -591,10 +600,11 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+       if (r->Link.tcUrl.av_len)
+ 	{
+ 	  len = server->arglen + r->Link.playpath.av_len + 4 +
+-	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12;
++	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12 +
++	    r->Link.usherToken.av_len + 64;
+ 	  server->argc += 5;
+ 
+-	  cmd = malloc(len + server->argc * sizeof(AVal));
++	  cmd = malloc(len + (server->argc + 2) * sizeof(AVal));
+ 	  ptr = cmd;
+ 	  argv = (AVal *)(cmd + len);
+ 	  argv[0].av_val = cmd;
+@@ -640,6 +650,17 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+ 	      ptr += sprintf(ptr, " -p \"%s\"", r->Link.pageUrl.av_val);
+ 	      argv[argc++].av_len = r->Link.pageUrl.av_len;
+ 	    }
++          if (r->Link.usherToken.av_val)
++            {
++              char *usherToken = strreplace(r->Link.usherToken.av_val, r->Link.usherToken.av_len, "\"", "\\\"");
++	      argv[argc].av_val = ptr + 1;
++	      argv[argc++].av_len = 5;
++	      argv[argc].av_val = ptr + 8;
++              ptr += sprintf(ptr, " --jtv \"%s\"", usherToken);
++	      argv[argc++].av_len = strlen(usherToken);
++              server->argc += 2;
++              free(usherToken);
++            }
+ 	  if (r->Link.extras.o_num) {
+ 	    ptr = dumpAMF(&r->Link.extras, ptr, argv, &argc);
+ 	    AMF_Reset(&r->Link.extras);
+@@ -1111,3 +1132,39 @@ main(int argc, char **argv)
+ #endif
+   return nStatus;
+ }
++
++char *
++strreplace(char *srcstr, int srclen, char *orig, char *repl)
++{
++  char *ptr = NULL, *srcstrstart = srcstr;
++  int origlen = strlen(orig);
++  int repllen = strlen(repl);
++  if (!srclen)
++    srclen = strlen(srcstr);
++  char *srcend = srcstr + srclen;
++  int deststrbuffer = srclen / origlen * repllen;
++  if (deststrbuffer < srclen)
++    deststrbuffer = srclen;
++  char *deststr = calloc(deststrbuffer + 1, sizeof(char));
++  char *deststrstart = deststr;
++
++  if ( (ptr = strstr(srcstr, orig)) )
++  {
++    do
++    {
++      int len = ptr - srcstrstart;
++      memcpy(deststrstart, srcstrstart, len);
++      srcstrstart += len + origlen;
++      deststrstart += len;
++      memcpy(deststrstart, repl, repllen);
++      deststrstart += repllen;
++      ptr = strstr(srcstrstart, orig);
++    }
++    while (ptr && (ptr < srcend));
++    strncpy(deststrstart, srcstrstart, srcend-srcstrstart);
++    return deststr;
++  }
++
++  strncpy(deststr, srcstr, srclen);
++  return deststr;
++}
+-- 
+1.7.10.4
+
+
+From f1abda046ca5a3f1efa63033c542e686b43dbcf3 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Sun, 31 Jul 2011 13:21:12 -0700
+Subject: [PATCH 12/33] Cleanup previous commit
+
+---
+ rtmpsrv.c |  111 ++++++++++++++++++++++++++++++++++---------------------------
+ 1 file changed, 62 insertions(+), 49 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 805ce0d..b45aae3 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -1,6 +1,6 @@
+ /*  Simple RTMP Server
+  *  Copyright (C) 2009 Andrej Stepanchuk
+- *  Copyright (C) 2009 Howard Chu
++ *  Copyright (C) 2009-2011 Howard Chu
+  *
+  *  This Program is free software; you can redistribute it and/or modify
+  *  it under the terms of the GNU General Public License as published by
+@@ -95,7 +95,10 @@ STREAMING_SERVER *rtmpServer = 0;	// server structure pointer
+ 
+ STREAMING_SERVER *startStreaming(const char *address, int port);
+ void stopStreaming(STREAMING_SERVER * server);
+-char *strreplace(char *srcstr, int srclen, char *orig, char *repl);
++void AVreplace(AVal *src, const AVal *orig, const AVal *repl);
++
++static const AVal av_dquote = AVC("\"");
++static const AVal av_escdquote = AVC("\\\"");
+ 
+ typedef struct
+ {
+@@ -579,10 +582,12 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+     }
+   else if (AVMATCH(&method, &av_NetStream_Authenticate_UsherToken))
+     {
+-      AMFObjectProperty *prop = AMF_GetProp(&obj, NULL, 3);
+-      AMFProp_GetString(prop, &r->Link.usherToken);
+-      prop->p_vu.p_aval.av_len = 0;
+-      prop->p_vu.p_aval.av_val = NULL;
++      AVal usherToken;
++      AMFProp_GetString(AMF_GetProp(&obj, NULL, 3), &usherToken);
++      AVreplace(&usherToken, &av_dquote, &av_escdquote);
++      server->arglen += 6 + usherToken.av_len;
++      server->argc += 2;
++      r->Link.usherToken = usherToken;
+     }
+   else if (AVMATCH(&method, &av_play))
+     {
+@@ -600,11 +605,10 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+       if (r->Link.tcUrl.av_len)
+ 	{
+ 	  len = server->arglen + r->Link.playpath.av_len + 4 +
+-	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12 +
+-	    r->Link.usherToken.av_len + 64;
++	    sizeof("rtmpdump") + r->Link.playpath.av_len + 12;
+ 	  server->argc += 5;
+ 
+-	  cmd = malloc(len + (server->argc + 2) * sizeof(AVal));
++	  cmd = malloc(len + server->argc * sizeof(AVal));
+ 	  ptr = cmd;
+ 	  argv = (AVal *)(cmd + len);
+ 	  argv[0].av_val = cmd;
+@@ -650,17 +654,17 @@ ServeInvoke(STREAMING_SERVER *server, RTMP * r, RTMPPacket *packet, unsigned int
+ 	      ptr += sprintf(ptr, " -p \"%s\"", r->Link.pageUrl.av_val);
+ 	      argv[argc++].av_len = r->Link.pageUrl.av_len;
+ 	    }
+-          if (r->Link.usherToken.av_val)
+-            {
+-              char *usherToken = strreplace(r->Link.usherToken.av_val, r->Link.usherToken.av_len, "\"", "\\\"");
++	  if (r->Link.usherToken.av_val)
++	    {
+ 	      argv[argc].av_val = ptr + 1;
+-	      argv[argc++].av_len = 5;
+-	      argv[argc].av_val = ptr + 8;
+-              ptr += sprintf(ptr, " --jtv \"%s\"", usherToken);
+-	      argv[argc++].av_len = strlen(usherToken);
+-              server->argc += 2;
+-              free(usherToken);
+-            }
++	      argv[argc++].av_len = 2;
++	      argv[argc].av_val = ptr + 5;
++	      ptr += sprintf(ptr, " -j \"%s\"", r->Link.usherToken.av_val);
++	      argv[argc++].av_len = r->Link.usherToken.av_len;
++	      free(r->Link.usherToken.av_val);
++	      r->Link.usherToken.av_val = NULL;
++	      r->Link.usherToken.av_len = 0;
++	    }
+ 	  if (r->Link.extras.o_num) {
+ 	    ptr = dumpAMF(&r->Link.extras, ptr, argv, &argc);
+ 	    AMF_Reset(&r->Link.extras);
+@@ -932,6 +936,11 @@ cleanup:
+   rtmp.Link.pageUrl.av_val = NULL;
+   rtmp.Link.app.av_val = NULL;
+   rtmp.Link.flashVer.av_val = NULL;
++  if (rtmp.Link.usherToken.av_val)
++    {
++      free(rtmp.Link.usherToken.av_val);
++      rtmp.Link.usherToken.av_val = NULL;
++    }
+   RTMP_LogPrintf("done!\n\n");
+ 
+ quit:
+@@ -1133,38 +1142,42 @@ main(int argc, char **argv)
+   return nStatus;
+ }
+ 
+-char *
+-strreplace(char *srcstr, int srclen, char *orig, char *repl)
++void
++AVreplace(AVal *src, const AVal *orig, const AVal *repl)
+ {
+-  char *ptr = NULL, *srcstrstart = srcstr;
+-  int origlen = strlen(orig);
+-  int repllen = strlen(repl);
+-  if (!srclen)
+-    srclen = strlen(srcstr);
+-  char *srcend = srcstr + srclen;
+-  int deststrbuffer = srclen / origlen * repllen;
+-  if (deststrbuffer < srclen)
+-    deststrbuffer = srclen;
+-  char *deststr = calloc(deststrbuffer + 1, sizeof(char));
+-  char *deststrstart = deststr;
+-
+-  if ( (ptr = strstr(srcstr, orig)) )
+-  {
+-    do
++  char *srcbeg = src->av_val;
++  char *srcend = src->av_val + src->av_len;
++  char *dest, *sptr, *dptr;
++  int n = 0;
++
++  /* count occurrences of orig in src */
++  sptr = src->av_val;
++  while (sptr < srcend && (sptr = strstr(sptr, orig->av_val)))
+     {
+-      int len = ptr - srcstrstart;
+-      memcpy(deststrstart, srcstrstart, len);
+-      srcstrstart += len + origlen;
+-      deststrstart += len;
+-      memcpy(deststrstart, repl, repllen);
+-      deststrstart += repllen;
+-      ptr = strstr(srcstrstart, orig);
++      n++;
++      sptr += orig->av_len;
+     }
+-    while (ptr && (ptr < srcend));
+-    strncpy(deststrstart, srcstrstart, srcend-srcstrstart);
+-    return deststr;
+-  }
++  if (!n)
++    return;
+ 
+-  strncpy(deststr, srcstr, srclen);
+-  return deststr;
++  dest = malloc(src->av_len + 1 + (repl->av_len - orig->av_len) * n);
++
++  sptr = src->av_val;
++  dptr = dest;
++  while (sptr < srcend && (sptr = strstr(sptr, orig->av_val)))
++    {
++      n = sptr - srcbeg;
++      memcpy(dptr, srcbeg, n);
++      srcbeg += n;
++      dptr += n;
++      memcpy(dptr, repl->av_val, repl->av_len);
++      dptr += repl->av_len;
++      sptr += orig->av_len;
++    }
++  n = srcend - srcbeg;
++  memcpy(dptr, srcbeg, n);
++  dptr += n;
++  *dptr = '\0';
++  src->av_val = dest;
++  src->av_len = dptr - dest;
+ }
+-- 
+1.7.10.4
+
+
+From 8880d1456b282ee79979adbe7b6a6eb8ad371081 Mon Sep 17 00:00:00 2001
+From: Chris Larsen <clarsen@euphoriaaudio.com>
+Date: Tue, 2 Aug 2011 12:33:44 -0400
+Subject: [PATCH 13/33] Unexpected BW Response Fix
+
+Bug: SendCheckBWResult sends an invalid bw response due to casting issues
+from a double to an int.
+---
+ librtmp/rtmp.c |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index df2cb27..5311a8a 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2339,7 +2339,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ {
+   AMFObject obj;
+   AVal method;
+-  int txn;
++  double txn;
+   int ret = 0, nRes;
+   if (body[0] != 0x02)		/* make sure it is a string method name we start with */
+     {
+@@ -2357,7 +2357,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 
+   AMF_Dump(&obj);
+   AMFProp_GetString(AMF_GetProp(&obj, NULL, 0), &method);
+-  txn = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
++  txn = AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 1));
+   RTMP_Log(RTMP_LOGDEBUG, "%s, server invoking <%s>", __FUNCTION__, method.av_val);
+ 
+   if (AVMATCH(&method, &av__result))
+@@ -2366,7 +2366,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+       int i;
+ 
+       for (i=0; i<r->m_numCalls; i++) {
+-  	if (r->m_methodCalls[i].num == txn) {
++	if (r->m_methodCalls[i].num == (int)txn) {
+ 	  methodInvoked = r->m_methodCalls[i].name;
+ 	  AV_erase(r->m_methodCalls, &r->m_numCalls, i, FALSE);
+ 	  break;
+-- 
+1.7.10.4
+
+
+From c528451068de033d7cc76eb1c5a606c10215fcfb Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Wed, 3 Aug 2011 11:46:07 -0700
+Subject: [PATCH 14/33] Fix <arpa/inet.h> include order
+
+---
+ librtmp/rtmp_sys.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 6a3f215..638374f 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -46,10 +46,10 @@
+ #include <sys/socket.h>
+ #include <sys/times.h>
+ #include <netdb.h>
+-#include <arpa/inet.h>
+ #include <unistd.h>
+ #include <netinet/in.h>
+ #include <netinet/tcp.h>
++#include <arpa/inet.h>
+ #define GetSockError()	errno
+ #define SetSockError(e)	errno = e
+ #undef closesocket
+-- 
+1.7.10.4
+
+
+From a1114e09bf0d74ef1d575eb88f3aa36bc7c6d790 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 9 Aug 2011 14:44:14 -0700
+Subject: [PATCH 15/33] Fix AVreplace for usherToken
+
+---
+ rtmpsrv.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index b45aae3..91fc4da 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -1168,11 +1168,11 @@ AVreplace(AVal *src, const AVal *orig, const AVal *repl)
+     {
+       n = sptr - srcbeg;
+       memcpy(dptr, srcbeg, n);
+-      srcbeg += n;
+       dptr += n;
+       memcpy(dptr, repl->av_val, repl->av_len);
+       dptr += repl->av_len;
+       sptr += orig->av_len;
++      srcbeg = sptr;
+     }
+   n = srcend - srcbeg;
+   memcpy(dptr, srcbeg, n);
+-- 
+1.7.10.4
+
+
+From c58cfb3e9208c6e6bc1aa18f1b1d650d799084e5 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 11 Aug 2011 18:02:10 -0700
+Subject: [PATCH 16/33] Add RD_NO_CONNECT return code for Connect failures
+
+---
+ rtmpdump.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index e506fa9..01decf9 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -46,6 +46,7 @@
+ #define RD_SUCCESS		0
+ #define RD_FAILED		1
+ #define RD_INCOMPLETE		2
++#define RD_NO_CONNECT		3
+ 
+ #define DEF_TIMEOUT	30	/* seconds */
+ #define DEF_BUFTIME	(10 * 60 * 60 * 1000)	/* 10 hours default */
+@@ -1253,7 +1254,7 @@ main(int argc, char **argv)
+ 
+ 	  if (!RTMP_Connect(&rtmp, NULL))
+ 	    {
+-	      nStatus = RD_FAILED;
++	      nStatus = RD_NO_CONNECT;
+ 	      break;
+ 	    }
+ 
+-- 
+1.7.10.4
+
+
+From 6230845ab0fba07289d4b2d9b97269e4b2d90766 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Sun, 25 Sep 2011 03:07:14 -0700
+Subject: [PATCH 17/33] PolarSSL support now requires version 1.0.0.
+
+---
+ README             |    1 +
+ librtmp/dh.h       |    7 +++----
+ librtmp/rtmp_sys.h |    3 ++-
+ 3 files changed, 6 insertions(+), 5 deletions(-)
+
+diff --git a/README b/README
+index 865c6c4..dcf5f52 100644
+--- a/README
++++ b/README
+@@ -50,6 +50,7 @@ library. You can also turn it off if desired
+ The rtmpdump programs still link to the static library, regardless.
+ 
+ Note that if using OpenSSL, you must have version 0.9.8 or newer.
++For Polar SSL you must have version 1.0.0 or newer.
+ 
+ Credit goes to team boxee for the XBMC RTMP code originally used in RTMPDumper.
+ The current code is based on the XBMC code but rewritten in C by Howard Chu.
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index efef0fd..a9f3763 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -30,14 +30,14 @@
+ #ifdef USE_POLARSSL
+ #include <polarssl/dhm.h>
+ typedef mpi * MP_t;
+-#define MP_new(m)	m = malloc(sizeof(mpi)); mpi_init(m, NULL)
++#define MP_new(m)	m = malloc(sizeof(mpi)); mpi_init(m)
+ #define MP_set_w(mpi, w)	mpi_lset(mpi, w)
+ #define MP_cmp(u, v)	mpi_cmp_mpi(u, v)
+ #define MP_set(u, v)	mpi_copy(u, v)
+ #define MP_sub_w(mpi, w)	mpi_sub_int(mpi, mpi, w)
+ #define MP_cmp_1(mpi)	mpi_cmp_int(mpi, 1)
+ #define MP_modexp(r, y, q, p)	mpi_exp_mod(r, y, q, p, NULL)
+-#define MP_free(mpi)	mpi_free(mpi, NULL); free(mpi)
++#define MP_free(mpi)	mpi_free(mpi); free(mpi)
+ #define MP_gethex(u, hex, res)	MP_new(u); res = mpi_read_string(u, 16, hex) == 0
+ #define MP_bytes(u)	mpi_size(u)
+ #define MP_setbin(u,buf,len)	mpi_write_binary(u,buf,len)
+@@ -71,9 +71,8 @@ static int MDH_generate_key(MDH *dh)
+ 
+ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+ {
+-  int n = len;
+   MP_set(&dh->ctx.GY, pub);
+-  dhm_calc_secret(&dh->ctx, secret, &n);
++  dhm_calc_secret(&dh->ctx, secret, &len);
+   return 0;
+ }
+ 
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 638374f..c3fd4a6 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -71,7 +71,8 @@ typedef struct tls_ctx {
+ #define TLS_CTX tls_ctx *
+ #define TLS_client(ctx,s)	s = malloc(sizeof(ssl_context)); ssl_init(s);\
+ 	ssl_set_endpoint(s, SSL_IS_CLIENT); ssl_set_authmode(s, SSL_VERIFY_NONE);\
+-	ssl_set_rng(s, havege_rand, &ctx->hs); ssl_set_ciphers(s, ssl_default_ciphers);\
++	ssl_set_rng(s, havege_rand, &ctx->hs);\
++	ssl_set_ciphersuites(s, ssl_default_ciphersuites);\
+ 	ssl_set_session(s, 1, 600, &ctx->ssn)
+ #define TLS_setfd(s,fd)	ssl_set_bio(s, net_recv, &fd, net_send, &fd)
+ #define TLS_connect(s)	ssl_handshake(s)
+-- 
+1.7.10.4
+
+
+From 60218d0af0f4bd683ecdebe49986f188820cf8ce Mon Sep 17 00:00:00 2001
+From: Kirill Zorin <cyril.zorin@gmail.com>
+Date: Fri, 30 Sep 2011 13:38:23 -0400
+Subject: [PATCH 18/33] fixed undefined behaviour due to union assignment
+
+---
+ librtmp/amf.c  |    2 +-
+ librtmp/rtmp.c |    4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index 7fa289e..ae920e4 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -1111,7 +1111,7 @@ AMF_AddProp(AMFObject *obj, const AMFObjectProperty *prop)
+   if (!(obj->o_num & 0x0f))
+     obj->o_props =
+       realloc(obj->o_props, (obj->o_num + 16) * sizeof(AMFObjectProperty));
+-  obj->o_props[obj->o_num++] = *prop;
++  memcpy(&obj->o_props[obj->o_num++], prop, sizeof(AMFObjectProperty));
+ }
+ 
+ int
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5311a8a..4b17a49 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -2584,7 +2584,7 @@ RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
+ 
+       if (AVMATCH(&prop->p_name, name))
+ 	{
+-	  *p = *prop;
++	  memcpy(p, prop, sizeof(*prop));
+ 	  return TRUE;
+ 	}
+ 
+@@ -2610,7 +2610,7 @@ RTMP_FindPrefixProperty(AMFObject *obj, const AVal *name,
+       if (prop->p_name.av_len > name->av_len &&
+       	  !memcmp(prop->p_name.av_val, name->av_val, name->av_len))
+ 	{
+-	  *p = *prop;
++	  memcpy(p, prop, sizeof(*prop));
+ 	  return TRUE;
+ 	}
+ 
+-- 
+1.7.10.4
+
+
+From c90c05892cbaebfb1b2095759597d9fb38238c64 Mon Sep 17 00:00:00 2001
+From: KSV <faltuvistor@yahoo.co.in>
+Date: Mon, 7 Nov 2011 11:38:27 -0800
+Subject: [PATCH 19/33] Fix bytes-received report
+
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 4b17a49..a9c1bc1 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -1337,7 +1337,7 @@ ReadN(RTMP *r, char *buffer, int n)
+ 	  nBytes = nRead;
+ 	  r->m_nBytesIn += nRead;
+ 	  if (r->m_bSendCounter
+-	      && r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
++	      && r->m_nBytesIn > ( r->m_nBytesInSent + r->m_nClientBW / 10))
+ 	    if (!SendBytesReceived(r))
+ 	        return FALSE;
+ 	}
+-- 
+1.7.10.4
+
+
+From b3467069ad7c26d748ca13ce0ee88a41f85b22dd Mon Sep 17 00:00:00 2001
+From: Jeff Johnson <jeff@rogueamoeba.com>
+Date: Mon, 7 Nov 2011 11:43:26 -0800
+Subject: [PATCH 20/33] Fix getting swf hash with https URLs
+
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 3c56b69..5576730 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -163,7 +163,7 @@ HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
+ #else
+       TLS_client(RTMP_TLS_ctx, sb.sb_ssl);
+       TLS_setfd(sb.sb_ssl, sb.sb_socket);
+-      if ((i = TLS_connect(sb.sb_ssl)) < 0)
++      if (TLS_connect(sb.sb_ssl) < 0)
+ 	{
+ 	  RTMP_Log(RTMP_LOGERROR, "%s, TLS_Connect failed", __FUNCTION__);
+ 	  ret = HTTPRES_LOST_CONNECTION;
+-- 
+1.7.10.4
+
+
+From 90799efbb67f415ff930d68905e8267d5aa5dc4e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:04:01 -0800
+Subject: [PATCH 21/33] Increase tcUrl buffer size
+
+---
+ rtmpdump.c |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 01decf9..a8fa128 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1152,9 +1152,9 @@ main(int argc, char **argv)
+ 
+   if (tcUrl.av_len == 0)
+     {
+-      char str[512] = { 0 };
++      char str[1024];
+ 
+-      tcUrl.av_len = snprintf(str, 511, "%s://%.*s:%d/%.*s",
++      tcUrl.av_len = snprintf(str, sizeof(str), "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+       tcUrl.av_val = (char *) malloc(tcUrl.av_len + 1);
+-- 
+1.7.10.4
+
+
+From 9df7959a71ec33cc9c83c9d3ef25c17b1c527f0e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:05:01 -0800
+Subject: [PATCH 22/33] Spell Referer according to RFC1945
+
+---
+ librtmp/hashswf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 5576730..0320480 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -141,7 +141,7 @@ HTTP_get(struct HTTP_ctx *http, const char *url, HTTP_read_callback *cb)
+     return HTTPRES_LOST_CONNECTION;
+   i =
+     sprintf(sb.sb_buf,
+-	    "GET %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\nReferrer: %.*s\r\n",
++	    "GET %s HTTP/1.0\r\nUser-Agent: %s\r\nHost: %s\r\nReferer: %.*s\r\n",
+ 	    path, AGENT, host, (int)(path - url + 1), url);
+   if (http->date[0])
+     i += sprintf(sb.sb_buf + i, "If-Modified-Since: %s\r\n", http->date);
+-- 
+1.7.10.4
+
+
+From 1c77ff43439068981d2ad9872952922a1ee37f89 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:13:14 -0800
+Subject: [PATCH 23/33] Calculate tcUrl length
+
+---
+ rtmpdump.c |    9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index a8fa128..892a8bc 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1152,13 +1152,12 @@ main(int argc, char **argv)
+ 
+   if (tcUrl.av_len == 0)
+     {
+-      char str[1024];
+-
+-      tcUrl.av_len = snprintf(str, sizeof(str), "%s://%.*s:%d/%.*s",
++	  tcUrl.av_len = strlen(RTMPProtocolStringsLower[protocol]) +
++	  	hostname.av_len + app.av_len + sizeof("://:65535/");
++      tcUrl.av_val = (char *) malloc(tcUrl.av_len);
++      tcUrl.av_len = snprintf(tcUrl.av_val, tcUrl.av_len, "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+-      tcUrl.av_val = (char *) malloc(tcUrl.av_len + 1);
+-      strcpy(tcUrl.av_val, str);
+     }
+ 
+   int first = 1;
+-- 
+1.7.10.4
+
+
+From 30fcf46fc82f96ca41b710fc38bbc15f2489795e Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Tue, 8 Nov 2011 02:14:21 -0800
+Subject: [PATCH 24/33] Check for malloc failure in prev commit
+
+---
+ rtmpdump.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index 892a8bc..c37def2 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -1155,6 +1155,8 @@ main(int argc, char **argv)
+ 	  tcUrl.av_len = strlen(RTMPProtocolStringsLower[protocol]) +
+ 	  	hostname.av_len + app.av_len + sizeof("://:65535/");
+       tcUrl.av_val = (char *) malloc(tcUrl.av_len);
++	  if (!tcUrl.av_val)
++	    return RD_FAILED;
+       tcUrl.av_len = snprintf(tcUrl.av_val, tcUrl.av_len, "%s://%.*s:%d/%.*s",
+ 	  	   RTMPProtocolStringsLower[protocol], hostname.av_len,
+ 		   hostname.av_val, port, app.av_len, app.av_val);
+-- 
+1.7.10.4
+
+
+From 83e701eef0d7947713280fe3e7561bed1e7195f5 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:09:26 -0800
+Subject: [PATCH 25/33] Fix missing log message parameter
+
+---
+ librtmp/rtmp.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index a9c1bc1..4da318b 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -974,7 +974,7 @@ SocksNegotiate(RTMP *r)
+       }
+     else
+       {
+-        RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", packet[1]);
++        RTMP_Log(RTMP_LOGERROR, "%s, SOCKS returned error code %d", __FUNCTION__, packet[1]);
+         return FALSE;
+       }
+   }
+-- 
+1.7.10.4
+
+
+From 949da84ab1f659597d6e7fa1ef0ab8fc1ca8e246 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:11:13 -0800
+Subject: [PATCH 26/33] Tell gcc about log format strings
+
+---
+ librtmp/log.h |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/librtmp/log.h b/librtmp/log.h
+index 97c9aac..2adb111 100644
+--- a/librtmp/log.h
++++ b/librtmp/log.h
+@@ -48,9 +48,15 @@ extern RTMP_LogLevel RTMP_debuglevel;
+ typedef void (RTMP_LogCallback)(int level, const char *fmt, va_list);
+ void RTMP_LogSetCallback(RTMP_LogCallback *cb);
+ void RTMP_LogSetOutput(FILE *file);
++#ifdef __GNUC__
++void RTMP_LogPrintf(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
++void RTMP_LogStatus(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
++void RTMP_Log(int level, const char *format, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
++#else
+ void RTMP_LogPrintf(const char *format, ...);
+ void RTMP_LogStatus(const char *format, ...);
+ void RTMP_Log(int level, const char *format, ...);
++#endif
+ void RTMP_LogHex(int level, const uint8_t *data, unsigned long len);
+ void RTMP_LogHexString(int level, const uint8_t *data, unsigned long len);
+ void RTMP_LogSetLevel(RTMP_LogLevel lvl);
+-- 
+1.7.10.4
+
+
+From 45556fb3b372402d7bd5235832176f58dede90ae Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Mon, 14 Nov 2011 16:12:26 -0800
+Subject: [PATCH 27/33] Fix mismatched format string conversions
+
+---
+ librtmp/amf.c  |    4 ++--
+ librtmp/rtmp.c |   22 +++++++++++-----------
+ 2 files changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index ae920e4..f9ecf21 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -586,7 +586,7 @@ AMF3Prop_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+     case AMF3_ARRAY:
+     case AMF3_BYTE_ARRAY:
+     default:
+-      RTMP_Log(RTMP_LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @0x%08X",
++      RTMP_Log(RTMP_LOGDEBUG, "%s - AMF3 unknown/unsupported datatype 0x%02x, @%p",
+ 	  __FUNCTION__, (unsigned char)(*pBuffer), pBuffer);
+       return -1;
+     }
+@@ -772,7 +772,7 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	break;
+       }
+     default:
+-      RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @0x%08X", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s - unknown datatype 0x%02x, @%p", __FUNCTION__,
+ 	  prop->p_type, pBuffer - 1);
+       return -1;
+     }
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 4da318b..52d0254 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -185,7 +185,7 @@ void
+ RTMPPacket_Dump(RTMPPacket *p)
+ {
+   RTMP_Log(RTMP_LOGDEBUG,
+-      "RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %lu. body: 0x%02x",
++      "RTMP PACKET: packet type: 0x%02x. channel: 0x%02x. info 1: %d info 2: %d. Body size: %u. body: 0x%02x",
+       p->m_packetType, p->m_nChannel, p->m_nTimeStamp, p->m_nInfoField2,
+       p->m_nBodySize, p->m_body ? (unsigned char)p->m_body[0] : 0);
+ }
+@@ -367,7 +367,7 @@ RTMP_SetupStream(RTMP *r,
+     RTMP_Log(RTMP_LOGDEBUG, "StopTime      : %d msec", dStop);
+ 
+   RTMP_Log(RTMP_LOGDEBUG, "live     : %s", bLiveStream ? "yes" : "no");
+-  RTMP_Log(RTMP_LOGDEBUG, "timeout  : %d sec", timeout);
++  RTMP_Log(RTMP_LOGDEBUG, "timeout  : %ld sec", timeout);
+ 
+ #ifdef CRYPTO
+   if (swfSHA256Hash != NULL && swfSize > 0)
+@@ -376,7 +376,7 @@ RTMP_SetupStream(RTMP *r,
+       r->Link.SWFSize = swfSize;
+       RTMP_Log(RTMP_LOGDEBUG, "SWFSHA256:");
+       RTMP_LogHex(RTMP_LOGDEBUG, r->Link.SWFHash, sizeof(r->Link.SWFHash));
+-      RTMP_Log(RTMP_LOGDEBUG, "SWFSize  : %lu", r->Link.SWFSize);
++      RTMP_Log(RTMP_LOGDEBUG, "SWFSize  : %u", r->Link.SWFSize);
+     }
+   else
+     {
+@@ -1161,14 +1161,14 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+     case RTMP_PACKET_TYPE_FLEX_STREAM_SEND:
+       /* flex stream send */
+       RTMP_Log(RTMP_LOGDEBUG,
+-	  "%s, flex stream send, size %lu bytes, not supported, ignoring",
++	  "%s, flex stream send, size %u bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+     case RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT:
+       /* flex shared object */
+       RTMP_Log(RTMP_LOGDEBUG,
+-	  "%s, flex shared object, size %lu bytes, not supported, ignoring",
++	  "%s, flex shared object, size %u bytes, not supported, ignoring",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       break;
+ 
+@@ -1176,7 +1176,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+       /* flex message */
+       {
+ 	RTMP_Log(RTMP_LOGDEBUG,
+-	    "%s, flex message, size %lu bytes, not fully supported",
++	    "%s, flex message, size %u bytes, not fully supported",
+ 	    __FUNCTION__, packet->m_nBodySize);
+ 	/*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+@@ -1198,7 +1198,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+       }
+     case RTMP_PACKET_TYPE_INFO:
+       /* metadata (notify) */
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: notify %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       if (HandleMetadata(r, packet->m_body, packet->m_nBodySize))
+ 	bHasMediaPacket = 1;
+@@ -1211,7 +1211,7 @@ RTMP_ClientPacket(RTMP *r, RTMPPacket *packet)
+ 
+     case RTMP_PACKET_TYPE_INVOKE:
+       /* invoke */
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       /*RTMP_LogHex(packet.m_body, packet.m_nBodySize); */
+ 
+@@ -2373,7 +2373,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
+ 	}
+       }
+       if (!methodInvoked.av_val) {
+-        RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %d without matching request",
++        RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request",
+ 	  __FUNCTION__, txn);
+ 	goto leave;
+       }
+@@ -3055,7 +3055,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
+ 
+   if (ReadN(r, packet->m_body + packet->m_nBytesRead, nChunk) != nChunk)
+     {
+-      RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %lu",
++      RTMP_Log(RTMP_LOGERROR, "%s, failed to read RTMP packet body. len: %u",
+ 	  __FUNCTION__, packet->m_nBodySize);
+       return FALSE;
+     }
+@@ -4176,7 +4176,7 @@ Read_1_Packet(RTMP *r, char *buf, unsigned int buflen)
+ 		  if (pos + 11 + dataSize > nPacketLen)
+ 		    {
+ 		      RTMP_Log(RTMP_LOGERROR,
+-			  "Wrong data size (%lu), stream corrupted, aborting!",
++			  "Wrong data size (%u), stream corrupted, aborting!",
+ 			  dataSize);
+ 		      ret = RTMP_READ_ERROR;
+ 		      break;
+-- 
+1.7.10.4
+
+
+From 5d03a4f0d6216da92830306436eae7eb318d5115 Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Mon, 14 Nov 2011 16:17:27 -0800
+Subject: [PATCH 28/33] Fix log messages
+
+---
+ rtmpdump.c |    4 ++--
+ rtmpgw.c   |    6 +++---
+ rtmpsrv.c  |    8 ++++----
+ rtmpsuck.c |    6 +++---
+ 4 files changed, 12 insertions(+), 12 deletions(-)
+
+diff --git a/rtmpdump.c b/rtmpdump.c
+index c37def2..34bfdba 100644
+--- a/rtmpdump.c
++++ b/rtmpdump.c
+@@ -686,7 +686,7 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--resume|-e             Resume a partial RTMP download\n");
+ 	  RTMP_LogPrintf
+-	    ("--timeout|-m num        Timeout connection num seconds (default: %lu)\n",
++	    ("--timeout|-m num        Timeout connection num seconds (default: %u)\n",
+ 	     DEF_TIMEOUT);
+ 	  RTMP_LogPrintf
+ 	    ("--start|-A num          Start at num seconds into stream (not valid when using --live)\n");
+@@ -699,7 +699,7 @@ void usage(char *prog)
+ 	  RTMP_LogPrintf
+ 	    ("--hashes|-#             Display progress with hashes, not with the byte counter\n");
+ 	  RTMP_LogPrintf
+-	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n",
++	    ("--buffer|-b             Buffer time in milliseconds (default: %u)\n",
+ 	     DEF_BUFTIME);
+ 	  RTMP_LogPrintf
+ 	    ("--skip|-k num           Skip num keyframes when looking for last keyframe to resume from. Useful if resume fails (default: %d)\n\n",
+diff --git a/rtmpgw.c b/rtmpgw.c
+index 733e105..0cf56bb 100644
+--- a/rtmpgw.c
++++ b/rtmpgw.c
+@@ -563,7 +563,7 @@ void processTCPrequest(STREAMING_SERVER * server,	// server socket and state (ou
+   rtmp.Link.token = req.token;
+   rtmp.m_read.timestamp = dSeek;
+ 
+-  RTMP_LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app);
++  RTMP_LogPrintf("Connecting ... port: %d, app: %s\n", req.rtmpport, req.app.av_val);
+   if (!RTMP_Connect(&rtmp, NULL))
+     {
+       RTMP_LogPrintf("%s, failed to connect!\n", __FUNCTION__);
+@@ -738,7 +738,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (closesocket(server->socket))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+@@ -1103,7 +1103,7 @@ main(int argc, char **argv)
+ 	  RTMP_LogPrintf
+ 	    ("--jtv|-j JSON           Authentication token for Justin.tv legacy servers\n");
+ 	  RTMP_LogPrintf
+-	    ("--buffer|-b             Buffer time in milliseconds (default: %lu)\n\n",
++	    ("--buffer|-b             Buffer time in milliseconds (default: %u)\n\n",
+ 	     defaultRTMPRequest.bufferTime);
+ 
+ 	  RTMP_LogPrintf
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index 91fc4da..b662d54 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -765,7 +765,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ {
+   int ret = 0;
+ 
+-  RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %lu bytes", __FUNCTION__,
++  RTMP_Log(RTMP_LOGDEBUG, "%s, received packet type %02X, size %u bytes", __FUNCTION__,
+     packet->m_packetType, packet->m_nBodySize);
+ 
+   switch (packet->m_packetType)
+@@ -812,7 +812,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ 
+     case 0x11:			// flex message
+       {
+-	RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %lu bytes, not fully supported",
++	RTMP_Log(RTMP_LOGDEBUG, "%s, flex message, size %u bytes, not fully supported",
+ 	    __FUNCTION__, packet->m_nBodySize);
+ 	//RTMP_LogHex(packet.m_body, packet.m_nBodySize);
+ 
+@@ -840,7 +840,7 @@ ServePacket(STREAMING_SERVER *server, RTMP *r, RTMPPacket *packet)
+ 
+     case 0x14:
+       // invoke
+-      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %lu bytes", __FUNCTION__,
++      RTMP_Log(RTMP_LOGDEBUG, "%s, received: invoke %u bytes", __FUNCTION__,
+ 	  packet->m_nBodySize);
+       //RTMP_LogHex(packet.m_body, packet.m_nBodySize);
+ 
+@@ -1053,7 +1053,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (closesocket(server->socket))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+diff --git a/rtmpsuck.c b/rtmpsuck.c
+index 661e64b..e886179 100644
+--- a/rtmpsuck.c
++++ b/rtmpsuck.c
+@@ -456,7 +456,7 @@ ServePacket(STREAMING_SERVER *server, int which, RTMPPacket *packet)
+ {
+   int ret = 0;
+ 
+-  RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %lu bytes", __FUNCTION__,
++  RTMP_Log(RTMP_LOGDEBUG, "%s, %s sent packet type %02X, size %u bytes", __FUNCTION__,
+     cst[which], packet->m_packetType, packet->m_nBodySize);
+ 
+   switch (packet->m_packetType)
+@@ -649,7 +649,7 @@ WriteStream(char **buf,	// target pointer, maybe preallocated
+ 		  if (pos + 11 + dataSize > nPacketLen)
+ 		    {
+ 		      RTMP_Log(RTMP_LOGERROR,
+-			  "Wrong data size (%lu), stream corrupted, aborting!",
++			  "Wrong data size (%u), stream corrupted, aborting!",
+ 			  dataSize);
+ 		      ret = -2;
+ 		      break;
+@@ -1117,7 +1117,7 @@ stopStreaming(STREAMING_SERVER * server)
+ 
+       if (fd && closesocket(fd))
+ 	RTMP_Log(RTMP_LOGERROR, "%s: Failed to close listening socket, error %d",
+-	    GetSockError());
++	    __FUNCTION__, GetSockError());
+ 
+       server->state = STREAMING_STOPPED;
+     }
+-- 
+1.7.10.4
+
+
+From 4e06e218e230a86608637b613499984703a342cf Mon Sep 17 00:00:00 2001
+From: Antti Ajanki <antti.ajanki@iki.fi>
+Date: Thu, 22 Dec 2011 17:54:10 -0800
+Subject: [PATCH 29/33] Support decoding AMF_XML_DOC
+
+MF_XML_DOC data is an XML document which is encoded similarly to a
+long string.
+---
+ librtmp/amf.c |   10 +++-------
+ 1 file changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index f9ecf21..659421e 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -735,13 +735,15 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	break;
+       }
+     case AMF_LONG_STRING:
++    case AMF_XML_DOC:
+       {
+ 	unsigned int nStringSize = AMF_DecodeInt32(pBuffer);
+ 	if (nSize < (long)nStringSize + 4)
+ 	  return -1;
+ 	AMF_DecodeLongString(pBuffer, &prop->p_vu.p_aval);
+ 	nSize -= (4 + nStringSize);
+-	prop->p_type = AMF_STRING;
++	if (prop->p_type == AMF_LONG_STRING)
++	  prop->p_type = AMF_STRING;
+ 	break;
+       }
+     case AMF_RECORDSET:
+@@ -750,12 +752,6 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
+ 	return -1;
+ 	break;
+       }
+-    case AMF_XML_DOC:
+-      {
+-	RTMP_Log(RTMP_LOGERROR, "AMF_XML_DOC not supported!");
+-	return -1;
+-	break;
+-      }
+     case AMF_TYPED_OBJECT:
+       {
+ 	RTMP_Log(RTMP_LOGERROR, "AMF_TYPED_OBJECT not supported!");
+-- 
+1.7.10.4
+
+
+From adb77ff4d72cea92b7c307ccb64e9aa930d866da Mon Sep 17 00:00:00 2001
+From: Joshua Allmann <joshua.allmann@gmail.com>
+Date: Fri, 24 Feb 2012 13:44:29 -0800
+Subject: [PATCH 30/33] Remove extra object end tag in Connect reply
+
+---
+ rtmpsrv.c |    3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/rtmpsrv.c b/rtmpsrv.c
+index b662d54..9aa62f3 100644
+--- a/rtmpsrv.c
++++ b/rtmpsrv.c
+@@ -223,9 +223,6 @@ SendConnectResult(RTMP *r, double txn)
+   *enc++ = 0;
+   *enc++ = 0;
+   *enc++ = AMF_OBJECT_END;
+-  *enc++ = 0;
+-  *enc++ = 0;
+-  *enc++ = AMF_OBJECT_END;
+ 
+   packet.m_nBodySize = enc - packet.m_body;
+ 
+-- 
+1.7.10.4
+
+
+From 2ad1d5d133a46ceeaaa05c9375e293f332871f3b Mon Sep 17 00:00:00 2001
+From: Josh Allmann <joshua.allmann@gmail.com>
+Date: Fri, 24 Feb 2012 13:46:59 -0800
+Subject: [PATCH 31/33] Fix upper bound check in AMF_GetProp
+
+---
+ librtmp/amf.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/librtmp/amf.c b/librtmp/amf.c
+index 659421e..ce84f81 100644
+--- a/librtmp/amf.c
++++ b/librtmp/amf.c
+@@ -1121,7 +1121,7 @@ AMF_GetProp(AMFObject *obj, const AVal *name, int nIndex)
+ {
+   if (nIndex >= 0)
+     {
+-      if (nIndex <= obj->o_num)
++      if (nIndex < obj->o_num)
+ 	return &obj->o_props[nIndex];
+     }
+   else
+-- 
+1.7.10.4
+
+
+From eea470fa5f9a5481a36dedd257549595ef7480d6 Mon Sep 17 00:00:00 2001
+From: Martin Storsjo <martin@martin.st>
+Date: Thu, 8 Mar 2012 23:10:11 -0800
+Subject: [PATCH 32/33] Add support for building with gnutls with nettle as
+ backend
+
+---
+ Makefile            |    1 +
+ librtmp/Makefile    |    3 +++
+ librtmp/dh.h        |   20 +++++++++++++++++++-
+ librtmp/handshake.h |   20 ++++++++++++++++++++
+ librtmp/hashswf.c   |   11 +++++++++++
+ librtmp/rtmp.c      |    4 ++--
+ librtmp/rtmp_sys.h  |    2 +-
+ 7 files changed, 57 insertions(+), 4 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 6ef5742..0cf41be 100644
+--- a/Makefile
++++ b/Makefile
+@@ -13,6 +13,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index a0125f1..353c6c8 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -21,14 +21,17 @@ CRYPTO=OPENSSL
+ DEF_POLARSSL=-DUSE_POLARSSL
+ DEF_OPENSSL=-DUSE_OPENSSL
+ DEF_GNUTLS=-DUSE_GNUTLS
++DEF_GNUTLS_NETTLE=-DUSE_GNUTLS_NETTLE
+ DEF_=-DNO_CRYPTO
+ REQ_GNUTLS=gnutls
++REQ_GNUTLS_NETTLE=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+ LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
++LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ PRIVATE_LIBS=$(LIBS_$(SYS))
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index a9f3763..830000e 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -76,7 +76,8 @@ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+   return 0;
+ }
+ 
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#ifdef USE_GNUTLS
+ #include <gcrypt.h>
+ typedef gcry_mpi_t MP_t;
+ #define MP_new(m)	m = gcry_mpi_new(1)
+@@ -91,6 +92,23 @@ typedef gcry_mpi_t MP_t;
+ #define MP_bytes(u)	(gcry_mpi_get_nbits(u) + 7) / 8
+ #define MP_setbin(u,buf,len)	gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u)
+ #define MP_getbin(u,buf,len)	gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL)
++#else
++#include <gmp.h>
++#include <nettle/bignum.h>
++typedef mpz_ptr MP_t;
++#define MP_new(m)	m = malloc(sizeof(*m)); mpz_init2(m, 1)
++#define MP_set_w(mpi, w)	mpz_set_ui(mpi, w)
++#define MP_cmp(u, v)	mpz_cmp(u, v)
++#define MP_set(u, v)	mpz_set(u, v)
++#define MP_sub_w(mpi, w)	mpz_sub_ui(mpi, mpi, w)
++#define MP_cmp_1(mpi)	mpz_cmp_ui(mpi, 1)
++#define MP_modexp(r, y, q, p)	mpz_powm(r, y, q, p)
++#define MP_free(mpi)	mpz_clear(mpi); free(mpi)
++#define MP_gethex(u, hex, res)	u = malloc(sizeof(*u)); mpz_init2(u, 1); res = (mpz_set_str(u, hex, 16) == 0)
++#define MP_bytes(u)	(mpz_sizeinbase(u, 2) + 7) / 8
++#define MP_setbin(u,buf,len)	nettle_mpz_get_str_256(len,buf,u)
++#define MP_getbin(u,buf,len)	u = malloc(sizeof(*u)); mpz_init2(u, 1); nettle_mpz_set_str_256_u(u,len,buf)
++#endif
+ 
+ typedef struct MDH {
+   MP_t p;
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 98bf3c8..4c2ea7f 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -59,6 +59,26 @@ typedef gcry_cipher_hd_t	RC4_handle;
+ #define RC4_encrypt2(h,l,s,d)	gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l)
+ #define RC4_free(h)	gcry_cipher_close(h)
+ 
++#elif defined(USE_GNUTLS_NETTLE)
++#include <nettle/hmac.h>
++#include <nettle/arcfour.h>
++#ifndef SHA256_DIGEST_LENGTH
++#define SHA256_DIGEST_LENGTH    32
++#endif
++#undef HMAC_CTX
++#define HMAC_CTX	struct hmac_sha256_ctx
++#define HMAC_setup(ctx, key, len)	hmac_sha256_set_key(&ctx, len, key)
++#define HMAC_crunch(ctx, buf, len)	hmac_sha256_update(&ctx, len, buf)
++#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
++#define HMAC_close(ctx)
++
++typedef struct arcfour_ctx*	RC4_handle;
++#define RC4_alloc(h)	*h = malloc(sizeof(struct arcfour_ctx))
++#define RC4_setkey(h,l,k)	arcfour_set_key(h, l, k)
++#define RC4_encrypt(h,l,d)	arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)d)
++#define RC4_encrypt2(h,l,s,d)	arcfour_crypt(h,l,(uint8_t *)d,(uint8_t *)s)
++#define RC4_free(h)	free(h)
++
+ #else	/* USE_OPENSSL */
+ #include <openssl/sha.h>
+ #include <openssl/hmac.h>
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 0320480..8cefd3b 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -52,6 +52,17 @@
+ #define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+ #define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen)
+ #define HMAC_close(ctx)	gcry_md_close(ctx)
++#elif defined(USE_GNUTLS_NETTLE)
++#include <nettle/hmac.h>
++#ifndef SHA256_DIGEST_LENGTH
++#define SHA256_DIGEST_LENGTH	32
++#endif
++#undef HMAC_CTX
++#define HMAC_CTX	struct hmac_sha256_ctx
++#define HMAC_setup(ctx, key, len)	hmac_sha256_set_key(&ctx, len, key)
++#define HMAC_crunch(ctx, buf, len)	hmac_sha256_update(&ctx, len, buf)
++#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; hmac_sha256_digest(&ctx, SHA256_DIGEST_LENGTH, dig)
++#define HMAC_close(ctx)
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+ #include <openssl/sha.h>
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 52d0254..5cd7b8d 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -34,7 +34,7 @@
+ #ifdef CRYPTO
+ #ifdef USE_POLARSSL
+ #include <polarssl/havege.h>
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+ #include <gnutls/gnutls.h>
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+@@ -204,7 +204,7 @@ RTMP_TLS_Init()
+   /* Do this regardless of NO_SSL, we use havege for rtmpe too */
+   RTMP_TLS_ctx = calloc(1,sizeof(struct tls_ctx));
+   havege_init(&RTMP_TLS_ctx->hs);
+-#elif defined(USE_GNUTLS) && !defined(NO_SSL)
++#elif (defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)) && !defined(NO_SSL)
+   /* Technically we need to initialize libgcrypt ourselves if
+    * we're not going to call gnutls_global_init(). Ignoring this
+    * for now.
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index c3fd4a6..478c59f 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -81,7 +81,7 @@ typedef struct tls_ctx {
+ #define TLS_shutdown(s)	ssl_close_notify(s)
+ #define TLS_close(s)	ssl_free(s); free(s)
+ 
+-#elif defined(USE_GNUTLS)
++#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+ #include <gnutls/gnutls.h>
+ typedef struct tls_ctx {
+ 	gnutls_certificate_credentials_t cred;
+-- 
+1.7.10.4
+
+
+From 7340f6dbc6b3c8e552baab2e5a891c2de75cddcc Mon Sep 17 00:00:00 2001
+From: Howard Chu <hyc@highlandsun.com>
+Date: Thu, 8 Mar 2012 23:19:45 -0800
+Subject: [PATCH 33/33] Cleanup prev commit, drop gcrypt support
+
+---
+ Makefile            |    3 +--
+ librtmp/Makefile    |    5 +----
+ librtmp/dh.h        |   19 +------------------
+ librtmp/handshake.h |   19 +------------------
+ librtmp/hashswf.c   |   11 -----------
+ librtmp/rtmp.c      |    4 ++--
+ librtmp/rtmp_sys.h  |    2 +-
+ 7 files changed, 7 insertions(+), 56 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 0cf41be..a1595a8 100644
+--- a/Makefile
++++ b/Makefile
+@@ -12,8 +12,7 @@ CRYPTO=OPENSSL
+ #CRYPTO=POLARSSL
+ #CRYPTO=GNUTLS
+ LIBZ=-lz
+-LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
++LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ CRYPTO_LIB=$(LIB_$(CRYPTO))
+diff --git a/librtmp/Makefile b/librtmp/Makefile
+index 353c6c8..74ee3b5 100644
+--- a/librtmp/Makefile
++++ b/librtmp/Makefile
+@@ -21,17 +21,14 @@ CRYPTO=OPENSSL
+ DEF_POLARSSL=-DUSE_POLARSSL
+ DEF_OPENSSL=-DUSE_OPENSSL
+ DEF_GNUTLS=-DUSE_GNUTLS
+-DEF_GNUTLS_NETTLE=-DUSE_GNUTLS_NETTLE
+ DEF_=-DNO_CRYPTO
+ REQ_GNUTLS=gnutls
+-REQ_GNUTLS_NETTLE=gnutls
+ REQ_OPENSSL=libssl,libcrypto
+ LIBZ=-lz
+ LIBS_posix=
+ LIBS_darwin=
+ LIBS_mingw=-lws2_32 -lwinmm -lgdi32
+-LIB_GNUTLS=-lgnutls -lgcrypt $(LIBZ)
+-LIB_GNUTLS_NETTLE=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
++LIB_GNUTLS=-lgnutls -lhogweed -lnettle -lgmp $(LIBZ)
+ LIB_OPENSSL=-lssl -lcrypto $(LIBZ)
+ LIB_POLARSSL=-lpolarssl $(LIBZ)
+ PRIVATE_LIBS=$(LIBS_$(SYS))
+diff --git a/librtmp/dh.h b/librtmp/dh.h
+index 830000e..9959532 100644
+--- a/librtmp/dh.h
++++ b/librtmp/dh.h
+@@ -76,23 +76,7 @@ static int MDH_compute_key(uint8_t *secret, size_t len, MP_t pub, MDH *dh)
+   return 0;
+ }
+ 
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
+-#ifdef USE_GNUTLS
+-#include <gcrypt.h>
+-typedef gcry_mpi_t MP_t;
+-#define MP_new(m)	m = gcry_mpi_new(1)
+-#define MP_set_w(mpi, w)	gcry_mpi_set_ui(mpi, w)
+-#define MP_cmp(u, v)	gcry_mpi_cmp(u, v)
+-#define MP_set(u, v)	gcry_mpi_set(u, v)
+-#define MP_sub_w(mpi, w)	gcry_mpi_sub_ui(mpi, mpi, w)
+-#define MP_cmp_1(mpi)	gcry_mpi_cmp_ui(mpi, 1)
+-#define MP_modexp(r, y, q, p)	gcry_mpi_powm(r, y, q, p)
+-#define MP_free(mpi)	gcry_mpi_release(mpi)
+-#define MP_gethex(u, hex, res)	res = (gcry_mpi_scan(&u, GCRYMPI_FMT_HEX, hex, 0, 0) == 0)
+-#define MP_bytes(u)	(gcry_mpi_get_nbits(u) + 7) / 8
+-#define MP_setbin(u,buf,len)	gcry_mpi_print(GCRYMPI_FMT_USG,buf,len,NULL,u)
+-#define MP_getbin(u,buf,len)	gcry_mpi_scan(&u,GCRYMPI_FMT_USG,buf,len,NULL)
+-#else
++#elif defined(USE_GNUTLS)
+ #include <gmp.h>
+ #include <nettle/bignum.h>
+ typedef mpz_ptr MP_t;
+@@ -108,7 +92,6 @@ typedef mpz_ptr MP_t;
+ #define MP_bytes(u)	(mpz_sizeinbase(u, 2) + 7) / 8
+ #define MP_setbin(u,buf,len)	nettle_mpz_get_str_256(len,buf,u)
+ #define MP_getbin(u,buf,len)	u = malloc(sizeof(*u)); mpz_init2(u, 1); nettle_mpz_set_str_256_u(u,len,buf)
+-#endif
+ 
+ typedef struct MDH {
+   MP_t p;
+diff --git a/librtmp/handshake.h b/librtmp/handshake.h
+index 4c2ea7f..0438486 100644
+--- a/librtmp/handshake.h
++++ b/librtmp/handshake.h
+@@ -43,27 +43,10 @@ typedef arc4_context *	RC4_handle;
+ #define RC4_free(h)	free(h)
+ 
+ #elif defined(USE_GNUTLS)
+-#include <gcrypt.h>
+-#ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH	32
+-#endif
+-#define HMAC_CTX	gcry_md_hd_t
+-#define HMAC_setup(ctx, key, len)	gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
+-#define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+-#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen); gcry_md_close(ctx)
+-
+-typedef gcry_cipher_hd_t	RC4_handle;
+-#define	RC4_alloc(h)	gcry_cipher_open(h, GCRY_CIPHER_ARCFOUR, GCRY_CIPHER_MODE_STREAM, 0)
+-#define RC4_setkey(h,l,k)	gcry_cipher_setkey(h,k,l)
+-#define RC4_encrypt(h,l,d)	gcry_cipher_encrypt(h,(void *)d,l,NULL,0)
+-#define RC4_encrypt2(h,l,s,d)	gcry_cipher_encrypt(h,(void *)d,l,(void *)s,l)
+-#define RC4_free(h)	gcry_cipher_close(h)
+-
+-#elif defined(USE_GNUTLS_NETTLE)
+ #include <nettle/hmac.h>
+ #include <nettle/arcfour.h>
+ #ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH    32
++#define SHA256_DIGEST_LENGTH	32
+ #endif
+ #undef HMAC_CTX
+ #define HMAC_CTX	struct hmac_sha256_ctx
+diff --git a/librtmp/hashswf.c b/librtmp/hashswf.c
+index 8cefd3b..9f4e2c0 100644
+--- a/librtmp/hashswf.c
++++ b/librtmp/hashswf.c
+@@ -42,17 +42,6 @@
+ #define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; sha2_hmac_finish(&ctx, dig)
+ #define HMAC_close(ctx)
+ #elif defined(USE_GNUTLS)
+-#include <gnutls/gnutls.h>
+-#include <gcrypt.h>
+-#ifndef SHA256_DIGEST_LENGTH
+-#define SHA256_DIGEST_LENGTH	32
+-#endif
+-#define HMAC_CTX	gcry_md_hd_t
+-#define HMAC_setup(ctx, key, len)	gcry_md_open(&ctx, GCRY_MD_SHA256, GCRY_MD_FLAG_HMAC); gcry_md_setkey(ctx, key, len)
+-#define HMAC_crunch(ctx, buf, len)	gcry_md_write(ctx, buf, len)
+-#define HMAC_finish(ctx, dig, dlen)	dlen = SHA256_DIGEST_LENGTH; memcpy(dig, gcry_md_read(ctx, 0), dlen)
+-#define HMAC_close(ctx)	gcry_md_close(ctx)
+-#elif defined(USE_GNUTLS_NETTLE)
+ #include <nettle/hmac.h>
+ #ifndef SHA256_DIGEST_LENGTH
+ #define SHA256_DIGEST_LENGTH	32
+diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
+index 5cd7b8d..52d0254 100644
+--- a/librtmp/rtmp.c
++++ b/librtmp/rtmp.c
+@@ -34,7 +34,7 @@
+ #ifdef CRYPTO
+ #ifdef USE_POLARSSL
+ #include <polarssl/havege.h>
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#elif defined(USE_GNUTLS)
+ #include <gnutls/gnutls.h>
+ #else	/* USE_OPENSSL */
+ #include <openssl/ssl.h>
+@@ -204,7 +204,7 @@ RTMP_TLS_Init()
+   /* Do this regardless of NO_SSL, we use havege for rtmpe too */
+   RTMP_TLS_ctx = calloc(1,sizeof(struct tls_ctx));
+   havege_init(&RTMP_TLS_ctx->hs);
+-#elif (defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)) && !defined(NO_SSL)
++#elif defined(USE_GNUTLS) && !defined(NO_SSL)
+   /* Technically we need to initialize libgcrypt ourselves if
+    * we're not going to call gnutls_global_init(). Ignoring this
+    * for now.
+diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h
+index 478c59f..c3fd4a6 100644
+--- a/librtmp/rtmp_sys.h
++++ b/librtmp/rtmp_sys.h
+@@ -81,7 +81,7 @@ typedef struct tls_ctx {
+ #define TLS_shutdown(s)	ssl_close_notify(s)
+ #define TLS_close(s)	ssl_free(s); free(s)
+ 
+-#elif defined(USE_GNUTLS) || defined(USE_GNUTLS_NETTLE)
++#elif defined(USE_GNUTLS)
+ #include <gnutls/gnutls.h>
+ typedef struct tls_ctx {
+ 	gnutls_certificate_credentials_t cred;
+-- 
+1.7.10.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/librtmp.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,27 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := librtmp
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := b65ce7708ae79adb51d1f43dd0b6d987076d7c42
+$(PKG)_SUBDIR   := rtmpdump-2.3
+$(PKG)_FILE     := rtmpdump-2.3.tgz
+$(PKG)_URL      := http://rtmpdump.mplayerhq.hu/download/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc gnutls
+
+define $(PKG)_UPDATE
+    wget -q -O- 'http://rtmpdump.mplayerhq.hu/download/' | \
+    $(SED) -n 's,.*rtmpdump-\([0-9.]*\)\.tgz.*,\1,ip' | \
+    sort -r | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    make -C '$(1)' \
+        CROSS_COMPILE='$(TARGET)-' \
+        prefix='$(PREFIX)/$(TARGET)' \
+        SYS=mingw \
+        CRYPTO=GNUTLS \
+        SHARED=no \
+        -j '$(JOBS)' install
+endef
--- a/src/libsamplerate.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libsamplerate.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mega-nerd.com/SRC/download.html' | \
+    $(WGET) -q -O- 'http://www.mega-nerd.com/SRC/download.html' | \
     $(SED) -n 's,.*libsamplerate-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v alpha | \
     grep -v beta | \
--- a/src/libshout-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libshout-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -3,44 +3,17 @@
 
 Contains ad hoc patches for cross building.
 
-From 25255ff19813e122e6442518b29a55c15860d3a3 Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Fri, 1 Oct 2010 17:20:29 +0200
+From b05b2d82333e13f637dffb93f821907f775eb585 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 20 May 2012 23:23:37 +0200
 Subject: [PATCH] mingw fixes
 
+---
+ include/shout/shout.h.in |    2 ++
+ 1 file changed, 2 insertions(+)
 
-diff --git a/examples/nonblocking.c b/examples/nonblocking.c
-index 0f4aa68..49a3d36 100644
---- a/examples/nonblocking.c
-+++ b/examples/nonblocking.c
-@@ -68,7 +68,11 @@ int main()
- 
- 	while (ret == SHOUTERR_BUSY) {
- 	  printf("Connection pending. Sleeping...\n");
-+#ifdef __MINGW32__
-+	  Sleep(1000);
-+#else
- 	  sleep(1);
-+#endif
- 	  ret = shout_get_connected(shout);
- 	}
- 	
-diff --git a/include/os.h b/include/os.h
-index 7d065b3..d7ae425 100755
---- a/include/os.h
-+++ b/include/os.h
-@@ -1,7 +1,9 @@
- #ifdef _WIN32
-+#ifndef __MINGW32__
- typedef __int64 int64_t;
- typedef unsigned __int64 uint64_t;
- typedef unsigned __int32 uint32_t;
- typedef __int32 int32_t;
- typedef int  ssize_t;
- #endif
-+#endif
 diff --git a/include/shout/shout.h.in b/include/shout/shout.h.in
-index 43b0e7a..b026c10 100644
+index 682ad49..f412cdc 100644
 --- a/include/shout/shout.h.in
 +++ b/include/shout/shout.h.in
 @@ -23,8 +23,10 @@
@@ -55,5 +28,5 @@
  #define SHOUTERR_SUCCESS	(0)
  #define SHOUTERR_INSANE		(-1)
 -- 
-1.7.1
+1.7.9.2
 
--- a/src/libshout.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libshout.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libshout
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := cabc409e63f55383f4d85fac26d3056bf0365aac
+$(PKG)_CHECKSUM := a6f26441ec27b6f9b55fba38b99bd1d7ca17fecf
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://downloads.us.xiph.org/releases/$(PKG)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc vorbis ogg theora speex
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.icecast.org/download.php' | \
+    $(WGET) -q -O- 'http://www.icecast.org/download.php' | \
     $(SED) -n 's,.*libshout-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,9 +18,9 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-shared \
-        --disable-debug \
         --disable-thread \
         --infodir='$(1)/sink' \
         --mandir='$(1)/sink'
--- a/src/libsigc++.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libsigc++.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libsigc++
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 240d3e0a02e764a6362f6ce1b32de71401e50844
+$(PKG)_CHECKSUM := 493d6e60c08bd8ec3688478d176e04b5713ced2a
 $(PKG)_SUBDIR   := libsigc++-$($(PKG)_VERSION)
-$(PKG)_FILE     := libsigc++-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := libsigc++-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/libsigc++/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libsigc++2/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libsigc++2/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n 's,.*<a[^>]*>\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libsndfile.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libsndfile.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sqlite flac ogg vorbis
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mega-nerd.com/libsndfile/' | \
+    $(WGET) -q -O- 'http://www.mega-nerd.com/libsndfile/' | \
     grep '<META NAME="Version"' | \
     $(SED) -n 's,.*CONTENT="libsndfile-\([0-9][^"]*\)">.*,\1,p' | \
     head -1
--- a/src/libssh2-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libssh2-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -1,32 +1,32 @@
 This file is part of MXE.
 See index.html for further information.
 
-From b3ade9a63e881e69b4c9cfe7b5dbad78dcc4a0e0 Mon Sep 17 00:00:00 2001
-From: Peter Stuge <peter@stuge.se>
-Date: Wed, 1 Feb 2012 09:53:44 +0100
-Subject: [PATCH] Fix undefined reference to _libssh_error in libgcrypt
- backend
+From 6b8a3edae23dc93cc02e6c9572d0796e338ddc4f Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sat, 19 May 2012 10:40:36 +0200
+Subject: [PATCH] libgcrypt does not provide pkg-config support
 
-Commit 209de22299b4b58e582891dfba70f57e1e0492db introduced a function
-call to a non-existing function, and since then the libgcrypt backend
-has not been buildable.
+Commits 04692445d4a32430610ccf8c256e18245cbb3e06
+and e887a8bd0f043fd49e9119756858e75e82dee504 add
+'libgcrypt' to Requires.private of libssh2.pc
+file, but libgcrypt does not provide a .pc file, so
+this does not work.
 ---
- src/libgcrypt.c |    2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
+ configure.ac |    1 -
+ 1 file changed, 1 deletion(-)
 
-diff --git a/src/libgcrypt.c b/src/libgcrypt.c
-index 1bda5ee..5c2787b 100644
---- a/src/libgcrypt.c
-+++ b/src/libgcrypt.c
-@@ -581,7 +581,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
-                           const char *privatekey,
-                           const char *passphrase)
- {
--    return _libssh_error(session, LIBSSH2_ERROR_FILE,
-+    return _libssh2_error(session, LIBSSH2_ERROR_FILE,
-                          "Unable to extract public key from private key file: "
-                          "Method unimplemented in libgcrypt backend");
- }
+diff --git a/configure.ac b/configure.ac
+index aa9d397..0d35a27 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -102,7 +102,6 @@ fi
+ # Look for libgcrypt
+ if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
+   AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
+-  LIBSREQUIRED=libgcrypt
+ fi
+ 
+ AC_SUBST(LIBSREQUIRED)
 -- 
-1.7.8.3
+1.7.9.2
 
--- a/src/libssh2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libssh2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,20 +3,21 @@
 
 PKG             := libssh2
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 53428b4935ab6eb843d45f1593dc434cb287b93e
+$(PKG)_CHECKSUM := 7fc084254dabe14a9bc90fa3d569faa7ee943e19
 $(PKG)_SUBDIR   := libssh2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libssh2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.libssh2.org/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libgcrypt zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.libssh2.org/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.libssh2.org/download/?C=M;O=D' | \
     grep 'libssh2-' | \
     $(SED) -n 's,.*libssh2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
+    cd '$(1)' && ./buildconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
         --disable-shared \
--- a/src/libtool.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libtool.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/libtool/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/libtool/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="libtool-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libunistring.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libunistring.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
+    $(WGET) -q -O- 'http://git.savannah.gnu.org/gitweb/?p=$(PKG).git;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/libusb.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libusb.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/libvpx-1-config.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-# This file is part of MXE.
-# See index.html for further information.
-
-diff --git a/configure b/configure
---- a/configure
-+++ b/configure
-@@ -465,9 +465,6 @@ process_detect() {
-         }
-     fi
-     check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
--    check_ld <<EOF || die "Toolchain is unable to link executables"
--int main(void) {return 0;}
--EOF
-     # check system headers
-     check_header stdint.h
-     check_header pthread.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libvpx-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,154 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+From 0db7805768cb8be8dfe2c95f451fd5965b2b52b7 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 25 May 2012 23:36:41 +0200
+Subject: [PATCH 1/3] add Libs.private to vpx.pc
+
+---
+ libs.mk |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libs.mk b/libs.mk
+index e2ba737..209f77e 100644
+--- a/libs.mk
++++ b/libs.mk
+@@ -242,6 +242,7 @@ vpx.pc: config.mk libs.mk
+ 	$(qexec)echo 'Requires:' >> $@
+ 	$(qexec)echo 'Conflicts:' >> $@
+ 	$(qexec)echo 'Libs: -L$${libdir} -lvpx' >> $@
++	$(qexec)echo 'Libs.private: -lpthread' >> $@
+ 	$(qexec)echo 'Cflags: -I$${includedir}' >> $@
+ INSTALL-LIBS-yes += $(LIBSUBDIR)/pkgconfig/vpx.pc
+ INSTALL_MAPS += $(LIBSUBDIR)/pkgconfig/%.pc %.pc
+-- 
+1.7.9.2
+
+
+From 5805ff3f9f16036b7556d74b2874a6d18ea655fa Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 25 May 2012 23:40:00 +0200
+Subject: [PATCH 2/3] linking as test is not good for cross compiling
+
+---
+ configure |    3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/configure b/configure
+index 62e1ffb..0c4faf9 100755
+--- a/configure
++++ b/configure
+@@ -481,9 +481,6 @@ process_detect() {
+         }
+     fi
+     check_header stdio.h || die "Unable to invoke compiler: ${CC} ${CFLAGS}"
+-    check_ld <<EOF || die "Toolchain is unable to link executables"
+-int main(void) {return 0;}
+-EOF
+     # check system headers
+     check_header stdint.h
+     check_header pthread.h
+-- 
+1.7.9.2
+
+
+From bf308b8ed07f8bf0e9c648314e1f3c070a647731 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Fri, 25 May 2012 23:40:55 +0200
+Subject: [PATCH 3/3] fix bin/bash
+
+---
+ build/make/armlink_adapter.sh |    2 +-
+ build/make/configure.sh       |    2 +-
+ build/make/gen_asm_deps.sh    |    2 +-
+ build/make/gen_msvs_def.sh    |    2 +-
+ build/make/gen_msvs_proj.sh   |    2 +-
+ build/make/gen_msvs_sln.sh    |    2 +-
+ build/make/version.sh         |    2 +-
+ configure                     |    2 +-
+ 8 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/build/make/armlink_adapter.sh b/build/make/armlink_adapter.sh
+index b53669c..71cf7e9 100755
+--- a/build/make/armlink_adapter.sh
++++ b/build/make/armlink_adapter.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/configure.sh b/build/make/configure.sh
+index 3c772e5..032b5e8 100755
+--- a/build/make/configure.sh
++++ b/build/make/configure.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  configure.sh
+ ##
+diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
+index 717f870..81b7095 100755
+--- a/build/make/gen_asm_deps.sh
++++ b/build/make/gen_asm_deps.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_def.sh b/build/make/gen_msvs_def.sh
+index 4defcc2..12e3573 100755
+--- a/build/make/gen_msvs_def.sh
++++ b/build/make/gen_msvs_def.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh
+index 6d42941..4418034 100755
+--- a/build/make/gen_msvs_proj.sh
++++ b/build/make/gen_msvs_proj.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/gen_msvs_sln.sh b/build/make/gen_msvs_sln.sh
+index 240678b..2089f68 100755
+--- a/build/make/gen_msvs_sln.sh
++++ b/build/make/gen_msvs_sln.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/build/make/version.sh b/build/make/version.sh
+index 3efb956..b3a9c23 100755
+--- a/build/make/version.sh
++++ b/build/make/version.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
+ ##
+diff --git a/configure b/configure
+index 0c4faf9..5d1db69 100755
+--- a/configure
++++ b/configure
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ ##
+ ##  configure
+ ##
+-- 
+1.7.9.2
+
--- a/src/libvpx-2-fix-bin-bash.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://code.google.com/p/webm/issues/detail?id=54
-
-diff --git a/build/make/armlink_adapter.sh b/build/make/armlink_adapter.sh
---- a/build/make/armlink_adapter.sh
-+++ b/build/make/armlink_adapter.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/configure.sh b/build/make/configure.sh
---- a/build/make/configure.sh
-+++ b/build/make/configure.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  configure.sh
- ##
-diff --git a/build/make/gen_asm_deps.sh b/build/make/gen_asm_deps.sh
---- a/build/make/gen_asm_deps.sh
-+++ b/build/make/gen_asm_deps.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_def.sh b/build/make/gen_msvs_def.sh
---- a/build/make/gen_msvs_def.sh
-+++ b/build/make/gen_msvs_def.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_proj.sh b/build/make/gen_msvs_proj.sh
---- a/build/make/gen_msvs_proj.sh
-+++ b/build/make/gen_msvs_proj.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/gen_msvs_sln.sh b/build/make/gen_msvs_sln.sh
---- a/build/make/gen_msvs_sln.sh
-+++ b/build/make/gen_msvs_sln.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/build/make/version.sh b/build/make/version.sh
---- a/build/make/version.sh
-+++ b/build/make/version.sh
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
- ##
-diff --git a/configure b/configure
---- a/configure
-+++ b/configure
-@@ -1,4 +1,4 @@
--#!/bin/bash
-+#!/usr/bin/env bash
- ##
- ##  configure
- ##
--- a/src/libvpx.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libvpx.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := libvpx
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2919e11074fef72fc61ef1a75160050ffaad6074
+$(PKG)_CHECKSUM := 356af5f770c50cd021c60863203d8f30164f6021
 $(PKG)_SUBDIR   := $(PKG)-v$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-v$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://webm.googlecode.com/files/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc
+$(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://code.google.com/p/webm/downloads/list?sort=-uploaded' | \
+    $(WGET) -q -O- 'http://code.google.com/p/webm/downloads/list?sort=-uploaded' | \
     $(SED) -n 's,.*libvpx-v\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/libxml++.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libxml++.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libxml2 glibmm
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxml++/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxml++/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/libxml2.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libxml2.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxml2/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxml2/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=v\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/libxslt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/libxslt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libxml2 libgcrypt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/libxslt/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/libxslt/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=v\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/llvm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/llvm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://llvm.org/releases/download.html' | \
+    $(WGET) -q -O- 'http://llvm.org/releases/download.html' | \
     grep 'Download LLVM' | \
     $(SED) -n 's,.*\([0-9]\.[0-9]\).*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-1-gcc.4.4.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,47 @@
+This file is part of MXE.
+See index.html for further information.
+
+These changes have already been applied to log4cxx trunk to update inclusions
+for recent gcc's.
+
+diff -NBaur vanilla/src/examples/cpp/console.cpp mingw_cross/src/examples/cpp/console.cpp
+--- vanilla/src/examples/cpp/console.cpp	2008-04-01 07:34:52.000000000 +0900
++++ mingw_cross/src/examples/cpp/console.cpp	2011-05-09 10:27:52.923808248 +0900
+@@ -15,6 +15,7 @@
+  * limitations under the License.
+  */
+ 
++#include <cstdio>
+ #include <stdlib.h>
+ #include <log4cxx/logger.h>
+ #include <log4cxx/consoleappender.h>
+@@ -22,6 +23,7 @@
+ #include <log4cxx/logmanager.h>
+ #include <iostream>
+ #include <locale.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
+diff -NBaur vanilla/src/main/cpp/inputstreamreader.cpp mingw_cross/src/main/cpp/inputstreamreader.cpp
+--- vanilla/src/main/cpp/inputstreamreader.cpp	2008-04-01 07:34:09.000000000 +0900
++++ mingw_cross/src/main/cpp/inputstreamreader.cpp	2011-05-09 10:27:27.991842868 +0900
+@@ -20,6 +20,7 @@
+ #include <log4cxx/helpers/exception.h>
+ #include <log4cxx/helpers/pool.h>
+ #include <log4cxx/helpers/bytebuffer.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
+diff -NBaur vanilla/src/main/cpp/socketoutputstream.cpp mingw_cross/src/main/cpp/socketoutputstream.cpp
+--- vanilla/src/main/cpp/socketoutputstream.cpp	2008-04-01 07:34:09.000000000 +0900
++++ mingw_cross/src/main/cpp/socketoutputstream.cpp	2011-05-09 10:27:27.999058156 +0900
+@@ -19,6 +19,7 @@
+ #include <log4cxx/helpers/socketoutputstream.h>
+ #include <log4cxx/helpers/socket.h>
+ #include <log4cxx/helpers/bytebuffer.h>
++#include <string.h>
+ 
+ using namespace log4cxx;
+ using namespace log4cxx::helpers;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-2-pkgconfig.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,19 @@
+This file is part of MXE.
+See index.html for further information.
+
+This patch ensures that the correct dependencies can always be found for
+static mingw builds. Submitted upstream: 
+
+   https://issues.apache.org/jira/browse/LOGCXX-381
+
+diff -NBaur vanilla/liblog4cxx.pc.in mingw_cross/liblog4cxx.pc.in
+--- vanilla/liblog4cxx.pc.in	2008-04-01 07:34:52.000000000 +0900
++++ mingw_cross/liblog4cxx.pc.in	2011-05-09 10:31:00.175584637 +0900
+@@ -20,6 +20,7 @@
+ Name: log4cxx
+ Description: log4cxx C++ logging framework
+ Version: @VERSION@
++Requires: apr-util-1, apr-1
+ Libs: -L${libdir} -llog4cxx
+ Cflags: -I${includedir}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-3-warnings.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,20 @@
+This file is part of MXE.
+See index.html for further information.
+
+Already applied to log4cxx trunk.
+
+diff -NBaur vanilla/src/main/include/log4cxx/helpers/objectptr.h mingw_cross/src/main/include/log4cxx/helpers/objectptr.h
+--- vanilla/src/main/include/log4cxx/helpers/objectptr.h	2008-04-01 07:34:26.000000000 +0900
++++ mingw_cross/src/main/include/log4cxx/helpers/objectptr.h	2011-05-09 10:30:03.767560165 +0900
+@@ -28,9 +28,9 @@
+ //   switching between the initialization styles.
+ //
+ #if LOG4CXX_HELGRIND
+-#define _LOG4CXX_OBJECTPTR_INIT(x) { exchange(x); 
++#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x); 
+ #else
+-#define _LOG4CXX_OBJECTPTR_INIT(x) : p(x) {
++#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
+ #endif
+ 
+ namespace log4cxx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-4-mingw.definitions.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,28 @@
+This file is part of MXE.
+See index.html for further information.
+
+Fixes a problem with the mismatched calling conventions in apr and log4cxx.
+See http://www.mail-archive.com/log4cxx-user@logging.apache.org/msg02671.html
+Submitted upstream:
+
+  https://issues.apache.org/jira/browse/LOGCXX-382
+
+diff -NBaur vanilla/src/main/include/log4cxx/helpers/thread.h mingw_cross/src/main/include/log4cxx/helpers/thread.h
+--- vanilla/src/main/include/log4cxx/helpers/thread.h	2008-04-01 07:34:26.000000000 +0900
++++ mingw_cross/src/main/include/log4cxx/helpers/thread.h	2011-05-09 11:08:23.123558232 +0900
+@@ -23,9 +23,13 @@
+ 
+ #if !defined(LOG4CXX_THREAD_FUNC)
+ #if defined(_WIN32)
+-#define LOG4CXX_THREAD_FUNC __stdcall
++  #if defined(__MINGW32__)
++    #define LOG4CXX_THREAD_FUNC
++  #else
++    #define LOG4CXX_THREAD_FUNC __stdcall
++  #endif
+ #else
+-#define LOG4CXX_THREAD_FUNC
++  #define LOG4CXX_THREAD_FUNC
+ #endif
+ #endif
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-5-cmake.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,17 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -NBaur vanilla/log4cxx-config.cmake mingw_cross/log4cxx-config.cmake
+--- vanilla/log4cxx-config.cmake	1970-01-01 09:00:00.000000000 +0900
++++ mingw_cross/log4cxx-config.cmake	2012-03-14 15:29:54.706247316 +0900
+@@ -0,0 +1,10 @@
++
++set(LOG4CXX_VERSION 0.10.0)
++
++get_filename_component(LOG4CXX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
++
++set(LOG4CXX_INCLUDE_DIR "${LOG4CXX_CMAKE_DIR}/../../../include" CACHE FILEPATH "Log4cxx include directory")
++set(LOG4CXX_INCLUDE_DIRS "${LOG4CXX_INCLUDE_DIR}")
++set(LOG4CXX_LIBRARY_DIRS "${LOG4CXX_CMAKE_DIR}/../../../lib")
++set(LOG4CXX_LIBRARIES "log4cxx;aprutil-1;iconv;expat;apr-1;rpcrt4;shell32;ws2_32;advapi32;kernel32;msvcrt")
++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx-test.cpp	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,33 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <cstdlib>
+#include "log4cxx/logger.h"
+#include "log4cxx/basicconfigurator.h"
+#include "log4cxx/helpers/exception.h"
+
+using namespace log4cxx;
+using namespace log4cxx::helpers;
+
+LoggerPtr logger(Logger::getLogger("MXE"));
+
+int main(int argc, char **argv)
+{
+    (void)argc;
+    (void)argv;
+
+    int result = EXIT_SUCCESS;
+    try
+    {
+        BasicConfigurator::configure();
+        LOG4CXX_INFO(logger, "Hello World!");
+    }
+    catch(Exception&)
+    {
+        result = EXIT_FAILURE;
+    }
+
+    return result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/log4cxx.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,37 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := log4cxx
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := d79c053e8ac90f66c5e873b712bb359fd42b648d
+$(PKG)_SUBDIR   := apache-log4cxx-$($(PKG)_VERSION)
+$(PKG)_FILE     := apache-log4cxx-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://apache.naggo.co.kr/logging/log4cxx/0.10.0/$($(PKG)_FILE)
+$(PKG)_URL_2    := http://apache.mirror.cdnetworks.com//logging/log4cxx/0.10.0/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc apr-util
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://logging.apache.org/log4cxx/download.html' | \
+    $(SED) -n 's,.*log4cxx-\([0-9.]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --host='$(TARGET)' \
+        --disable-shared \
+        --enable-static \
+        --with-apr='$(PREFIX)/$(TARGET)' \
+        --with-apr-util='$(PREFIX)/$(TARGET)' \
+        CFLAGS=-D_WIN32_WINNT=0x0500 \
+        CXXFLAGS=-D_WIN32_WINNT=0x0500
+    $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= man_MANS=
+    mkdir -p '$(PREFIX)/$(TARGET)/share/cmake/log4cxx'
+    cp '$(1)/log4cxx-config.cmake' '$(PREFIX)/$(TARGET)/share/cmake/log4cxx/log4cxx-config.cmake'
+
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cpp' -o '$(PREFIX)/$(TARGET)/bin/test-log4cxx.exe' \
+        `$(TARGET)-pkg-config liblog4cxx --libs`
+endef
--- a/src/lua-test.c	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lua-test.c	Wed Jun 13 19:11:14 2012 +0200
@@ -14,7 +14,7 @@
     (void)argc;
     (void)argv;
 
-    L = lua_open();
+    L = luaL_newstate();
     lua_close(L);
     return 0;
 }
--- a/src/lua.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lua.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := lua
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2b11c8e60306efb7f0734b747588f57995493db7
+$(PKG)_CHECKSUM := 08f84c355cdd646f617f09cebea48bd832415829
 $(PKG)_SUBDIR   := lua-$($(PKG)_VERSION)
 $(PKG)_FILE     := lua-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.lua.org/ftp/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.lua.org/download.html' | \
+    $(WGET) -q -O- 'http://www.lua.org/download.html' | \
     $(SED) -n 's,.*lua-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -29,12 +29,9 @@
         TO_BIN='lua.h' \
         INSTALL='$(INSTALL)' \
         install
-    $(SED) -i 's,^prefix=.*,prefix=$(PREFIX)/$(TARGET),' '$(1)/etc/lua.pc'
-    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
-    $(INSTALL) -m644 '$(1)/etc/lua.pc' '$(PREFIX)/$(TARGET)/lib/pkgconfig/lua.pc'
 
     '$(TARGET)-gcc' \
         -W -Wall -Werror -ansi -pedantic \
         '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-lua.exe' \
-        `'$(TARGET)-pkg-config' lua --cflags --libs`
+        -llua
 endef
--- a/src/lzo.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/lzo.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.oberhumer.com/opensource/lzo/download/' | \
+    $(WGET) -q -O- 'http://www.oberhumer.com/opensource/lzo/download/' | \
     grep 'lzo-' | \
     grep -v 'minilzo-' | \
     $(SED) -n 's,.*lzo-\([0-9][^>]*\)\.tar.*,\1,p' | \
--- a/src/matio.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/matio.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/matio/files/matio/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/matio/files/matio/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mdbtools-1-header.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,15 @@
+This file is part of MXE.
+See index.html for further information.
+
+diff -ur mdbtools-0.6pre1-orig//include/mdbtools.h mdbtools-0.6pre1//include/mdbtools.h
+--- mdbtools-0.6pre1-orig//include/mdbtools.h	2011-06-01 00:07:12.336088034 +0900
++++ mdbtools-0.6pre1//include/mdbtools.h	2011-06-01 00:10:51.536088143 +0900
+@@ -147,7 +147,7 @@
+ #define IS_JET3(mdb) (mdb->f->jet_version==MDB_VER_JET3)
+
+ /* hash to store registered backends */
+-extern GHashTable	*mdb_backends;
++static GHashTable	*mdb_backends;
+
+ /* forward declarations */
+ typedef struct mdbindex MdbIndex;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mdbtools.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,26 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# mdbtools
+PKG             := mdbtools
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 37a50d623a444ec690d2677b12b59c2f11e497c0
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mdbtools/files/mdbtools/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --disable-shared \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        PKG_CONFIG='$(PREFIX)/bin/$(TARGET)-pkg-config'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS= html_DATA=
+endef
--- a/src/mingw-utils.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/mingw-utils.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Extension/mingw-utils/' | \
     $(SED) -n 's,.*mingw-utils-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mingwrt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/mingwrt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/mingw-rt/' | \
     $(SED) -n 's,.*mingwrt-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mpfr.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/mpfr.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc gmp
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \
+    $(WGET) -q -O- 'http://www.mpfr.org/mpfr-current/#download' | \
     grep 'mpfr-' | \
     $(SED) -n 's,.*mpfr-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/muparser.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/muparser.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := muparser
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := d6d834d3ba2bd3c316c9b3070369d32701703f78
-$(PKG)_SUBDIR   := $(PKG)_v$(subst .,,$($(PKG)_VERSION))
-$(PKG)_FILE     := $(PKG)_v$(subst .,,$($(PKG)_VERSION)).tar.gz
+$(PKG)_CHECKSUM := 830383b1bcfa706be5a6ac8b7ba43f32f16a1497
+$(PKG)_SUBDIR   := $(PKG)_v$(subst .,_,$($(PKG)_VERSION))
+$(PKG)_FILE     := $(PKG)_v$(subst .,_,$($(PKG)_VERSION)).zip
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/Version $($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/muparser/files/muparser/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/muparser/files/muparser/' | \
     $(SED) -n 's,.*Version%20\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/mxml.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/mxml.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.easysw.com/pub/mxml/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.easysw.com/pub/mxml/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="\([0-9][^"]*\)/.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ncurses.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,35 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# ncurses
+PKG             := ncurses
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 3e042e5f2c7223bffdaac9646a533b8c758b65b5
+$(PKG)_SUBDIR   := ncurses-$($(PKG)_VERSION)
+$(PKG)_FILE     := ncurses-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://ftp.gnu.org/pub/gnu/ncurses/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://ftp.gnu.org/pub/gnu/ncurses/?C=M;O=D' | \
+    $(SED) -n 's,.*<a href="ncurses-\([0-9][^"]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --build="`config.guess`" \
+        --prefix=$(PREFIX)/$(TARGET) \
+        --disable-home-terminfo \
+        --enable-sp-funcs \
+        --enable-term-driver \
+        --enable-interop \
+        --without-debug \
+        --without-ada \
+        --without-manpages \
+        --enable-pc-files \
+        --with-normal \
+        --without-shared
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+endef
--- a/src/nettle.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/nettle.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gmp
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.lysator.liu.se/~nisse/archive/' | \
+    $(WGET) -q -O- 'http://www.lysator.liu.se/~nisse/archive/' | \
     $(SED) -n 's,.*nettle-\([0-9][^>]*\)\.tar.*,\1,p' | \
     grep -v 'pre' | \
     tail -1
--- a/src/nsis.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/nsis.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://nsis.svn.sourceforge.net/viewvc/nsis/NSIS/tags/?sortby=date' | \
+    $(WGET) -q -O- 'http://nsis.svn.sourceforge.net/viewvc/nsis/NSIS/tags/?sortby=date' | \
     grep '<a name="' | \
     $(SED) -n 's,.*<a name="v\([0-9]\)\([^"]*\)".*,\1.\2,p' | \
     head -1
--- a/src/ogg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/ogg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libogg-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/old.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/old.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://blitiri.com.ar/p/old/' | \
+    $(WGET) -q -O- 'http://blitiri.com.ar/p/old/' | \
     grep 'old-' | \
     $(SED) -n 's,.*old-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/openal-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,29 @@
+This file is part of MXE.
+See index.html for further information.
+
+Contains ad hoc patches for cross building.
+
+From b5c7c4853307964f0b8e11e2c9edb5bf0f8511f7 Mon Sep 17 00:00:00 2001
+From: Tony Theodore <tonyt@logyst.com>
+Date: Tue, 3 Apr 2012 14:36:58 +0200
+Subject: [PATCH] add static private dependencies to pkg-config for cmake
+
+---
+ CMakeLists.txt |    1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index ef3d08d..88de1e5 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -543,6 +543,7 @@ IF(DSOUND)
+                 SET(BACKENDS  "${BACKENDS} DirectSound \(linked\),")
+                 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
+             ENDIF()
++            SET(PKG_CONFIG_LIBS "${PKG_CONFIG_LIBS} -luuid -lole32")
+         ENDIF()
+     ENDIF()
+ ENDIF()
+-- 
+1.7.9.2
+
--- a/src/openal-1-luuid-pkg-config.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-
-
-diff -ur openal-soft-1.13.orig/CMakeLists.txt openal-soft-1.13/CMakeLists.txt
---- openal-soft-1.13.orig/CMakeLists.txt	2011-02-16 07:05:40.000000000 +1100
-+++ openal-soft-1.13/CMakeLists.txt	2011-03-02 15:40:02.000000000 +1100
-@@ -393,6 +393,7 @@
-                 SET(BACKENDS  "${BACKENDS} DirectSound \(linked\),")
-                 SET(EXTRA_LIBS dsound ${EXTRA_LIBS})
-             ENDIF()
-+            SET(PKG_CONFIG_LIBS "${PKG_CONFIG_LIBS} -luuid")
-         ENDIF()
-     ENDIF()
- ENDIF()
--- a/src/openal-2-guid-static-link.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-
-
---- openal-soft-1.13.orig/Alc/dsound.c	2011-02-08 01:44:06.000000000 -0500
-+++ openal-soft-1.13/Alc/dsound.c	2011-03-02 22:57:58.000000000 -0500
-@@ -21,7 +21,6 @@
- #include "config.h"
- 
- #define _WIN32_WINNT 0x0500
--#define INITGUID
- #include <stdlib.h>
- #include <stdio.h>
- #include <memory.h>
-@@ -45,8 +44,8 @@
- #define DSSPEAKER_7POINT1       7
- #endif
- 
--DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
--DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
-+const GUID KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010,{0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
-+const GUID KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
- 
- static void *ds_handle;
- static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter);
--- a/src/openal.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/openal.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := openal
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 0e2449375a12cee65a9cea354533dcaabf9d5068
+$(PKG)_CHECKSUM := e6d69db13ec15465b83a45ef89978e8a0f55beca
 $(PKG)_SUBDIR   := openal-soft-$($(PKG)_VERSION)
 $(PKG)_FILE     := openal-soft-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://kcat.strangesoft.net/openal-releases/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc portaudio
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://kcat.strangesoft.net/openal-releases/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://kcat.strangesoft.net/openal-releases/?C=M;O=D' | \
     $(SED) -n 's,.*"openal-soft-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/opencore-amr.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/opencore-amr.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/opencore-amr/files/opencore-amr/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/opencore-amr/files/opencore-amr/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/opencsg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/opencsg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc freeglut glew qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.opencsg.org/#download' | \
+    $(WGET) -q -O- 'http://www.opencsg.org/#download' | \
     grep 'OpenCSG-' | \
     $(SED) -n 's,.*OpenCSG-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/openexr.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/openexr.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc ilmbase pthreads zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openexr.com/downloads.html' | \
+    $(WGET) -q -O- 'http://www.openexr.com/downloads.html' | \
     grep 'openexr-' | \
     $(SED) -n 's,.*openexr-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/openscenegraph.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/openscenegraph.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc curl ffmpeg freetype gdal giflib jasper jpeg libpng openexr tiff xine-lib zlib dcmtk qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags?order=date&desc=1' | \
+    $(WGET) -q -O- 'http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/tags?order=date&desc=1' | \
     grep '<a ' | \
     $(SED) -n 's,.*>OpenSceneGraph-\([0-9][^<]*\)<.*,\1,p' | \
     grep -v '^2\.9\.' | \
--- a/src/openssl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/openssl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := openssl
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a6476d33fd38c2e7dfb438d1e3be178cc242c907
+$(PKG)_CHECKSUM := 91b684de947cb021ac61b8c51027cc4b63d894ce
 $(PKG)_SUBDIR   := openssl-$($(PKG)_VERSION)
 $(PKG)_FILE     := openssl-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.openssl.org/source/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib libgcrypt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.openssl.org/source/' | \
+    $(WGET) -q -O- 'http://www.openssl.org/source/' | \
     $(SED) -n 's,.*openssl-\([0-9][0-9a-z.]*\)\.tar.*,\1,p' | \
     grep -v '^0\.9\.' | \
     head -1
--- a/src/pango-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pango-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -24,7 +24,7 @@
  
  BOOL WINAPI
 -DllMain (HINSTANCE hinstDLL,
-+static _disabled_DllMain (HINSTANCE hinstDLL,
++pango_DllMain (HINSTANCE hinstDLL,
  	 DWORD     fdwReason,
  	 LPVOID    lpvReserved)
  {
--- a/src/pango.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pango.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := pango
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 467a3dacc0f3173e6fd457524b9ccd9772039a62
+$(PKG)_CHECKSUM := f0bf7974ef3e8826fbbb55c0974466ede1e67dd3
 $(PKG)_SUBDIR   := pango-$($(PKG)_VERSION)
-$(PKG)_FILE     := pango-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := pango-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/pango/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc fontconfig freetype cairo glib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/pango/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/pango/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/pangomm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pangomm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc cairomm glibmm pango
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.gnome.org/browse/pangomm/refs/tags' | \
+    $(WGET) -q -O- 'http://git.gnome.org/browse/pangomm/refs/tags' | \
     grep '<a href=' | \
     $(SED) -n "s,.*<a href='[^']*/tag/?id=\\([0-9][^']*\\)'.*,\\1,p" | \
     head -1
--- a/src/pcre.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pcre.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pcre/files/pcre/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pcre/files/pcre/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/pdcurses.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pdcurses.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pdcurses/files/pdcurses/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pdcurses/files/pdcurses/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/pdflib_lite-1-mingw.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pdflib_lite-1-mingw.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -1,12 +1,21 @@
 This file is part of MXE.
 See index.html for further information.
 
+From ad526da840d636da440ce31a6c7f7909ed7ce61c Mon Sep 17 00:00:00 2001
+From: a <a@mxe.cc>
+Date: Mon, 11 Jun 2012 17:27:15 +0200
+Subject: [PATCH 1/2] fix for mingw
+
 This patch has been taken from:
 http://tech.groups.yahoo.com/group/pdflib/message/20472
+---
+ libs/pdcore/pc_util.c |    6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
 
-diff -urN a/libs/pdcore/pc_util.c b/libs/pdcore/pc_util.c
---- a/libs/pdcore/pc_util.c	2010-04-29 15:50:05.000000000 +0200
-+++ b/libs/pdcore/pc_util.c	2010-05-11 23:59:03.915954995 +0200
+diff --git a/libs/pdcore/pc_util.c b/libs/pdcore/pc_util.c
+index e8d8fec..f874bad 100644
+--- a/libs/pdcore/pc_util.c
++++ b/libs/pdcore/pc_util.c
 @@ -30,8 +30,12 @@
  #include <ieeefp.h>     /* for finite */
  #endif
@@ -21,3 +30,32 @@
  #else /* isfinite */
  
  #if defined(WIN32)
+-- 
+1.7.10.3
+
+
+From 315d17f1b6d050df824a26418b191ca38ebd4602 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Mon, 11 Jun 2012 17:33:04 +0200
+Subject: [PATCH 2/2] force mingw detection
+
+---
+ configure.in |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.in b/configure.in
+index 3944168..de6ec09 100644
+--- a/configure.in
++++ b/configure.in
+@@ -98,7 +98,7 @@ then
+ 	ac_sys_system=next && ac_sys_release=$4
+ 	MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
+     else
+-	ac_sys_system=`uname -s`
++	ac_sys_system=MinGW
+ 	if test "$ac_sys_system" = "AIX" ; then
+ 		ac_sys_release=`uname -v`
+ 	else
+-- 
+1.7.10.3
+
--- a/src/pdflib_lite.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pdflib_lite.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,22 +3,24 @@
 
 PKG             := pdflib_lite
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 5b2bf5edc49dba3da0997ade0e191511a37fae01
+$(PKG)_CHECKSUM := 42e0605ae21f4b6d25fa2d20e78fed6df36fbaa9
 $(PKG)_SUBDIR   := PDFlib-Lite-$($(PKG)_VERSION)
 $(PKG)_FILE     := PDFlib-Lite-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.pdflib.com/binaries/PDFlib/$(subst .,,$(word 1,$(subst p, ,$($(PKG)_VERSION))))/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.pdflib.com/download/free-software/pdflib-lite-7/' | \
+    $(WGET) -q -O- 'http://www.pdflib.com/download/free-software/pdflib-lite-7/' | \
     $(SED) -n 's,.*PDFlib-Lite-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i 's,ac_sys_system=`uname -s`,ac_sys_system=MinGW,' '$(1)/configure'
+    cd '$(1)' && aclocal -I config --install
+    cd '$(1)' && autoconf
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --without-openssl \
@@ -27,7 +29,6 @@
         --without-perl \
         --without-ruby \
         --without-tcl \
-        --disable-php \
         --enable-cxx \
         --enable-large-files \
         CFLAGS='-D_IOB_ENTRIES=20'
--- a/src/pfstools.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pfstools.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/pfstools/files/pfstools/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/pfstools/files/pfstools/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/physfs.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/physfs.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://icculus.org/physfs/downloads/?M=D' | \
+    $(WGET) -q -O- 'http://icculus.org/physfs/downloads/?M=D' | \
     $(SED) -n 's,.*<a href="physfs-\([0-9][^"]*\)\.tar.*,\1,pI' | \
     head -1
 endef
--- a/src/pixman.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pixman.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := pixman
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 2785cedd25fb6ded0ceac8d427432f16b074dd52
+$(PKG)_CHECKSUM := ebd1b438a28aca0099777b1e383c60d4fcb88196
 $(PKG)_SUBDIR   := pixman-$($(PKG)_VERSION)
 $(PKG)_FILE     := pixman-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://cairographics.org/snapshots/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://cairographics.org/snapshots/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://cairographics.org/snapshots/?C=M;O=D' | \
     $(SED) -n 's,.*"pixman-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/plotmm.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/plotmm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc gtkmm2
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/plotmm/files/plotmm/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/plotmm/files/plotmm/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/plotutils.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/plotutils.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libpng pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://ftp.gnu.org/gnu/plotutils/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://ftp.gnu.org/gnu/plotutils/?C=M;O=D' | \
     grep '<a href="plotutils-' | \
     $(SED) -n 's,.*plotutils-\([0-9][^<]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/poco.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/poco.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://pocoproject.org/download/' | \
+    $(WGET) -q -O- 'http://pocoproject.org/download/' | \
     $(SED) -n 's,.*poco-\([0-9][^>/]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -20,7 +20,7 @@
         --config=MinGW-CrossEnv \
         --static \
         --prefix='$(PREFIX)/$(TARGET)'
-    $(MAKE) -C '$(1)' -j '$(JOBS)' install
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install CROSSENV=$(TARGET)
 
     '$(TARGET)-g++' \
         -W -Wall -Werror -ansi -pedantic \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler-1-win32.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,243 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 991d23243522e1ae2bd8efd279032792681f3789 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 09:29:25 +0200
+Subject: [PATCH 1/4] Fix Standard-14 fallback fonts
+
+wingding.ttf is totally different from ZapfDingbats. symbol.ttf is only a lousy fallback for Symbol.
+Based on patch provided by Jonathan Kew.
+Proposed upstream at https://bugs.freedesktop.org/show_bug.cgi?id=49037
+---
+ poppler/GlobalParamsWin.cc |    6 +++++-
+ 1 files changed, 5 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index f989fb8..b15773f 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -73,13 +73,17 @@ static struct {
+     {"Helvetica-BoldOblique", "n019024l.pfb", "arialbi.ttf"},
+     {"Helvetica-Oblique",     "n019023l.pfb", "ariali.ttf"},
+     // TODO: not sure if "symbol.ttf" is right
++    // "symbol.ttf" can be used as a fallback, but some symbols are differently
++    // encoded (e.g., the glyphs for 'f', 'j', 'v'), while most other glyphs
++    // have a fairly different appearance
+     {"Symbol",                "s050000l.pfb", "symbol.ttf"},
+     {"Times-Bold",            "n021004l.pfb", "timesbd.ttf"},
+     {"Times-BoldItalic",      "n021024l.pfb", "timesbi.ttf"},
+     {"Times-Italic",          "n021023l.pfb", "timesi.ttf"},
+     {"Times-Roman",           "n021003l.pfb", "times.ttf"},
+     // TODO: not sure if "wingding.ttf" is right
+-    {"ZapfDingbats",          "d050000l.pfb", "wingding.ttf"},
++    // No, the symbol sets are totally different
++    {"ZapfDingbats",          "d050000l.pfb", NULL},
+ 
+     // those seem to be frequently accessed by PDF files and I kind of guess
+     // which font file do the refer to
+-- 
+1.7.5.4
+
+
+From 482782fa1951c8c75636918fb45c90f3f329bf86 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 09:34:46 +0200
+Subject: [PATCH 2/4] Only check for Type1 fonts in custom directory if path
+ is non-NULL
+
+Otherwise, programs using poppler may crash
+Proposed upstream at https://bugs.freedesktop.org/show_bug.cgi?id=49037
+---
+ poppler/GlobalParamsWin.cc |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index b15773f..f68577f 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -243,7 +243,7 @@ void GlobalParams::setupBaseFonts(char * dir)
+         if (displayFonts->lookup(fontName))
+             continue;
+ 
+-        if (dir) {
++        if (dir && displayFontTab[i].t1FileName) {
+             GooString *fontPath = appendToPath(new GooString(dir), displayFontTab[i].t1FileName);
+             if (FileExists(fontPath->getCString())) {
+                 AddFont(displayFonts, fontName, fontPath, displayFontT1);
+-- 
+1.7.5.4
+
+
+From 7f01e803b134d01a72f6912d088d7887eba0df08 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 11:57:02 +0200
+Subject: [PATCH 3/4] Allow custom substitution fonts on Windows
+
+Standard-compliant PDF viewers must be able to handle 14 standard fonts even if they are not embedded. For the Symbol and ZapfDingbats fonts, there is no suitable alternative available on Windows by default, so they must be provided separately (and poppler must find them).
+
+The search path is share/fonts/type1/gsfonts (relative to poppler) similar to *nix systems and the search path for poppler-data.
+Proposed upstream at https://bugs.freedesktop.org/show_bug.cgi?id=49037
+---
+ poppler/GlobalParams.cc    |   31 +++++++++++++++++++++++++++++++
+ poppler/GlobalParamsWin.cc |    2 +-
+ 2 files changed, 32 insertions(+), 1 deletions(-)
+
+diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc
+index 687fd25..eea60be 100644
+--- a/poppler/GlobalParams.cc
++++ b/poppler/GlobalParams.cc
+@@ -214,6 +214,37 @@ get_poppler_datadir (void)
+ 
+ #ifdef _WIN32
+ 
++static char *
++get_poppler_fontdir (void)
++{
++#if !ENABLE_RELOCATABLE
++  static HMODULE hmodule = 0;
++#endif
++  static char retval[MAX_PATH];
++  static int beenhere = 0;
++
++  unsigned char *p;
++
++  if (beenhere)
++    return retval;
++
++  if (!GetModuleFileName (hmodule, (CHAR *) retval, sizeof(retval) - 32))
++    return NULL;
++
++  p = _mbsrchr ((unsigned char *) retval, '\\');
++  *p = '\0';
++  p = _mbsrchr ((unsigned char *) retval, '\\');
++  if (p) {
++    if (stricmp ((const char *) (p+1), "bin") == 0)
++      *p = '\0';
++  }
++  strcat (retval, "\\share\\fonts\\type1\\gsfonts");
++
++  beenhere = 1;
++
++  return retval;
++}
++
+ //------------------------------------------------------------------------
+ // WinFontInfo
+ //------------------------------------------------------------------------
+diff --git a/poppler/GlobalParamsWin.cc b/poppler/GlobalParamsWin.cc
+index f68577f..3ee75e4 100644
+--- a/poppler/GlobalParamsWin.cc
++++ b/poppler/GlobalParamsWin.cc
+@@ -281,7 +281,7 @@ DisplayFontParam *GlobalParams::getDisplayFont(GfxFont *font) {
+ 
+     if (!fontName) return NULL;
+     lockGlobalParams;
+-    setupBaseFonts(NULL);
++    setupBaseFonts(get_poppler_fontdir());
+     dfp = (DisplayFontParam *)displayFonts->lookup(fontName);
+     if (!dfp) {
+         substFontName = findSubstituteName(fontName->getCString());
+-- 
+1.7.5.4
+
+
+From e000aafa7dec5441d072158814fa35631c5a9c52 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20L=C3=B6ffler?= <st.loeffler@gmail.com>
+Date: Sat, 21 Apr 2012 13:19:54 +0200
+Subject: [PATCH 4/4] Don't use dllimport/dllexport
+
+Otherwise static linking fails
+MXE workaround for https://bugs.freedesktop.org/show_bug.cgi?id=49038 (presumably would break shared linking!)
+---
+ cpp/poppler-global.h     |    5 -----
+ poppler/XpdfPluginAPI.h  |   18 ------------------
+ qt4/src/poppler-export.h |    5 -----
+ 3 files changed, 0 insertions(+), 28 deletions(-)
+
+diff --git a/cpp/poppler-global.h b/cpp/poppler-global.h
+index 5650182..6c3e01b 100644
+--- a/cpp/poppler-global.h
++++ b/cpp/poppler-global.h
+@@ -20,13 +20,8 @@
+ #ifndef POPPLER_GLOBAL_H
+ #define POPPLER_GLOBAL_H
+ 
+-#if defined(_WIN32)
+-#  define LIB_EXPORT __declspec(dllexport)
+-#  define LIB_IMPORT __declspec(dllimport)
+-#else
+ #  define LIB_EXPORT
+ #  define LIB_IMPORT
+-#endif
+ 
+ #if defined(poppler_cpp_EXPORTS)
+ #  define POPPLER_CPP_EXPORT LIB_EXPORT
+diff --git a/poppler/XpdfPluginAPI.h b/poppler/XpdfPluginAPI.h
+index 22540f7..290aa63 100644
+--- a/poppler/XpdfPluginAPI.h
++++ b/poppler/XpdfPluginAPI.h
+@@ -28,19 +28,11 @@ extern "C" {
+  */
+ #define xpdfPluginAPIVersion 1
+ 
+-#ifdef _WIN32
+-#  ifdef __cplusplus
+-#    define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
+-#  else
+-#    define PLUGINFUNC(retType) extern __declspec(dllexport) retType
+-#  endif
+-#else
+ #  ifdef __cplusplus
+ #    define PLUGINFUNC(retType) extern "C" retType
+ #  else
+ #    define PLUGINFUNC(retType) extern retType
+ #  endif
+-#endif
+ 
+ /*------------------------------------------------------------------------
+  * Plugin setup/cleanup
+@@ -285,22 +277,12 @@ void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
+ 
+ } XpdfPluginVecTable;
+ 
+-#ifdef _WIN32
+-
+-extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
+-
+-#define xpdfPluginSetup \
+-  extern __declspec(dllexport) \
+-  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+-
+-#else
+ 
+ extern XpdfPluginVecTable xpdfPluginVecTable;
+ 
+ #define xpdfPluginSetup \
+   XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
+ 
+-#endif
+ 
+ #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
+ #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
+diff --git a/qt4/src/poppler-export.h b/qt4/src/poppler-export.h
+index 7661fe9..ebb1e18 100644
+--- a/qt4/src/poppler-export.h
++++ b/qt4/src/poppler-export.h
+@@ -2,13 +2,8 @@
+ * This file is used to set the poppler_qt4_EXPORT macros right.
+ * This is needed for setting the visibility on windows, it will have no effect on other platforms.
+ */
+-#if defined(_WIN32)
+-# define LIB_EXPORT __declspec(dllexport)
+-# define LIB_IMPORT __declspec(dllimport)
+-#else
+ # define LIB_EXPORT
+ # define LIB_IMPORT
+-#endif
+ 
+ #ifdef poppler_qt4_EXPORTS
+ # define POPPLER_QT4_EXPORT LIB_EXPORT
+-- 
+1.7.5.4
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler-test.cxx	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,12 @@
+#include <iostream>
+#include <cpp/poppler-version.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    std::cout << "Poppler version: " << poppler::version_string() << std::endl;
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/poppler.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,58 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := poppler
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 3753caecba71afaf29f097e0b9c52e0f83a10a59
+$(PKG)_SUBDIR   := poppler-$($(PKG)_VERSION)
+$(PKG)_FILE     := poppler-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://poppler.freedesktop.org/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc glib cairo libpng lcms jpeg tiff freetype zlib curl qt
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://poppler.freedesktop.org/' | \
+    $(SED) -n 's,.*"poppler-\([0-9.]\+\)\.tar\.gz".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # Note: Specifying LIBS explicitly is necessary for configure to properly
+    #       pick up libtiff (otherwise linking a minimal test program fails not
+    #       because libtiff is not found, but because some references are
+    #       undefined)
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --disable-silent-rules \
+        --disable-shared \
+        --enable-static \
+        --enable-xpdf-headers \
+        --enable-poppler-qt4 \
+        --enable-zlib \
+        --enable-libcurl \
+        --enable-libtiff \
+        --enable-libjpeg \
+        --enable-libpng \
+        --enable-poppler-glib \
+        --enable-poppler-cpp \
+        --enable-cairo-output \
+        --enable-splash-output \
+        --enable-compile-warnings=yes \
+        --enable-introspection=auto \
+        --disable-libopenjpeg \
+        --disable-gtk-test \
+        --disable-utils \
+        --disable-gtk-doc \
+        --disable-gtk-doc-html \
+        --disable-gtk-doc-pdf \
+        --with-font-configuration=win32 \
+        LIBS="`'$(TARGET)-pkg-config' zlib liblzma --libs` -ljpeg"
+    $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
+
+    # Test program
+    '$(TARGET)-g++' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).cxx' -o '$(PREFIX)/$(TARGET)/bin/test-poppler.exe' \
+        `'$(TARGET)-pkg-config' poppler poppler-cpp --cflags --libs`
+endef
+
--- a/src/popt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/popt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libiconv gettext
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://rpm5.org/files/popt/' | \
+    $(WGET) -q -O- 'http://rpm5.org/files/popt/' | \
     grep 'popt-' | \
     $(SED) -n 's,.*popt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
--- a/src/portaudio.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/portaudio.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.portaudio.com/download.html' | \
+    $(WGET) -q -O- 'http://www.portaudio.com/download.html' | \
     $(SED) -n 's,.*pa_stable_v\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/postgresql-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/postgresql-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,17 @@
 
 Contains ad hoc patches for cross building.
 
-From 7985f049ed030c1f49927828a4b8e3d7552e52a4 Mon Sep 17 00:00:00 2001
-From: MXE
+From 43bdcd7403f7e58f4da47a84a324ee02f80ba4c9 Mon Sep 17 00:00:00 2001
+From: "a@a.org" <a@a.org>
 Date: Mon, 24 Oct 2011 14:02:33 +0200
-Subject: [PATCH 1/2] use unix style names for openssl on MXE
+Subject: [PATCH 1/2] use unix style names for openssl on mingw-cross-env
 
+---
+ configure.in |    9 ++-------
+ 1 file changed, 2 insertions(+), 7 deletions(-)
 
 diff --git a/configure.in b/configure.in
-index 7c0e94e..2ee79c7 100644
+index ff0063d..c64b88e 100644
 --- a/configure.in
 +++ b/configure.in
 @@ -943,13 +943,8 @@ fi
@@ -30,22 +33,25 @@
  
  if test "$with_pam" = yes ; then
 -- 
-1.7.9
+1.7.9.2
 
 
-From 9471812a4e7021fea291469d636bdeca6078c1e5 Mon Sep 17 00:00:00 2001
-From: MXE
+From fc01a0853f56b3ce377e0b5fd461e3ee8a89877d Mon Sep 17 00:00:00 2001
+From: "a@a.org" <a@a.org>
 Date: Mon, 24 Oct 2011 14:09:38 +0200
 Subject: [PATCH 2/2] do not check autoconf version
 
+---
+ configure.in |    4 ----
+ 1 file changed, 4 deletions(-)
 
 diff --git a/configure.in b/configure.in
-index 2ee79c7..102b95b 100644
+index c64b88e..ee52a70 100644
 --- a/configure.in
 +++ b/configure.in
 @@ -19,10 +19,6 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
  
- AC_INIT([PostgreSQL], [9.1.3], [pgsql-bugs@postgresql.org])
+ AC_INIT([PostgreSQL], [9.1.4], [pgsql-bugs@postgresql.org])
  
 -m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.63], [], [m4_fatal([Autoconf version 2.63 is required.
 -Untested combinations of 'autoconf' and PostgreSQL versions are not
@@ -55,5 +61,5 @@
  AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
  AC_CONFIG_AUX_DIR(config)
 -- 
-1.7.9
+1.7.9.2
 
--- a/src/postgresql.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/postgresql.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := postgresql
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 1cf3044415df807c08bb8ad8e40e24e8d375cf34
+$(PKG)_CHECKSUM := c75fd5696af02a275a104260eac8b3a4abe35682
 $(PKG)_SUBDIR   := postgresql-$($(PKG)_VERSION)
 $(PKG)_FILE     := postgresql-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://ftp.postgresql.org/pub/source/v$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib openssl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.postgresql.org/gitweb?p=postgresql.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.postgresql.org/gitweb?p=postgresql.git;a=tags' | \
     grep 'refs/tags/REL9[0-9_]*"' | \
     $(SED) 's,.*refs/tags/REL\(.*\)".*,\1,g;' | \
     $(SED) 's,_,.,g' | \
--- a/src/proj.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/proj.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://trac.osgeo.org/proj/' | \
+    $(WGET) -q -O- 'http://trac.osgeo.org/proj/' | \
     $(SED) -n 's,.*proj-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/pthreads-1-autostatic.patch	Wed Jun 13 02:35:57 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-This file is part of MXE.
-See index.html for further information.
-
-This patch has been taken from:
-http://sourceware.org/ml/pthreads-win32/2010/msg00006.html
-
-diff -ur pthreads-win32-20091019.orig/GNUmakefile pthreads-win32-20091019/GNUmakefile
---- pthreads-win32-20091019.orig/GNUmakefile	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/GNUmakefile	2010-02-01 14:45:28.471432337 -0200
-@@ -63,7 +63,6 @@
- XOPT	=
- 
- RCFLAGS		= --include-dir=.
--LFLAGS		= -lwsock32
- 
- # ----------------------------------------------------------------------
- # The library can be built with some alternative behaviour to
-diff -ur pthreads-win32-20091019.orig/pthread.c pthreads-win32-20091019/pthread.c
---- pthreads-win32-20091019.orig/pthread.c	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread.c	2010-02-01 14:26:48.601487556 -0200
-@@ -49,6 +49,7 @@
- #include "condvar.c"
- #include "create.c"
- #include "dll.c"
-+#include "autostatic.c"
- #include "errno.c"
- #include "exit.c"
- #include "fork.c"
-diff -ur pthreads-win32-20091019.orig/pthread_getspecific.c pthreads-win32-20091019/pthread_getspecific.c
---- pthreads-win32-20091019.orig/pthread_getspecific.c	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread_getspecific.c	2010-02-01 14:28:36.603981857 -0200
-@@ -72,12 +72,10 @@
-   else
-     {
-       int lasterror = GetLastError ();
--      int lastWSAerror = WSAGetLastError ();
- 
-       ptr = TlsGetValue (key->key);
- 
-       SetLastError (lasterror);
--      WSASetLastError (lastWSAerror);
-     }
- 
-   return ptr;
-diff -ur pthreads-win32-20091019.orig/pthread.h pthreads-win32-20091019/pthread.h
---- pthreads-win32-20091019.orig/pthread.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/pthread.h	2010-02-02 16:51:05.047931915 -0200
-@@ -533,7 +533,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
-diff -ur pthreads-win32-20091019.orig/sched.h pthreads-win32-20091019/sched.h
---- pthreads-win32-20091019.orig/sched.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/sched.h	2010-02-02 16:51:00.665887720 -0200
-@@ -76,7 +76,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
-diff -ur pthreads-win32-20091019.orig/semaphore.h pthreads-win32-20091019/semaphore.h
---- pthreads-win32-20091019.orig/semaphore.h	2009-10-19 08:07:32.000000000 -0200
-+++ pthreads-win32-20091019/semaphore.h	2010-02-02 16:50:45.916576916 -0200
-@@ -75,7 +75,7 @@
-  * do NOT define PTW32_BUILD, and then the variables/functions will
-  * be imported correctly.
-  */
--#ifndef PTW32_STATIC_LIB
-+#if !defined(PTW32_STATIC_LIB) && !defined(__MINGW32__)
- #  ifdef PTW32_BUILD
- #    define PTW32_DLLPORT __declspec (dllexport)
- #  else
---- /dev/null	2010-01-29 12:57:37.677072272 -0200
-+++ pthreads-win32-20091019/autostatic.c	2010-02-01 14:26:48.601487556 -0200
-@@ -0,0 +1,67 @@
-+/*
-+ * autostatic.c
-+ *
-+ * Description:
-+ * This translation unit implements static library initialisation.
-+ *
-+ * --------------------------------------------------------------------------
-+ *
-+ *      Pthreads-win32 - POSIX Threads Library for Win32
-+ *      Copyright(C) 1998 John E. Bossom
-+ *      Copyright(C) 1999,2005 Pthreads-win32 contributors
-+ * 
-+ *      Contact Email: rpj@callisto.canberra.edu.au
-+ * 
-+ *      The current list of contributors is contained
-+ *      in the file CONTRIBUTORS included with the source
-+ *      code distribution. The list can also be seen at the
-+ *      following World Wide Web location:
-+ *      http://sources.redhat.com/pthreads-win32/contributors.html
-+ * 
-+ *      This library is free software; you can redistribute it and/or
-+ *      modify it under the terms of the GNU Lesser General Public
-+ *      License as published by the Free Software Foundation; either
-+ *      version 2 of the License, or (at your option) any later version.
-+ * 
-+ *      This library is distributed in the hope that it will be useful,
-+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
-+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-+ *      Lesser General Public License for more details.
-+ * 
-+ *      You should have received a copy of the GNU Lesser General Public
-+ *      License along with this library in the file COPYING.LIB;
-+ *      if not, write to the Free Software Foundation, Inc.,
-+ *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
-+ */
-+
-+#ifdef PTW32_STATIC_LIB
-+
-+#include "pthread.h"
-+#include "implement.h"
-+
-+static void on_process_init(void)
-+{
-+    pthread_win32_process_attach_np ();
-+}
-+
-+static void on_process_exit(void)
-+{
-+    pthread_win32_thread_detach_np  ();
-+    pthread_win32_process_detach_np ();
-+}
-+
-+#ifdef __MINGW32__
-+#    define attribute_section(a) __attribute__((section(a)))
-+#elif defined(_MSC_VER)
-+#    define attribute_section(a) __pragma(section(a,long,read)); __declspec(allocate(a))
-+#else
-+#error compiler not supported!
-+#endif
-+
-+attribute_section(".CRT$XCU") void *msc_ctor = on_process_init;
-+attribute_section(".CRT$XPU") void *msc_dtor = on_process_exit;
-+
-+attribute_section(".ctors"  ) void *gcc_ctor = on_process_init;
-+attribute_section(".dtors"  ) void *gcc_dtor = on_process_exit;
-+
-+#endif /* PTW32_STATIC_LIB */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pthreads-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,62 @@
+This file is part of MXE.
+See index.html for further information.
+
+From e951f784c852f4cd8298864190936fded1efceba Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 22:00:19 +0200
+Subject: [PATCH] force static for convenience
+
+---
+ pthread.h   |    4 ++++
+ sched.h     |    4 ++++
+ semaphore.h |    4 ++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/pthread.h b/pthread.h
+index b4072f7..c88c886 100755
+--- a/pthread.h
++++ b/pthread.h
+@@ -547,6 +547,10 @@ extern "C"
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+diff --git a/sched.h b/sched.h
+index f36a97a..1f4f401 100755
+--- a/sched.h
++++ b/sched.h
+@@ -76,6 +76,10 @@
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+diff --git a/semaphore.h b/semaphore.h
+index c6e9407..2b64173 100755
+--- a/semaphore.h
++++ b/semaphore.h
+@@ -75,6 +75,10 @@
+  * do NOT define PTW32_BUILD, and then the variables/functions will
+  * be imported correctly.
+  */
++
++// MXE: Set this for convenience here since MXE only does static.
++#define PTW32_STATIC_LIB
++
+ #if !defined(PTW32_STATIC_LIB)
+ #  if defined(PTW32_BUILD)
+ #    define PTW32_DLLPORT __declspec (dllexport)
+-- 
+1.7.9.2
+
--- a/src/pthreads.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/pthreads.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,24 +3,20 @@
 
 PKG             := pthreads
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := da8371cb20e8e238f96a1d0651212f154d84a9ac
+$(PKG)_CHECKSUM := 24d40e89c2e66a765733e8c98d6f94500343da86
 $(PKG)_SUBDIR   := pthreads-w32-$($(PKG)_VERSION)-release
 $(PKG)_FILE     := pthreads-w32-$($(PKG)_VERSION)-release.tar.gz
 $(PKG)_URL      := ftp://sourceware.org/pub/pthreads-win32/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'ftp://sourceware.org/pub/pthreads-win32/Release_notes' | \
+    $(WGET) -q -O- 'ftp://sourceware.org/pub/pthreads-win32/Release_notes' | \
     $(SED) -n 's,^RELEASE \([0-9][^[:space:]]*\).*,\1,p' | \
     tr '.' '-' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    $(SED) -i '35i\#define PTW32_STATIC_LIB' '$(1)/pthread.h'
-    $(SED) -i '41i\#define PTW32_STATIC_LIB' '$(1)/sched.h'
-    $(SED) -i '41i\#define PTW32_STATIC_LIB' '$(1)/semaphore.h'
-    $(SED) -i 's,#include "config.h",,'      '$(1)/pthread.h'
     $(MAKE) -C '$(1)' -j 1 GC-static CROSS='$(TARGET)-'
     $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib'
     $(INSTALL) -m644 '$(1)/libpthreadGC2.a' '$(PREFIX)/$(TARGET)/lib/libpthread.a'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qdbm-test.c	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,51 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ *
+ * Taken from examples at http://fallabs.com/qdbm/spex.html
+ */
+
+#include <depot.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#define NAME     "mikio"
+#define NUMBER   "000-1234-5678"
+#define DBNAME   "book"
+
+int main(int argc, char **argv){
+    DEPOT *depot;
+    char *val;
+
+    (void)argc;
+    (void)argv;
+
+    /* open the database */
+    if(!(depot = dpopen(DBNAME, DP_OWRITER | DP_OCREAT, -1))){
+        fprintf(stderr, "dpopen: %s\n", dperrmsg(dpecode));
+        return 1;
+    }
+
+    /* store the record */
+    if(!dpput(depot, NAME, -1, NUMBER, -1, DP_DOVER)){
+        fprintf(stderr, "dpput: %s\n", dperrmsg(dpecode));
+    }
+
+    /* retrieve the record */
+    if(!(val = dpget(depot, NAME, -1, 0, -1, NULL))){
+        fprintf(stderr, "dpget: %s\n", dperrmsg(dpecode));
+    }
+    else {
+        printf("Name: %s\n", NAME);
+        printf("Number: %s\n", val);
+        free(val);
+    }
+
+    /* close the database */
+    if(!dpclose(depot)){
+        fprintf(stderr, "dpclose: %s\n", dperrmsg(dpecode));
+        return 1;
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qdbm.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,44 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := qdbm
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := 8c2ab938c2dad8067c29b0aa93efc6389f0e7076
+$(PKG)_SUBDIR   := qdbm-$($(PKG)_VERSION)
+$(PKG)_FILE     := qdbm-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://fallabs.com/qdbm/qdbm-1.8.78.tar.gz
+$(PKG)_DEPS     := gcc bzip2 libiconv lzo zlib
+
+define $(PKG)_UPDATE
+    wget -q -O- 'http://fallabs.com/qdbm/' | \
+    grep 'qdbm-' | \
+    $(SED) -n 's,.*qdbm-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --enable-lzo \
+        --enable-bzip \
+        --enable-zlib \
+        --enable-iconv
+    $(MAKE) -C '$(1)' -j '$(JOBS)' \
+        static \
+        MYBINS= \
+        MYLIBS=libqdbm.a \
+        AR=i686-pc-mingw32-ar \
+        RANLIB=i686-pc-mingw32-ranlib
+    $(INSTALL) -d '$(PREFIX)/$(TARGET)/lib/pkgconfig'
+    $(INSTALL) -m644 '$(1)/libqdbm.a' '$(PREFIX)/$(TARGET)/lib/'
+    $(INSTALL) -m644 '$(1)/qdbm.pc'   '$(PREFIX)/$(TARGET)/lib/pkgconfig/'
+    $(INSTALL) -d '$(PREFIX)/$(TARGET)/include'
+    cd '$(1)' && $(INSTALL) -m644 depot.h curia.h relic.h hovel.h \
+        cabin.h villa.h vista.h odeum.h '$(PREFIX)/$(TARGET)/include/'
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-qdbm.exe' \
+        `'$(TARGET)-pkg-config' qdbm --cflags --libs`
+endef
--- a/src/qjson.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/qjson.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc qt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/qjson/files/qjson/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/qjson/files/qjson/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/qt-1-cherrypicks.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/qt-1-cherrypicks.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -5,10 +5,10 @@
 http://qt.gitorious.org/qt
 Also contains MXE specific fixes.
 
-From 16a4f14e8e879a14ae5db47d0731c9199c01a816 Mon Sep 17 00:00:00 2001
+From c9337a775daa3a53426403fdc6984656c0e08c29 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 13 Jan 2012 00:17:48 +0100
-Subject: [PATCH 01/17] remove trailing whitespace
+Subject: [PATCH 01/15] remove trailing whitespace
 
 backported from qt5/qtbase
 Change-Id: If53a0bd1794e69b4856f993c6e2959369bd007d6
@@ -19,7 +19,7 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 6bc2fa6..9b7967d 100644
+index 9090773..859ec8d 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -42,7 +42,7 @@ unix {
@@ -35,10 +35,10 @@
 1.7.9.2
 
 
-From 162708efc51e40ed59d4e3397d399920c21d03a6 Mon Sep 17 00:00:00 2001
+From 2afee6408f010376ede9f58aaee1fe4e23aa116d Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 30 Jun 2011 10:22:33 +0200
-Subject: [PATCH 02/17] do not detect or configure iconv for Windows
+Subject: [PATCH 02/15] do not detect or configure iconv for Windows
 
 Qt doesn't use iconv on Windows, but configuring it will appear to
 work and the build will complete. The result is that character
@@ -56,10 +56,10 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/configure b/configure
-index a706908..0690822 100755
+index c1667b6..862aad5 100755
 --- a/configure
 +++ b/configure
-@@ -5600,7 +5600,7 @@ fi
+@@ -5627,7 +5627,7 @@ fi
  
  # auto-detect iconv(3) support
  if [ "$CFG_ICONV" != "no" ]; then
@@ -72,10 +72,10 @@
 1.7.9.2
 
 
-From dd34e052a555203b2bfb415bd0ce348ef232aa7e Mon Sep 17 00:00:00 2001
+From f66200e240a3664dd62beb9eb8aa38efdecfddb1 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Wed, 18 Jan 2012 11:43:10 +0100
-Subject: [PATCH 03/17] fix whitespace
+Subject: [PATCH 03/15] fix whitespace
 
 backported from qt5/qtbase
 Change-Id: I0cfccae085c000d4368386a34f288c1e6f01a88f
@@ -86,7 +86,7 @@
  1 file changed, 16 insertions(+), 17 deletions(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 9b7967d..836cc34 100644
+index 859ec8d..70cd890 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -1,23 +1,23 @@
@@ -149,10 +149,10 @@
 1.7.9.2
 
 
-From 7f2e5f5e4bc740446f0160ae3246907fa4f6dc2f Mon Sep 17 00:00:00 2001
+From a82277bac5c8ac6fa43577bcc9642534714c91fb Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 4 Jul 2011 00:42:24 +0200
-Subject: [PATCH 04/17] build and load text codecs regardless of iconv and
+Subject: [PATCH 04/15] build and load text codecs regardless of iconv and
  platform
 
 Otherwise applications linking to static Qt may have to import
@@ -174,7 +174,7 @@
  2 files changed, 24 insertions(+), 28 deletions(-)
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 836cc34..8ff9070 100644
+index 70cd890..c847264 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -10,6 +10,15 @@ HEADERS += \
@@ -237,10 +237,10 @@
  }
  symbian:LIBS += -lcharconv
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 74e5e90..2b3100a 100644
+index ea8a5fd..7966df2 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -65,15 +65,14 @@
+@@ -66,15 +66,14 @@
  #  include "qtsciicodec_p.h"
  #  include "qisciicodec_p.h"
  #if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
@@ -258,7 +258,7 @@
  #  if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED)
  #    include "qfontlaocodec_p.h"
  #    include "../../plugins/codecs/jp/qfontjpcodec.h"
-@@ -759,8 +758,6 @@ static void setup()
+@@ -751,8 +750,6 @@ static void setup()
  #  if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED)
      // no font codecs when bootstrapping
      (void)new QFontLaoCodec;
@@ -267,7 +267,7 @@
      (void)new QFontGb2312Codec;
      (void)new QFontGbkCodec;
      (void)new QFontGb18030_0Codec;
-@@ -769,12 +766,11 @@ static void setup()
+@@ -761,12 +758,11 @@ static void setup()
      (void)new QFontKsc5601Codec;
      (void)new QFontBig5hkscsCodec;
      (void)new QFontBig5Codec;
@@ -282,7 +282,7 @@
      // no asian codecs when bootstrapping, sorry
      (void)new QGb18030Codec;
      (void)new QGbkCodec;
-@@ -786,7 +782,7 @@ static void setup()
+@@ -778,7 +774,7 @@ static void setup()
      (void)new QCP949Codec;
      (void)new QBig5Codec;
      (void)new QBig5hkscsCodec;
@@ -295,10 +295,10 @@
 1.7.9.2
 
 
-From 00db0d7b9b99b18fd08463f86102f1b63eb3a527 Mon Sep 17 00:00:00 2001
+From 1ec39e28f1790723df212eb158a6695c355a304a Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Fri, 13 Jan 2012 00:24:13 +0100
-Subject: [PATCH 05/17] move plugin text codecs to QtCore
+Subject: [PATCH 05/15] move plugin text codecs to QtCore
 
 Having plugin text codecs adds considerable complexity to
 configuring Qt. The plugin interface is designed for optional
@@ -416,7 +416,7 @@
  delete mode 100644 src/plugins/codecs/tw/tw.pro
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 8ff9070..02f30f5 100644
+index c847264..a1271b9 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -11,13 +11,14 @@ HEADERS += \
@@ -39528,10 +39528,10 @@
 +
 +#endif // QSJISCODEC_H
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 2b3100a..3399034 100644
+index 7966df2..3a2a60e 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -66,16 +66,16 @@
+@@ -67,16 +67,16 @@
  #  include "qisciicodec_p.h"
  #if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_INTEGRITY)
  #  if !defined(QT_BOOTSTRAPPED)
@@ -79337,10 +79337,10 @@
 1.7.9.2
 
 
-From 0332650cdfb4c5847a4678a1aebfbe146c850b87 Mon Sep 17 00:00:00 2001
+From 71aff51d79b2b92edbf40d642903b5114548cc42 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Wed, 18 Jan 2012 21:01:26 +0100
-Subject: [PATCH 06/17] update private header references
+Subject: [PATCH 06/15] update private header references
 
 backported from qt5/qtbase
 Change-Id: I092d879653b6900532a0c4534c1eb2be84e9d0f6
@@ -79513,10 +79513,10 @@
 1.7.9.2
 
 
-From e76298384079852d9cc1e0138a10b0637f34687f Mon Sep 17 00:00:00 2001
+From 4cc7d919207633377a3afc52f750d551bc7a90bd Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 3 Jul 2011 21:53:27 +0200
-Subject: [PATCH 07/17] cosmetic adjustments for files moved to core/codecs
+Subject: [PATCH 07/15] cosmetic adjustments for files moved to core/codecs
 
 -update old reference to 'plugin'
 -rename multiple inclusion guards
@@ -80024,10 +80024,10 @@
 1.7.9.2
 
 
-From 16ea320980842c9c16d380f3bdd84c5a413dbd21 Mon Sep 17 00:00:00 2001
+From e57ad0b10f420f62db94ba3ed3367d34ad2825ca Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 12 Jan 2012 10:43:29 +0100
-Subject: [PATCH 08/17] remove obsolete codec plugin loading code
+Subject: [PATCH 08/15] remove obsolete codec plugin loading code
 
 backported from qt5/qtbase
 Change-Id: I1f3dbb5c10009413f701947b1b89ed3dbc94bf3d
@@ -80053,7 +80053,7 @@
  delete mode 100644 src/corelib/codecs/qtextcodecplugin.h
 
 diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
-index 02f30f5..76e8d5e 100644
+index a1271b9..9274eda 100644
 --- a/src/corelib/codecs/codecs.pri
 +++ b/src/corelib/codecs/codecs.pri
 @@ -7,11 +7,9 @@ HEADERS += \
@@ -80083,13 +80083,13 @@
      codecs/qjpunicode.cpp \
      codecs/qeucjpcodec.cpp \
 diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
-index 3399034..552a195 100644
+index 3a2a60e..3cd5a5e 100644
 --- a/src/corelib/codecs/qtextcodec.cpp
 +++ b/src/corelib/codecs/qtextcodec.cpp
-@@ -47,11 +47,6 @@
- 
+@@ -48,11 +48,6 @@
  #include "qlist.h"
  #include "qfile.h"
+ #include "qvarlengtharray.h"
 -#ifndef QT_NO_LIBRARY
 -# include "qcoreapplication.h"
 -# include "qtextcodecplugin.h"
@@ -80098,7 +80098,7 @@
  #include "qstringlist.h"
  
  #ifdef Q_OS_UNIX
-@@ -104,11 +99,6 @@
+@@ -105,11 +100,6 @@
  
  QT_BEGIN_NAMESPACE
  
@@ -80110,7 +80110,7 @@
  //Cache for QTextCodec::codecForName and codecForMib.
  typedef QHash<QByteArray, QTextCodec *> QTextCodecCache;
  Q_GLOBAL_STATIC(QTextCodecCache, qTextCodecCache)
-@@ -150,39 +140,6 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
+@@ -151,39 +141,6 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
  }
  
  
@@ -80150,7 +80150,7 @@
  static QList<QTextCodec*> *all = 0;
  #ifdef Q_DEBUG_TEXTCODEC
  static bool destroying_is_ok = false;
-@@ -967,10 +924,6 @@ QTextCodec::ConverterState::~ConverterState()
+@@ -959,10 +916,6 @@ QTextCodec::ConverterState::~ConverterState()
           \o Converts a Unicode string to an 8-bit character string.
      \endtable
  
@@ -80161,7 +80161,7 @@
      \sa QTextStream, QTextDecoder, QTextEncoder, {Codecs Example}
  */
  
-@@ -1063,10 +1016,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
+@@ -1055,10 +1008,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name)
              }
      }
  
@@ -80173,7 +80173,7 @@
  }
  
  
-@@ -1103,16 +1053,7 @@ QTextCodec* QTextCodec::codecForMib(int mib)
+@@ -1095,16 +1045,7 @@ QTextCodec* QTextCodec::codecForMib(int mib)
          }
      }
  
@@ -80191,7 +80191,7 @@
  }
  
  /*!
-@@ -1145,18 +1086,6 @@ QList<QByteArray> QTextCodec::availableCodecs()
+@@ -1137,18 +1078,6 @@ QList<QByteArray> QTextCodec::availableCodecs()
      locker.unlock();
  #endif
  
@@ -80210,7 +80210,7 @@
      return codecs;
  }
  
-@@ -1185,18 +1114,6 @@ QList<int> QTextCodec::availableMibs()
+@@ -1177,18 +1106,6 @@ QList<int> QTextCodec::availableMibs()
      locker.unlock();
  #endif
  
@@ -80574,10 +80574,10 @@
 1.7.9.2
 
 
-From 5a5ae1066dbcf8a663e7f292d8679aae2ccd7b73 Mon Sep 17 00:00:00 2001
+From ea246a109c1ebc2cfaad6e92ac87c4a1cc18ec7e Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Mon, 23 Jan 2012 23:12:46 +0100
-Subject: [PATCH 09/17] remove vestiges of text codec plugins
+Subject: [PATCH 09/15] remove vestiges of text codec plugins
 
 follow-up to 3a3356a85079d734dfa57205a00e1996afc033df
 
@@ -80611,10 +80611,10 @@
 1.7.9.2
 
 
-From 90daa3f753c91a3efde3dfdc9151f9a639c653d0 Mon Sep 17 00:00:00 2001
+From 6fa42258f48a5e03ad9faa708202a1c53e1e5e20 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 15:10:26 +0100
-Subject: [PATCH 10/17] use pkg-config for libmng (MXE specific)
+Subject: [PATCH 10/15] use pkg-config for libmng (MXE specific)
 
 Change-Id: Ifce956d5cad06d5273088656b8500b87980063f4
 ---
@@ -80640,10 +80640,10 @@
 1.7.9.2
 
 
-From 1d4c3643de6eea011e74ed73dc2290c58f41d865 Mon Sep 17 00:00:00 2001
+From 94cbc5be38cb1386ec6acd6045615abb9b370874 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Thu, 3 Nov 2011 14:11:02 +0100
-Subject: [PATCH 11/17] use pkg-config for libtiff-4 (MXE specific)
+Subject: [PATCH 11/15] use pkg-config for libtiff-4 (MXE specific)
 
 Change-Id: I5e89e66fc1606d425553e781c9e62db703136957
 ---
@@ -80669,10 +80669,10 @@
 1.7.9.2
 
 
-From a3c87e93fd4aa06163eb157b060e155c44fbbe14 Mon Sep 17 00:00:00 2001
+From 2faf7d28bd1aa3b8b889ad68268700403ccba4d0 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sat, 5 Jun 2010 23:41:04 +0200
-Subject: [PATCH 12/17] restore support for static linking of QtWebKit (MXE
+Subject: [PATCH 12/15] restore support for static linking of QtWebKit (MXE
  specific)
 
 Support was removed by 4221d629e2cf37ee8c5ba7cb595b05ab8c82f113.
@@ -80693,10 +80693,10 @@
  5 files changed, 26 insertions(+), 8 deletions(-)
 
 diff --git a/configure b/configure
-index 0690822..2837eec 100755
+index 862aad5..f679fa4 100755
 --- a/configure
 +++ b/configure
-@@ -7599,12 +7599,6 @@ if [ "$CFG_GUI" = "no" ]; then
+@@ -7626,12 +7626,6 @@ if [ "$CFG_GUI" = "no" ]; then
      canBuildWebKit="no"
  fi
  
@@ -80779,10 +80779,10 @@
 1.7.9.2
 
 
-From 0f6cab5fff9eb2e0cfc173eaf71e068f9b82e9d3 Mon Sep 17 00:00:00 2001
+From e2187b030e2d7bd0fc9f51190737d5d45d693197 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:47:10 +0200
-Subject: [PATCH 13/17] fix building on GNU/kFreeBSD (MXE specific)
+Subject: [PATCH 13/15] fix building on GNU/kFreeBSD (MXE specific)
 
 This patch has been taken from:
 
@@ -80797,7 +80797,7 @@
  1 file changed, 2 insertions(+)
 
 diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
-index ed8f9eb..e571c4e 100644
+index 15b6afb..55f7df3 100644
 --- a/src/corelib/global/qglobal.h
 +++ b/src/corelib/global/qglobal.h
 @@ -226,6 +226,8 @@ namespace QT_NAMESPACE {}
@@ -80813,10 +80813,10 @@
 1.7.9.2
 
 
-From 3b9839cc26fc7997b043a74c7d30fc3b0b81ad83 Mon Sep 17 00:00:00 2001
+From edc8e5747312fb0dbc61ae4a1c432440cb70ad94 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:49:47 +0200
-Subject: [PATCH 14/17] fix missing platform when building on GNU/kFreeBSD
+Subject: [PATCH 14/15] fix missing platform when building on GNU/kFreeBSD
  (MXE specific)
 
 This patch is inspired by:
@@ -80830,10 +80830,10 @@
  1 file changed, 3 insertions(+)
 
 diff --git a/configure b/configure
-index 2837eec..8b4e5e8 100755
+index f679fa4..bb563fe 100755
 --- a/configure
 +++ b/configure
-@@ -2749,6 +2749,9 @@ if [ -z "$PLATFORM" ]; then
+@@ -2809,6 +2809,9 @@ if [ -z "$PLATFORM" ]; then
       GNU:*)
          PLATFORM=hurd-g++
          ;;
@@ -80847,10 +80847,10 @@
 1.7.9.2
 
 
-From e15286869c4e9b5714209ec38686f63c8b2ff44c Mon Sep 17 00:00:00 2001
+From 9e5f8124bdb183e115d742d45acb00fd7a8250c3 Mon Sep 17 00:00:00 2001
 From: Tony Theodore <tonyt@logyst.com>
 Date: Thu, 1 Sep 2011 13:51:50 +0200
-Subject: [PATCH 15/17] fix building on dragonfly (MXE specific)
+Subject: [PATCH 15/15] fix building on dragonfly (MXE specific)
 
 This patch is inspired by:
 http://cvsweb.NetBSD.org/bsdweb.cgi/pkgsrc/x11/qt4-libs/Makefile.common?rev=1.27&content-type=text/x-cvsweb-markup
@@ -80861,10 +80861,10 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/configure b/configure
-index 8b4e5e8..99948d1 100755
+index bb563fe..79ca8d3 100755
 --- a/configure
 +++ b/configure
-@@ -2761,7 +2761,7 @@ if [ -z "$PLATFORM" ]; then
+@@ -2821,7 +2821,7 @@ if [ -z "$PLATFORM" ]; then
       ULTRIX:*)
          PLATFORM=ultrix-g++
          ;;
@@ -80876,82 +80876,3 @@
 -- 
 1.7.9.2
 
-
-From 87952077f0d192d2ce15ea111be3f320bc03be40 Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 23 Mar 2012 16:29:57 +0100
-Subject: [PATCH 16/17] gcc 4.7.0 compatibility fix for javascript
-
-taken from http://qt-project.org/forums/viewthread/15071
-
-Change-Id: I701fb5a8d754afe9fcd6b327d779365673e07b5d
----
- .../JavaScriptCore/runtime/JSGlobalObject.h        |    2 +-
- .../JavaScriptCore/runtime/JSStaticScopeObject.h   |    2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-index 7c20272..9eb86e7 100644
---- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h
-@@ -59,7 +59,7 @@ namespace JSC {
-     protected:
-         using JSVariableObject::JSVariableObjectData;
- 
--        struct JSGlobalObjectData : public JSVariableObjectData {
-+        struct JSGlobalObjectData : public JSVariableObject::JSVariableObjectData {
-             // We use an explicit destructor function pointer instead of a
-             // virtual destructor because we want to avoid adding a vtable
-             // pointer to this struct. Adding a vtable pointer would force the
-diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-index 2542878..3cb66a0 100644
---- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-+++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSStaticScopeObject.h
-@@ -33,7 +33,7 @@ namespace JSC{
-     class JSStaticScopeObject : public JSVariableObject {
-     protected:
-         using JSVariableObject::JSVariableObjectData;
--        struct JSStaticScopeObjectData : public JSVariableObjectData {
-+        struct JSStaticScopeObjectData : public JSVariableObject::JSVariableObjectData {
-             JSStaticScopeObjectData()
-                 : JSVariableObjectData(&symbolTable, &registerStore + 1)
-             {
--- 
-1.7.9.2
-
-
-From 4de5298ed5b06dea106f054ef110146a45f06b6f Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Thu, 19 Apr 2012 14:48:34 +0200
-Subject: [PATCH 17/17] fix static library names when generating .pc files for
- pkgconfig
-
-c354d16cc64cf516a0b5149cdc9ef74de096a998 added the version extension
-which only occurs on the DLL import library.
-
-cherry-picked from qt5/qtbase 8e053a5dfc9b4c8f100b1e77335439774f52fc61
-Change-Id: Ie913adf039d7f3a9aadf43f4af014289a8aeacbe
-Reviewed-by: Mark Brand <mabrand@mabrand.nl>
-Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
-(cherry picked from commit 51a2b0fde9bf635482fd2463b901139c82ed0dc4)
----
- qmake/generators/makefile.cpp |    3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp
-index 66c6d49..447943a 100644
---- a/qmake/generators/makefile.cpp
-+++ b/qmake/generators/makefile.cpp
-@@ -3258,7 +3258,8 @@ MakefileGenerator::writePkgConfigFile()
-     } else {
-         pkgConfiglibDir = "-L${libdir}";
-         pkgConfiglibName = "-l" + lname.left(lname.length()-Option::libtool_ext.length());
--        pkgConfiglibName += project->first("TARGET_VERSION_EXT");
-+        if (project->isActiveConfig("shared"))
-+            pkgConfiglibName += project->first("TARGET_VERSION_EXT");
-     }
-     t << pkgConfiglibDir << " " << pkgConfiglibName << " " << endl;
- 
--- 
-1.7.9.2
-
--- a/src/qt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/qt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := qt
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a074d0f605f009e23c63e0a4cb9b71c978146ffc
+$(PKG)_CHECKSUM := e1e2edef1d63ed677d6534d32800c2e1f7ad0e73
 $(PKG)_SUBDIR   := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-everywhere-opensource-src-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://get.qt.nokia.com/qt/source/$($(PKG)_FILE)
+$(PKG)_URL      := http://releases.qt-project.org/qt4/source/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc libodbc++ postgresql freetds openssl zlib libpng jpeg libmng tiff sqlite dbus
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://qt.gitorious.org/qt/qt/commits' | \
+    $(WGET) -q -O- 'http://qt.gitorious.org/qt/qt/commits' | \
     grep '<li><a href="/qt/qt/commit/' | \
     $(SED) -n 's,.*<a[^>]*>v\([0-9][^<-]*\)<.*,\1,p' | \
     tail -1
@@ -37,7 +37,7 @@
         -script \
         -no-iconv \
         -opengl desktop \
-        -webkit \
+        -no-webkit \
         -no-glib \
         -no-gstreamer \
         -no-phonon \
@@ -71,6 +71,12 @@
     $(INSTALL) -m755 '$(1)/bin/uic'   '$(PREFIX)/bin/$(TARGET)-uic'
     $(INSTALL) -m755 '$(1)/bin/qmake' '$(PREFIX)/bin/$(TARGET)-qmake'
 
+    cd '$(1)/tools/assistant' && '$(1)/bin/qmake' assistant.pro
+    $(MAKE) -C '$(1)/tools/assistant' -j '$(JOBS)' install
+
+    cd '$(1)/tools/designer' && '$(1)/bin/qmake' designer.pro
+    $(MAKE) -C '$(1)/tools/designer' -j '$(JOBS)' install
+
     # at least some of the qdbus tools are useful on target
     cd '$(1)/tools/qdbus' && '$(1)/bin/qmake' qdbus.pro
     $(MAKE) -C '$(1)/tools/qdbus' -j '$(JOBS)' install
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qwt-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,23 @@
+This file is part of MXE.
+See index.html for further information.
+
+--- qwt-6.0.1/qwtconfig.pri	2011-08-01 16:34:05.000000000 +0200
++++ qwt-6.0.1/qwtconfig.pri	2011-12-03 10:14:53.371757822 +0100
+@@ -23,7 +23,7 @@
+ }
+ 
+ win32 {
+-    QWT_INSTALL_PREFIX    = C:/Qwt-$$QWT_VERSION
++#    QWT_INSTALL_PREFIX    = C:/Qwt-$$QWT_VERSION
+ }
+ 
+ QWT_INSTALL_DOCS      = $${QWT_INSTALL_PREFIX}/doc
+@@ -58,7 +58,7 @@
+ # it will be a static library.
+ ######################################################################
+ 
+-QWT_CONFIG           += QwtDll
++#QWT_CONFIG           += QwtDll
+ 
+ ######################################################################
+ # QwtPlot enables all classes, that are needed to use the QwtPlot 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/qwt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,30 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# Qwt - Qt widgets for technical applications
+PKG             := qwt
+$(PKG)_CHECKSUM := 7ea84ee47339809c671a456b5363d941c45aea92
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).zip
+$(PKG)_WEBSITE  := http://qwt.sourceforge.net/
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc qt
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/qwt/files/qwt/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # build
+    cd '$(1)/src' && $(PREFIX)/bin/$(TARGET)-qmake
+    $(MAKE) -C '$(1)/src' -f 'Makefile.Release' -j '$(JOBS)' install
+
+    #build sinusplot example to test linkage
+    cd '$(1)/examples/sinusplot' && $(PREFIX)/bin/$(TARGET)-qmake
+    $(MAKE) -C '$(1)/examples/sinusplot' -f 'Makefile.Release' -j '$(JOBS)'
+
+    # install
+    $(INSTALL) -m755 '$(1)/examples/bin/sinusplot.exe' '$(PREFIX)/$(TARGET)/bin/test-qwt.exe'
+endef
--- a/src/qwtplot3d.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/qwtplot3d.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc qt zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/$(PKG)/files/$(PKG)/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/$(PKG)/files/$(PKG)/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/readline.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/readline.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pdcurses
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://tiswww.case.edu/php/chet/readline/rltop.html' | \
+    $(WGET) -q -O- 'http://tiswww.case.edu/php/chet/readline/rltop.html' | \
     grep 'readline-' | \
     $(SED) -n 's,.*readline-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
--- a/src/sdl.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_image.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_image.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl jpeg libpng tiff
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_image/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_image/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_mixer.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_mixer.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -7,10 +7,10 @@
 $(PKG)_SUBDIR   := SDL_mixer-$($(PKG)_VERSION)
 $(PKG)_FILE     := SDL_mixer-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.libsdl.org/projects/SDL_mixer/release/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc sdl libmikmod ogg vorbis smpeg
+$(PKG)_DEPS     := gcc sdl libmodplug ogg vorbis smpeg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_mixer/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_mixer/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
@@ -19,7 +19,7 @@
     $(SED) -i 's,^\(Requires:.*\),\1 vorbisfile,' '$(1)/SDL_mixer.pc.in'
     echo \
         'Libs.private:' \
-        "`$(PREFIX)/$(TARGET)/bin/libmikmod-config --libs`" \
+        "`$(TARGET)-pkg-config libmodplug --libs`" \
         "`$(PREFIX)/$(TARGET)/bin/smpeg-config     --libs`" \
         >> '$(1)/SDL_mixer.pc.in'
     $(SED) -i 's,for path in /usr/local; do,for path in; do,' '$(1)/configure'
@@ -29,7 +29,8 @@
         --prefix='$(PREFIX)/$(TARGET)' \
         --with-sdl-prefix='$(PREFIX)/$(TARGET)' \
         --disable-sdltest \
-        --enable-music-mod \
+        --disable-music-mod \
+        --enable-music-mod-modplug \
         --enable-music-ogg \
         --disable-music-flac \
         --enable-music-mp3 \
@@ -39,7 +40,6 @@
         --disable-music-mp3-shared \
         --disable-smpegtest \
         --with-smpeg-prefix='$(PREFIX)/$(TARGET)' \
-        LIBMIKMOD_CONFIG='$(PREFIX)/$(TARGET)/bin/libmikmod-config' \
         LIBS='-lvorbis -logg'
     $(MAKE) -C '$(1)' -j '$(JOBS)' install bin_PROGRAMS= sbin_PROGRAMS= noinst_PROGRAMS=
 
--- a/src/sdl_net.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_net.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.libsdl.org/projects/SDL_net/release/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.libsdl.org/projects/SDL_net/release/?C=M;O=D' | \
     $(SED) -n 's,.*SDL_net-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/sdl_pango.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_pango.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl pango
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/sdlpango/files/SDL_Pango/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/sdlpango/files/SDL_Pango/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/sdl_sound.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_sound.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl libmikmod ogg vorbis flac speex
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.icculus.org/icculus/SDL_sound/tags' | \
+    $(WGET) -q -O- 'http://hg.icculus.org/icculus/SDL_sound/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/sdl_ttf.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sdl_ttf.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl freetype
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.libsdl.org/SDL_ttf/tags' | \
+    $(WGET) -q -O- 'http://hg.libsdl.org/SDL_ttf/tags' | \
     $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
     head -1
 endef
--- a/src/smpeg.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/smpeg.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://packages.debian.org/unstable/source/smpeg' | \
+    $(WGET) -q -O- 'http://packages.debian.org/unstable/source/smpeg' | \
     $(SED) -n 's,.*smpeg_\([0-9][^>]*\)\.orig\.tar.*,\1,p' | \
     head -1
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sox-test.c	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,15 @@
+/*
+ * This file is part of MXE.
+ * See index.html for further information.
+ */
+
+#include <sox.h>
+
+int main(int argc, char *argv[])
+{
+    (void)argc;
+    (void)argv;
+
+    sox_format_init();
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sox.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,39 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+# sox
+PKG             := sox
+$(PKG)_IGNORE   :=
+$(PKG)_CHECKSUM := d809cab382c7a9d015491c69051a9d1c1a1a44f1
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := gcc ffmpeg flac lame libgomp libmad libsndfile vorbis
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'http://sourceforge.net/projects/sox/files/sox/' | \
+    $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+    # set pkg-config cflags and libs
+    $(SED) -i 's,^\(Cflags:.*\),\1 -fopenmp,' '$(1)/sox.pc.in'
+    $(SED) -i '/Libs.private/d'               '$(1)/sox.pc.in'
+    echo Libs.private: `grep sox_LDADD '$(1)/src/optional-fmts.am' | \
+    $(SED) 's, sox_LDADD += ,,g' | tr -d '\n'` >>'$(1)/sox.pc.in'
+
+    cd '$(1)' && ./configure \
+        --host='$(TARGET)' \
+        --prefix='$(PREFIX)/$(TARGET)' \
+        --build="`config.guess`" \
+        --disable-shared
+
+    $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS= EXTRA_PROGRAMS=
+    $(MAKE) -C '$(1)' -j 1 install
+
+    '$(TARGET)-gcc' \
+        -W -Wall -Werror -ansi -pedantic \
+        '$(2).c' -o '$(PREFIX)/$(TARGET)/bin/test-sox.exe' \
+        `'$(TARGET)-pkg-config' sox --cflags --libs`
+endef
--- a/src/speex.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/speex.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://git.xiph.org/?p=speex.git;a=tags' | \
+    $(WGET) -q -O- 'http://git.xiph.org/?p=speex.git;a=tags' | \
     grep '<a class="list name"' | \
     $(SED) -n 's,.*<a[^>]*>Speex-\([0-9][^<]*\)<.*,\1,p' | \
     head -1
--- a/src/sqlite.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/sqlite.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := sqlite
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := a768f76b10df84d6a2c66178544d42725a8fdaf0
+$(PKG)_CHECKSUM := d3833b6ad68db8505d1044f761dd962f415cd302
 $(PKG)_SUBDIR   := $(PKG)-autoconf-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-autoconf-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.sqlite.org/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.sqlite.org/download.html' | \
+    $(WGET) -q -O- 'http://www.sqlite.org/download.html' | \
     $(SED) -n 's,.*sqlite-autoconf-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,6 +18,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         --disable-readline \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/suitesparse-1.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -0,0 +1,42 @@
+This file is part of MXE.
+See index.html for further information.
+
+From 60ff05e30eaa435a7776b178f5f240f0c11e8f38 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 20 May 2012 23:41:27 +0200
+Subject: [PATCH] build lib not demo
+
+---
+ CHOLMOD/Makefile |    2 +-
+ UMFPACK/Makefile |    2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CHOLMOD/Makefile b/CHOLMOD/Makefile
+index d27ae54..878f9d8 100644
+--- a/CHOLMOD/Makefile
++++ b/CHOLMOD/Makefile
+@@ -13,7 +13,7 @@ include ../UFconfig/UFconfig.mk
+ 
+ # Compile the C-callable libraries and the Demo programs.
+ all:
+-	( cd Demo ; $(MAKE) )
++	( cd Lib ; $(MAKE) )
+ 
+ # Compile the C-callable libraries only.
+ library:
+diff --git a/UMFPACK/Makefile b/UMFPACK/Makefile
+index 6163045..4973e55 100644
+--- a/UMFPACK/Makefile
++++ b/UMFPACK/Makefile
+@@ -13,7 +13,7 @@ include ../UFconfig/UFconfig.mk
+ # compile all C code (except hb, fortran, and fortran64), including AMD and the
+ # demos, but not the MATLAB mexFunctions
+ all:
+-	( cd Demo   ; $(MAKE) )
++	( cd Lib    ; $(MAKE) )
+ 
+ # compile just the C-callable UMFPACK library
+ library:
+-- 
+1.7.9.2
+
--- a/src/suitesparse.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/suitesparse.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -2,14 +2,14 @@
 # See index.html for further information.
 
 PKG             := suitesparse
-$(PKG)_CHECKSUM := d0eb24b43ee2f7def032e80eaa7a589f94f546fc
+$(PKG)_CHECKSUM := 4f1f5af64625606d58c129087a66d58d90c4dd58
 $(PKG)_SUBDIR   := SuiteSparse
 $(PKG)_FILE     := SuiteSparse-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.cise.ufl.edu/research/sparse/SuiteSparse/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc blas lapack
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.cise.ufl.edu/research/sparse/SuiteSparse/' | \
+    $(WGET) -q -O- 'http://www.cise.ufl.edu/research/sparse/SuiteSparse/' | \
     $(SED) -n 's,.*SuiteSparse-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -24,7 +24,7 @@
         CC='$(TARGET)-gcc' \
         CPLUSPLUS='$(TARGET)-g++' \
         F77='$(TARGET)-gfortran' \
-        AR='$(TARGET)-ar cr' \
+        AR='$(TARGET)-ar' \
         RANLIB='$(TARGET)-ranlib' \
         BLAS='-lblas -lgfortran -lgfortranbegin' \
         CHOLMOD_CONFIG='-DNPARTITION'
@@ -36,16 +36,17 @@
 
     # install include files
     $(INSTALL) -d                                '$(PREFIX)/$(TARGET)/include/suitesparse/'
+    $(INSTALL) -m644 '$(1)/SuiteSparse_config/'*.h '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/AMD/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/BTF/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CAMD/Include/'*.h     '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CCOLAMD/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CHOLMOD/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/COLAMD/Include/'*.h   '$(PREFIX)/$(TARGET)/include/suitesparse/'
+    $(INSTALL) -m644 '$(1)/CSparse/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/CXSparse/Include/'*.h '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/KLU/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/LDL/Include/'*.h      '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/SPQR/Include/'*       '$(PREFIX)/$(TARGET)/include/suitesparse/'
-    $(INSTALL) -m644 '$(1)/UFconfig/'*.h         '$(PREFIX)/$(TARGET)/include/suitesparse/'
     $(INSTALL) -m644 '$(1)/UMFPACK/Include/'*.h  '$(PREFIX)/$(TARGET)/include/suitesparse/'
 endef
--- a/src/t4k_common.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/t4k_common.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc sdl sdl_mixer sdl_image sdl_net sdl_pango sdl_ttf libpng librsvg libxml2 pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://alioth.debian.org/frs/?group_id=31080' | \
+    $(WGET) -q -O- 'http://alioth.debian.org/frs/?group_id=31080' | \
     $(SED) -n 's,.*t4k_common-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/taglib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/taglib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := taglib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := bafe0958eb884981cade83d45c18ee34165479b8
+$(PKG)_CHECKSUM := e657384ccf3284db2daba32dccece74534286012
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://developer.kde.org/~wheeler/files/src/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://developer.kde.org/~wheeler/files/src/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://developer.kde.org/~wheeler/files/src/?C=M;O=D' | \
     $(SED) -n 's,.*"taglib-\([0-9][^"]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/theora.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/theora.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc ogg vorbis
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libtheora-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/tiff.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/tiff.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc zlib jpeg xz
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.remotesensing.org/libtiff/' | \
+    $(WGET) -q -O- 'http://www.remotesensing.org/libtiff/' | \
     $(SED) -n 's,.*>v\([0-9][^<]*\)<.*,\1,p' | \
     head -1
 endef
--- a/src/tinyxml.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/tinyxml.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/tinyxml/files/tinyxml/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/tinyxml/files/tinyxml/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/tre.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/tre.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://laurikari.net/tre/download.html' | \
+    $(WGET) -q -O- 'http://laurikari.net/tre/download.html' | \
     $(SED) -n 's,.*tre-\([a-z0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/vigra.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/vigra.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc jpeg tiff libpng openexr
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hci.iwr.uni-heidelberg.de/vigra/' | \
+    $(WGET) -q -O- 'http://hci.iwr.uni-heidelberg.de/vigra/' | \
     grep 'Sources' | \
     grep '<a href="vigra' | \
     $(SED) -n 's,.*"vigra-\([0-9][^"]*\)-src.*,\1,p' | \
--- a/src/vmime-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/vmime-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -1,49 +1,18 @@
 This file is part of MXE.
 See index.html for further information.
 
-Cherry picked fixes from svn
-http://sourceforge.net/projects/vmime/develop
-
-Produced with this script:
-#--------------------------------------------------------------------#
-#!/usr/bin/env bash
-
-(
-  echo "This file is part of MXE."
-  echo "See index.html for further information."
-  echo
-  echo "Cherry picked fixes from svn"
-  echo "http://sourceforge.net/projects/vmime/develop"
-  echo
-  echo "Produced with this script:"
-  echo "#--------------------------------------------------------------------#"
-  cat "$0"
-  echo "#--------------------------------------------------------------------#"
-) > src/vmime-1-fixes.patch
-
-# setup git svn clone
-#cd ~/projects/vmime/git
-#git svn clone -s https://vmime.svn.sourceforge.net/svnroot/vmime
-#git reset --hard
-# get updates
-#git svn fetch
-#git svn rebase
-
-GITDIR=~/projects/vmime/git/vmime
-
-(
-  cd $GITDIR
-  echo
-  git format-patch -p --relative=vmime --stdout ":/Version 0.9.1"..master-fixed
-) >> src/vmime-1-fixes.patch
-#--------------------------------------------------------------------#
-
-From ed4451fd3c86faf9ecc03a59ba9f1ad78417a9f9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+Commits from master branch of git://github.com/kisli/vmime
+rebased onto version 0.9.1 tarball files.
+
+From 17ff5157ffdc749f60b8285f84e64ac5e06d4283 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 16 Nov 2010 13:28:05 +0000
-Subject: [PATCH 01/27] Started version 0.9.2.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@576 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 01/38] Started version 0.9.2.
+
+---
+ ChangeLog  |    8 ++++++++
+ SConstruct |    2 +-
+ 2 files changed, 9 insertions(+), 1 deletion(-)
 
 diff --git a/ChangeLog b/ChangeLog
 index 871d055..8fdcdb0 100644
@@ -76,15 +45,17 @@
  # API version number (libtool)
  #
 -- 
-1.7.7.3
-
-
-From bf282a05cdbbb538a1cafbd7305cece14f5b1571 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From c12ee2b267b9dcfd092a298dfd9a8eec81ab3a0b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 30 Nov 2010 14:57:03 +0000
-Subject: [PATCH 02/27] Initialize and delete object.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@577 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 02/38] Initialize and delete object.
+
+---
+ vmime/net/imap/IMAPParser.hpp |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
 index 0f3e9ec..d71c3ca 100644
@@ -110,29 +81,19 @@
  
  		void go(IMAPParser& parser, string& line, string::size_type* currentPos)
 -- 
-1.7.7.3
-
-
-From 941b10bca8e89ca61eebee1345ee3e5cbebd7530 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
-Date: Mon, 6 Dec 2010 11:57:44 +0000
-Subject: [PATCH 03/27] Updated deprecated function.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@578 5301114d-f842-0410-bbdd-996ee0417009
-
-SKIPPED
--- 
-1.7.7.3
-
-
-From 4a4c3a94db671ff7750b32ebf2c998a914717367 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From fd277afe87485c9d3377964794b76006c6d36a56 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Wed, 8 Dec 2010 08:52:54 +0000
-Subject: [PATCH 04/27] No extra space between ':' and '<' in MAIL FROM and
+Subject: [PATCH 03/38] No extra space between ':' and '<' in MAIL FROM and
  RCPT TO. Wait for server response after QUIT and
  before closing connection.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@579 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/net/smtp/SMTPTransport.cpp |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
 index 204daae..d9fb7b8 100644
@@ -165,15 +126,17 @@
  		if ((resp = readResponse())->getCode() != 250)
  		{
 -- 
-1.7.7.3
-
-
-From 4ea325c953f0cdc669b932aa4961a434656f3ecf Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From d64da50e879c0e480d2e65c43e3b903c3e80101f Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Dec 2010 16:24:06 +0000
-Subject: [PATCH 05/27] Fixed unit test after bug fix.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@580 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 04/38] Fixed unit test after bug fix.
+
+---
+ tests/net/smtp/SMTPTransportTest.cpp |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp
 index 5015552..6552f9e 100644
@@ -189,16 +152,19 @@
  				localSend("250 OK\r\n");
  			}
 -- 
-1.7.7.3
-
-
-From ff207927a5aab002f38af0224133b345ab458144 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 130d0aabda2a9988913ad201390796775dc16a65 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Dec 2010 16:54:38 +0000
-Subject: [PATCH 06/27] Fixed boundary parsing (thanks to John van der Kamp,
+Subject: [PATCH 05/38] Fixed boundary parsing (thanks to John van der Kamp,
  Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@581 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/body.cpp                  |   43 +++++++++++++++++++++++++++++++++++++++--
+ tests/parser/bodyPartTest.cpp |    2 +-
+ 2 files changed, 42 insertions(+), 3 deletions(-)
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 13dff6b..738d3e7 100644
@@ -278,16 +244,19 @@
  
  		vmime::bodyPart p;
 -- 
-1.7.7.3
-
-
-From 3f5172e47f75f64952adef349bec875416ae9b89 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From c63f37c888798f0e7e99aa03afda16445a72b7b2 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 21 Jan 2011 15:28:06 +0000
-Subject: [PATCH 07/27] Fixed possible infinite loop (thanks to John van der
+Subject: [PATCH 06/38] Fixed possible infinite loop (thanks to John van der
  Kamp, Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@582 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/word.cpp              |    2 +-
+ tests/parser/textTest.cpp |   11 +++++++++++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
 
 diff --git a/src/word.cpp b/src/word.cpp
 index db720dc..1c1c1a6 100644
@@ -331,16 +300,18 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 4e9eb3191066dec7f17592c2ce099b16e6329941 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 1fafad8f913e700b350e6915de8be710fc2d1ced Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 28 Jan 2011 12:11:08 +0000
-Subject: [PATCH 08/27] Fixed possible read to invalid memory location (thanks
+Subject: [PATCH 07/38] Fixed possible read to invalid memory location (thanks
  to Alexander Konovalov).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@583 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/word.cpp |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/word.cpp b/src/word.cpp
 index 1c1c1a6..fa08d33 100644
@@ -356,17 +327,21 @@
  					else
  						state->lastCharIsSpace = false;
 -- 
-1.7.7.3
-
-
-From 07ebf241115eba44675223e307d212c772e1cc08 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 73298423f695d7c4441d44619e4b7f9de75f566e Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Wed, 9 Mar 2011 18:03:31 +0000
-Subject: [PATCH 09/27] Fixed bug #3174903. Fixed word parsing when buffer
+Subject: [PATCH 08/38] Fixed bug #3174903. Fixed word parsing when buffer
  does not end with NL. Fixed 'no encoding' when
  forced.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@584 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/body.cpp                  |   14 +++++---
+ src/word.cpp                  |   25 ++++++++------
+ tests/parser/bodyPartTest.cpp |   76 +++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 101 insertions(+), 14 deletions(-)
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 738d3e7..8596833 100644
@@ -563,16 +538,18 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 22ca7dc23b6bbbc8cc6aedd569ec938ecae96e92 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 5f5757b9d4bb0febb1e2183578eb91e801a08038 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 27 Mar 2011 11:26:55 +0000
-Subject: [PATCH 10/27] Allow static linking in MXE. Added 'iconv'
+Subject: [PATCH 09/38] Allow static linking in mingw-cross-env. Added 'iconv'
  and uses 'ws2_32' instead of 'winsock32' (#3213487).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@585 5301114d-f842-0410-bbdd-996ee0417009
+---
+ SConstruct |    4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/SConstruct b/SConstruct
 index 55f9223..177f5b4 100644
@@ -597,16 +574,19 @@
  
  # -- getaddrinfo (POSIX)
 -- 
-1.7.7.3
-
-
-From 9e06cc39d47e2eba8f554b337d472cc995be0d9d Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 2b48b4a68ce3e9b9b1a3f485123af5938a568324 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Thu, 31 Mar 2011 19:13:03 +0000
-Subject: [PATCH 11/27] Flush stateful data from iconv (thanks to John van der
+Subject: [PATCH 10/38] Flush stateful data from iconv (thanks to John van der
  Kamp, Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@586 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/charsetConverter.cpp     |   13 +++++++++----
+ tests/parser/charsetTest.cpp |   10 ++++++++++
+ 2 files changed, 19 insertions(+), 4 deletions(-)
 
 diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
 index 38b9e5e..2135788 100644
@@ -679,15 +659,17 @@
  	// Conversion to hexadecimal for easier debugging
  	static const vmime::string toHex(const vmime::string str)
 -- 
-1.7.7.3
-
-
-From 418a39a7d33921672bd1c4beb31c8a31bc87d8dd Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 8d2e039c5201e144ff08e2ff7cf9efe77fe4b3d0 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 10 Jun 2011 19:39:09 +0000
-Subject: [PATCH 12/27] Requested email change.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@587 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 11/38] Requested email change.
+
+---
+ AUTHORS |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/AUTHORS b/AUTHORS
 index 20a0181..bbddb30 100644
@@ -703,15 +685,17 @@
   - Georg Sauthoff <gsauthof@techfak.uni-bielefeld.de>
   - Pierre Thierry <nowhere.man@levallois.eu.org> (patches for STL algorithms)
 -- 
-1.7.7.3
-
-
-From 4008955783ef566b98b16762c7bfa28df26e9198 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From cc6317f28ae0b61fea36e1bc78b09dc8300579f8 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 14 Jun 2011 18:37:54 +0000
-Subject: [PATCH 13/27] Fixed compilation issue following namespace change.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@588 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 12/38] Fixed compilation issue following namespace change.
+
+---
+ examples/example7.cpp |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/examples/example7.cpp b/examples/example7.cpp
 index 1ddb3d0..243b1da 100644
@@ -740,16 +724,18 @@
  		std::vector <vmime::string> props = e->getAvailableProperties();
  
 -- 
-1.7.7.3
-
-
-From e80db1ce802a45b71659d16d77ea47368beeabc1 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From a916d12d44ac43fc8e4729e0a91f4d6243f29a11 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 17:51:33 +0000
-Subject: [PATCH 14/27] Fixed parsing of an attachment filename that is
+Subject: [PATCH 13/38] Fixed parsing of an attachment filename that is
  between 66 and 76 characters long (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@589 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/parameter.cpp |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/parameter.cpp b/src/parameter.cpp
 index 91a7e5c..f59d5ab 100644
@@ -766,16 +752,18 @@
  		switch (value[i])
  		{
 -- 
-1.7.7.3
-
-
-From 58316dddddbfe8a7c582aa52e9abff8ca3a227b6 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 9735165c57000a6368e91ce8852206a20930c1ca Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:08:12 +0000
-Subject: [PATCH 15/27] Correctly generate attachment names which are long and
+Subject: [PATCH 14/38] Correctly generate attachment names which are long and
  have high characters for Outlook Express (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@590 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/parameter.cpp |   70 ++++++++++++++++++++++++++++++++++++-----------------
+ 1 file changed, 48 insertions(+), 22 deletions(-)
 
 diff --git a/src/parameter.cpp b/src/parameter.cpp
 index f59d5ab..d757e1b 100644
@@ -906,15 +894,17 @@
  #endif // !VMIME_ALWAYS_GENERATE_7BIT_PARAMETER
  
 -- 
-1.7.7.3
-
-
-From f7ad17cffea462faf8cbe4f785644da0f3ee812a Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 8d69ad6849d8d6b211674942157f2af8bcd51c26 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:16:49 +0000
-Subject: [PATCH 16/27] Alias for UTF-7 charset.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@591 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 15/38] Alias for UTF-7 charset.
+
+---
+ src/charset.cpp |    7 +++++++
+ 1 file changed, 7 insertions(+)
 
 diff --git a/src/charset.cpp b/src/charset.cpp
 index e043186..0fda450 100644
@@ -942,17 +932,19 @@
  
  	if (newPosition)
 -- 
-1.7.7.3
-
-
-From eac20f47a33a7fdd617f9fd905b8029621259269 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From ccd95daf9cdd7171fc2027afa5d0ad80b0475ded Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:39:35 +0000
-Subject: [PATCH 17/27] Fixed messageBuilder to accept an empty mailbox group
+Subject: [PATCH 16/38] Fixed messageBuilder to accept an empty mailbox group
  in 'To:' field, to allow for undisclosed-recipients
  (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@592 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/messageBuilder.cpp |    8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
 
 diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp
 index 870d59e..3597b3a 100644
@@ -980,17 +972,20 @@
  	if (!m_to.isEmpty())
  		msg->getHeader()->To()->setValue(m_to);
 -- 
-1.7.7.3
-
-
-From 1e5dfa80a63b0a7fe90406ce4a3de1593f2e4045 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 583e25bcdee132e53e0792cd8f0d8e535cabb743 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 19 Jun 2011 18:49:55 +0000
-Subject: [PATCH 18/27] Added support for mailboxes that specify an (encoded)
+Subject: [PATCH 17/38] Added support for mailboxes that specify an (encoded)
  full name with an empty email address, set by a <>
  marker (Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@593 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/mailbox.cpp              |    4 +++-
+ tests/parser/mailboxTest.cpp |   15 +++++++++++++++
+ 2 files changed, 18 insertions(+), 1 deletion(-)
 
 diff --git a/src/mailbox.cpp b/src/mailbox.cpp
 index 5cb0139..fea7479 100644
@@ -1054,15 +1049,17 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 960f2195516eb776eea7b7e4f92612192edfdcd9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 461b92f84d5c16b297d33610fcd89fc7ca5a161a Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Fri, 24 Jun 2011 15:46:23 +0000
-Subject: [PATCH 19/27] Added missing libs in pkg-config file.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@594 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 18/38] Added missing libs in pkg-config file.
+
+---
+ SConstruct |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/SConstruct b/SConstruct
 index 177f5b4..37c0ac6 100644
@@ -1078,16 +1075,19 @@
  	vmime_pc_in.write("Cflags: -I${includedir}/ @LIBGNUTLS_CFLAGS@\n")
  	vmime_pc_in.close()
 -- 
-1.7.7.3
-
-
-From 9f9084b71b4e3c96edc6513020984ef76fe26e0c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 2b2c0abd02a17ccff7d49e266b9854f4ea47f8e4 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sat, 25 Jun 2011 17:07:53 +0000
-Subject: [PATCH 20/27] Fixed parsing of empty body parts (thanks to John van
+Subject: [PATCH 19/38] Fixed parsing of empty body parts (thanks to John van
  der Kamp, from Zarafa).
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@595 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/body.cpp                  |    5 +++++
+ tests/parser/bodyPartTest.cpp |   19 +++++++++++++++++++
+ 2 files changed, 24 insertions(+)
 
 diff --git a/src/body.cpp b/src/body.cpp
 index 8596833..9d7d57f 100644
@@ -1142,16 +1142,19 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 318848aa87761214a6f21c1ea1a9776a7bcbf83c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 2648d744da0e2e744c7959999ac513c3016072b4 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 26 Jun 2011 08:19:11 +0000
-Subject: [PATCH 21/27] Use gnutls_priority_set_direct() instead of GNUTLS
+Subject: [PATCH 20/38] Use gnutls_priority_set_direct() instead of GNUTLS
  deprecated functions.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@596 5301114d-f842-0410-bbdd-996ee0417009
+---
+ SConstruct                 |   33 +++++++++++++++++++++++++++++++++
+ src/net/tls/TLSSession.cpp |   17 +++++++++++++++++
+ 2 files changed, 50 insertions(+)
 
 diff --git a/SConstruct b/SConstruct
 index 37c0ac6..01ad3f3 100644
@@ -1252,15 +1255,18 @@
  	gnutls_credentials_set(*m_gnutlsSession,
  		GNUTLS_CRD_ANON, g_gnutlsGlobal.anonCred);
 -- 
-1.7.7.3
-
-
-From 70a0282a3f96febf973475a298ac95ffaab82c3c Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 1060121ffd4315c3158ffc001040f4f705514e7a Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 26 Jun 2011 12:47:25 +0000
-Subject: [PATCH 22/27] Fixed encoding of whitespace. Fixed old test case.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@597 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 21/38] Fixed encoding of whitespace. Fixed old test case.
+
+---
+ src/text.cpp              |    6 ------
+ tests/parser/textTest.cpp |   42 +++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 41 insertions(+), 7 deletions(-)
 
 diff --git a/src/text.cpp b/src/text.cpp
 index 2454456..66c3b35 100644
@@ -1346,15 +1352,17 @@
  VMIME_TEST_SUITE_END
  
 -- 
-1.7.7.3
-
-
-From 7d399583a458abe5cd16ce0974bd4dc11daba9f6 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From dc6dc039fc0edccf4630894fa6ed8cd4bf3bb3ce Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sat, 20 Aug 2011 06:35:06 +0000
-Subject: [PATCH 23/27] Use gnutls_strerror() for reporting errors.
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@598 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 22/38] Use gnutls_strerror() for reporting errors.
+
+---
+ src/net/tls/TLSSession.cpp |  120 ++++----------------------------------------
+ 1 file changed, 9 insertions(+), 111 deletions(-)
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index af73a05..7426a73 100644
@@ -1497,16 +1505,18 @@
  
  
 -- 
-1.7.7.3
-
-
-From aae321dede5e725140534a08a8b2ee997faa30be Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From 7ea6fc3737ef36407e1c90f3aa05f89a39bdefb7 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 21 Aug 2011 08:55:46 +0000
-Subject: [PATCH 24/27] Removed dependency on gcrypt for gnutls version >=
+Subject: [PATCH 23/38] Removed dependency on gcrypt for gnutls version >=
  2.12.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@599 5301114d-f842-0410-bbdd-996ee0417009
+---
+ src/net/tls/TLSSession.cpp |   14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index 7426a73..d3f6d49 100644
@@ -1551,16 +1561,18 @@
  
  		gnutls_global_init();
 -- 
-1.7.7.3
-
-
-From af1e5664afb663fb7d26d468adf675fb1b3f8737 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From f21c55be642b166a2f0518ace2b179bed3916b23 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Sun, 21 Aug 2011 09:04:46 +0000
-Subject: [PATCH 25/27] Fixed HAVE_GNUTLS_PRIORITY_FUNCS never defined when
+Subject: [PATCH 24/38] Fixed HAVE_GNUTLS_PRIORITY_FUNCS never defined when
  configured with no TLS support.
 
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@600 5301114d-f842-0410-bbdd-996ee0417009
+---
+ SConstruct |    6 ++++++
+ 1 file changed, 6 insertions(+)
 
 diff --git a/SConstruct b/SConstruct
 index 01ad3f3..11e884b 100644
@@ -1584,15 +1596,17 @@
  
  AC_SUBST(LIBGNUTLS_CFLAGS)
 -- 
-1.7.7.3
-
-
-From 41079b2f188bb4a6d8aea9ec1328653faee3e2c9 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From d4e66226a696745adafa1767210580f8fbb7ae00 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 15 Nov 2011 11:40:42 +0000
-Subject: [PATCH 26/27] GNU TLS 3 has no 'extra' (thanks to mabrand).
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@601 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 25/38] GNU TLS 3 has no 'extra' (thanks to mabrand).
+
+---
+ src/net/tls/TLSSession.cpp |    2 ++
+ 1 file changed, 2 insertions(+)
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index d3f6d49..cb50acc 100644
@@ -1609,15 +1623,17 @@
  #include "vmime/config.hpp"
  
 -- 
-1.7.7.3
-
-
-From eafae52d9b8ec9682c229090b6208092b1d1e6f1 Mon Sep 17 00:00:00 2001
-From: vincent-richard <vincent-richard@5301114d-f842-0410-bbdd-996ee0417009>
+1.7.10.3
+
+
+From bacbe512e406d22f6acc83597fcdfc2d624cf82b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
 Date: Tue, 15 Nov 2011 11:46:07 +0000
-Subject: [PATCH 27/27] Set Diffie-Hellman prime size (bug SF#3434852).
-
-git-svn-id: https://vmime.svn.sourceforge.net/svnroot/vmime/trunk@602 5301114d-f842-0410-bbdd-996ee0417009
+Subject: [PATCH 26/38] Set Diffie-Hellman prime size (bug SF#3434852).
+
+---
+ src/net/tls/TLSSession.cpp |    1 +
+ 1 file changed, 1 insertion(+)
 
 diff --git a/src/net/tls/TLSSession.cpp b/src/net/tls/TLSSession.cpp
 index cb50acc..0606808 100644
@@ -1632,5 +1648,8138 @@
  	if ((res = gnutls_priority_set_direct
  		(*m_gnutlsSession, "NORMAL:%SSL3_RECORD_VERSION", NULL)) != 0)
 -- 
-1.7.7.3
-
+1.7.10.3
+
+
+From 6574b60a303c5d864e840aa23959656bb2803485 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 22 Dec 2011 08:51:28 +0000
+Subject: [PATCH 27/38] Updated coding conventions.
+
+---
+ HACKING |   53 +++++++++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 45 insertions(+), 8 deletions(-)
+
+diff --git a/HACKING b/HACKING
+index 4f35a53..f51d738 100644
+--- a/HACKING
++++ b/HACKING
+@@ -1,10 +1,10 @@
+ 
+-This file contains coding guidelines for VMime. You should follow these
+-guidelines if you want to contribute to VMime. It guarantees some minimal
+-quality of the code.
++This file contains coding guidelines for VMime. You should follow them
++if you want to contribute to VMime. The rules below are not guidelines
++or recommendations, but strict rules.
+ 
+ 
+-1. General guidelines
++1. General rules
+      1.1. Language
+      1.2. Unit tests
+      1.3. CVS
+@@ -18,19 +18,22 @@ quality of the code.
+      2.5. Line length
+      2.6. Spaces and parentheses
+      2.7. End-of-line character
++     2.8. Short functions
++     2.9. Limit Variable Scope
+ 3. Naming conventions
+      3.1. Classes
+      3.2. Variables/parameters/member variables
+      3.3. Member variables
+      3.4. Files
+      3.5. Namespaces
++     3.6. Constants
+ 4. Comments
+ 5. Miscellaneous
+ 
+ 
+ 
+-1. General guidelines
+-=====================
++1. General rules
++================
+ 
+ 1.1. Language
+ -------------
+@@ -50,7 +53,7 @@ When you fix a bug, also add a new test case to ensure the bug will not
+ happen anymore.
+ 
+ 
+-1.3. CVS
++1.3. SVN
+ --------
+ 
+ Each commit MUST be done with a message ('-m' flag) that briefly describes what
+@@ -154,7 +157,11 @@ Except when body spans over multiple lines:
+ 2.5. Line length
+ ----------------
+ 
+-Line length should not exceed 80 characters.
++Each line of text should not exceed 80 characters.
++
++Exception: if a comment line contains an example command or a literal URL
++longer than 100 characters, that line may be longer than 100 characters
++for ease of cut and paste.
+ 
+ 
+ 2.6. Spaces and parentheses
+@@ -193,6 +200,30 @@ Configure your editor to use "\n" (UNIX convention) for end-of-line sequence,
+ and not "\r\n" (Windows), nor "\n\r", nor any other combination.
+ 
+ 
++2.8. Short functions
++--------------------
++
++To the extent that it is feasible, functions should be kept small and focused.
++It is, however, recognized that long functions are sometimes appropriate, so no
++hard limit is placed on method length. If a function exceeds 40 lines or so,
++think about whether it can be broken up without harming the structure of the
++program.
++
++
++2.9. Limit Variable Scope
++-------------------------
++
++The scope of local variables should be kept to a minimum. By doing so, you
++increase the readability and maintainability of your code and reduce the
++likelihood of error. Each variable should be declared in the innermost block
++that encloses all uses of the variable.
++
++Local variables should be declared at the point they are first used. Nearly
++every local variable declaration should contain an initializer. If you don't
++yet have enough information to initialize a variable sensibly, you should
++postpone the declaration until you do.
++
++
+ 
+ 3. Naming conventions
+ =====================
+@@ -255,6 +286,12 @@ Implementation files must be placed in 'src/' directory.
+ Namespaces are named exactly like variables.
+ 
+ 
++3.6. Constants
++--------------
++
++Constants are ALL_CAPS_WITH_UNDERSCORES.
++
++
+ 
+ 4. Comments
+ ===========
+-- 
+1.7.10.3
+
+
+From 130e5223dea0af2f8d9d01cca7845be4e1a08d13 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 11:46:39 +0200
+Subject: [PATCH 28/38] Added function to retrieve sequence numbers of
+ messages whose UID is greater or equal than a
+ specified UID (thanks to Zahi Mashael).
+
+---
+ src/net/imap/IMAPFolder.cpp         |   56 +++++++++++++++++++++++++++++++++++
+ src/net/maildir/maildirFolder.cpp   |    6 ++++
+ src/net/pop3/POP3Folder.cpp         |    6 ++++
+ vmime/net/folder.hpp                |    7 +++++
+ vmime/net/imap/IMAPFolder.hpp       |    2 ++
+ vmime/net/maildir/maildirFolder.hpp |    2 ++
+ vmime/net/pop3/POP3Folder.hpp       |    2 ++
+ 7 files changed, 81 insertions(+)
+
+diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
+index 0122d21..50a2f2b 100644
+--- a/src/net/imap/IMAPFolder.cpp
++++ b/src/net/imap/IMAPFolder.cpp
+@@ -1772,6 +1772,62 @@ void IMAPFolder::status(int& count, int& unseen)
+ }
+ 
+ 
++std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& uid)
++{
++	std::vector<int> v;
++
++	std::ostringstream command;
++	command.imbue(std::locale::classic());
++
++	command << "SEARCH UID " << uid;
++
++	// Send the request
++	m_connection->send(true, command.str(), true);
++
++	// Get the response
++	utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
++
++	if (resp->isBad() ||
++	    resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
++	{
++		throw exceptions::command_error("SEARCH",
++			m_connection->getParser()->lastLine(), "bad response");
++	}
++
++	const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList = resp->continue_req_or_response_data();
++
++	for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
++	     it = respDataList.begin() ; it != respDataList.end() ; ++it)
++	{
++		if ((*it)->response_data() == NULL)
++		{
++			throw exceptions::command_error("SEARCH",
++				m_connection->getParser()->lastLine(), "invalid response");
++		}
++
++		const IMAPParser::mailbox_data* mailboxData =
++			(*it)->response_data()->mailbox_data();
++
++		// We are only interested in responses of type "SEARCH"
++		if (mailboxData == NULL ||
++		    mailboxData->type() != IMAPParser::mailbox_data::SEARCH)
++		{
++			continue;
++		}
++
++		for (std::vector <IMAPParser::nz_number*>::const_iterator
++				it = mailboxData->search_nz_number_list().begin() ;
++		     it != mailboxData->search_nz_number_list().end();
++		     ++it)
++		{
++			v.push_back((*it)->value());
++		}
++	}
++
++	return v;
++}
++
++
+ } // imap
+ } // net
+ } // vmime
+diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
+index dd680c9..d11ae3b 100644
+--- a/src/net/maildir/maildirFolder.cpp
++++ b/src/net/maildir/maildirFolder.cpp
+@@ -1363,6 +1363,12 @@ const utility::file::path maildirFolder::getMessageFSPath(const int number) cons
+ }
+ 
+ 
++std::vector <int> maildirFolder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ } // maildir
+ } // net
+ } // vmime
+diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
+index d5fc687..e085609 100644
+--- a/src/net/pop3/POP3Folder.cpp
++++ b/src/net/pop3/POP3Folder.cpp
+@@ -843,6 +843,12 @@ void POP3Folder::expunge()
+ }
+ 
+ 
++std::vector <int> POP3Folder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
++{
++	throw exceptions::operation_not_supported();
++}
++
++
+ } // pop3
+ } // net
+ } // vmime
+diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
+index b20e9c9..df9cbaf 100644
+--- a/vmime/net/folder.hpp
++++ b/vmime/net/folder.hpp
+@@ -383,6 +383,13 @@ public:
+ 	  */
+ 	virtual int getFetchCapabilities() const = 0;
+ 
++	/** Return the sequence numbers of messages whose UID equal or greater than uid
++ 	  *
++ 	  * @param uid the uid of the first message
++ 	  * @throw net_exception if an error occurs
++ 	  */
++	virtual std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid) = 0;
++
+ 	// Event listeners
+ 	void addMessageChangedListener(events::messageChangedListener* l);
+ 	void removeMessageChangedListener(events::messageChangedListener* l);
+diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
+index dec3878..cc52596 100644
+--- a/vmime/net/imap/IMAPFolder.hpp
++++ b/vmime/net/imap/IMAPFolder.hpp
+@@ -120,6 +120,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void registerMessage(IMAPMessage* msg);
+diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
+index 7474b1a..68b5b89 100644
+--- a/vmime/net/maildir/maildirFolder.hpp
++++ b/vmime/net/maildir/maildirFolder.hpp
+@@ -121,6 +121,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void scanFolder();
+diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
+index abaa8eb..c482908 100644
+--- a/vmime/net/pop3/POP3Folder.hpp
++++ b/vmime/net/pop3/POP3Folder.hpp
+@@ -119,6 +119,8 @@ public:
+ 
+ 	int getFetchCapabilities() const;
+ 
++	std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
++
+ private:
+ 
+ 	void registerMessage(POP3Message* msg);
+-- 
+1.7.10.3
+
+
+From 3f1a565b8b532f0d11a13d3f6d763b00c8ce625b Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 11:55:07 +0200
+Subject: [PATCH 29/38] Added .gitignore.
+
+---
+ .gitignore |   11 +++++++++++
+ 1 file changed, 11 insertions(+)
+ create mode 100644 .gitignore
+
+diff --git a/.gitignore b/.gitignore
+new file mode 100644
+index 0000000..44e03a8
+--- /dev/null
++++ b/.gitignore
+@@ -0,0 +1,11 @@
++*.o
++*.swp
++build/
++
++/libvmime.a
++/vmime.pc
++/vmime/config.hpp
++
++# SConstruct
++.sconsign.dblite
++/options.cache
+-- 
+1.7.10.3
+
+
+From 5937bcda0fac9cb80d0cecbaa663ecdfe2839c09 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 12:08:01 +0200
+Subject: [PATCH 30/38] Added check before dereferencing.
+
+---
+ vmime/utility/smartPtr.hpp |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/vmime/utility/smartPtr.hpp b/vmime/utility/smartPtr.hpp
+index c448632..df63685 100644
+--- a/vmime/utility/smartPtr.hpp
++++ b/vmime/utility/smartPtr.hpp
+@@ -338,7 +338,9 @@ protected:
+ 	{
+ 		if (m_ptr)
+ 		{
+-			m_ptr->getRefManager()->releaseStrong();
++			if (m_ptr->getRefManager())
++				m_ptr->getRefManager()->releaseStrong();
++
+ 			m_ptr = 0;
+ 		}
+ 	}
+-- 
+1.7.10.3
+
+
+From b0d74ce63ea9563ef4b218bce2497bd668dfad29 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 12:34:51 +0200
+Subject: [PATCH 31/38] Updated README.
+
+---
+ README |   30 +++++++++++++++++++++++++++++-
+ 1 file changed, 29 insertions(+), 1 deletion(-)
+
+diff --git a/README b/README
+index 6921cea..7db9175 100644
+--- a/README
++++ b/README
+@@ -1,2 +1,30 @@
+ 
+-TODO
++VMime is a powerful C++ class library for working with RFC-822 and MIME messages
++and Internet messaging services like IMAP, POP or SMTP.
++
++With VMime you can parse, generate and modify messages, and also connect to store
++and transport services to receive or send messages over the Internet. The library
++offers all the features to build a complete mail client.
++
++Key Features
++------------
++
++* it is free software! GNU GPL license (Commercial licenses available!)
++* fully RFC-compliant implementation
++* object-oriented and modular design
++* very easy-to-use (intuitive design)
++* well documented code
++* very high reliability
++* maximum portability
++
++Features Overview
++-----------------
++
++* RFC-2822 and multipart messages
++* aggregate documents and embedded objects
++* 8-bit MIME and encoded word extensions
++* full support for attachments
++* POP3, IMAP, SMTP, maildir and sendmail
++* SSL/TLS security layer and X.509 certificates (using GNU TLS)
++* SASL authentication (using GNU SASL)
++
+-- 
+1.7.10.3
+
+
+From 350fada21a4f11c2f633a3cde1f2195efefe7e32 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 22:10:54 +0200
+Subject: [PATCH 32/38] Added test: Ensure '7bit' encoding is used when body
+ is 7-bit only.
+
+---
+ tests/parser/bodyPartTest.cpp |   14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index 075b8f9..e1d47a3 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -37,6 +37,7 @@ VMIME_TEST_SUITE_BEGIN
+ 		VMIME_TEST(testPrologEpilog)
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
++		VMIME_TEST(testGenerate7bit)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -200,5 +201,18 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("part2-body", "", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
+ 	}
+ 
++	/** Ensure '7bit' encoding is used when body is 7-bit only. */
++	void testGenerate7bit()
++	{
++		vmime::ref <vmime::plainTextPart> p1 = vmime::create <vmime::plainTextPart>();
++		p1->setText(vmime::create <vmime::stringContentHandler>("Part1 is US-ASCII only."));
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		p1->generateIn(msg, msg);
++
++		vmime::ref <vmime::header> header1 = msg->getBody()->getPartAt(0)->getHeader();
++		VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
++	}
++
+ VMIME_TEST_SUITE_END
+ 
+-- 
+1.7.10.3
+
+
+From 6c877ea41a2e408df61ac6f988c3bae7e0821141 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 22:29:32 +0200
+Subject: [PATCH 33/38] Added tests for Quoted-Printable encoding.
+
+---
+ tests/utility/encoderTest.cpp |   31 +++++++++++++++++++++++++++++++
+ 1 file changed, 31 insertions(+)
+
+diff --git a/tests/utility/encoderTest.cpp b/tests/utility/encoderTest.cpp
+index f2d42b6..b2d6bc8 100644
+--- a/tests/utility/encoderTest.cpp
++++ b/tests/utility/encoderTest.cpp
+@@ -33,6 +33,8 @@ VMIME_TEST_SUITE_BEGIN
+ 	VMIME_TEST_LIST_BEGIN
+ 		VMIME_TEST(testBase64)
+ 		VMIME_TEST(testQuotedPrintable)
++		VMIME_TEST(testQuotedPrintable_SoftLineBreaks)
++		VMIME_TEST(testQuotedPrintable_CRLF)
+ 		VMIME_TEST(testQuotedPrintable_RFC2047)
+ 	VMIME_TEST_LIST_END
+ 
+@@ -288,6 +290,35 @@ VMIME_TEST_SUITE_BEGIN
+ 		}
+ 	}
+ 
++	/** Tests Soft Line Breaks (RFC-2047/6.7(5). */
++	void testQuotedPrintable_SoftLineBreaks()
++	{
++		VASSERT_EQ("1", "Now's the time=\r\n"
++		                " for all folk =\r\n"
++		                "to come to the=\r\n"
++		                " aid of their =\r\n"
++		                "country.",
++		                encode("quoted-printable", "Now's the time for all folk "
++		                                           "to come to the aid of their country.", 15));
++	}
++
++	/** In text mode, ensure line breaks in QP-encoded text are represented
++	  * by a CRLF sequence, as per RFC-2047/6.7(4). */
++	void testQuotedPrintable_CRLF()
++	{
++		vmime::propertySet encProps;
++
++		// in "text" mode
++		encProps["text"] = true;
++		VASSERT_EQ("text", "line1\r\nline2",
++		           encode("quoted-printable", "line1\r\nline2", 80, encProps));
++
++		// in "binary" mode
++		encProps["text"] = false;
++		VASSERT_EQ("binary", "line1=0D=0Aline2",
++		           encode("quoted-printable", "line1\r\nline2", 80, encProps));
++	}
++
+ 	void testQuotedPrintable_RFC2047()
+ 	{
+ 		/*
+-- 
+1.7.10.3
+
+
+From e88f062ab58654aee3cf45f94e8a5dd6c1256279 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Thu, 5 Apr 2012 23:15:04 +0200
+Subject: [PATCH 34/38] Fixed wrong encoding of line breaks in QP-encoded text
+ (issue #7).
+
+---
+ src/encoding.cpp                  |   52 ++++++++++++++++++++++++++++++++-----
+ src/utility/encoder/qpEncoder.cpp |    9 ++++---
+ tests/parser/bodyPartTest.cpp     |   24 +++++++++++++++++
+ vmime/encoding.hpp                |   16 ++++++++++++
+ 4 files changed, 91 insertions(+), 10 deletions(-)
+
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index 0919d44..b4e79db 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -34,19 +34,28 @@ namespace vmime
+ 
+ 
+ encoding::encoding()
+-	: m_name(encodingTypes::SEVEN_BIT)
++	: m_name(encodingTypes::SEVEN_BIT),
++	  m_usage(USAGE_UNKNOWN)
+ {
+ }
+ 
+ 
+ encoding::encoding(const string& name)
+-	: m_name(utility::stringUtils::toLower(name))
++	: m_name(utility::stringUtils::toLower(name)),
++	  m_usage(USAGE_UNKNOWN)
++{
++}
++
++
++encoding::encoding(const string& name, const EncodingUsage usage)
++	: m_name(utility::stringUtils::toLower(name)),
++	  m_usage(usage)
+ {
+ }
+ 
+ 
+ encoding::encoding(const encoding& enc)
+-	: headerFieldValue(), m_name(enc.m_name)
++	: headerFieldValue(), m_name(enc.m_name), m_usage(enc.m_usage)
+ {
+ }
+ 
+@@ -54,6 +63,8 @@ encoding::encoding(const encoding& enc)
+ void encoding::parse(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
++	m_usage = USAGE_UNKNOWN;
++
+ 	m_name = utility::stringUtils::toLower(utility::stringUtils::trim
+ 		(utility::stringUtils::unquote(utility::stringUtils::trim
+ 			(string(buffer.begin() + position, buffer.begin() + end)))));
+@@ -80,7 +91,14 @@ void encoding::generate(utility::outputStream& os, const string::size_type /* ma
+ 
+ ref <utility::encoder::encoder> encoding::getEncoder() const
+ {
+-	return (utility::encoder::encoderFactory::getInstance()->create(generate()));
++	ref <utility::encoder::encoder> encoder =
++		utility::encoder::encoderFactory::getInstance()->create(generate());
++
++	// FIXME: this should not be here (move me into QP encoder instead?)
++	if (m_usage == USAGE_TEXT && m_name == encodingTypes::QUOTED_PRINTABLE)
++		encoder->getProperties()["text"] = true;
++
++	return encoder;
+ }
+ 
+ 
+@@ -94,6 +112,7 @@ encoding& encoding::operator=(const encoding& other)
+ encoding& encoding::operator=(const string& name)
+ {
+ 	m_name = utility::stringUtils::toLower(name);
++	m_usage = USAGE_UNKNOWN;
+ 	return (*this);
+ }
+ 
+@@ -167,6 +186,8 @@ const encoding encoding::decideImpl
+ const encoding encoding::decide
+ 	(ref <const contentHandler> data, const EncodingUsage usage)
+ {
++	encoding enc;
++
+ 	if (usage == USAGE_TEXT && data->isBuffered() &&
+ 	    data->getLength() > 0 && data->getLength() < 32768)
+ 	{
+@@ -177,12 +198,16 @@ const encoding encoding::decide
+ 		data->extract(os);
+ 		os.flush();
+ 
+-		return decideImpl(buffer.begin(), buffer.end());
++		enc = decideImpl(buffer.begin(), buffer.end());
+ 	}
+ 	else
+ 	{
+-		return encoding(encodingTypes::BASE64);
++		enc = encoding(encodingTypes::BASE64);
+ 	}
++
++	enc.setUsage(usage);
++
++	return enc;
+ }
+ 
+ 
+@@ -194,7 +219,10 @@ const encoding encoding::decide(ref <const contentHandler> data,
+ 		encoding recEncoding;
+ 
+ 		if (chset.getRecommendedEncoding(recEncoding))
++		{
++			recEncoding.setUsage(usage);
+ 			return recEncoding;
++		}
+ 	}
+ 
+ 	return decide(data, usage);
+@@ -227,6 +255,18 @@ void encoding::setName(const string& name)
+ }
+ 
+ 
++encoding::EncodingUsage encoding::getUsage() const
++{
++	return m_usage;
++}
++
++
++void encoding::setUsage(const EncodingUsage usage)
++{
++	m_usage = usage;
++}
++
++
+ const std::vector <ref <const component> > encoding::getChildComponents() const
+ {
+ 	return std::vector <ref <const component> >();
+diff --git a/src/utility/encoder/qpEncoder.cpp b/src/utility/encoder/qpEncoder.cpp
+index aa95022..ab8db2e 100644
+--- a/src/utility/encoder/qpEncoder.cpp
++++ b/src/utility/encoder/qpEncoder.cpp
+@@ -292,14 +292,15 @@ utility::stream::size_type qpEncoder::encode(utility::inputStream& in,
+ 			case 13:  // CR
+ 			case 10:  // LF
+ 			{
+-				// Text mode (where using CRLF or LF or ... does not
+-				// care for a new line...)
+-				if (text)
++				// RFC-2045/6.7(4)
++
++				// Text data
++				if (text && !rfc2047)
+ 				{
+ 					outBuffer[outBufferPos++] = c;
+ 					++curCol;
+ 				}
+-				// Binary mode (where CR and LF bytes are important!)
++				// Binary data
+ 				else
+ 				{
+ 					QP_ENCODE_HEX(c);
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index e1d47a3..9d51262 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -38,6 +38,7 @@ VMIME_TEST_SUITE_BEGIN
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
+ 		VMIME_TEST(testGenerate7bit)
++		VMIME_TEST(testTextUsageForQPEncoding)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -214,5 +215,28 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
+ 	}
+ 
++	void testTextUsageForQPEncoding()
++	{
++		vmime::ref <vmime::plainTextPart> part = vmime::create <vmime::plainTextPart>();
++		part->setText(vmime::create <vmime::stringContentHandler>("Part1-line1\r\nPart1-line2\r\n\x89"));
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		part->generateIn(msg, msg);
++
++		vmime::ref <vmime::body> body = msg->getBody()->getPartAt(0)->getBody();
++		vmime::ref <vmime::header> header = msg->getBody()->getPartAt(0)->getHeader();
++
++		std::ostringstream oss;
++		vmime::utility::outputStreamAdapter os(oss);
++		body->generate(os, 80);
++
++		VASSERT_EQ("1", "quoted-printable", header->ContentTransferEncoding()->getValue()->generate());
++
++		// This should *NOT* be:
++		//    Part1-line1=0D=0APart1-line2=0D=0A=89
++		VASSERT_EQ("2", "Part1-line1\r\nPart1-line2\r\n=89", oss.str());
++	}
++
++
+ VMIME_TEST_SUITE_END
+ 
+diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp
+index ba78081..42f5246 100644
+--- a/vmime/encoding.hpp
++++ b/vmime/encoding.hpp
+@@ -47,6 +47,7 @@ public:
+ 
+ 	enum EncodingUsage
+ 	{
++		USAGE_UNKNOWN,
+ 		USAGE_TEXT,         /**< Use for body text. */
+ 		USAGE_BINARY_DATA   /**< Use for attachment, image... */
+ 	};
+@@ -54,6 +55,7 @@ public:
+ 
+ 	encoding();
+ 	explicit encoding(const string& name);
++	encoding(const string& name, const EncodingUsage usage);
+ 	encoding(const encoding& enc);
+ 
+ public:
+@@ -72,6 +74,19 @@ public:
+ 	  */
+ 	void setName(const string& name);
+ 
++	/** Return the type of contents this encoding is used for.
++	  * See the EncodingUsage enum.
++	  */
++	EncodingUsage getUsage() const;
++
++	/** Set the type of contents this encoding is used for.
++	  * See the EncodingUsage enum.
++	  *
++	  * @param usage type of contents
++	  */
++	void setUsage(const EncodingUsage usage);
++
++
+ 	encoding& operator=(const encoding& other);
+ 	encoding& operator=(const string& name);
+ 
+@@ -113,6 +128,7 @@ public:
+ private:
+ 
+ 	string m_name;
++	EncodingUsage m_usage;
+ 
+ 	/** Decide which encoding to use based on the specified data.
+ 	  *
+-- 
+1.7.10.3
+
+
+From ea77bdba96588345090e3de81d9d6af116edeeb5 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Fri, 6 Apr 2012 22:26:18 +0200
+Subject: [PATCH 35/38] Fixed memory leak.
+
+---
+ src/net/tls/TLSSocket.cpp |    6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/net/tls/TLSSocket.cpp b/src/net/tls/TLSSocket.cpp
+index dab0338..3cccc1e 100644
+--- a/src/net/tls/TLSSocket.cpp
++++ b/src/net/tls/TLSSocket.cpp
+@@ -50,6 +50,12 @@ TLSSocket::TLSSocket(ref <TLSSession> session, ref <socket> sok)
+ 
+ TLSSocket::~TLSSocket()
+ {
++	if (m_ex)
++	{
++		delete m_ex;
++		m_ex = NULL;
++	}
++
+ 	try
+ 	{
+ 		disconnect();
+-- 
+1.7.10.3
+
+
+From 440d491fd6da134fcb5f19416743e8f2044556bf Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Sat, 14 Apr 2012 13:46:05 +0200
+Subject: [PATCH 36/38] Split stream.hpp/.cpp into multiple source files.
+
+---
+ SConstruct                                      |   14 +
+ src/charsetConverter.cpp                        |    2 +
+ src/component.cpp                               |    1 +
+ src/encoding.cpp                                |    1 +
+ src/fileAttachment.cpp                          |    1 +
+ src/generatedMessageAttachment.cpp              |    2 +
+ src/htmlTextPart.cpp                            |    2 +
+ src/mdn/MDNHelper.cpp                           |    2 +
+ src/mdn/receivedMDNInfos.cpp                    |    2 +
+ src/message.cpp                                 |    2 +
+ src/net/imap/IMAPFolder.cpp                     |    2 +
+ src/net/imap/IMAPMessage.cpp                    |    2 +
+ src/net/imap/IMAPMessagePartContentHandler.cpp  |    3 +
+ src/net/maildir/maildirFolder.cpp               |    3 +
+ src/net/maildir/maildirMessage.cpp              |    2 +
+ src/net/pop3/POP3Message.cpp                    |    2 +
+ src/net/pop3/POP3Store.cpp                      |    1 +
+ src/net/sendmail/sendmailTransport.cpp          |    2 +
+ src/net/smtp/SMTPTransport.cpp                  |    2 +
+ src/net/transport.cpp                           |    3 +
+ src/parameter.cpp                               |    3 +
+ src/parsedMessageAttachment.cpp                 |    2 +
+ src/security/cert/X509Certificate.cpp           |    2 +
+ src/security/sasl/SASLContext.cpp               |    3 +
+ src/streamContentHandler.cpp                    |    4 +
+ src/stringContentHandler.cpp                    |    4 +
+ src/utility/encoder/defaultEncoder.cpp          |    2 +
+ src/utility/inputStream.cpp                     |   33 ++
+ src/utility/inputStreamAdapter.cpp              |   70 ++++
+ src/utility/inputStreamByteBufferAdapter.cpp    |   90 +++++
+ src/utility/inputStreamPointerAdapter.cpp       |   46 +++
+ src/utility/inputStreamSocketAdapter.cpp        |   82 ++++
+ src/utility/inputStreamStringAdapter.cpp        |   94 +++++
+ src/utility/inputStreamStringProxyAdapter.cpp   |   89 +++++
+ src/utility/outputStream.cpp                    |   33 ++
+ src/utility/outputStreamAdapter.cpp             |   54 +++
+ src/utility/outputStreamByteArrayAdapter.cpp    |   51 +++
+ src/utility/outputStreamSocketAdapter.cpp       |   68 ++++
+ src/utility/outputStreamStringAdapter.cpp       |   51 +++
+ src/utility/stream.cpp                          |  485 -----------------------
+ src/utility/streamUtils.cpp                     |   92 +++++
+ src/utility/stringProxy.cpp                     |    2 +
+ src/word.cpp                                    |    3 +
+ src/wordEncoder.cpp                             |    3 +
+ vmime/base.hpp                                  |   20 +-
+ vmime/charset.hpp                               |    2 +
+ vmime/component.hpp                             |    2 +
+ vmime/net/imap/IMAPParser.hpp                   |    5 +-
+ vmime/utility/filteredStream.hpp                |    3 +-
+ vmime/utility/inputStream.hpp                   |   76 ++++
+ vmime/utility/inputStreamAdapter.hpp            |   64 +++
+ vmime/utility/inputStreamByteBufferAdapter.hpp  |   63 +++
+ vmime/utility/inputStreamPointerAdapter.hpp     |   63 +++
+ vmime/utility/inputStreamSocketAdapter.hpp      |   77 ++++
+ vmime/utility/inputStreamStringAdapter.hpp      |   66 +++
+ vmime/utility/inputStreamStringProxyAdapter.hpp |   68 ++++
+ vmime/utility/outputStream.hpp                  |  107 +++++
+ vmime/utility/outputStreamAdapter.hpp           |   62 +++
+ vmime/utility/outputStreamByteArrayAdapter.hpp  |   58 +++
+ vmime/utility/outputStreamSocketAdapter.hpp     |   75 ++++
+ vmime/utility/outputStreamStringAdapter.hpp     |   59 +++
+ vmime/utility/stream.hpp                        |  381 +-----------------
+ vmime/utility/streamUtils.hpp                   |   66 +++
+ vmime/utility/stringProxy.hpp                   |    1 +
+ vmime/vmime.hpp                                 |   16 +
+ 65 files changed, 1884 insertions(+), 867 deletions(-)
+ create mode 100644 src/utility/inputStream.cpp
+ create mode 100644 src/utility/inputStreamAdapter.cpp
+ create mode 100644 src/utility/inputStreamByteBufferAdapter.cpp
+ create mode 100644 src/utility/inputStreamPointerAdapter.cpp
+ create mode 100644 src/utility/inputStreamSocketAdapter.cpp
+ create mode 100644 src/utility/inputStreamStringAdapter.cpp
+ create mode 100644 src/utility/inputStreamStringProxyAdapter.cpp
+ create mode 100644 src/utility/outputStream.cpp
+ create mode 100644 src/utility/outputStreamAdapter.cpp
+ create mode 100644 src/utility/outputStreamByteArrayAdapter.cpp
+ create mode 100644 src/utility/outputStreamSocketAdapter.cpp
+ create mode 100644 src/utility/outputStreamStringAdapter.cpp
+ create mode 100644 src/utility/streamUtils.cpp
+ create mode 100644 vmime/utility/inputStream.hpp
+ create mode 100644 vmime/utility/inputStreamAdapter.hpp
+ create mode 100644 vmime/utility/inputStreamByteBufferAdapter.hpp
+ create mode 100644 vmime/utility/inputStreamPointerAdapter.hpp
+ create mode 100644 vmime/utility/inputStreamSocketAdapter.hpp
+ create mode 100644 vmime/utility/inputStreamStringAdapter.hpp
+ create mode 100644 vmime/utility/inputStreamStringProxyAdapter.hpp
+ create mode 100644 vmime/utility/outputStream.hpp
+ create mode 100644 vmime/utility/outputStreamAdapter.hpp
+ create mode 100644 vmime/utility/outputStreamByteArrayAdapter.hpp
+ create mode 100644 vmime/utility/outputStreamSocketAdapter.hpp
+ create mode 100644 vmime/utility/outputStreamStringAdapter.hpp
+ create mode 100644 vmime/utility/streamUtils.hpp
+
+diff --git a/SConstruct b/SConstruct
+index 11e884b..ea5c4eb 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -144,6 +144,20 @@ libvmime_sources = [
+ 	'utility/smartPtr.cpp', 'utility/smartPtr.hpp',
+ 	'utility/smartPtrInt.cpp', 'utility/smartPtrInt.hpp',
+ 	'utility/stream.cpp', 'utility/stream.hpp',
++	'utility/streamUtils.cpp', 'utility/streamUtils.hpp',
++	'utility/filteredStream.cpp', 'utility/filteredStream.hpp',
++	'utility/inputStream.cpp', 'utility/inputStream.hpp',
++	'utility/inputStreamAdapter.cpp', 'utility/inputStreamAdapter.hpp',
++	'utility/inputStreamByteBufferAdapter.cpp', 'utility/inputStreamByteBufferAdapter.hpp',
++	'utility/inputStreamPointerAdapter.cpp', 'utility/inputStreamPointerAdapter.hpp',
++	'utility/inputStreamSocketAdapter.cpp', 'utility/inputStreamSocketAdapter.hpp',
++	'utility/inputStreamStringAdapter.cpp', 'utility/inputStreamStringAdapter.hpp',
++	'utility/inputStreamStringProxyAdapter.cpp', 'utility/inputStreamStringProxyAdapter.hpp',
++	'utility/outputStream.cpp', 'utility/outputStream.hpp',
++	'utility/outputStreamAdapter.cpp', 'utility/outputStreamAdapter.hpp',
++	'utility/outputStreamByteArrayAdapter.cpp', 'utility/outputStreamByteArrayAdapter.hpp',
++	'utility/outputStreamSocketAdapter.cpp', 'utility/outputStreamSocketAdapter.hpp',
++	'utility/outputStreamStringAdapter.cpp', 'utility/outputStreamStringAdapter.hpp',
+ 	'utility/stringProxy.cpp', 'utility/stringProxy.hpp',
+ 	'utility/stringUtils.cpp', 'utility/stringUtils.hpp',
+ 	'utility/url.cpp', 'utility/url.hpp',
+diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
+index 2135788..cf75bdd 100644
+--- a/src/charsetConverter.cpp
++++ b/src/charsetConverter.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/charsetConverter.hpp"
+ #include "vmime/exception.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
+ 
+ 
+ extern "C"
+diff --git a/src/component.cpp b/src/component.cpp
+index fbf677b..139cf66 100644
+--- a/src/component.cpp
++++ b/src/component.cpp
+@@ -23,6 +23,7 @@
+ 
+ #include "vmime/component.hpp"
+ #include "vmime/base.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
+ 
+ #include <sstream>
+ 
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index b4e79db..5d99ab6 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -24,6 +24,7 @@
+ #include "vmime/encoding.hpp"
+ #include "vmime/contentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
+ #include <algorithm>
+diff --git a/src/fileAttachment.cpp b/src/fileAttachment.cpp
+index da7c4b7..cb23cd0 100644
+--- a/src/fileAttachment.cpp
++++ b/src/fileAttachment.cpp
+@@ -28,6 +28,7 @@
+ #include "vmime/exception.hpp"
+ 
+ #include "vmime/streamContentHandler.hpp"
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
+ 
+ #include "vmime/contentDispositionField.hpp"
+ 
+diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp
+index e9bd1a6..443a9d3 100644
+--- a/src/generatedMessageAttachment.cpp
++++ b/src/generatedMessageAttachment.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/generatedMessageAttachment.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp
+index c845b57..98524af 100644
+--- a/src/htmlTextPart.cpp
++++ b/src/htmlTextPart.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/emptyContentHandler.hpp"
+ #include "vmime/stringContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp
+index b419b85..1dd7ff3 100644
+--- a/src/mdn/MDNHelper.cpp
++++ b/src/mdn/MDNHelper.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/path.hpp"
+ #include "vmime/dateTime.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace mdn {
+diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp
+index cff211c..f97a58d 100644
+--- a/src/mdn/receivedMDNInfos.cpp
++++ b/src/mdn/receivedMDNInfos.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/mdn/receivedMDNInfos.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace mdn {
+diff --git a/src/message.cpp b/src/message.cpp
+index 6f4b046..1b4f086 100644
+--- a/src/message.cpp
++++ b/src/message.cpp
+@@ -24,6 +24,8 @@
+ #include "vmime/message.hpp"
+ #include "vmime/options.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ 
+ 
+diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
+index 50a2f2b..81bf386 100644
+--- a/src/net/imap/IMAPFolder.cpp
++++ b/src/net/imap/IMAPFolder.cpp
+@@ -34,6 +34,8 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <algorithm>
+ #include <sstream>
+ 
+diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
+index bc661ed..702d5f2 100644
+--- a/src/net/imap/IMAPMessage.cpp
++++ b/src/net/imap/IMAPMessage.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/net/imap/IMAPPart.hpp"
+ #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ #include <iterator>
+ #include <typeinfo>
+diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
+index 4e6ba97..85c6ec2 100644
+--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
++++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
+@@ -23,6 +23,9 @@
+ 
+ #include "vmime/net/imap/IMAPMessagePartContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
+index d11ae3b..8c4b275 100644
+--- a/src/net/maildir/maildirFolder.cpp
++++ b/src/net/maildir/maildirFolder.cpp
+@@ -35,6 +35,9 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/platform.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
+index 51cd1ba..4ab75e7 100644
+--- a/src/net/maildir/maildirMessage.cpp
++++ b/src/net/maildir/maildirMessage.cpp
+@@ -31,6 +31,8 @@
+ #include "vmime/exception.hpp"
+ #include "vmime/platform.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp
+index 50f4f87..69ef004 100644
+--- a/src/net/pop3/POP3Message.cpp
++++ b/src/net/pop3/POP3Message.cpp
+@@ -25,6 +25,8 @@
+ #include "vmime/net/pop3/POP3Folder.hpp"
+ #include "vmime/net/pop3/POP3Store.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <sstream>
+ 
+ 
+diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp
+index 9d554c6..793112a 100644
+--- a/src/net/pop3/POP3Store.cpp
++++ b/src/net/pop3/POP3Store.cpp
+@@ -30,6 +30,7 @@
+ #include "vmime/security/digest/messageDigestFactory.hpp"
+ #include "vmime/utility/filteredStream.hpp"
+ #include "vmime/utility/stringUtils.hpp"
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
+ 
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
+index 53ff0d1..e7762cc 100644
+--- a/src/net/sendmail/sendmailTransport.cpp
++++ b/src/net/sendmail/sendmailTransport.cpp
+@@ -32,6 +32,8 @@
+ #include "vmime/utility/childProcess.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
++#include "vmime/utility/streamUtils.hpp"
++
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+ #include "vmime/config.hpp"
+diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
+index d9fb7b8..bbbea75 100644
+--- a/src/net/smtp/SMTPTransport.cpp
++++ b/src/net/smtp/SMTPTransport.cpp
+@@ -30,6 +30,8 @@
+ 
+ #include "vmime/utility/filteredStream.hpp"
+ #include "vmime/utility/stringUtils.hpp"
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
+ 
+ #include "vmime/net/defaultConnectionInfos.hpp"
+ 
+diff --git a/src/net/transport.cpp b/src/net/transport.cpp
+index dd4663d..f8ca7b7 100644
+--- a/src/net/transport.cpp
++++ b/src/net/transport.cpp
+@@ -27,6 +27,9 @@
+ #include "vmime/mailboxList.hpp"
+ #include "vmime/message.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace net {
+diff --git a/src/parameter.cpp b/src/parameter.cpp
+index d757e1b..ccbe1a5 100644
+--- a/src/parameter.cpp
++++ b/src/parameter.cpp
+@@ -27,6 +27,9 @@
+ #include "vmime/text.hpp"
+ #include "vmime/encoding.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp
+index bde56aa..cb7d71d 100644
+--- a/src/parsedMessageAttachment.cpp
++++ b/src/parsedMessageAttachment.cpp
+@@ -26,6 +26,8 @@
+ #include "vmime/stringContentHandler.hpp"
+ #include "vmime/contentDisposition.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/security/cert/X509Certificate.cpp b/src/security/cert/X509Certificate.cpp
+index 1cd079c..8df4e5e 100644
+--- a/src/security/cert/X509Certificate.cpp
++++ b/src/security/cert/X509Certificate.cpp
+@@ -28,6 +28,8 @@
+ 
+ #include "vmime/security/cert/X509Certificate.hpp"
+ 
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++
+ 
+ namespace vmime {
+ namespace security {
+diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp
+index 51c2bed..4bb33c1 100644
+--- a/src/security/sasl/SASLContext.cpp
++++ b/src/security/sasl/SASLContext.cpp
+@@ -33,6 +33,9 @@
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
+ #include "vmime/utility/stream.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
+ 
+ 
+ namespace vmime {
+diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
+index 2ebd073..89a36b4 100644
+--- a/src/streamContentHandler.cpp
++++ b/src/streamContentHandler.cpp
+@@ -23,6 +23,10 @@
+ 
+ #include "vmime/streamContentHandler.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp
+index 4e85a6c..5a1e72c 100644
+--- a/src/stringContentHandler.cpp
++++ b/src/stringContentHandler.cpp
+@@ -23,6 +23,10 @@
+ 
+ #include "vmime/stringContentHandler.hpp"
+ 
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/src/utility/encoder/defaultEncoder.cpp b/src/utility/encoder/defaultEncoder.cpp
+index 4d0ffb5..e2d226e 100644
+--- a/src/utility/encoder/defaultEncoder.cpp
++++ b/src/utility/encoder/defaultEncoder.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/utility/encoder/defaultEncoder.hpp"
+ 
++#include "vmime/utility/streamUtils.hpp"
++
+ 
+ namespace vmime {
+ namespace utility {
+diff --git a/src/utility/inputStream.cpp b/src/utility/inputStream.cpp
+new file mode 100644
+index 0000000..dd0adf4
+--- /dev/null
++++ b/src/utility/inputStream.cpp
+@@ -0,0 +1,33 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamAdapter.cpp b/src/utility/inputStreamAdapter.cpp
+new file mode 100644
+index 0000000..b44b084
+--- /dev/null
++++ b/src/utility/inputStreamAdapter.cpp
+@@ -0,0 +1,70 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamAdapter::inputStreamAdapter(std::istream& is)
++	: m_stream(is)
++{
++}
++
++
++bool inputStreamAdapter::eof() const
++{
++	return (m_stream.eof());
++}
++
++
++void inputStreamAdapter::reset()
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.seekg(0, std::ios::beg);
++	m_stream.clear();
++}
++
++
++stream::size_type inputStreamAdapter::read
++	(value_type* const data, const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.read(data, count);
++	return (m_stream.gcount());
++}
++
++
++stream::size_type inputStreamAdapter::skip(const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.ignore(count);
++	return (m_stream.gcount());
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamByteBufferAdapter.cpp b/src/utility/inputStreamByteBufferAdapter.cpp
+new file mode 100644
+index 0000000..92e779f
+--- /dev/null
++++ b/src/utility/inputStreamByteBufferAdapter.cpp
+@@ -0,0 +1,90 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length)
++	: m_buffer(buffer), m_length(length), m_pos(0)
++{
++}
++
++
++bool inputStreamByteBufferAdapter::eof() const
++{
++	return m_pos >= m_length;
++}
++
++
++void inputStreamByteBufferAdapter::reset()
++{
++	m_pos = 0;
++}
++
++
++stream::size_type inputStreamByteBufferAdapter::read
++	(value_type* const data, const size_type count)
++{
++	const size_type remaining = m_length - m_pos;
++
++	if (remaining < count)
++	{
++		std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data);
++		m_pos += remaining;
++
++		return remaining;
++	}
++	else
++	{
++		std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data);
++		m_pos += count;
++
++		return count;
++	}
++}
++
++
++stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
++{
++	const size_type remaining = m_length - m_pos;
++
++	if (remaining < count)
++	{
++		m_pos += remaining;
++		return remaining;
++	}
++	else
++	{
++		m_pos += count;
++		return count;
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamPointerAdapter.cpp b/src/utility/inputStreamPointerAdapter.cpp
+new file mode 100644
+index 0000000..4d03e30
+--- /dev/null
++++ b/src/utility/inputStreamPointerAdapter.cpp
+@@ -0,0 +1,46 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamPointerAdapter::inputStreamPointerAdapter(std::istream* is, const bool own)
++	: inputStreamAdapter(*is), m_stream(is), m_own(own)
++{
++}
++
++
++inputStreamPointerAdapter::~inputStreamPointerAdapter()
++{
++	if (m_own)
++		delete (m_stream);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamSocketAdapter.cpp b/src/utility/inputStreamSocketAdapter.cpp
+new file mode 100644
+index 0000000..b93cc3c
+--- /dev/null
++++ b/src/utility/inputStreamSocketAdapter.cpp
+@@ -0,0 +1,82 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++#include "vmime/net/socket.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamSocketAdapter::inputStreamSocketAdapter(net::socket& sok)
++	: m_socket(sok)
++{
++}
++
++
++bool inputStreamSocketAdapter::eof() const
++{
++	// Can't know...
++	return false;
++}
++
++
++void inputStreamSocketAdapter::reset()
++{
++	// Not supported
++}
++
++
++stream::size_type inputStreamSocketAdapter::read
++	(value_type* const data, const size_type count)
++{
++	return m_socket.receiveRaw(data, count);
++}
++
++
++stream::size_type inputStreamSocketAdapter::skip
++	(const size_type /* count */)
++{
++	// Not supported
++	return 0;
++}
++
++
++stream::size_type inputStreamSocketAdapter::getBlockSize()
++{
++	return m_socket.getBlockSize();
++}
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
+diff --git a/src/utility/inputStreamStringAdapter.cpp b/src/utility/inputStreamStringAdapter.cpp
+new file mode 100644
+index 0000000..31c9fda
+--- /dev/null
++++ b/src/utility/inputStreamStringAdapter.cpp
+@@ -0,0 +1,94 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer)
++	: m_buffer(buffer), m_begin(0), m_end(buffer.length()), m_pos(0)
++{
++}
++
++
++inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer,
++	const string::size_type begin, const string::size_type end)
++	: m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin)
++{
++}
++
++
++bool inputStreamStringAdapter::eof() const
++{
++	return (m_pos >= m_end);
++}
++
++
++void inputStreamStringAdapter::reset()
++{
++	m_pos = m_begin;
++}
++
++
++stream::size_type inputStreamStringAdapter::read
++	(value_type* const data, const size_type count)
++{
++	if (m_pos + count >= m_end)
++	{
++		const size_type remaining = m_end - m_pos;
++
++		std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data);
++		m_pos = m_end;
++		return (remaining);
++	}
++	else
++	{
++		std::copy(m_buffer.begin() + m_pos, m_buffer.begin() + m_pos + count, data);
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++stream::size_type inputStreamStringAdapter::skip(const size_type count)
++{
++	if (m_pos + count >= m_end)
++	{
++		const size_type remaining = m_end - m_pos;
++		m_pos = m_end;
++		return (remaining);
++	}
++	else
++	{
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/inputStreamStringProxyAdapter.cpp b/src/utility/inputStreamStringProxyAdapter.cpp
+new file mode 100644
+index 0000000..5e4b60b
+--- /dev/null
++++ b/src/utility/inputStreamStringProxyAdapter.cpp
+@@ -0,0 +1,89 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/stringProxy.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++inputStreamStringProxyAdapter::inputStreamStringProxyAdapter(const stringProxy& buffer)
++	: m_buffer(buffer), m_pos(0)
++{
++}
++
++
++bool inputStreamStringProxyAdapter::eof() const
++{
++	return (m_pos >= m_buffer.length());
++}
++
++
++void inputStreamStringProxyAdapter::reset()
++{
++	m_pos = 0;
++}
++
++
++stream::size_type inputStreamStringProxyAdapter::read
++	(value_type* const data, const size_type count)
++{
++	const size_type remaining = m_buffer.length() - m_pos;
++
++	if (count > remaining)
++	{
++		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_end(), data);
++		m_pos = m_buffer.length();
++		return (remaining);
++	}
++	else
++	{
++		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_begin() + m_pos + count, data);
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
++{
++	const size_type remaining = m_buffer.length() - m_pos;
++
++	if (count > remaining)
++	{
++		m_pos = m_buffer.length();
++		return (remaining);
++	}
++	else
++	{
++		m_pos += count;
++		return (count);
++	}
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStream.cpp b/src/utility/outputStream.cpp
+new file mode 100644
+index 0000000..8a65db5
+--- /dev/null
++++ b/src/utility/outputStream.cpp
+@@ -0,0 +1,33 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamAdapter.cpp b/src/utility/outputStreamAdapter.cpp
+new file mode 100644
+index 0000000..2da94f1
+--- /dev/null
++++ b/src/utility/outputStreamAdapter.cpp
+@@ -0,0 +1,54 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamAdapter::outputStreamAdapter(std::ostream& os)
++	: m_stream(os)
++{
++}
++
++
++void outputStreamAdapter::write
++	(const value_type* const data, const size_type count)
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.write(data, count);
++}
++
++
++void outputStreamAdapter::flush()
++{
++	m_stream.exceptions(std::ios_base::badbit);
++	m_stream.flush();
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamByteArrayAdapter.cpp b/src/utility/outputStreamByteArrayAdapter.cpp
+new file mode 100644
+index 0000000..97b27d2
+--- /dev/null
++++ b/src/utility/outputStreamByteArrayAdapter.cpp
+@@ -0,0 +1,51 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array)
++	: m_array(array)
++{
++}
++
++
++void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count)
++{
++	m_array.insert(m_array.end(), data, data + count);
++}
++
++
++void outputStreamByteArrayAdapter::flush()
++{
++	// Do nothing
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/outputStreamSocketAdapter.cpp b/src/utility/outputStreamSocketAdapter.cpp
+new file mode 100644
+index 0000000..d933e73
+--- /dev/null
++++ b/src/utility/outputStreamSocketAdapter.cpp
+@@ -0,0 +1,68 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++#include "vmime/net/socket.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok)
++	: m_socket(sok)
++{
++}
++
++
++void outputStreamSocketAdapter::write
++	(const value_type* const data, const size_type count)
++{
++	m_socket.sendRaw(data, count);
++}
++
++
++void outputStreamSocketAdapter::flush()
++{
++	// Do nothing
++}
++
++
++stream::size_type outputStreamSocketAdapter::getBlockSize()
++{
++	return m_socket.getBlockSize();
++}
++
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
+diff --git a/src/utility/outputStreamStringAdapter.cpp b/src/utility/outputStreamStringAdapter.cpp
+new file mode 100644
+index 0000000..62b2a72
+--- /dev/null
++++ b/src/utility/outputStreamStringAdapter.cpp
+@@ -0,0 +1,51 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStreamStringAdapter::outputStreamStringAdapter(string& buffer)
++	: m_buffer(buffer)
++{
++}
++
++
++void outputStreamStringAdapter::write(const value_type* const data, const size_type count)
++{
++	m_buffer.append(data, count);
++}
++
++
++void outputStreamStringAdapter::flush()
++{
++	// Do nothing
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
+index ec30b7d..1c940c2 100644
+--- a/src/utility/stream.cpp
++++ b/src/utility/stream.cpp
+@@ -22,503 +22,18 @@
+ //
+ 
+ #include "vmime/utility/stream.hpp"
+-#include "vmime/utility/stringProxy.hpp"
+ 
+-#include <algorithm>  // for std::copy
+-#include <iterator>   // for std::back_inserter
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-   #include "vmime/net/socket.hpp"
+-#endif
+ 
+ 
+ namespace vmime {
+ namespace utility {
+ 
+ 
+-// stream
+-
+ stream::size_type stream::getBlockSize()
+ {
+ 	return 32768;  // 32 KB
+ }
+ 
+ 
+-// Helpers
+-
+-outputStream& operator<<(outputStream& os, const stream::value_type c)
+-{
+-	os.write(&c, 1);
+-	return (os);
+-}
+-
+-
+-outputStream& operator<<(outputStream& os, const string& str)
+-{
+-	os.write(str.data(), str.length());
+-	return (os);
+-}
+-
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
+-{
+-	return bufferedStreamCopy(is, os, 0, NULL);
+-}
+-
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+-	const stream::size_type length, progressListener* progress)
+-{
+-	const stream::size_type blockSize =
+-		std::min(is.getBlockSize(), os.getBlockSize());
+-
+-	std::vector <stream::value_type> vbuffer(blockSize);
+-
+-	stream::value_type* buffer = &vbuffer.front();
+-	stream::size_type total = 0;
+-
+-	if (progress != NULL)
+-		progress->start(length);
+-
+-	while (!is.eof())
+-	{
+-		const stream::size_type read = is.read(buffer, blockSize);
+-
+-		if (read != 0)
+-		{
+-			os.write(buffer, read);
+-			total += read;
+-
+-			if (progress != NULL)
+-				progress->progress(total, std::max(total, length));
+-		}
+-	}
+-
+-	if (progress != NULL)
+-		progress->stop(total);
+-
+-	return (total);
+-}
+-
+-
+-
+-// outputStreamAdapter
+-
+-outputStreamAdapter::outputStreamAdapter(std::ostream& os)
+-	: m_stream(os)
+-{
+-}
+-
+-
+-void outputStreamAdapter::write
+-	(const value_type* const data, const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.write(data, count);
+-}
+-
+-
+-void outputStreamAdapter::flush()
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.flush();
+-}
+-
+-
+-
+-// outputStreamStringAdapter
+-
+-outputStreamStringAdapter::outputStreamStringAdapter(string& buffer)
+-	: m_buffer(buffer)
+-{
+-}
+-
+-
+-void outputStreamStringAdapter::write(const value_type* const data, const size_type count)
+-{
+-	m_buffer.append(data, count);
+-}
+-
+-
+-void outputStreamStringAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-
+-// outputStreamByteArrayAdapter
+-
+-outputStreamByteArrayAdapter::outputStreamByteArrayAdapter(byteArray& array)
+-	: m_array(array)
+-{
+-}
+-
+-
+-void outputStreamByteArrayAdapter::write(const value_type* const data, const size_type count)
+-{
+-	m_array.insert(m_array.end(), data, data + count);
+-}
+-
+-
+-void outputStreamByteArrayAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-
+-// inputStreamAdapter
+-
+-inputStreamAdapter::inputStreamAdapter(std::istream& is)
+-	: m_stream(is)
+-{
+-}
+-
+-
+-bool inputStreamAdapter::eof() const
+-{
+-	return (m_stream.eof());
+-}
+-
+-
+-void inputStreamAdapter::reset()
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.seekg(0, std::ios::beg);
+-	m_stream.clear();
+-}
+-
+-
+-stream::size_type inputStreamAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.read(data, count);
+-	return (m_stream.gcount());
+-}
+-
+-
+-stream::size_type inputStreamAdapter::skip(const size_type count)
+-{
+-	m_stream.exceptions(std::ios_base::badbit);
+-	m_stream.ignore(count);
+-	return (m_stream.gcount());
+-}
+-
+-
+-
+-// inputStreamStringAdapter
+-
+-inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer)
+-	: m_buffer(buffer), m_begin(0), m_end(buffer.length()), m_pos(0)
+-{
+-}
+-
+-
+-inputStreamStringAdapter::inputStreamStringAdapter(const string& buffer,
+-	const string::size_type begin, const string::size_type end)
+-	: m_buffer(buffer), m_begin(begin), m_end(end), m_pos(begin)
+-{
+-}
+-
+-
+-bool inputStreamStringAdapter::eof() const
+-{
+-	return (m_pos >= m_end);
+-}
+-
+-
+-void inputStreamStringAdapter::reset()
+-{
+-	m_pos = m_begin;
+-}
+-
+-
+-stream::size_type inputStreamStringAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	if (m_pos + count >= m_end)
+-	{
+-		const size_type remaining = m_end - m_pos;
+-
+-		std::copy(m_buffer.begin() + m_pos, m_buffer.end(), data);
+-		m_pos = m_end;
+-		return (remaining);
+-	}
+-	else
+-	{
+-		std::copy(m_buffer.begin() + m_pos, m_buffer.begin() + m_pos + count, data);
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-stream::size_type inputStreamStringAdapter::skip(const size_type count)
+-{
+-	if (m_pos + count >= m_end)
+-	{
+-		const size_type remaining = m_end - m_pos;
+-		m_pos = m_end;
+-		return (remaining);
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-
+-// inputStreamStringProxyAdapter
+-
+-inputStreamStringProxyAdapter::inputStreamStringProxyAdapter(const stringProxy& buffer)
+-	: m_buffer(buffer), m_pos(0)
+-{
+-}
+-
+-
+-bool inputStreamStringProxyAdapter::eof() const
+-{
+-	return (m_pos >= m_buffer.length());
+-}
+-
+-
+-void inputStreamStringProxyAdapter::reset()
+-{
+-	m_pos = 0;
+-}
+-
+-
+-stream::size_type inputStreamStringProxyAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	const size_type remaining = m_buffer.length() - m_pos;
+-
+-	if (count > remaining)
+-	{
+-		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_end(), data);
+-		m_pos = m_buffer.length();
+-		return (remaining);
+-	}
+-	else
+-	{
+-		std::copy(m_buffer.it_begin() + m_pos, m_buffer.it_begin() + m_pos + count, data);
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
+-{
+-	const size_type remaining = m_buffer.length() - m_pos;
+-
+-	if (count > remaining)
+-	{
+-		m_pos = m_buffer.length();
+-		return (remaining);
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return (count);
+-	}
+-}
+-
+-
+-
+-// inputStreamPointerAdapter
+-
+-inputStreamPointerAdapter::inputStreamPointerAdapter(std::istream* is, const bool own)
+-	: m_stream(is), m_own(own)
+-{
+-}
+-
+-
+-inputStreamPointerAdapter::inputStreamPointerAdapter(const inputStreamPointerAdapter&)
+-	: inputStream(), m_stream(NULL), m_own(false)
+-{
+-	// Not copiable
+-}
+-
+-
+-inputStreamPointerAdapter::~inputStreamPointerAdapter()
+-{
+-	if (m_own)
+-		delete (m_stream);
+-}
+-
+-
+-bool inputStreamPointerAdapter::eof() const
+-{
+-	return (m_stream->eof());
+-}
+-
+-
+-void inputStreamPointerAdapter::reset()
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->seekg(0, std::ios::beg);
+-	m_stream->clear();
+-}
+-
+-
+-stream::size_type inputStreamPointerAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->read(data, count);
+-	return (m_stream->gcount());
+-}
+-
+-
+-stream::size_type inputStreamPointerAdapter::skip(const size_type count)
+-{
+-	m_stream->exceptions(std::ios_base::badbit);
+-	m_stream->ignore(count);
+-	return (m_stream->gcount());
+-}
+-
+-
+-
+-// inputStreamByteBufferAdapter
+-
+-inputStreamByteBufferAdapter::inputStreamByteBufferAdapter(const byte_t* buffer, const size_type length)
+-	: m_buffer(buffer), m_length(length), m_pos(0)
+-{
+-}
+-
+-
+-bool inputStreamByteBufferAdapter::eof() const
+-{
+-	return m_pos >= m_length;
+-}
+-
+-
+-void inputStreamByteBufferAdapter::reset()
+-{
+-	m_pos = 0;
+-}
+-
+-
+-stream::size_type inputStreamByteBufferAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	const size_type remaining = m_length - m_pos;
+-
+-	if (remaining < count)
+-	{
+-		std::copy(m_buffer + m_pos, m_buffer + m_pos + remaining, data);
+-		m_pos += remaining;
+-
+-		return remaining;
+-	}
+-	else
+-	{
+-		std::copy(m_buffer + m_pos, m_buffer + m_pos + count, data);
+-		m_pos += count;
+-
+-		return count;
+-	}
+-}
+-
+-
+-stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
+-{
+-	const size_type remaining = m_length - m_pos;
+-
+-	if (remaining < count)
+-	{
+-		m_pos += remaining;
+-		return remaining;
+-	}
+-	else
+-	{
+-		m_pos += count;
+-		return count;
+-	}
+-}
+-
+-
+-
+-#ifdef VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+-// outputStreamSocketAdapter
+-
+-outputStreamSocketAdapter::outputStreamSocketAdapter(net::socket& sok)
+-	: m_socket(sok)
+-{
+-}
+-
+-
+-void outputStreamSocketAdapter::write
+-	(const value_type* const data, const size_type count)
+-{
+-	m_socket.sendRaw(data, count);
+-}
+-
+-
+-void outputStreamSocketAdapter::flush()
+-{
+-	// Do nothing
+-}
+-
+-
+-stream::size_type outputStreamSocketAdapter::getBlockSize()
+-{
+-	return m_socket.getBlockSize();
+-}
+-
+-
+-
+-// inputStreamSocketAdapter
+-
+-inputStreamSocketAdapter::inputStreamSocketAdapter(net::socket& sok)
+-	: m_socket(sok)
+-{
+-}
+-
+-
+-bool inputStreamSocketAdapter::eof() const
+-{
+-	// Can't know...
+-	return false;
+-}
+-
+-
+-void inputStreamSocketAdapter::reset()
+-{
+-	// Not supported
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::read
+-	(value_type* const data, const size_type count)
+-{
+-	return m_socket.receiveRaw(data, count);
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::skip
+-	(const size_type /* count */)
+-{
+-	// Not supported
+-	return 0;
+-}
+-
+-
+-stream::size_type inputStreamSocketAdapter::getBlockSize()
+-{
+-	return m_socket.getBlockSize();
+-}
+-
+-
+-#endif // VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+ } // utility
+ } // vmime
+diff --git a/src/utility/streamUtils.cpp b/src/utility/streamUtils.cpp
+new file mode 100644
+index 0000000..f1d3b9d
+--- /dev/null
++++ b/src/utility/streamUtils.cpp
+@@ -0,0 +1,92 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/streamUtils.hpp"
++
++#include <algorithm>  // for std::copy
++#include <iterator>   // for std::back_inserter
++
++
++
++namespace vmime {
++namespace utility {
++
++
++outputStream& operator<<(outputStream& os, const stream::value_type c)
++{
++	os.write(&c, 1);
++	return (os);
++}
++
++
++outputStream& operator<<(outputStream& os, const string& str)
++{
++	os.write(str.data(), str.length());
++	return (os);
++}
++
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
++{
++	return bufferedStreamCopy(is, os, 0, NULL);
++}
++
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
++	const stream::size_type length, progressListener* progress)
++{
++	const stream::size_type blockSize =
++		std::min(is.getBlockSize(), os.getBlockSize());
++
++	std::vector <stream::value_type> vbuffer(blockSize);
++
++	stream::value_type* buffer = &vbuffer.front();
++	stream::size_type total = 0;
++
++	if (progress != NULL)
++		progress->start(length);
++
++	while (!is.eof())
++	{
++		const stream::size_type read = is.read(buffer, blockSize);
++
++		if (read != 0)
++		{
++			os.write(buffer, read);
++			total += read;
++
++			if (progress != NULL)
++				progress->progress(total, std::max(total, length));
++		}
++	}
++
++	if (progress != NULL)
++		progress->stop(total);
++
++	return (total);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stringProxy.cpp b/src/utility/stringProxy.cpp
+index a4ba6d2..74344b5 100644
+--- a/src/utility/stringProxy.cpp
++++ b/src/utility/stringProxy.cpp
+@@ -23,6 +23,8 @@
+ 
+ #include "vmime/utility/stringProxy.hpp"
+ 
++#include "vmime/utility/outputStreamAdapter.hpp"
++
+ #include <iterator>
+ #include <algorithm>
+ 
+diff --git a/src/word.cpp b/src/word.cpp
+index aeaa737..79060a1 100644
+--- a/src/word.cpp
++++ b/src/word.cpp
+@@ -28,6 +28,9 @@
+ #include "vmime/utility/smartPtr.hpp"
+ #include "vmime/parserHelpers.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ #include "vmime/utility/encoder/encoder.hpp"
+ #include "vmime/utility/encoder/b64Encoder.hpp"
+ #include "vmime/utility/encoder/qpEncoder.hpp"
+diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp
+index 67bd7a1..194a189 100644
+--- a/src/wordEncoder.cpp
++++ b/src/wordEncoder.cpp
+@@ -33,6 +33,9 @@
+ 
+ #include "vmime/utility/stringUtils.hpp"
+ 
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++
+ 
+ namespace vmime
+ {
+diff --git a/vmime/base.hpp b/vmime/base.hpp
+index 60e637d..b794031 100644
+--- a/vmime/base.hpp
++++ b/vmime/base.hpp
+@@ -35,7 +35,6 @@
+ #include "vmime/config.hpp"
+ #include "vmime/types.hpp"
+ #include "vmime/constants.hpp"
+-#include "vmime/utility/stream.hpp"
+ #include "vmime/utility/smartPtr.hpp"
+ 
+ 
+@@ -255,7 +254,26 @@ namespace vmime
+ 		return y.dynamicCast <X>();
+ 	}
+ 
++	/** Inherit from this class to indicate the subclass is not copyable,
++	  * ie. you want to prohibit copy construction and copy assignment.
++	  */
++	class noncopyable
++	{
++	protected:
++
++		noncopyable() { }
++		virtual ~noncopyable() { }
++
++	private:
++
++		noncopyable(const noncopyable&);
++		void operator=(const noncopyable&);
++	};
++
+ } // vmime
+ 
+ 
++#include "vmime/utility/stream.hpp"
++
++
+ #endif // VMIME_BASE_HPP_INCLUDED
+diff --git a/vmime/charset.hpp b/vmime/charset.hpp
+index b2e241c..5f5e8e5 100644
+--- a/vmime/charset.hpp
++++ b/vmime/charset.hpp
+@@ -26,6 +26,8 @@
+ 
+ 
+ #include "vmime/base.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ #include "vmime/component.hpp"
+ 
+ 
+diff --git a/vmime/component.hpp b/vmime/component.hpp
+index b38127f..12b0406 100644
+--- a/vmime/component.hpp
++++ b/vmime/component.hpp
+@@ -26,6 +26,8 @@
+ 
+ 
+ #include "vmime/base.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ 
+ 
+ namespace vmime
+diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
+index d71c3ca..f430510 100644
+--- a/vmime/net/imap/IMAPParser.hpp
++++ b/vmime/net/imap/IMAPParser.hpp
+@@ -37,6 +37,9 @@
+ #include "vmime/utility/encoder/b64Encoder.hpp"
+ #include "vmime/utility/encoder/qpEncoder.hpp"
+ 
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++
+ #include "vmime/platform.hpp"
+ 
+ #include "vmime/net/timeoutHandler.hpp"
+@@ -3825,7 +3828,7 @@ public:
+ 			: m_date_time(NULL), m_number(NULL), m_envelope(NULL),
+ 			  m_uniqueid(NULL), m_nstring(NULL), m_body(NULL), m_flag_list(NULL),
+ 			  m_section(NULL)
+-              
++
+ 		{
+ 		}
+ 
+diff --git a/vmime/utility/filteredStream.hpp b/vmime/utility/filteredStream.hpp
+index 00be785..2a55edd 100644
+--- a/vmime/utility/filteredStream.hpp
++++ b/vmime/utility/filteredStream.hpp
+@@ -27,7 +27,8 @@
+ 
+ #include <algorithm>
+ 
+-#include "vmime/utility/stream.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ 
+ 
+ namespace vmime {
+diff --git a/vmime/utility/inputStream.hpp b/vmime/utility/inputStream.hpp
+new file mode 100644
+index 0000000..4a76a7d
+--- /dev/null
++++ b/vmime/utility/inputStream.hpp
+@@ -0,0 +1,76 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/stream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Simple input stream.
++  */
++
++class inputStream : public stream
++{
++public:
++
++	/** Test for end of stream (no more data to read).
++	  *
++	  * @return true if we have reached the end of stream, false otherwise
++	  */
++	virtual bool eof() const = 0;
++
++	/** Set the read pointer to the beginning of the stream.
++	  *
++	  * @warning WARNING: this may not work for all stream types.
++	  */
++	virtual void reset() = 0;
++
++	/** Read data from the stream.
++	  *
++	  * @param data will receive the data read
++	  * @param count maximum number of bytes to read
++	  * @return number of bytes read
++	  */
++	virtual size_type read(value_type* const data, const size_type count) = 0;
++
++	/** Skip a number of bytes.
++	  *
++	  * @param count maximum number of bytes to ignore
++	  * @return number of bytes skipped
++	  */
++	virtual size_type skip(const size_type count) = 0;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamAdapter.hpp b/vmime/utility/inputStreamAdapter.hpp
+new file mode 100644
+index 0000000..278ab52
+--- /dev/null
++++ b/vmime/utility/inputStreamAdapter.hpp
+@@ -0,0 +1,64 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++#include <istream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for C++ standard input streams.
++  */
++
++class inputStreamAdapter : public inputStream
++{
++public:
++
++	/** @param is input stream to wrap
++	  */
++	inputStreamAdapter(std::istream& is);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	std::istream& m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamByteBufferAdapter.hpp b/vmime/utility/inputStreamByteBufferAdapter.hpp
+new file mode 100644
+index 0000000..0f6a442
+--- /dev/null
++++ b/vmime/utility/inputStreamByteBufferAdapter.hpp
+@@ -0,0 +1,63 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for reading from an array of bytes.
++  */
++
++class inputStreamByteBufferAdapter : public inputStream
++{
++public:
++
++	inputStreamByteBufferAdapter(const byte_t* buffer, size_type length);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	const byte_t* m_buffer;
++	const size_type m_length;
++
++	size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamPointerAdapter.hpp b/vmime/utility/inputStreamPointerAdapter.hpp
+new file mode 100644
+index 0000000..44e9bad
+--- /dev/null
++++ b/vmime/utility/inputStreamPointerAdapter.hpp
+@@ -0,0 +1,63 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStreamAdapter.hpp"
++
++#include <istream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for pointer to C++ standard input stream.
++  */
++
++class inputStreamPointerAdapter : public inputStreamAdapter
++{
++public:
++
++	/** @param is input stream to wrap
++	  * @param own if set to 'true', the pointer will be deleted when
++	  * this object is destroyed
++	  */
++	inputStreamPointerAdapter(std::istream* is, const bool own = true);
++	~inputStreamPointerAdapter();
++
++private:
++
++	std::istream* m_stream;
++	const bool m_own;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMPOINTERADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamSocketAdapter.hpp b/vmime/utility/inputStreamSocketAdapter.hpp
+new file mode 100644
+index 0000000..0f99c21
+--- /dev/null
++++ b/vmime/utility/inputStreamSocketAdapter.hpp
+@@ -0,0 +1,77 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++namespace vmime {
++namespace net {
++	class socket;  // forward reference
++} // net
++} // vmime
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An input stream that is connected to a socket.
++  */
++
++class inputStreamSocketAdapter : public inputStream
++{
++public:
++
++	inputStreamSocketAdapter(net::socket& sok);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++	size_type getBlockSize();
++
++private:
++
++	inputStreamSocketAdapter(const inputStreamSocketAdapter&);
++
++	net::socket& m_socket;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamStringAdapter.hpp b/vmime/utility/inputStreamStringAdapter.hpp
+new file mode 100644
+index 0000000..a7d986f
+--- /dev/null
++++ b/vmime/utility/inputStreamStringAdapter.hpp
+@@ -0,0 +1,66 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for string input.
++  */
++
++class inputStreamStringAdapter : public inputStream
++{
++public:
++
++	inputStreamStringAdapter(const string& buffer);
++	inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	inputStreamStringAdapter(const inputStreamStringAdapter&);
++
++	const string m_buffer;  // do _NOT_ keep a reference...
++	const string::size_type m_begin;
++	const string::size_type m_end;
++	string::size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/inputStreamStringProxyAdapter.hpp b/vmime/utility/inputStreamStringProxyAdapter.hpp
+new file mode 100644
+index 0000000..74b3f60
+--- /dev/null
++++ b/vmime/utility/inputStreamStringProxyAdapter.hpp
+@@ -0,0 +1,68 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++class stringProxy;
++
++
++/** An adapter class for stringProxy input.
++  */
++
++class inputStreamStringProxyAdapter : public inputStream
++{
++public:
++
++	/** @param buffer stringProxy object to wrap
++	  */
++	inputStreamStringProxyAdapter(const stringProxy& buffer);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++
++private:
++
++	inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&);
++
++	const stringProxy& m_buffer;
++	string::size_type m_pos;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStream.hpp b/vmime/utility/outputStream.hpp
+new file mode 100644
+index 0000000..7372d20
+--- /dev/null
++++ b/vmime/utility/outputStream.hpp
+@@ -0,0 +1,107 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/stream.hpp"
++
++
++#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // VC++6
++#	include <cstring>
++#endif
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Simple output stream.
++  */
++
++class outputStream : public stream
++{
++public:
++
++	/** Write data to the stream.
++	  *
++	  * @param data buffer containing data to write
++	  * @param count number of bytes to write
++	  */
++	virtual void write(const value_type* const data, const size_type count) = 0;
++
++	/** Flush this output stream and forces any buffered output
++	  * bytes to be written out to the stream.
++	  */
++	virtual void flush() = 0;
++};
++
++
++// Helpers functions
++
++outputStream& operator<<(outputStream& os, const string& str);
++outputStream& operator<<(outputStream& os, const stream::value_type c);
++
++
++#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // Internal compiler error with VC++6
++
++inline outputStream& operator<<(outputStream& os, const char* str)
++{
++	os.write(str, ::strlen(str));
++	return (os);
++}
++
++#else
++
++template <int N>
++outputStream& operator<<(outputStream& os, const char (&str)[N])
++{
++	os.write(str, N - 1);
++	return (os);
++}
++
++#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
++
++
++template <typename T>
++outputStream& operator<<(outputStream& os, const T& t)
++{
++	std::ostringstream oss;
++	oss.imbue(std::locale::classic());  // no formatting
++
++	oss << t;
++
++	os << oss.str();
++
++	return (os);
++}
++
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamAdapter.hpp b/vmime/utility/outputStreamAdapter.hpp
+new file mode 100644
+index 0000000..be55d8d
+--- /dev/null
++++ b/vmime/utility/outputStreamAdapter.hpp
+@@ -0,0 +1,62 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++#include <ostream>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for C++ standard output streams.
++  */
++
++class outputStreamAdapter : public outputStream
++{
++public:
++
++	/** @param os output stream to wrap
++	  */
++	outputStreamAdapter(std::ostream& os);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++private:
++
++	std::ostream& m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamByteArrayAdapter.hpp b/vmime/utility/outputStreamByteArrayAdapter.hpp
+new file mode 100644
+index 0000000..bf7d839
+--- /dev/null
++++ b/vmime/utility/outputStreamByteArrayAdapter.hpp
+@@ -0,0 +1,58 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for byte array output.
++  */
++
++class outputStreamByteArrayAdapter : public outputStream
++{
++public:
++
++	outputStreamByteArrayAdapter(byteArray& array);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++private:
++
++	byteArray& m_array;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMBYTEARRAYADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamSocketAdapter.hpp b/vmime/utility/outputStreamSocketAdapter.hpp
+new file mode 100644
+index 0000000..e3d3eb0
+--- /dev/null
++++ b/vmime/utility/outputStreamSocketAdapter.hpp
+@@ -0,0 +1,75 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++#if VMIME_HAVE_MESSAGING_FEATURES
++
++
++namespace vmime {
++namespace net {
++	class socket;  // forward reference
++} // net
++} // vmime
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An output stream that is connected to a socket.
++  */
++
++class outputStreamSocketAdapter : public outputStream
++{
++public:
++
++	outputStreamSocketAdapter(net::socket& sok);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++	size_type getBlockSize();
++
++private:
++
++	outputStreamSocketAdapter(const outputStreamSocketAdapter&);
++
++	net::socket& m_socket;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_HAVE_MESSAGING_FEATURES
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMSOCKETADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/outputStreamStringAdapter.hpp b/vmime/utility/outputStreamStringAdapter.hpp
+new file mode 100644
+index 0000000..8c8b304
+--- /dev/null
++++ b/vmime/utility/outputStreamStringAdapter.hpp
+@@ -0,0 +1,59 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/outputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class for string output.
++  */
++
++class outputStreamStringAdapter : public outputStream
++{
++public:
++
++	outputStreamStringAdapter(string& buffer);
++
++	void write(const value_type* const data, const size_type count);
++	void flush();
++
++size_type getBlockSize(){return 8192;}
++private:
++
++	string& m_buffer;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_OUTPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp
+index 1faab55..566ab9d 100644
+--- a/vmime/utility/stream.hpp
++++ b/vmime/utility/stream.hpp
+@@ -25,40 +25,22 @@
+ #define VMIME_UTILITY_STREAM_HPP_INCLUDED
+ 
+ 
+-#include <istream>
+-#include <ostream>
+ #include <sstream>
+ 
+ #include "vmime/config.hpp"
+ #include "vmime/types.hpp"
+-
+-#include "vmime/utility/progressListener.hpp"
+-
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-	namespace vmime {
+-	namespace net {
+-		class socket;  // forward reference
+-	} // net
+-	} // vmime
+-#endif
+-
+-#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // VC++6
+-#   include <cstring>
+-#endif
++#include "vmime/base.hpp"
+ 
+ 
+ namespace vmime {
+ namespace utility {
+ 
+ 
+-class stringProxy;
+-
+ 
+ /** Base class for input/output stream.
+   */
+ 
+-class stream : public object
++class stream : public object, private noncopyable
+ {
+ public:
+ 
+@@ -81,365 +63,6 @@ public:
+ };
+ 
+ 
+-
+-/** Simple output stream.
+-  */
+-
+-class outputStream : public stream
+-{
+-public:
+-
+-	/** Write data to the stream.
+-	  *
+-	  * @param data buffer containing data to write
+-	  * @param count number of bytes to write
+-	  */
+-	virtual void write(const value_type* const data, const size_type count) = 0;
+-
+-	/** Flush this output stream and forces any buffered output
+-	  * bytes to be written out to the stream.
+-	  */
+-	virtual void flush() = 0;
+-};
+-
+-
+-
+-/** Simple input stream.
+-  */
+-
+-class inputStream : public stream
+-{
+-public:
+-
+-	/** Test for end of stream (no more data to read).
+-	  *
+-	  * @return true if we have reached the end of stream, false otherwise
+-	  */
+-	virtual bool eof() const = 0;
+-
+-	/** Set the read pointer to the beginning of the stream.
+-	  *
+-	  * @warning WARNING: this may not work for all stream types.
+-	  */
+-	virtual void reset() = 0;
+-
+-	/** Read data from the stream.
+-	  *
+-	  * @param data will receive the data read
+-	  * @param count maximum number of bytes to read
+-	  * @return number of bytes read
+-	  */
+-	virtual size_type read(value_type* const data, const size_type count) = 0;
+-
+-	/** Skip a number of bytes.
+-	  *
+-	  * @param count maximum number of bytes to ignore
+-	  * @return number of bytes skipped
+-	  */
+-	virtual size_type skip(const size_type count) = 0;
+-};
+-
+-
+-
+-// Helpers functions
+-
+-outputStream& operator<<(outputStream& os, const string& str);
+-outputStream& operator<<(outputStream& os, const stream::value_type c);
+-
+-
+-#if defined(_MSC_VER) && (_MSC_VER <= 1200)  // Internal compiler error with VC++6
+-
+-inline outputStream& operator<<(outputStream& os, const char* str)
+-{
+-	os.write(str, ::strlen(str));
+-	return (os);
+-}
+-
+-#else
+-
+-template <int N>
+-outputStream& operator<<(outputStream& os, const char (&str)[N])
+-{
+-	os.write(str, N - 1);
+-	return (os);
+-}
+-
+-#endif // defined(_MSC_VER) && (_MSC_VER <= 1200)
+-
+-
+-template <typename T>
+-outputStream& operator<<(outputStream& os, const T& t)
+-{
+-	std::ostringstream oss;
+-	oss.imbue(std::locale::classic());  // no formatting
+-
+-	oss << t;
+-
+-	os << oss.str();
+-
+-	return (os);
+-}
+-
+-
+-/** Copy data from one stream into another stream using a buffered method.
+-  *
+-  * @param is input stream (source data)
+-  * @param os output stream (destination for data)
+-  * @return number of bytes copied
+-  */
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
+-
+-/** Copy data from one stream into another stream using a buffered method
+-  * and notify progress state of the operation.
+-  *
+-  * @param is input stream (source data)
+-  * @param os output stream (destination for data)
+-  * @param length predicted number of bytes to copy
+-  * @param progress listener to notify
+-  * @return number of bytes copied
+-  */
+-
+-stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+-	const stream::size_type length, progressListener* progress);
+-
+-
+-// Adapters
+-
+-
+-/** An adapter class for C++ standard output streams.
+-  */
+-
+-class outputStreamAdapter : public outputStream
+-{
+-public:
+-
+-	/** @param os output stream to wrap
+-	  */
+-	outputStreamAdapter(std::ostream& os);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-private:
+-
+-	std::ostream& m_stream;
+-};
+-
+-
+-/** An adapter class for string output.
+-  */
+-
+-class outputStreamStringAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamStringAdapter(string& buffer);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-size_type getBlockSize(){return 8192;}
+-private:
+-
+-	string& m_buffer;
+-};
+-
+-
+-/** An adapter class for byte array output.
+-  */
+-
+-class outputStreamByteArrayAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamByteArrayAdapter(byteArray& array);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-private:
+-
+-	byteArray& m_array;
+-};
+-
+-
+-/** An adapter class for C++ standard input streams.
+-  */
+-
+-class inputStreamAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param is input stream to wrap
+-	  */
+-	inputStreamAdapter(std::istream& is);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	std::istream& m_stream;
+-};
+-
+-
+-/** An adapter class for string input.
+-  */
+-
+-class inputStreamStringAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamStringAdapter(const string& buffer);
+-	inputStreamStringAdapter(const string& buffer, const string::size_type begin, const string::size_type end);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamStringAdapter(const inputStreamStringAdapter&);
+-
+-	const string m_buffer;  // do _NOT_ keep a reference...
+-	const string::size_type m_begin;
+-	const string::size_type m_end;
+-	string::size_type m_pos;
+-};
+-
+-
+-/** An adapter class for stringProxy input.
+-  */
+-
+-class inputStreamStringProxyAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param buffer stringProxy object to wrap
+-	  */
+-	inputStreamStringProxyAdapter(const stringProxy& buffer);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamStringProxyAdapter(const inputStreamStringProxyAdapter&);
+-
+-	const stringProxy& m_buffer;
+-	string::size_type m_pos;
+-};
+-
+-
+-/** An adapter class for pointer to C++ standard input stream.
+-  */
+-
+-class inputStreamPointerAdapter : public inputStream
+-{
+-public:
+-
+-	/** @param is input stream to wrap
+-	  * @param own if set to 'true', the pointer will be deleted when
+-	  * this object is destroyed
+-	  */
+-	inputStreamPointerAdapter(std::istream* is, const bool own = true);
+-	~inputStreamPointerAdapter();
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	inputStreamPointerAdapter(const inputStreamPointerAdapter&);
+-
+-	std::istream* m_stream;
+-	const bool m_own;
+-};
+-
+-
+-/** An adapter class for reading from an array of bytes.
+-  */
+-
+-class inputStreamByteBufferAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamByteBufferAdapter(const byte_t* buffer, size_type length);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-private:
+-
+-	const byte_t* m_buffer;
+-	const size_type m_length;
+-
+-	size_type m_pos;
+-};
+-
+-
+-#if VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+-/** An output stream that is connected to a socket.
+-  */
+-
+-class outputStreamSocketAdapter : public outputStream
+-{
+-public:
+-
+-	outputStreamSocketAdapter(net::socket& sok);
+-
+-	void write(const value_type* const data, const size_type count);
+-	void flush();
+-
+-	size_type getBlockSize();
+-
+-private:
+-
+-	outputStreamSocketAdapter(const outputStreamSocketAdapter&);
+-
+-	net::socket& m_socket;
+-};
+-
+-
+-/** An input stream that is connected to a socket.
+-  */
+-
+-class inputStreamSocketAdapter : public inputStream
+-{
+-public:
+-
+-	inputStreamSocketAdapter(net::socket& sok);
+-
+-	bool eof() const;
+-	void reset();
+-	size_type read(value_type* const data, const size_type count);
+-	size_type skip(const size_type count);
+-
+-	size_type getBlockSize();
+-
+-private:
+-
+-	inputStreamSocketAdapter(const inputStreamSocketAdapter&);
+-
+-	net::socket& m_socket;
+-};
+-
+-
+-#endif // VMIME_HAVE_MESSAGING_FEATURES
+-
+-
+ } // utility
+ } // vmime
+ 
+diff --git a/vmime/utility/streamUtils.hpp b/vmime/utility/streamUtils.hpp
+new file mode 100644
+index 0000000..cdf70aa
+--- /dev/null
++++ b/vmime/utility/streamUtils.hpp
+@@ -0,0 +1,66 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++#define VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/outputStream.hpp"
++
++#include "vmime/utility/progressListener.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** Copy data from one stream into another stream using a buffered method.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
++
++/** Copy data from one stream into another stream using a buffered method
++  * and notify progress state of the operation.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @param length predicted number of bytes to copy
++  * @param progress listener to notify
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
++	const stream::size_type length, progressListener* progress);
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_STREAMUTILS_HPP_INCLUDED
++
+diff --git a/vmime/utility/stringProxy.hpp b/vmime/utility/stringProxy.hpp
+index 21c65ea..66a6dfd 100644
+--- a/vmime/utility/stringProxy.hpp
++++ b/vmime/utility/stringProxy.hpp
+@@ -29,6 +29,7 @@
+ 
+ #include "vmime/types.hpp"
+ #include "vmime/utility/stream.hpp"
++#include "vmime/utility/outputStream.hpp"
+ #include "vmime/utility/progressListener.hpp"
+ 
+ 
+diff --git a/vmime/vmime.hpp b/vmime/vmime.hpp
+index f187b9e..fd04853 100644
+--- a/vmime/vmime.hpp
++++ b/vmime/vmime.hpp
+@@ -68,6 +68,22 @@
+ // Encoders
+ #include "vmime/utility/encoder/encoderFactory.hpp"
+ 
++// Streams
++#include "vmime/utility/filteredStream.hpp"
++#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/inputStreamAdapter.hpp"
++#include "vmime/utility/inputStreamByteBufferAdapter.hpp"
++#include "vmime/utility/inputStreamPointerAdapter.hpp"
++#include "vmime/utility/inputStreamSocketAdapter.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/inputStreamStringProxyAdapter.hpp"
++#include "vmime/utility/outputStream.hpp"
++#include "vmime/utility/outputStreamAdapter.hpp"
++#include "vmime/utility/outputStreamByteArrayAdapter.hpp"
++#include "vmime/utility/outputStreamSocketAdapter.hpp"
++#include "vmime/utility/outputStreamStringAdapter.hpp"
++#include "vmime/utility/streamUtils.hpp"
++
+ // Message builder/parser
+ #include "vmime/messageBuilder.hpp"
+ #include "vmime/messageParser.hpp"
+-- 
+1.7.10.3
+
+
+From be30b47f09c5358db2ac8e42fa2bb4a14ec24c51 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Mon, 16 Apr 2012 22:32:33 +0200
+Subject: [PATCH 37/38] Added ability to parse directly from an input stream
+ (eg. file). This allows very big messages to be
+ parsed without loading the whole message data into
+ memory.
+
+---
+ ChangeLog                                          |    6 +
+ SConstruct                                         |    3 +
+ src/addressList.cpp                                |    8 +-
+ src/body.cpp                                       |  220 ++++++++++++++------
+ src/bodyPart.cpp                                   |   17 +-
+ src/charset.cpp                                    |    8 +-
+ src/component.cpp                                  |  137 ++++++++++--
+ src/contentDisposition.cpp                         |    8 +-
+ src/dateTime.cpp                                   |    8 +-
+ src/disposition.cpp                                |    8 +-
+ src/encoding.cpp                                   |    8 +-
+ src/header.cpp                                     |    8 +-
+ src/headerField.cpp                                |    8 +-
+ src/mailbox.cpp                                    |    8 +-
+ src/mailboxGroup.cpp                               |    8 +-
+ src/mailboxList.cpp                                |    6 +-
+ src/mediaType.cpp                                  |    8 +-
+ src/message.cpp                                    |    9 +-
+ src/messageId.cpp                                  |    8 +-
+ src/messageIdSequence.cpp                          |    8 +-
+ src/parameter.cpp                                  |   40 ++--
+ src/parameterizedHeaderField.cpp                   |   12 +-
+ src/path.cpp                                       |   12 +-
+ src/platforms/posix/posixFile.cpp                  |   20 ++
+ src/platforms/windows/windowsFile.cpp              |   18 ++
+ src/relay.cpp                                      |    8 +-
+ src/streamContentHandler.cpp                       |    4 +
+ src/text.cpp                                       |    8 +-
+ src/utility/inputStreamAdapter.cpp                 |   12 ++
+ src/utility/inputStreamByteBufferAdapter.cpp       |   13 ++
+ src/utility/inputStreamStringAdapter.cpp           |   13 ++
+ src/utility/inputStreamStringProxyAdapter.cpp      |   13 ++
+ src/utility/parserInputStreamAdapter.cpp           |  162 ++++++++++++++
+ src/utility/seekableInputStreamRegionAdapter.cpp   |   95 +++++++++
+ src/utility/stream.cpp                             |    4 +
+ src/utility/streamUtils.cpp                        |   29 +++
+ src/word.cpp                                       |    8 +-
+ tests/parser/bodyPartTest.cpp                      |   89 ++++++++
+ vmime/addressList.hpp                              |   20 +-
+ vmime/body.hpp                                     |   20 +-
+ vmime/bodyPart.hpp                                 |   20 +-
+ vmime/charset.hpp                                  |   20 +-
+ vmime/component.hpp                                |   97 +++++++--
+ vmime/contentDisposition.hpp                       |   20 +-
+ vmime/dateTime.hpp                                 |   20 +-
+ vmime/disposition.hpp                              |   20 +-
+ vmime/encoding.hpp                                 |   20 +-
+ vmime/header.hpp                                   |   20 +-
+ vmime/headerField.hpp                              |   25 ++-
+ vmime/mailbox.hpp                                  |   15 +-
+ vmime/mailboxGroup.hpp                             |   20 +-
+ vmime/mailboxList.hpp                              |   20 +-
+ vmime/mediaType.hpp                                |   20 +-
+ vmime/message.hpp                                  |   23 +-
+ vmime/messageId.hpp                                |   28 ++-
+ vmime/messageIdSequence.hpp                        |   20 +-
+ vmime/parameter.hpp                                |   22 +-
+ vmime/parameterizedHeaderField.hpp                 |   22 +-
+ vmime/parserHelpers.hpp                            |    4 +
+ vmime/path.hpp                                     |   19 +-
+ vmime/platforms/posix/posixFile.hpp                |    6 +-
+ vmime/platforms/windows/windowsFile.hpp            |    3 +
+ vmime/relay.hpp                                    |   18 +-
+ vmime/text.hpp                                     |   19 +-
+ vmime/utility/inputStreamAdapter.hpp               |    6 +-
+ vmime/utility/inputStreamByteBufferAdapter.hpp     |    6 +-
+ vmime/utility/inputStreamStringAdapter.hpp         |    6 +-
+ vmime/utility/inputStreamStringProxyAdapter.hpp    |    6 +-
+ vmime/utility/parserInputStreamAdapter.hpp         |  173 +++++++++++++++
+ vmime/utility/seekableInputStream.hpp              |   64 ++++++
+ vmime/utility/seekableInputStreamRegionAdapter.hpp |   71 +++++++
+ vmime/utility/stream.hpp                           |    4 +
+ vmime/utility/streamUtils.hpp                      |   13 ++
+ vmime/word.hpp                                     |   49 ++++-
+ 74 files changed, 1643 insertions(+), 378 deletions(-)
+ create mode 100644 src/utility/parserInputStreamAdapter.cpp
+ create mode 100644 src/utility/seekableInputStreamRegionAdapter.cpp
+ create mode 100644 vmime/utility/parserInputStreamAdapter.hpp
+ create mode 100644 vmime/utility/seekableInputStream.hpp
+ create mode 100644 vmime/utility/seekableInputStreamRegionAdapter.hpp
+
+diff --git a/ChangeLog b/ChangeLog
+index 8fdcdb0..1b5b2cf 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -2,6 +2,12 @@
+ VERSION 0.9.2svn
+ ================
+ 
++2012-04-16  Vincent Richard  <vincent@vincent-richard.net>
++
++ * MIME Parser can now operate directly on an input stream (eg. file).
++   This allows very big messages to be parsed without loading the whole
++   message data into memory.
++
+ 2010-11-16  Vincent Richard  <vincent@vincent-richard.net>
+ 
+  * Started version 0.9.2.
+diff --git a/SConstruct b/SConstruct
+index ea5c4eb..2690172 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -153,11 +153,14 @@ libvmime_sources = [
+ 	'utility/inputStreamSocketAdapter.cpp', 'utility/inputStreamSocketAdapter.hpp',
+ 	'utility/inputStreamStringAdapter.cpp', 'utility/inputStreamStringAdapter.hpp',
+ 	'utility/inputStreamStringProxyAdapter.cpp', 'utility/inputStreamStringProxyAdapter.hpp',
++	'utility/seekableInputStream.hpp',
++	'utility/seekableInputStreamRegionAdapter.cpp', 'utility/seekableInputStreamRegionAdapter.hpp',
+ 	'utility/outputStream.cpp', 'utility/outputStream.hpp',
+ 	'utility/outputStreamAdapter.cpp', 'utility/outputStreamAdapter.hpp',
+ 	'utility/outputStreamByteArrayAdapter.cpp', 'utility/outputStreamByteArrayAdapter.hpp',
+ 	'utility/outputStreamSocketAdapter.cpp', 'utility/outputStreamSocketAdapter.hpp',
+ 	'utility/outputStreamStringAdapter.cpp', 'utility/outputStreamStringAdapter.hpp',
++	'utility/parserInputStreamAdapter.cpp', 'utility/parserInputStreamAdapter.hpp',
+ 	'utility/stringProxy.cpp', 'utility/stringProxy.hpp',
+ 	'utility/stringUtils.cpp', 'utility/stringUtils.hpp',
+ 	'utility/url.cpp', 'utility/url.hpp',
+diff --git a/src/addressList.cpp b/src/addressList.cpp
+index 31a2a3d..f06460d 100644
+--- a/src/addressList.cpp
++++ b/src/addressList.cpp
+@@ -50,7 +50,7 @@ addressList::~addressList()
+ }
+ 
+ 
+-void addressList::parse(const string& buffer, const string::size_type position,
++void addressList::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllAddresses();
+@@ -72,7 +72,7 @@ void addressList::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void addressList::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void addressList::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+@@ -248,9 +248,9 @@ const std::vector <ref <address> > addressList::getAddressList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > addressList::getChildComponents() const
++const std::vector <ref <component> > addressList::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_list, list);
+ 
+diff --git a/src/body.cpp b/src/body.cpp
+index 9d7d57f..732fa8b 100644
+--- a/src/body.cpp
++++ b/src/body.cpp
+@@ -31,10 +31,13 @@
+ 
+ #include "vmime/utility/random.hpp"
+ 
++#include "vmime/utility/seekableInputStreamRegionAdapter.hpp"
++
+ #include "vmime/parserHelpers.hpp"
+ 
+ #include "vmime/emptyContentHandler.hpp"
+ #include "vmime/stringContentHandler.hpp"
++#include "vmime/streamContentHandler.hpp"
+ 
+ 
+ namespace vmime
+@@ -52,11 +55,28 @@ body::~body()
+ }
+ 
+ 
+-void body::parse(const string& buffer, const string::size_type position,
+-	const string::size_type end, string::size_type* newPosition)
++void body::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser,
++	 const utility::stream::size_type position,
++	 const utility::stream::size_type end,
++	 utility::stream::size_type* newPosition)
+ {
+ 	removeAllParts();
+ 
++	m_prologText.clear();
++	m_epilogText.clear();
++
++	if (end == position)
++	{
++
++		setParsedBounds(position, end);
++
++		if (newPosition)
++			*newPosition = end;
++
++		return;
++	}
++
+ 	// Check whether the body is a MIME-multipart
+ 	bool isMultipart = false;
+ 	string boundary;
+@@ -80,37 +100,61 @@ void body::parse(const string& buffer, const string::size_type position,
+ 			{
+ 				// No "boundary" parameter specified: we can try to
+ 				// guess it by scanning the body contents...
+-				string::size_type pos = buffer.find("\n--", position);
++				utility::stream::size_type pos = position;
++
++				parser->seek(pos);
++
++				if (pos + 2 < end && parser->matchBytes("--", 2))
++				{
++					pos += 2;
++				}
++				else
++				{
++					pos = parser->findNext("\n--", position);
+ 
+-				if ((pos != string::npos) && (pos < end))
++					if ((pos != utility::stream::npos) && (pos + 3 < end))
++						pos += 3;  // skip \n--
++				}
++
++				if ((pos != utility::stream::npos) && (pos < end))
+ 				{
+-					pos += 3;
++					parser->seek(pos);
+ 
+-					const string::size_type start = pos;
++					// Read some bytes after boundary separator
++					utility::stream::value_type buffer[256];
++					const utility::stream::size_type bufferLen =
++						parser->read(buffer, std::min(end - pos, sizeof(buffer) / sizeof(buffer[0])));
+ 
+-					char_t c = buffer[pos];
+-					string::size_type length = 0;
++					buffer[sizeof(buffer) / sizeof(buffer[0]) - 1] = '\0';
+ 
++					// Extract boundary from buffer (stop at first CR or LF).
+ 					// We have to stop after a reasonnably long boundary length (100)
+ 					// not to take the whole body contents for a boundary...
+-					while (pos < end && length < 100 && !(c == '\r' || c == '\n'))
++					string::value_type boundaryBytes[100];
++					string::size_type boundaryLen = 0;
++
++					for (string::value_type c = buffer[0] ;
++					     boundaryLen < bufferLen && boundaryLen < 100 && !(c == '\r' || c == '\n') ;
++					     c = buffer[++boundaryLen])
+ 					{
+-						++length;
+-						c = buffer[pos++];
++						boundaryBytes[boundaryLen] = buffer[boundaryLen];
+ 					}
+ 
+-					if (pos < end && length < 100)
++					if (boundaryLen >= 1 && boundaryLen < 100)
+ 					{
+ 						// RFC #1521, Page 31:
+ 						// "...the boundary parameter, which consists of 1 to 70
+ 						//  characters from a set of characters known to be very
+ 						//  robust through email gateways, and NOT ending with
+ 						//  white space..."
+-						while (pos != start && parserHelpers::isSpace(buffer[pos - 1]))
+-							--pos;
+-
+-						boundary = string(buffer.begin() + start,
+-						                  buffer.begin() + pos);
++						while (boundaryLen != 0 &&
++						       parserHelpers::isSpace(boundaryBytes[boundaryLen - 1]))
++						{
++							boundaryLen--;
++						}
++
++						if (boundaryLen >= 1)
++							boundary = string(boundaryBytes, boundaryBytes + boundaryLen);
+ 					}
+ 				}
+ 			}
+@@ -126,51 +170,79 @@ void body::parse(const string& buffer, const string::size_type position,
+ 	{
+ 		const string boundarySep("--" + boundary);
+ 
+-		string::size_type partStart = position;
+-		string::size_type pos = position;
++		utility::stream::size_type partStart = position;
++		utility::stream::size_type pos = position;
+ 
+ 		bool lastPart = false;
+ 
+-		while (pos != string::npos && pos < end)
++		while (pos != utility::stream::npos && pos < end)
+ 		{
+-			pos = buffer.find(boundarySep, pos);
+-
+-			if (pos == string::npos ||
+-			    ((pos == 0 || buffer[pos - 1] == '\n') &&
+-			     (buffer[pos + boundarySep.length()] == '\r' ||
+-			      buffer[pos + boundarySep.length()] == '\n' ||
+-			      buffer[pos + boundarySep.length()] == '-'
+-			     )
+-			    )
+-			   )
++			pos = parser->findNext(boundarySep, pos);
++
++			if (pos == utility::stream::npos)
++				break;  // not found
++
++			if (pos != 0)
+ 			{
+-				break;
++				parser->seek(pos - 1);
++
++				if (parser->peekByte() != '\n')
++				{
++					// Boundary is not at a beginning of a line
++					pos++;
++					continue;
++				}
++
++				parser->skip(1 + boundarySep.length());
++			}
++			else
++			{
++				parser->seek(pos + boundarySep.length());
+ 			}
+ 
+-			// boundary not a beginning of line, or just a prefix of another, continue the search.
++			const utility::stream::value_type next = parser->peekByte();
++
++			if (next == '\r' || next == '\n' || next == '-')
++				break;
++
++			// Boundary is a prefix of another, continue the search
+ 			pos++;
+ 		}
+ 
+-		if (pos != string::npos && pos < end)
++		if (pos != utility::stream::npos && pos < end)
+ 		{
+ 			vmime::text text;
+-			text.parse(buffer, position, pos);
++			text.parse(parser, position, pos);
+ 
+ 			m_prologText = text.getWholeBuffer();
+ 		}
+ 
+-		for (int index = 0 ; !lastPart && (pos != string::npos) && (pos < end) ; ++index)
++		for (int index = 0 ; !lastPart && (pos != utility::stream::npos) && (pos < end) ; ++index)
+ 		{
+-			string::size_type partEnd = pos;
++			utility::stream::size_type partEnd = pos;
+ 
+ 			// Get rid of the [CR]LF just before the boundary string
+-			if (pos >= (position + 1) && buffer[pos - 1] == '\n') --partEnd;
+-			if (pos >= (position + 2) && buffer[pos - 2] == '\r') --partEnd;
++			if (pos >= (position + 1))
++			{
++				parser->seek(pos - 1);
++
++				if (parser->peekByte() == '\n')
++					--partEnd;
++			}
++
++			if (pos >= (position + 2))
++			{
++				parser->seek(pos - 2);
++
++				if (parser->peekByte() == '\r')
++					--partEnd;
++			}
+ 
+ 			// Check whether it is the last part (boundary terminated by "--")
+ 			pos += boundarySep.length();
++			parser->seek(pos);
+ 
+-			if (pos + 1 < end && buffer[pos] == '-' && buffer[pos + 1] == '-')
++			if (pos + 1 < end && parser->matchBytes("--", 2))
+ 			{
+ 				lastPart = true;
+ 				pos += 2;
+@@ -180,15 +252,15 @@ void body::parse(const string& buffer, const string::size_type position,
+ 			// "...(If a boundary appears to end with white space, the
+ 			//  white space must be presumed to have been added by a
+ 			//  gateway, and must be deleted.)..."
+-			while (pos < end && (buffer[pos] == ' ' || buffer[pos] == '\t'))
+-				++pos;
++			parser->seek(pos);
++			pos += parser->skipIf(parserHelpers::isSpaceOrTab, end);
+ 
+ 			// End of boundary line
+-			if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] =='\n')
++			if (pos + 1 < end && parser->matchBytes("\r\n", 2))
+ 			{
+ 				pos += 2;
+ 			}
+-			else if (pos < end && buffer[pos] == '\n')
++			else if (pos < end && parser->peekByte() == '\n')
+ 			{
+ 				++pos;
+ 			}
+@@ -202,7 +274,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ 				if (partEnd < partStart)
+ 					std::swap(partStart, partEnd);
+ 
+-				part->parse(buffer, partStart, partEnd, NULL);
++				part->parse(parser, partStart, partEnd, NULL);
+ 				part->m_parent = m_part;
+ 
+ 				m_parts.push_back(part);
+@@ -210,23 +282,37 @@ void body::parse(const string& buffer, const string::size_type position,
+ 
+ 			partStart = pos;
+ 
+-			while (pos != string::npos && pos < end)
++			while (pos != utility::stream::npos && pos < end)
+ 			{
+-				pos = buffer.find(boundarySep, pos);
+-
+-				if (pos == string::npos ||
+-				    ((pos == 0 || buffer[pos - 1] == '\n') &&
+-				     (buffer[pos + boundarySep.length()] == '\r' ||
+-				      buffer[pos + boundarySep.length()] == '\n' ||
+-					buffer[pos + boundarySep.length()] == '-'
+-				     )
+-				    )
+-				   )
++				pos = parser->findNext(boundarySep, pos);
++
++				if (pos == utility::stream::npos)
++					break;  // not found
++
++				if (pos != 0)
+ 				{
+-					break;
++					parser->seek(pos - 1);
++
++					if (parser->peekByte() != '\n')
++					{
++						// Boundary is not at a beginning of a line
++						pos++;
++						continue;
++					}
++
++					parser->skip(1 + boundarySep.length());
++				}
++				else
++				{
++					parser->seek(pos + boundarySep.length());
+ 				}
+ 
+-				// boundary not a beginning of line, or just a prefix of another, continue the search.
++				const utility::stream::value_type next = parser->peekByte();
++
++				if (next == '\r' || next == '\n' || next == '-')
++					break;
++
++				// Boundary is a prefix of another, continue the search
+ 				pos++;
+ 			}
+ 		}
+@@ -234,13 +320,13 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		m_contents = vmime::create <emptyContentHandler>();
+ 
+ 		// Last part was not found: recover from missing boundary
+-		if (!lastPart && pos == string::npos)
++		if (!lastPart && pos == utility::stream::npos)
+ 		{
+ 			ref <bodyPart> part = vmime::create <bodyPart>();
+ 
+ 			try
+ 			{
+-				part->parse(buffer, partStart, end);
++				part->parse(parser, partStart, end);
+ 			}
+ 			catch (std::exception&)
+ 			{
+@@ -255,7 +341,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		else if (partStart < end)
+ 		{
+ 			vmime::text text;
+-			text.parse(buffer, partStart, end);
++			text.parse(parser, partStart, end);
+ 
+ 			m_epilogText = text.getWholeBuffer();
+ 		}
+@@ -282,7 +368,13 @@ void body::parse(const string& buffer, const string::size_type position,
+ 		}
+ 
+ 		// Extract the (encoded) contents
+-		m_contents = vmime::create <stringContentHandler>(buffer, position, end, enc);
++		const utility::stream::size_type length = end - position;
++
++		ref <utility::inputStream> contentStream =
++			vmime::create <utility::seekableInputStreamRegionAdapter>
++				(parser->getUnderlyingStream(), position, length);
++
++		m_contents = vmime::create <streamContentHandler>(contentStream, length, enc);
+ 	}
+ 
+ 	setParsedBounds(position, end);
+@@ -292,7 +384,7 @@ void body::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void body::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void body::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	// MIME-Multipart
+@@ -862,9 +954,9 @@ const std::vector <ref <bodyPart> > body::getPartList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > body::getChildComponents() const
++const std::vector <ref <component> > body::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_parts, list);
+ 
+diff --git a/src/bodyPart.cpp b/src/bodyPart.cpp
+index 7d60461..522cbb2 100644
+--- a/src/bodyPart.cpp
++++ b/src/bodyPart.cpp
+@@ -46,15 +46,18 @@ bodyPart::bodyPart(weak_ref <vmime::bodyPart> parentPart)
+ }
+ 
+ 
+-void bodyPart::parse(const string& buffer, const string::size_type position,
+-	const string::size_type end, string::size_type* newPosition)
++void bodyPart::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser,
++	 const utility::stream::size_type position,
++	 const utility::stream::size_type end,
++	 utility::stream::size_type* newPosition)
+ {
+ 	// Parse the headers
+ 	string::size_type pos = position;
+-	m_header->parse(buffer, pos, end, &pos);
++	m_header->parse(parser, pos, end, &pos);
+ 
+ 	// Parse the body contents
+-	m_body->parse(buffer, pos, end, NULL);
++	m_body->parse(parser, pos, end, NULL);
+ 
+ 	setParsedBounds(position, end);
+ 
+@@ -63,7 +66,7 @@ void bodyPart::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void bodyPart::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void bodyPart::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	m_header->generate(os, maxLineLength);
+@@ -142,9 +145,9 @@ ref <const bodyPart> bodyPart::getParentPart() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > bodyPart::getChildComponents() const
++const std::vector <ref <component> > bodyPart::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	list.push_back(m_header);
+ 	list.push_back(m_body);
+diff --git a/src/charset.cpp b/src/charset.cpp
+index 0fda450..705664f 100644
+--- a/src/charset.cpp
++++ b/src/charset.cpp
+@@ -57,7 +57,7 @@ charset::charset(const char* name)
+ }
+ 
+ 
+-void charset::parse(const string& buffer, const string::size_type position,
++void charset::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_name = utility::stringUtils::trim
+@@ -74,7 +74,7 @@ void charset::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void charset::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void charset::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -142,9 +142,9 @@ void charset::copyFrom(const component& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > charset::getChildComponents() const
++const std::vector <ref <component> > charset::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/component.cpp b/src/component.cpp
+index 139cf66..e93aacf 100644
+--- a/src/component.cpp
++++ b/src/component.cpp
+@@ -23,6 +23,9 @@
+ 
+ #include "vmime/component.hpp"
+ #include "vmime/base.hpp"
++
++#include "vmime/utility/streamUtils.hpp"
++#include "vmime/utility/inputStreamStringAdapter.hpp"
+ #include "vmime/utility/outputStreamAdapter.hpp"
+ 
+ #include <sstream>
+@@ -43,9 +46,102 @@ component::~component()
+ }
+ 
+ 
++void component::parse
++	(ref <utility::inputStream> inputStream, const utility::stream::size_type length)
++{
++	parse(inputStream, 0, length, NULL);
++}
++
++
++void component::parse
++	(ref <utility::inputStream> inputStream, const utility::stream::size_type position,
++	 const utility::stream::size_type end, utility::stream::size_type* newPosition)
++{
++	m_parsedOffset = m_parsedLength = 0;
++
++	ref <utility::seekableInputStream> seekableStream =
++		inputStream.dynamicCast <utility::seekableInputStream>();
++
++	if (seekableStream == NULL || end == 0)
++	{
++		// Read the whole stream into a buffer
++		std::ostringstream oss;
++		utility::outputStreamAdapter ossAdapter(oss);
++
++		utility::bufferedStreamCopyRange(*inputStream, ossAdapter, position, end - position);
++
++		const string buffer = oss.str();
++		parseImpl(buffer, 0, buffer.length(), NULL);
++	}
++	else
++	{
++		ref <utility::parserInputStreamAdapter> parser =
++			vmime::create <utility::parserInputStreamAdapter>(seekableStream);
++
++		parseImpl(parser, position, end, newPosition);
++	}
++}
++
++
+ void component::parse(const string& buffer)
+ {
+-	parse(buffer, 0, buffer.length(), NULL);
++	m_parsedOffset = m_parsedLength = 0;
++
++	parseImpl(buffer, 0, buffer.length(), NULL);
++}
++
++
++void component::parse
++	(const string& buffer, const string::size_type position,
++	 const string::size_type end, string::size_type* newPosition)
++{
++	m_parsedOffset = m_parsedLength = 0;
++
++	parseImpl(buffer, position, end, newPosition);
++}
++
++
++void component::offsetParsedBounds(const utility::stream::size_type offset)
++{
++	// Offset parsed bounds of this component
++	if (m_parsedLength != 0)
++		m_parsedOffset += offset;
++
++	// Offset parsed bounds of our children
++	std::vector <ref <component> > children = getChildComponents();
++
++	for (unsigned int i = 0, n = children.size() ; i < n ; ++i)
++		children[i]->offsetParsedBounds(offset);
++}
++
++
++void component::parseImpl
++	(ref <utility::parserInputStreamAdapter> parser, const utility::stream::size_type position,
++	 const utility::stream::size_type end, utility::stream::size_type* newPosition)
++{
++	const std::string buffer = parser->extract(position, end);
++	parseImpl(buffer, 0, buffer.length(), newPosition);
++
++	// Recursivey offset parsed bounds on children
++	if (position != 0)
++		offsetParsedBounds(position);
++
++	if (newPosition != NULL)
++		*newPosition += position;
++}
++
++
++void component::parseImpl
++	(const string& buffer, const string::size_type position,
++	 const string::size_type end, string::size_type* newPosition)
++{
++	ref <utility::seekableInputStream> stream =
++		vmime::create <utility::inputStreamStringAdapter>(buffer);
++
++	ref <utility::parserInputStreamAdapter> parser =
++		vmime::create <utility::parserInputStreamAdapter>(stream);
++
++	parseImpl(parser, position, end, newPosition);
+ }
+ 
+ 
+@@ -61,6 +157,26 @@ const string component::generate(const string::size_type maxLineLength,
+ }
+ 
+ 
++void component::generate
++	(utility::outputStream& os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
++{
++	generateImpl(os, maxLineLength, curLinePos, newLinePos);
++}
++
++
++void component::generate
++	(ref <utility::outputStream> os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
++{
++	generateImpl(*os, maxLineLength, curLinePos, newLinePos);
++}
++
++
+ string::size_type component::getParsedOffset() const
+ {
+ 	return (m_parsedOffset);
+@@ -80,22 +196,5 @@ void component::setParsedBounds(const string::size_type start, const string::siz
+ }
+ 
+ 
+-const std::vector <ref <component> > component::getChildComponents()
+-{
+-	const std::vector <ref <const component> > constList =
+-		const_cast <const component*>(this)->getChildComponents();
+-
+-	std::vector <ref <component> > list;
+-
+-	const std::vector <ref <const component> >::size_type count = constList.size();
++} // vmime
+ 
+-	list.resize(count);
+-
+-	for (std::vector <ref <const component> >::size_type i = 0 ; i < count ; ++i)
+-		list[i] = constList[i].constCast <component>();
+-
+-	return (list);
+-}
+-
+-
+-}
+diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp
+index 0ab7c45..253dbba 100644
+--- a/src/contentDisposition.cpp
++++ b/src/contentDisposition.cpp
+@@ -47,7 +47,7 @@ contentDisposition::contentDisposition(const contentDisposition& type)
+ }
+ 
+ 
+-void contentDisposition::parse(const string& buffer, const string::size_type position,
++void contentDisposition::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_name = utility::stringUtils::trim(utility::stringUtils::toLower
+@@ -60,7 +60,7 @@ void contentDisposition::parse(const string& buffer, const string::size_type pos
+ }
+ 
+ 
+-void contentDisposition::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void contentDisposition::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -122,9 +122,9 @@ void contentDisposition::setName(const string& name)
+ }
+ 
+ 
+-const std::vector <ref <const component> > contentDisposition::getChildComponents() const
++const std::vector <ref <component> > contentDisposition::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/dateTime.cpp b/src/dateTime.cpp
+index 089a900..0d97b2f 100644
+--- a/src/dateTime.cpp
++++ b/src/dateTime.cpp
+@@ -67,7 +67,7 @@ zone = "UT" / "GMT"                               ; Universal Time
+ */
+ 
+ 
+-void datetime::parse(const string& buffer, const string::size_type position,
++void datetime::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -588,7 +588,7 @@ void datetime::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void datetime::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void datetime::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	static const string::value_type* dayNames[] =
+@@ -784,9 +784,9 @@ ref <component> datetime::clone() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > datetime::getChildComponents() const
++const std::vector <ref <component> > datetime::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/disposition.cpp b/src/disposition.cpp
+index b8059a7..24a4579 100644
+--- a/src/disposition.cpp
++++ b/src/disposition.cpp
+@@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > disposition::getChildComponents() const
++const std::vector <ref <component> > disposition::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+@@ -171,7 +171,7 @@ const std::vector <string> disposition::getModifierList() const
+ }
+ 
+ 
+-void disposition::parse(const string& buffer, const string::size_type position,
++void disposition::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	// disposition-mode ";" disposition-type
+@@ -276,7 +276,7 @@ void disposition::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void disposition::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void disposition::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+diff --git a/src/encoding.cpp b/src/encoding.cpp
+index 5d99ab6..343a822 100644
+--- a/src/encoding.cpp
++++ b/src/encoding.cpp
+@@ -61,7 +61,7 @@ encoding::encoding(const encoding& enc)
+ }
+ 
+ 
+-void encoding::parse(const string& buffer, const string::size_type position,
++void encoding::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_usage = USAGE_UNKNOWN;
+@@ -80,7 +80,7 @@ void encoding::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void encoding::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
++void encoding::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name;
+@@ -268,9 +268,9 @@ void encoding::setUsage(const EncodingUsage usage)
+ }
+ 
+ 
+-const std::vector <ref <const component> > encoding::getChildComponents() const
++const std::vector <ref <component> > encoding::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/header.cpp b/src/header.cpp
+index 443aab8..fcdca2c 100644
+--- a/src/header.cpp
++++ b/src/header.cpp
+@@ -61,7 +61,7 @@ field-body-contents =
+ 		 specials tokens, or else consisting of texts>
+ */
+ 
+-void header::parse(const string& buffer, const string::size_type position,
++void header::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	string::size_type pos = position;
+@@ -83,7 +83,7 @@ void header::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void header::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void header::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type /* curLinePos */, string::size_type* newLinePos) const
+ {
+ 	// Generate the fields
+@@ -337,9 +337,9 @@ const std::vector <ref <headerField> > header::getFieldList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > header::getChildComponents() const
++const std::vector <ref <component> > header::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_fields, list);
+ 
+diff --git a/src/headerField.cpp b/src/headerField.cpp
+index d1d4236..a8460aa 100644
+--- a/src/headerField.cpp
++++ b/src/headerField.cpp
+@@ -262,14 +262,14 @@ ref <headerField> headerField::parseNext(const string& buffer, const string::siz
+ }
+ 
+ 
+-void headerField::parse(const string& buffer, const string::size_type position, const string::size_type end,
++void headerField::parseImpl(const string& buffer, const string::size_type position, const string::size_type end,
+ 	string::size_type* newPosition)
+ {
+ 	m_value->parse(buffer, position, end, newPosition);
+ }
+ 
+ 
+-void headerField::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void headerField::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	os << m_name + ": ";
+@@ -296,9 +296,9 @@ bool headerField::isCustom() const
+ }
+ 
+ 
+-const std::vector <ref <const component> > headerField::getChildComponents() const
++const std::vector <ref <component> > headerField::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	if (m_value)
+ 		list.push_back(m_value);
+diff --git a/src/mailbox.cpp b/src/mailbox.cpp
+index fea7479..dfdccad 100644
+--- a/src/mailbox.cpp
++++ b/src/mailbox.cpp
+@@ -65,7 +65,7 @@ angle-addr      =       [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr
+ 
+ */
+ 
+-void mailbox::parse(const string& buffer, const string::size_type position,
++void mailbox::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -343,7 +343,7 @@ void mailbox::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mailbox::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailbox::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	if (m_name.isEmpty())
+@@ -514,9 +514,9 @@ void mailbox::setEmail(const string& email)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailbox::getChildComponents() const
++const std::vector <ref <component> > mailbox::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
+index 94f7ba6..c37444a 100644
+--- a/src/mailboxGroup.cpp
++++ b/src/mailboxGroup.cpp
+@@ -54,7 +54,7 @@ mailboxGroup::~mailboxGroup()
+ }
+ 
+ 
+-void mailboxGroup::parse(const string& buffer, const string::size_type position,
++void mailboxGroup::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -111,7 +111,7 @@ void mailboxGroup::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mailboxGroup::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailboxGroup::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	// We have to encode the name:
+@@ -348,9 +348,9 @@ const std::vector <ref <mailbox> > mailboxGroup::getMailboxList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailboxGroup::getChildComponents() const
++const std::vector <ref <component> > mailboxGroup::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_list, list);
+ 
+diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp
+index 0023d9d..f87fb48 100644
+--- a/src/mailboxList.cpp
++++ b/src/mailboxList.cpp
+@@ -190,20 +190,20 @@ mailboxList& mailboxList::operator=(const mailboxList& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mailboxList::getChildComponents() const
++const std::vector <ref <component> > mailboxList::getChildComponents()
+ {
+ 	return (m_list.getChildComponents());
+ }
+ 
+ 
+-void mailboxList::parse(const string& buffer, const string::size_type position,
++void mailboxList::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	m_list.parse(buffer, position, end, newPosition);
+ }
+ 
+ 
+-void mailboxList::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mailboxList::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	m_list.generate(os, maxLineLength, curLinePos, newLinePos);
+diff --git a/src/mediaType.cpp b/src/mediaType.cpp
+index 725f933..627b276 100644
+--- a/src/mediaType.cpp
++++ b/src/mediaType.cpp
+@@ -48,7 +48,7 @@ mediaType::mediaType(const string& type, const string& subType)
+ }
+ 
+ 
+-void mediaType::parse(const string& buffer, const string::size_type position,
++void mediaType::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -82,7 +82,7 @@ void mediaType::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void mediaType::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void mediaType::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	const string value = m_type + "/" + m_subType;
+@@ -176,9 +176,9 @@ void mediaType::setFromString(const string& type)
+ }
+ 
+ 
+-const std::vector <ref <const component> > mediaType::getChildComponents() const
++const std::vector <ref <component> > mediaType::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/message.cpp b/src/message.cpp
+index 1b4f086..3fa9b6a 100644
+--- a/src/message.cpp
++++ b/src/message.cpp
+@@ -61,9 +61,14 @@ const string message::generate(const string::size_type maxLineLength,
+ }
+ 
+ 
+-void message::parse(const string& buffer)
++
++void message::generate
++	(ref <utility::outputStream> os,
++	 const string::size_type maxLineLength,
++	 const string::size_type curLinePos,
++	 string::size_type* newLinePos) const
+ {
+-	bodyPart::parse(buffer);
++	bodyPart::generate(os, maxLineLength, curLinePos, newLinePos);
+ }
+ 
+ 
+diff --git a/src/messageId.cpp b/src/messageId.cpp
+index 961fb63..1f4b186 100644
+--- a/src/messageId.cpp
++++ b/src/messageId.cpp
+@@ -61,7 +61,7 @@ messageId::messageId(const string& left, const string& right)
+ 	msg-id          =       [CFWS] "<" id-left "@" id-right ">" [CFWS]
+ */
+ 
+-void messageId::parse(const string& buffer, const string::size_type position,
++void messageId::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -185,7 +185,7 @@ const string messageId::getId() const
+ }
+ 
+ 
+-void messageId::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void messageId::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+@@ -288,9 +288,9 @@ void messageId::setRight(const string& right)
+ }
+ 
+ 
+-const std::vector <ref <const component> > messageId::getChildComponents() const
++const std::vector <ref <component> > messageId::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/messageIdSequence.cpp b/src/messageIdSequence.cpp
+index 08103d0..0a5c9a0 100644
+--- a/src/messageIdSequence.cpp
++++ b/src/messageIdSequence.cpp
+@@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > messageIdSequence::getChildComponents() const
++const std::vector <ref <component> > messageIdSequence::getChildComponents()
+ {
+-	std::vector <ref <const component> > res;
++	std::vector <ref <component> > res;
+ 
+ 	copy_vector(m_list, res);
+ 
+@@ -84,7 +84,7 @@ const std::vector <ref <const component> > messageIdSequence::getChildComponents
+ }
+ 
+ 
+-void messageIdSequence::parse(const string& buffer, const string::size_type position,
++void messageIdSequence::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllMessageIds();
+@@ -106,7 +106,7 @@ void messageIdSequence::parse(const string& buffer, const string::size_type posi
+ }
+ 
+ 
+-void messageIdSequence::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void messageIdSequence::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+diff --git a/src/parameter.cpp b/src/parameter.cpp
+index ccbe1a5..58d9a3e 100644
+--- a/src/parameter.cpp
++++ b/src/parameter.cpp
+@@ -36,19 +36,19 @@ namespace vmime
+ 
+ 
+ parameter::parameter(const string& name)
+-	: m_name(name)
++	: m_name(name), m_value(vmime::create <word>())
+ {
+ }
+ 
+ 
+ parameter::parameter(const string& name, const word& value)
+-	: m_name(name), m_value(value)
++	: m_name(name), m_value(vmime::create <word>(value))
+ {
+ }
+ 
+ 
+ parameter::parameter(const string& name, const string& value)
+-	: m_name(name), m_value(value)
++	: m_name(name), m_value(vmime::create <word>(value))
+ {
+ }
+ 
+@@ -73,7 +73,7 @@ void parameter::copyFrom(const component& other)
+ 	const parameter& param = dynamic_cast <const parameter&>(other);
+ 
+ 	m_name = param.m_name;
+-	m_value.copyFrom(param.m_value);
++	m_value->copyFrom(*param.m_value);
+ }
+ 
+ 
+@@ -92,7 +92,7 @@ const string& parameter::getName() const
+ 
+ const word& parameter::getValue() const
+ {
+-	return m_value;
++	return *m_value;
+ }
+ 
+ 
+@@ -109,15 +109,15 @@ void parameter::setValue(const component& value)
+ 
+ void parameter::setValue(const word& value)
+ {
+-	m_value = value;
++	*m_value = value;
+ }
+ 
+ 
+-void parameter::parse(const string& buffer, const string::size_type position,
++void parameter::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+-	m_value.setBuffer(string(buffer.begin() + position, buffer.begin() + end));
+-	m_value.setCharset(charset(charsets::US_ASCII));
++	m_value->setBuffer(string(buffer.begin() + position, buffer.begin() + end));
++	m_value->setCharset(charset(charsets::US_ASCII));
+ 
+ 	if (newPosition)
+ 		*newPosition = end;
+@@ -248,16 +248,16 @@ void parameter::parse(const std::vector <valueChunk>& chunks)
+ 		}
+ 	}
+ 
+-	m_value.setBuffer(value.str());
+-	m_value.setCharset(ch);
++	m_value->setBuffer(value.str());
++	m_value->setCharset(ch);
+ }
+ 
+ 
+-void parameter::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void parameter::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	const string& name = m_name;
+-	const string& value = m_value.getBuffer();
++	const string& value = m_value->getBuffer();
+ 
+ 	// For compatibility with implementations that do not understand RFC-2231,
+ 	// also generate a normal "7bit/us-ascii" parameter
+@@ -344,7 +344,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 	// 7-bit (ASCII) bytes in the input will be used to determine if
+ 	// we need to encode the whole buffer.
+ 	encoding recommendedEnc;
+-	const bool alwaysEncode = m_value.getCharset().getRecommendedEncoding(recommendedEnc);
++	const bool alwaysEncode = m_value->getCharset().getRecommendedEncoding(recommendedEnc);
+ 	bool extended = alwaysEncode;
+ 
+ 	if (needQuotedPrintable)
+@@ -352,7 +352,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 		// Send the name in quoted-printable, so outlook express et.al.
+ 		// will understand the real filename
+ 		size_t oldLen = sevenBitBuffer.length();
+-		m_value.generate(sevenBitStream);
++		m_value->generate(sevenBitStream);
+ 		pos += sevenBitBuffer.length() - oldLen;
+ 		extended = true;		// also send with RFC-2231 encoding
+ 	}
+@@ -429,7 +429,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 		// + at least 5 characters for the value
+ 		const string::size_type firstSectionLength =
+ 			  name.length() + 4 /* *0*= */ + 2 /* '' */
+-			+ m_value.getCharset().getName().length();
++			+ m_value->getCharset().getName().length();
+ 
+ 		if (pos + firstSectionLength + 5 >= maxLineLength)
+ 		{
+@@ -539,7 +539,7 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ 
+ 			if (sectionNumber == 0)
+ 			{
+-				os << m_value.getCharset().getName();
++				os << m_value->getCharset().getName();
+ 				os << '\'' << /* No language */ '\'';
+ 			}
+ 
+@@ -570,11 +570,11 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
+ }
+ 
+ 
+-const std::vector <ref <const component> > parameter::getChildComponents() const
++const std::vector <ref <component> > parameter::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+-	list.push_back(ref <const component>::fromPtr(&m_value));
++	list.push_back(m_value);
+ 
+ 	return list;
+ }
+diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp
+index 464990e..756d02f 100644
+--- a/src/parameterizedHeaderField.cpp
++++ b/src/parameterizedHeaderField.cpp
+@@ -78,7 +78,7 @@ struct paramInfo
+ #endif // VMIME_BUILDING_DOC
+ 
+ 
+-void parameterizedHeaderField::parse(const string& buffer, const string::size_type position,
++void parameterizedHeaderField::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -328,13 +328,13 @@ void parameterizedHeaderField::parse(const string& buffer, const string::size_ty
+ }
+ 
+ 
+-void parameterizedHeaderField::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void parameterizedHeaderField::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	string::size_type pos = curLinePos;
+ 
+ 	// Parent header field
+-	headerField::generate(os, maxLineLength, pos, &pos);
++	headerField::generateImpl(os, maxLineLength, pos, &pos);
+ 
+ 	// Parameters
+ 	for (std::vector <ref <parameter> >::const_iterator
+@@ -552,11 +552,11 @@ const std::vector <ref <parameter> > parameterizedHeaderField::getParameterList(
+ }
+ 
+ 
+-const std::vector <ref <const component> > parameterizedHeaderField::getChildComponents() const
++const std::vector <ref <component> > parameterizedHeaderField::getChildComponents()
+ {
+-	std::vector <ref <const component> > list = headerField::getChildComponents();
++	std::vector <ref <component> > list = headerField::getChildComponents();
+ 
+-	for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
++	for (std::vector <ref <parameter> >::iterator it = m_params.begin() ;
+ 	     it != m_params.end() ; ++it)
+ 	{
+ 		list.push_back(*it);
+diff --git a/src/path.cpp b/src/path.cpp
+index 37a4090..d92bb0a 100644
+--- a/src/path.cpp
++++ b/src/path.cpp
+@@ -106,14 +106,14 @@ path& path::operator=(const path& other)
+ }
+ 
+ 
+-const std::vector <ref <const component> > path::getChildComponents() const
++const std::vector <ref <component> > path::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+-void path::parse(const string& buffer, const string::size_type position,
+-                 const string::size_type end, string::size_type* newPosition)
++void path::parseImpl(const string& buffer, const string::size_type position,
++	const string::size_type end, string::size_type* newPosition)
+ {
+ 	string::size_type pos = position;
+ 
+@@ -165,8 +165,8 @@ void path::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void path::generate(utility::outputStream& os, const string::size_type /* maxLineLength */,
+-                    const string::size_type curLinePos, string::size_type* newLinePos) const
++void path::generateImpl(utility::outputStream& os, const string::size_type /* maxLineLength */,
++	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	if (m_localPart.empty() && m_domain.empty())
+ 	{
+diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
+index ec529eb..4087a21 100644
+--- a/src/platforms/posix/posixFile.cpp
++++ b/src/platforms/posix/posixFile.cpp
+@@ -224,6 +224,26 @@ vmime::utility::stream::size_type posixFileReaderInputStream::skip(const size_ty
+ }
+ 
+ 
++vmime::utility::stream::size_type posixFileReaderInputStream::getPosition() const
++{
++	const off_t curPos = ::lseek(m_fd, 0, SEEK_CUR);
++
++	if (curPos == off_t(-1))
++		posixFileSystemFactory::reportError(m_path, errno);
++
++	return static_cast <size_type>(curPos);
++}
++
++
++void posixFileReaderInputStream::seek(const size_type pos)
++{
++	const off_t newPos = ::lseek(m_fd, pos, SEEK_SET);
++
++	if (newPos == off_t(-1))
++		posixFileSystemFactory::reportError(m_path, errno);
++}
++
++
+ 
+ //
+ // posixFileWriter
+diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp
+index 624612a..5da786e 100644
+--- a/src/platforms/windows/windowsFile.cpp
++++ b/src/platforms/windows/windowsFile.cpp
+@@ -479,6 +479,24 @@ vmime::utility::stream::size_type windowsFileReaderInputStream::skip(const size_
+ 	return (dwNewPos - dwCurPos);
+ }
+ 
++vmime::utility::stream::size_type windowsFileReaderInputStream::getPosition() const
++{
++	DWORD dwCurPos = SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
++
++	if (dwCurPos == INVALID_SET_FILE_POINTER)
++		windowsFileSystemFactory::reportError(m_path, GetLastError());
++
++	return static_cast <size_type>(dwCurPos);
++}
++
++void windowsFileReaderInputStream::seek(const size_type pos)
++{
++	DWORD dwNewPos = SetFilePointer(m_hFile, (LONG)pos, NULL, FILE_BEGIN);
++
++	if (dwNewPos == INVALID_SET_FILE_POINTER)
++		windowsFileSystemFactory::reportError(m_path, GetLastError());
++}
++
+ windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath)
+ : m_path(path), m_nativePath(nativePath)
+ {
+diff --git a/src/relay.cpp b/src/relay.cpp
+index 5cd454f..97f793d 100644
+--- a/src/relay.cpp
++++ b/src/relay.cpp
+@@ -57,7 +57,7 @@ relay::relay(const relay& r)
+                        ["for"  addr-spec]        ; initial form
+ */
+ 
+-void relay::parse(const string& buffer, const string::size_type position,
++void relay::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	const string::value_type* const pend = buffer.data() + end;
+@@ -198,7 +198,7 @@ void relay::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void relay::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void relay::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	std::ostringstream oss;
+@@ -338,10 +338,10 @@ std::vector <string>& relay::getWithList()
+ }
+ 
+ 
+-const std::vector <ref <const component> > relay::getChildComponents() const
++const std::vector <ref <component> > relay::getChildComponents()
+ {
+ 	// TODO: should fields inherit from 'component'? (using typeAdapter)
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
+index 89a36b4..14837d2 100644
+--- a/src/streamContentHandler.cpp
++++ b/src/streamContentHandler.cpp
+@@ -25,6 +25,7 @@
+ 
+ #include "vmime/utility/outputStreamAdapter.hpp"
+ #include "vmime/utility/inputStreamStringAdapter.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ #include "vmime/utility/streamUtils.hpp"
+ 
+ 
+@@ -207,6 +208,9 @@ const vmime::encoding& streamContentHandler::getEncoding() const
+ 
+ bool streamContentHandler::isBuffered() const
+ {
++	if (m_stream.dynamicCast <utility::seekableInputStream>() != NULL)
++		return true;
++
+ 	// FIXME: some streams can be resetted
+ 	return false;
+ }
+diff --git a/src/text.cpp b/src/text.cpp
+index 66c3b35..91b81e1 100644
+--- a/src/text.cpp
++++ b/src/text.cpp
+@@ -67,7 +67,7 @@ text::~text()
+ }
+ 
+ 
+-void text::parse(const string& buffer, const string::size_type position,
++void text::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	removeAllWords();
+@@ -85,7 +85,7 @@ void text::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void text::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void text::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	encodeAndFold(os, maxLineLength, curLinePos, newLinePos, 0);
+@@ -389,9 +389,9 @@ text* text::decodeAndUnfold(const string& in, text* generateInExisting)
+ }
+ 
+ 
+-const std::vector <ref <const component> > text::getChildComponents() const
++const std::vector <ref <component> > text::getChildComponents()
+ {
+-	std::vector <ref <const component> > list;
++	std::vector <ref <component> > list;
+ 
+ 	copy_vector(m_words, list);
+ 
+diff --git a/src/utility/inputStreamAdapter.cpp b/src/utility/inputStreamAdapter.cpp
+index b44b084..441307b 100644
+--- a/src/utility/inputStreamAdapter.cpp
++++ b/src/utility/inputStreamAdapter.cpp
+@@ -65,6 +65,18 @@ stream::size_type inputStreamAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamAdapter::getPosition() const
++{
++	return m_stream.tellg();
++}
++
++
++void inputStreamAdapter::seek(const size_type pos)
++{
++	m_stream.seekg(pos, std::ios_base::beg);
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamByteBufferAdapter.cpp b/src/utility/inputStreamByteBufferAdapter.cpp
+index 92e779f..907f1ee 100644
+--- a/src/utility/inputStreamByteBufferAdapter.cpp
++++ b/src/utility/inputStreamByteBufferAdapter.cpp
+@@ -85,6 +85,19 @@ stream::size_type inputStreamByteBufferAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamByteBufferAdapter::getPosition() const
++{
++	return m_pos;
++}
++
++
++void inputStreamByteBufferAdapter::seek(const size_type pos)
++{
++	if (pos <= m_length)
++		m_pos = pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamStringAdapter.cpp b/src/utility/inputStreamStringAdapter.cpp
+index 31c9fda..9b8fb0c 100644
+--- a/src/utility/inputStreamStringAdapter.cpp
++++ b/src/utility/inputStreamStringAdapter.cpp
+@@ -89,6 +89,19 @@ stream::size_type inputStreamStringAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamStringAdapter::getPosition() const
++{
++	return m_pos - m_begin;
++}
++
++
++void inputStreamStringAdapter::seek(const size_type pos)
++{
++	if (m_begin + pos <= m_end)
++		m_pos = m_begin + pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/inputStreamStringProxyAdapter.cpp b/src/utility/inputStreamStringProxyAdapter.cpp
+index 5e4b60b..feecddd 100644
+--- a/src/utility/inputStreamStringProxyAdapter.cpp
++++ b/src/utility/inputStreamStringProxyAdapter.cpp
+@@ -84,6 +84,19 @@ stream::size_type inputStreamStringProxyAdapter::skip(const size_type count)
+ }
+ 
+ 
++stream::size_type inputStreamStringProxyAdapter::getPosition() const
++{
++	return m_pos;
++}
++
++
++void inputStreamStringProxyAdapter::seek(const size_type pos)
++{
++	if (pos <= m_buffer.length())
++		m_pos = pos;
++}
++
++
+ } // utility
+ } // vmime
+ 
+diff --git a/src/utility/parserInputStreamAdapter.cpp b/src/utility/parserInputStreamAdapter.cpp
+new file mode 100644
+index 0000000..7a38ef1
+--- /dev/null
++++ b/src/utility/parserInputStreamAdapter.cpp
+@@ -0,0 +1,162 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/parserInputStreamAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++parserInputStreamAdapter::parserInputStreamAdapter(ref <seekableInputStream> stream)
++	: m_stream(stream)
++{
++}
++
++
++bool parserInputStreamAdapter::eof() const
++{
++	return m_stream->eof();
++}
++
++
++void parserInputStreamAdapter::reset()
++{
++	m_stream->reset();
++}
++
++
++stream::size_type parserInputStreamAdapter::read
++	(value_type* const data, const size_type count)
++{
++	return m_stream->read(data, count);
++}
++
++
++ref <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
++{
++	return m_stream;
++}
++
++
++const string parserInputStreamAdapter::extract(const size_type begin, const size_type end) const
++{
++	const size_type initialPos = m_stream->getPosition();
++
++	try
++	{
++		value_type *buffer = new value_type[end - begin + 1];
++
++		m_stream->seek(begin);
++
++		const size_type readBytes = m_stream->read(buffer, end - begin);
++		buffer[readBytes] = '\0';
++
++		m_stream->seek(initialPos);
++
++		string str(buffer, buffer + readBytes);
++		delete [] buffer;
++
++		return str;
++	}
++	catch (...)
++	{
++		m_stream->seek(initialPos);
++		throw;
++	}
++}
++
++
++stream::size_type parserInputStreamAdapter::findNext
++	(const std::string& token, const size_type startPosition)
++{
++	static const unsigned int BUFFER_SIZE = 4096;
++
++	// Token must not be longer than BUFFER_SIZE/2
++	if (token.empty() || token.length() > BUFFER_SIZE / 2)
++		return npos;
++
++	const size_type initialPos = getPosition();
++
++	seek(startPosition);
++
++	try
++	{
++		value_type findBuffer[BUFFER_SIZE];
++		value_type* findBuffer1 = findBuffer;
++		value_type* findBuffer2 = findBuffer + (BUFFER_SIZE / 2) * sizeof(value_type);
++
++		size_type findBufferLen = 0;
++		size_type findBufferOffset = 0;
++
++		// Fill in initial buffer
++		findBufferLen = read(findBuffer, BUFFER_SIZE * sizeof(value_type));
++
++		for (;;)
++		{
++			// Find token
++			for (value_type *begin = findBuffer, *end = findBuffer + findBufferLen - token.length() ;
++			     begin <= end ; ++begin)
++			{
++				if (begin[0] == token[0] &&
++				    (token.length() == 1 ||
++				     memcmp(static_cast <const void *>(&begin[1]),
++				            static_cast <const void *>(token.data() + 1),
++				            token.length() - 1) == 0))
++				{
++					seek(initialPos);
++					return startPosition + findBufferOffset + (begin - findBuffer);
++				}
++			}
++
++			// Rotate buffer
++			memcpy(findBuffer1, findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
++
++			// Read more bytes
++			if (findBufferLen < BUFFER_SIZE && eof())
++			{
++				break;
++			}
++			else
++			{
++				const size_type bytesRead = read(findBuffer2, (BUFFER_SIZE / 2) * sizeof(value_type));
++				findBufferLen = (BUFFER_SIZE / 2) + bytesRead;
++				findBufferOffset += (BUFFER_SIZE / 2);
++			}
++		}
++
++		seek(initialPos);
++	}
++	catch (...)
++	{
++		seek(initialPos);
++		throw;
++	}
++
++	return npos;
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/seekableInputStreamRegionAdapter.cpp b/src/utility/seekableInputStreamRegionAdapter.cpp
+new file mode 100644
+index 0000000..348618c
+--- /dev/null
++++ b/src/utility/seekableInputStreamRegionAdapter.cpp
+@@ -0,0 +1,95 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#include "vmime/utility/seekableInputStreamRegionAdapter.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++seekableInputStreamRegionAdapter::seekableInputStreamRegionAdapter
++	(ref <seekableInputStream> stream, const size_type begin, const size_type length)
++	: m_stream(stream), m_begin(begin), m_length(length)
++{
++}
++
++
++bool seekableInputStreamRegionAdapter::eof() const
++{
++	return getPosition() >= m_length;
++}
++
++
++void seekableInputStreamRegionAdapter::reset()
++{
++	m_stream->seek(m_begin);
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::read
++	(value_type* const data, const size_type count)
++{
++	if (getPosition() + count >= m_length)
++	{
++		const size_type remaining = m_length - getPosition();
++		return m_stream->read(data, remaining);
++	}
++	else
++	{
++		return m_stream->read(data, count);
++	}
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::skip(const size_type count)
++{
++	if (getPosition() + count >= m_length)
++	{
++		const size_type remaining = m_length - getPosition();
++		m_stream->skip(remaining);
++		return remaining;
++	}
++	else
++	{
++		m_stream->skip(count);
++		return count;
++	}
++}
++
++
++stream::size_type seekableInputStreamRegionAdapter::getPosition() const
++{
++	return m_stream->getPosition() - m_begin;
++}
++
++
++void seekableInputStreamRegionAdapter::seek(const size_type pos)
++{
++	m_stream->seek(m_begin + pos);
++}
++
++
++} // utility
++} // vmime
++
+diff --git a/src/utility/stream.cpp b/src/utility/stream.cpp
+index 1c940c2..67c1f33 100644
+--- a/src/utility/stream.cpp
++++ b/src/utility/stream.cpp
+@@ -29,6 +29,9 @@ namespace vmime {
+ namespace utility {
+ 
+ 
++const stream::size_type stream::npos = static_cast <size_type>(vmime::string::npos);
++
++
+ stream::size_type stream::getBlockSize()
+ {
+ 	return 32768;  // 32 KB
+@@ -37,3 +40,4 @@ stream::size_type stream::getBlockSize()
+ 
+ } // utility
+ } // vmime
++
+diff --git a/src/utility/streamUtils.cpp b/src/utility/streamUtils.cpp
+index f1d3b9d..f7ea62f 100644
+--- a/src/utility/streamUtils.cpp
++++ b/src/utility/streamUtils.cpp
+@@ -52,6 +52,35 @@ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os)
+ }
+ 
+ 
++stream::size_type bufferedStreamCopyRange(inputStream& is, outputStream& os,
++	const stream::size_type start, const stream::size_type length)
++{
++	const stream::size_type blockSize =
++		std::min(is.getBlockSize(), os.getBlockSize());
++
++	is.skip(start);
++
++	std::vector <stream::value_type> vbuffer(blockSize);
++
++	stream::value_type* buffer = &vbuffer.front();
++	stream::size_type total = 0;
++
++	while (!is.eof() && total < length)
++	{
++		const stream::size_type remaining = std::min(length - total, blockSize);
++		const stream::size_type read = is.read(buffer, blockSize);
++
++		if (read != 0)
++		{
++			os.write(buffer, read);
++			total += read;
++		}
++	}
++
++	return total;
++}
++
++
+ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os,
+ 	const stream::size_type length, progressListener* progress)
+ {
+diff --git a/src/word.cpp b/src/word.cpp
+index 79060a1..2876ddf 100644
+--- a/src/word.cpp
++++ b/src/word.cpp
+@@ -241,7 +241,7 @@ const std::vector <ref <word> > word::parseMultiple(const string& buffer, const
+ }
+ 
+ 
+-void word::parse(const string& buffer, const string::size_type position,
++void word::parseImpl(const string& buffer, const string::size_type position,
+ 	const string::size_type end, string::size_type* newPosition)
+ {
+ 	if (position + 6 < end && // 6 = "=?(.+)?(.*)?="
+@@ -324,7 +324,7 @@ void word::parse(const string& buffer, const string::size_type position,
+ }
+ 
+ 
+-void word::generate(utility::outputStream& os, const string::size_type maxLineLength,
++void word::generateImpl(utility::outputStream& os, const string::size_type maxLineLength,
+ 	const string::size_type curLinePos, string::size_type* newLinePos) const
+ {
+ 	generate(os, maxLineLength, curLinePos, newLinePos, 0, NULL);
+@@ -743,9 +743,9 @@ void word::setBuffer(const string& buffer)
+ }
+ 
+ 
+-const std::vector <ref <const component> > word::getChildComponents() const
++const std::vector <ref <component> > word::getChildComponents()
+ {
+-	return std::vector <ref <const component> >();
++	return std::vector <ref <component> >();
+ }
+ 
+ 
+diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
+index 9d51262..deb4b9c 100644
+--- a/tests/parser/bodyPartTest.cpp
++++ b/tests/parser/bodyPartTest.cpp
+@@ -33,12 +33,14 @@ VMIME_TEST_SUITE_BEGIN
+ 	VMIME_TEST_LIST_BEGIN
+ 		VMIME_TEST(testParse)
+ 		VMIME_TEST(testGenerate)
++		VMIME_TEST(testParseGuessBoundary)
+ 		VMIME_TEST(testParseMissingLastBoundary)
+ 		VMIME_TEST(testPrologEpilog)
+ 		VMIME_TEST(testPrologEncoding)
+ 		VMIME_TEST(testSuccessiveBoundaries)
+ 		VMIME_TEST(testGenerate7bit)
+ 		VMIME_TEST(testTextUsageForQPEncoding)
++		VMIME_TEST(testParseVeryBigMessage)
+ 	VMIME_TEST_LIST_END
+ 
+ 
+@@ -237,6 +239,93 @@ VMIME_TEST_SUITE_BEGIN
+ 		VASSERT_EQ("2", "Part1-line1\r\nPart1-line2\r\n=89", oss.str());
+ 	}
+ 
++	void testParseGuessBoundary()
++	{
++		// Boundary is not specified in "Content-Type" field
++		// Parser will try to guess it from message contents.
++
++		vmime::string str =
++			"Content-Type: multipart/mixed"
++			"\r\n\r\n"
++			"--UNKNOWN-BOUNDARY\r\nHEADER1\r\n\r\nBODY1\r\n"
++			"--UNKNOWN-BOUNDARY\r\nHEADER2\r\n\r\nBODY2\r\n"
++			"--UNKNOWN-BOUNDARY--";
++
++		vmime::bodyPart p;
++		p.parse(str);
++
++		VASSERT_EQ("count", 2, p.getBody()->getPartCount());
++
++		VASSERT_EQ("part1-body", "BODY1", extractContents(p.getBody()->getPartAt(0)->getBody()->getContents()));
++		VASSERT_EQ("part2-body", "BODY2", extractContents(p.getBody()->getPartAt(1)->getBody()->getContents()));
++	}
++
++	void testParseVeryBigMessage()
++	{
++		// When parsing from a seekable input stream, body contents should not
++		// be kept in memory in a "stringContentHandler" object. Instead, content
++		// should be accessible via a "streamContentHandler" object.
++
++		static const std::string BODY1_BEGIN = "BEGIN1BEGIN1BEGIN1";
++		static const std::string BODY1_LINE = "BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1BODY1";
++		static const std::string BODY1_END = "END1END1";
++		static const unsigned int BODY1_REPEAT = 35000;
++		static const unsigned int BODY1_LENGTH =
++			BODY1_BEGIN.length() + BODY1_LINE.length() * BODY1_REPEAT + BODY1_END.length();
++
++		static const std::string BODY2_LINE = "BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2BODY2";
++		static const unsigned int BODY2_REPEAT = 20000;
++
++		std::ostringstream oss;
++		oss << "Content-Type: multipart/mixed; boundary=\"MY-BOUNDARY\""
++		    << "\r\n\r\n"
++		    << "--MY-BOUNDARY\r\n"
++		    << "HEADER1\r\n"
++		    << "\r\n";
++
++		oss << BODY1_BEGIN;
++
++		for (unsigned int i = 0 ; i < BODY1_REPEAT ; ++i)
++			oss << BODY1_LINE;
++
++		oss << BODY1_END;
++
++		oss << "\r\n"
++		    << "--MY-BOUNDARY\r\n"
++		    << "HEADER2\r\n"
++		    << "\r\n";
++
++		for (unsigned int i = 0 ; i < BODY2_REPEAT ; ++i)
++			oss << BODY2_LINE;
++
++		oss << "\r\n"
++		    << "--MY-BOUNDARY--\r\n";
++
++		vmime::ref <vmime::utility::inputStreamStringAdapter> is =
++			vmime::create <vmime::utility::inputStreamStringAdapter>(oss.str());
++
++		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
++		msg->parse(is, oss.str().length());
++
++		vmime::ref <vmime::body> body1 = msg->getBody()->getPartAt(0)->getBody();
++		vmime::ref <const vmime::contentHandler> body1Cts = body1->getContents();
++
++		vmime::ref <vmime::body> body2 = msg->getBody()->getPartAt(1)->getBody();
++		vmime::ref <const vmime::contentHandler> body2Cts = body2->getContents();
++
++		vmime::string body1CtsExtracted;
++		vmime::utility::outputStreamStringAdapter body1CtsExtractStream(body1CtsExtracted);
++		body1Cts->extract(body1CtsExtractStream);
++
++		VASSERT_EQ("1.1", BODY1_LENGTH, body1Cts->getLength());
++		VASSERT("1.2", body1Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
++		VASSERT_EQ("1.3", BODY1_LENGTH, body1CtsExtracted.length());
++		VASSERT_EQ("1.4", BODY1_BEGIN, body1CtsExtracted.substr(0, BODY1_BEGIN.length()));
++		VASSERT_EQ("1.5", BODY1_END, body1CtsExtracted.substr(BODY1_LENGTH - BODY1_END.length(), BODY1_END.length()));
++
++		VASSERT_EQ("2.1", BODY2_LINE.length() * BODY2_REPEAT, body2Cts->getLength());
++		VASSERT("2.2", body2Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
++	}
+ 
+ VMIME_TEST_SUITE_END
+ 
+diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp
+index 2e537c0..9dc283c 100644
+--- a/vmime/addressList.hpp
++++ b/vmime/addressList.hpp
+@@ -56,7 +56,7 @@ public:
+ 	addressList& operator=(const addressList& other);
+ 	addressList& operator=(const mailboxList& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Add a address at the end of the list.
+@@ -163,14 +163,20 @@ private:
+ 
+ 	std::vector <ref <address> > m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/body.hpp b/vmime/body.hpp
+index 9e83d6b..bd5bbb9 100644
+--- a/vmime/body.hpp
++++ b/vmime/body.hpp
+@@ -278,7 +278,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	body& operator=(const body& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -299,14 +299,20 @@ private:
+ 
+ 	void initNewPart(ref <bodyPart> part);
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp
+index aa0f040..5f36d90 100644
+--- a/vmime/bodyPart.hpp
++++ b/vmime/bodyPart.hpp
+@@ -89,7 +89,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	bodyPart& operator=(const bodyPart& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -98,14 +98,20 @@ private:
+ 
+ 	weak_ref <bodyPart> m_parent;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/charset.hpp b/vmime/charset.hpp
+index 5f5e8e5..26abb4f 100644
+--- a/vmime/charset.hpp
++++ b/vmime/charset.hpp
+@@ -62,7 +62,7 @@ public:
+ 	bool operator==(const charset& value) const;
+ 	bool operator!=(const charset& value) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Gets the recommended encoding for this charset.
+ 	  * Note: there may be no recommended encoding.
+@@ -117,14 +117,20 @@ private:
+ 
+ 	string m_name;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/component.hpp b/vmime/component.hpp
+index 12b0406..5e6f393 100644
+--- a/vmime/component.hpp
++++ b/vmime/component.hpp
+@@ -27,6 +27,8 @@
+ 
+ #include "vmime/base.hpp"
+ #include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
++#include "vmime/utility/parserInputStreamAdapter.hpp"
+ #include "vmime/utility/outputStream.hpp"
+ 
+ 
+@@ -51,6 +53,12 @@ public:
+ 	  */
+ 	void parse(const string& buffer);
+ 
++	/** Parse RFC-822/MIME data for this component. If stream is not seekable,
++	  * or if length is not specified, entire contents of the stream will
++	  * be loaded into memory before parsing.
++	  */
++	void parse(ref <utility::inputStream> inputStream, const utility::stream::size_type length);
++
+ 	/** Parse RFC-822/MIME data for this component.
+ 	  *
+ 	  * @param buffer input buffer
+@@ -58,7 +66,26 @@ public:
+ 	  * @param end end position in the input buffer
+ 	  * @param newPosition will receive the new position in the input buffer
+ 	  */
+-	virtual void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL) = 0;
++	void parse
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	/** Parse RFC-822/MIME data for this component. If stream is not seekable,
++	  * or if end position is not specified, entire contents of the stream will
++	  * be loaded into memory before parsing.
++	  *
++	  * @param inputStream stream from which to read data
++	  * @param position current position in the input stream
++	  * @param end end position in the input stream
++	  * @param newPosition will receive the new position in the input stream
++	  */
++	void parse
++		(ref <utility::inputStream> inputStream,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
+ 
+ 	/** Generate RFC-2822/MIME data for this component.
+ 	  *
+@@ -68,16 +95,35 @@ public:
+ 	  * @param curLinePos length of the current line in the output buffer
+ 	  * @return generated data
+ 	  */
+-	const string generate(const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0) const;
++	virtual const string generate
++		(const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0) const;
+ 
+ 	/** Generate RFC-2822/MIME data for this component.
+ 	  *
+-	  * @param os output stream
++	  * @param outputStream output stream
+ 	  * @param maxLineLength maximum line length for output
+ 	  * @param curLinePos length of the current line in the output buffer
+ 	  * @param newLinePos will receive the new line position (length of the last line written)
+ 	  */
+-	virtual void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const = 0;
++	virtual void generate
++		(utility::outputStream& outputStream,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
++
++	/** Generate RFC-2822/MIME data for this component.
++	  *
++	  * @param outputStream output stream
++	  * @param maxLineLength maximum line length for output
++	  * @param curLinePos length of the current line in the output buffer
++	  * @param newLinePos will receive the new line position (length of the last line written)
++	  */
++	virtual void generate
++		(ref <utility::outputStream> outputStream,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ 	/** Clone this component.
+ 	  *
+@@ -95,41 +141,56 @@ public:
+ 	virtual void copyFrom(const component& other) = 0;
+ 
+ 	/** Return the start position of this component in the
+-	  * parsed message contents.
++	  * parsed message contents. Use for debugging only.
+ 	  *
+ 	  * @return start position in parsed buffer
+ 	  * or 0 if this component has not been parsed
+ 	  */
+-	string::size_type getParsedOffset() const;
++	utility::stream::size_type getParsedOffset() const;
+ 
+ 	/** Return the length of this component in the
+-	  * parsed message contents.
++	  * parsed message contents. Use for debugging only.
+ 	  *
+ 	  * @return length of the component in parsed buffer
+ 	  * or 0 if this component has not been parsed
+ 	  */
+-	string::size_type getParsedLength() const;
++	utility::stream::size_type getParsedLength() const;
+ 
+ 	/** Return the list of children of this component.
+ 	  *
+ 	  * @return list of child components
+ 	  */
+-	const std::vector <ref <component> > getChildComponents();
+-
+-	/** Return the list of children of this component (const version).
+-	  *
+-	  * @return list of child components
+-	  */
+-	virtual const std::vector <ref <const component> > getChildComponents() const = 0;
++	virtual const std::vector <ref <component> > getChildComponents() = 0;
+ 
+ protected:
+ 
+-	void setParsedBounds(const string::size_type start, const string::size_type end);
++	void setParsedBounds(const utility::stream::size_type start, const utility::stream::size_type end);
++
++	// AT LEAST ONE of these parseImpl() functions MUST be implemented in derived class
++	virtual void parseImpl
++		(ref <utility::parserInputStreamAdapter> parser,
++		 const utility::stream::size_type position,
++		 const utility::stream::size_type end,
++		 utility::stream::size_type* newPosition = NULL);
++
++	virtual void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	virtual void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const = 0;
+ 
+ private:
+ 
+-	string::size_type m_parsedOffset;
+-	string::size_type m_parsedLength;
++	void offsetParsedBounds(const utility::stream::size_type offset);
++
++	utility::stream::size_type m_parsedOffset;
++	utility::stream::size_type m_parsedLength;
+ };
+ 
+ 
+diff --git a/vmime/contentDisposition.hpp b/vmime/contentDisposition.hpp
+index 9d1749b..abd2e1a 100644
+--- a/vmime/contentDisposition.hpp
++++ b/vmime/contentDisposition.hpp
+@@ -63,7 +63,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	contentDisposition& operator=(const contentDisposition& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	contentDisposition& operator=(const string& name);
+@@ -75,14 +75,20 @@ private:
+ 
+ 	string m_name;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp
+index 8e99640..053f4a6 100644
+--- a/vmime/dateTime.hpp
++++ b/vmime/dateTime.hpp
+@@ -237,16 +237,22 @@ public:
+ 	// Current date and time
+ 	static const datetime now();
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/disposition.hpp b/vmime/disposition.hpp
+index 05bfca2..7bdc832 100644
+--- a/vmime/disposition.hpp
++++ b/vmime/disposition.hpp
+@@ -50,7 +50,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	disposition& operator=(const disposition& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Set the disposition action mode.
+@@ -134,14 +134,20 @@ private:
+ 
+ 	std::vector <string> m_modifiers;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp
+index 42f5246..4322b29 100644
+--- a/vmime/encoding.hpp
++++ b/vmime/encoding.hpp
+@@ -93,7 +93,7 @@ public:
+ 	bool operator==(const encoding& value) const;
+ 	bool operator!=(const encoding& value) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Decide which encoding to use based on the specified data.
+ 	  *
+@@ -141,14 +141,20 @@ private:
+ 	  */
+ 	static const encoding decideImpl(const string::const_iterator begin, const string::const_iterator end);
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/header.hpp b/vmime/header.hpp
+index 95a9326..ed555b0 100644
+--- a/vmime/header.hpp
++++ b/vmime/header.hpp
+@@ -220,7 +220,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	header& operator=(const header& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+@@ -251,14 +251,20 @@ private:
+ 		string m_name;
+ 	};
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp
+index 50494c9..61e01ee 100644
+--- a/vmime/headerField.hpp
++++ b/vmime/headerField.hpp
+@@ -59,7 +59,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	headerField& operator=(const headerField& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Sets the name of this field.
+ 	  *
+@@ -118,15 +118,26 @@ public:
+ 	void setValue(const string& value);
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+-protected:
+ 
+-	static ref <headerField> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
++	static ref <headerField> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+ 
+ 	string m_name;
+diff --git a/vmime/mailbox.hpp b/vmime/mailbox.hpp
+index 2072be8..2099355 100644
+--- a/vmime/mailbox.hpp
++++ b/vmime/mailbox.hpp
+@@ -85,7 +85,7 @@ public:
+ 
+ 	void clear();
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	bool isGroup() const;
+@@ -101,8 +101,17 @@ public:
+ 	using address::generate;
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp
+index 0061d5b..1433141 100644
+--- a/vmime/mailboxGroup.hpp
++++ b/vmime/mailboxGroup.hpp
+@@ -52,7 +52,7 @@ public:
+ 	ref <component> clone() const;
+ 	mailboxGroup& operator=(const component& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the name of the group.
+ 	  *
+@@ -165,14 +165,20 @@ private:
+ 	text m_name;
+ 	std::vector <ref <mailbox> > m_list;
+ 
+-public:
+-
+-	using address::parse;
+-	using address::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp
+index 11e4e79..1b480c1 100644
+--- a/vmime/mailboxList.hpp
++++ b/vmime/mailboxList.hpp
+@@ -51,7 +51,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	mailboxList& operator=(const mailboxList& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Add a mailbox at the end of the list.
+ 	  *
+@@ -155,14 +155,20 @@ private:
+ 
+ 	addressList m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/mediaType.hpp b/vmime/mediaType.hpp
+index 658b21f..18182f0 100644
+--- a/vmime/mediaType.hpp
++++ b/vmime/mediaType.hpp
+@@ -55,7 +55,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	mediaType& operator=(const mediaType& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the media type.
+ 	  * See the constants in vmime::mediaTypes.
+@@ -97,14 +97,18 @@ protected:
+ 	string m_type;
+ 	string m_subType;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
+-
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/message.hpp b/vmime/message.hpp
+index f3be229..9767564 100644
+--- a/vmime/message.hpp
++++ b/vmime/message.hpp
+@@ -43,12 +43,25 @@ public:
+ 	message();
+ 
+ 
+-	// Component parsing & assembling
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
+-
+-	const string generate(const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(), const string::size_type curLinePos = 0) const;
++public:
+ 
+-	void parse(const string& buffer);
++	// Override default generate() functions so that we can change
++	// the default 'maxLineLength' value
++	void generate
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(),
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
++
++	const string generate
++		(const string::size_type maxLineLength = options::getInstance()->message.maxLineLength(),
++		 const string::size_type curLinePos = 0) const;
++
++	void generate
++		(ref <utility::outputStream> os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/messageId.hpp b/vmime/messageId.hpp
+index 3686b11..ac408e6 100644
+--- a/vmime/messageId.hpp
++++ b/vmime/messageId.hpp
+@@ -97,23 +97,27 @@ public:
+ 	void copyFrom(const component& other);
+ 	messageId& operator=(const messageId& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ private:
+ 
+ 	string m_left;
+ 	string m_right;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
+-
+-protected:
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ 	/** Parse a message-id from an input buffer.
+ 	  *
+@@ -123,7 +127,11 @@ protected:
+ 	  * @param newPosition will receive the new position in the input buffer
+ 	  * @return a new message-id object, or null if no more message-id can be parsed from the input buffer
+ 	  */
+-	static ref <messageId> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition);
++	static ref <messageId> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition);
+ };
+ 
+ 
+diff --git a/vmime/messageIdSequence.hpp b/vmime/messageIdSequence.hpp
+index 5dfb840..6736d0a 100644
+--- a/vmime/messageIdSequence.hpp
++++ b/vmime/messageIdSequence.hpp
+@@ -49,7 +49,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	messageIdSequence& operator=(const messageIdSequence& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 
+ 	/** Add a message-id at the end of the list.
+@@ -148,14 +148,20 @@ private:
+ 
+ 	std::vector <ref <messageId> > m_list;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp
+index e1b13a1..0773ea6 100644
+--- a/vmime/parameter.hpp
++++ b/vmime/parameter.hpp
+@@ -67,7 +67,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	parameter& operator=(const parameter& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Return the name of this parameter.
+ 	  *
+@@ -104,7 +104,7 @@ public:
+ 	const T getValueAs() const
+ 	{
+ 		T ret;
+-		ret.parse(m_value.getBuffer());
++		ret.parse(m_value->getBuffer());
+ 
+ 		return ret;
+ 	}
+@@ -122,11 +122,19 @@ public:
+ 	void setValue(const word& value);
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ private:
+ 
+@@ -134,7 +142,7 @@ private:
+ 
+ 
+ 	string m_name;
+-	word m_value;
++	ref <word> m_value;
+ };
+ 
+ 
+diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
+index 2940ca3..d2c934f 100644
+--- a/vmime/parameterizedHeaderField.hpp
++++ b/vmime/parameterizedHeaderField.hpp
+@@ -172,19 +172,25 @@ public:
+ 	  */
+ 	const std::vector <ref <parameter> > getParameterList();
+ 
++	const std::vector <ref <component> > getChildComponents();
++
+ private:
+ 
+ 	std::vector <ref <parameter> > m_params;
+ 
+-public:
+-
+-	using headerField::parse;
+-	using headerField::generate;
+-
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++protected:
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/parserHelpers.hpp b/vmime/parserHelpers.hpp
+index 9b075f7..d4f1246 100644
+--- a/vmime/parserHelpers.hpp
++++ b/vmime/parserHelpers.hpp
+@@ -45,6 +45,10 @@ public:
+ 		return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+ 	}
+ 
++	static bool isSpaceOrTab(const char_t c)
++	{
++		return (c == ' ' || c == '\t');
++	}
+ 
+ 	static bool isDigit(const char_t c)
+ 	{
+diff --git a/vmime/path.hpp b/vmime/path.hpp
+index beaa72b..eec8dfc 100644
+--- a/vmime/path.hpp
++++ b/vmime/path.hpp
+@@ -76,21 +76,26 @@ public:
+ 	ref <component> clone() const;
+ 	path& operator=(const path& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ protected:
+ 
+ 	string m_localPart;
+ 	string m_domain;
+ 
+-public:
+-
+-	using component::parse;
+-	using component::generate;
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/platforms/posix/posixFile.hpp b/vmime/platforms/posix/posixFile.hpp
+index 70986df..704b7b0 100644
+--- a/vmime/platforms/posix/posixFile.hpp
++++ b/vmime/platforms/posix/posixFile.hpp
+@@ -26,6 +26,7 @@
+ 
+ 
+ #include "vmime/utility/file.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ #if VMIME_HAVE_FILESYSTEM_FEATURES
+@@ -57,7 +58,7 @@ private:
+ 
+ 
+ 
+-class posixFileReaderInputStream : public vmime::utility::inputStream
++class posixFileReaderInputStream : public vmime::utility::seekableInputStream
+ {
+ public:
+ 
+@@ -72,6 +73,9 @@ public:
+ 
+ 	size_type skip(const size_type count);
+ 
++	size_type getPosition() const;
++	void seek(const size_type pos);
++
+ private:
+ 
+ 	const vmime::utility::file::path m_path;
+diff --git a/vmime/platforms/windows/windowsFile.hpp b/vmime/platforms/windows/windowsFile.hpp
+index 6e1c8fb..f417032 100644
+--- a/vmime/platforms/windows/windowsFile.hpp
++++ b/vmime/platforms/windows/windowsFile.hpp
+@@ -26,6 +26,7 @@
+ 
+ 
+ #include "vmime/utility/file.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ #include <windows.h>
+ 
+@@ -157,6 +158,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/relay.hpp b/vmime/relay.hpp
+index 583ad80..dbaedf2 100644
+--- a/vmime/relay.hpp
++++ b/vmime/relay.hpp
+@@ -51,7 +51,7 @@ public:
+ 	void copyFrom(const component& other);
+ 	relay& operator=(const relay& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	const string& getFrom() const;
+ 	void setFrom(const string& from);
+@@ -85,13 +85,19 @@ private:
+ 
+ 	datetime m_date;
+ 
+-public:
++protected:
+ 
+-	using component::parse;
+-	using component::generate;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ };
+ 
+ 
+diff --git a/vmime/text.hpp b/vmime/text.hpp
+index 15e11ae..778ce86 100644
+--- a/vmime/text.hpp
++++ b/vmime/text.hpp
+@@ -58,7 +58,7 @@ public:
+ 	text& operator=(const component& other);
+ 	text& operator=(const text& other);
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++	const std::vector <ref <component> > getChildComponents();
+ 
+ 	/** Add a word at the end of the list.
+ 	  *
+@@ -226,13 +226,20 @@ public:
+ 	  */
+ 	static text* decodeAndUnfold(const string& in, text* generateInExisting);
+ 
+-
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+ 	// Component parsing & assembling
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
++
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamAdapter.hpp b/vmime/utility/inputStreamAdapter.hpp
+index 278ab52..bd4d21e 100644
+--- a/vmime/utility/inputStreamAdapter.hpp
++++ b/vmime/utility/inputStreamAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ #include <istream>
+ 
+@@ -37,7 +37,7 @@ namespace utility {
+ /** An adapter class for C++ standard input streams.
+   */
+ 
+-class inputStreamAdapter : public inputStream
++class inputStreamAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -49,6 +49,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamByteBufferAdapter.hpp b/vmime/utility/inputStreamByteBufferAdapter.hpp
+index 0f6a442..b3dafd9 100644
+--- a/vmime/utility/inputStreamByteBufferAdapter.hpp
++++ b/vmime/utility/inputStreamByteBufferAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMBYTEBUFFERADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -35,7 +35,7 @@ namespace utility {
+ /** An adapter class for reading from an array of bytes.
+   */
+ 
+-class inputStreamByteBufferAdapter : public inputStream
++class inputStreamByteBufferAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -45,6 +45,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamStringAdapter.hpp b/vmime/utility/inputStreamStringAdapter.hpp
+index a7d986f..18a9083 100644
+--- a/vmime/utility/inputStreamStringAdapter.hpp
++++ b/vmime/utility/inputStreamStringAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMSTRINGADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -35,7 +35,7 @@ namespace utility {
+ /** An adapter class for string input.
+   */
+ 
+-class inputStreamStringAdapter : public inputStream
++class inputStreamStringAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -46,6 +46,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/inputStreamStringProxyAdapter.hpp b/vmime/utility/inputStreamStringProxyAdapter.hpp
+index 74b3f60..dc52637 100644
+--- a/vmime/utility/inputStreamStringProxyAdapter.hpp
++++ b/vmime/utility/inputStreamStringProxyAdapter.hpp
+@@ -25,7 +25,7 @@
+ #define VMIME_UTILITY_INPUTSTREAMSTRINGPROXYADAPTER_HPP_INCLUDED
+ 
+ 
+-#include "vmime/utility/inputStream.hpp"
++#include "vmime/utility/seekableInputStream.hpp"
+ 
+ 
+ namespace vmime {
+@@ -38,7 +38,7 @@ class stringProxy;
+ /** An adapter class for stringProxy input.
+   */
+ 
+-class inputStreamStringProxyAdapter : public inputStream
++class inputStreamStringProxyAdapter : public seekableInputStream
+ {
+ public:
+ 
+@@ -50,6 +50,8 @@ public:
+ 	void reset();
+ 	size_type read(value_type* const data, const size_type count);
+ 	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
+ 
+ private:
+ 
+diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp
+new file mode 100644
+index 0000000..c24fa44
+--- /dev/null
++++ b/vmime/utility/parserInputStreamAdapter.hpp
+@@ -0,0 +1,173 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/seekableInputStream.hpp"
++
++#include <cstring>
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter class used for parsing from an input stream.
++  */
++
++class parserInputStreamAdapter : public seekableInputStream
++{
++public:
++
++	/** @param is input stream to wrap
++	  */
++	parserInputStreamAdapter(ref <seekableInputStream> inputStream);
++
++	ref <seekableInputStream> getUnderlyingStream();
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++
++	void seek(const size_type pos)
++	{
++		m_stream->seek(pos);
++	}
++
++	size_type skip(const size_type count)
++	{
++		return m_stream->skip(count);
++	}
++
++	size_type getPosition() const
++	{
++		return m_stream->getPosition();
++	}
++
++	/** Get the byte at the current position without updating the
++	  * current position.
++	  *
++	  * @return byte at the current position
++	  */
++	value_type peekByte() const
++	{
++		const size_type initialPos = m_stream->getPosition();
++
++		try
++		{
++			value_type buffer[1];
++			const size_type readBytes = m_stream->read(buffer, 1);
++
++			m_stream->seek(initialPos);
++
++			return (readBytes == 1 ? buffer[0] : 0);
++		}
++		catch (...)
++		{
++			m_stream->seek(initialPos);
++			throw;
++		}
++	}
++
++	/** Get the byte at the current position and advance current
++	  * position by one byte.
++	  *
++	  * @return byte at the current position
++	  */
++	value_type getByte()
++	{
++		value_type buffer[1];
++		const size_type readBytes = m_stream->read(buffer, 1);
++
++		return (readBytes == 1 ? buffer[0] : 0);
++	}
++
++	/** Check whether the bytes following the current position match
++	  * the specified bytes. Position is not updated.
++	  *
++	  * @param bytes bytes to compare
++	  * @param length number of bytes
++	  * @return true if the next bytes match the pattern, false otherwise
++	  */
++	bool matchBytes(const value_type* bytes, const size_type length) const
++	{
++		const size_type initialPos = m_stream->getPosition();
++
++		try
++		{
++			value_type buffer[32];
++			const size_type readBytes = m_stream->read(buffer, length);
++
++			m_stream->seek(initialPos);
++
++			return readBytes == length &&
++			       ::memcmp(bytes, buffer, length) == 0;
++		}
++		catch (...)
++		{
++			m_stream->seek(initialPos);
++			throw;
++		}
++	}
++
++	const string extract(const size_type begin, const size_type end) const;
++
++	/** Skips bytes matching a predicate from the current position.
++	  * The current position is updated to the next following byte
++	  * which does not match the predicate.
++	  *
++	  * @param pred predicate
++	  * @param endPosition stop at this position (or at end of the stream,
++	  * whichever comes first)
++	  * @return number of bytes skipped
++	  */
++	template <typename PREDICATE>
++	size_type skipIf(PREDICATE pred, const size_type endPosition)
++	{
++		const size_type initialPos = getPosition();
++		size_type pos = initialPos;
++
++		while (!m_stream->eof() && pos < endPosition && pred(getByte()))
++			++pos;
++
++		m_stream->seek(pos);
++
++		return pos - initialPos;
++	}
++
++	size_type findNext(const std::string& token, const size_type startPosition = 0);
++
++private:
++
++	mutable ref <seekableInputStream> m_stream;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_PARSERINPUTSTREAMADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/seekableInputStream.hpp b/vmime/utility/seekableInputStream.hpp
+new file mode 100644
+index 0000000..c2ab1bb
+--- /dev/null
++++ b/vmime/utility/seekableInputStream.hpp
+@@ -0,0 +1,64 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++#define VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++
++
++#include "vmime/utility/inputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An input stream that allows seeking within the input.
++  */
++
++class seekableInputStream : public inputStream
++{
++public:
++
++	/** Returns the current position in this stream.
++	  *
++	  * @return the offset from the beginning of the stream, in bytes,
++	  * at which the next read occurs
++	  */
++	virtual size_type getPosition() const = 0;
++
++	/** Sets the position, measured from the beginning of this stream,
++	  * at which the next read occurs.
++	  *
++	  * @param pos the offset position, measured in bytes from the
++	  * beginning of the stream, at which to set the stream pointer.
++	  */
++	virtual void seek(const size_type pos) = 0;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_SEEKABLEINPUTSTREAM_HPP_INCLUDED
++
+diff --git a/vmime/utility/seekableInputStreamRegionAdapter.hpp b/vmime/utility/seekableInputStreamRegionAdapter.hpp
+new file mode 100644
+index 0000000..5ebccc6
+--- /dev/null
++++ b/vmime/utility/seekableInputStreamRegionAdapter.hpp
+@@ -0,0 +1,71 @@
++//
++// VMime library (http://www.vmime.org)
++// Copyright (C) 2002-2012 Vincent Richard <vincent@vincent-richard.net>
++//
++// This program is free software; you can redistribute it and/or
++// modify it under the terms of the GNU General Public License as
++// published by the Free Software Foundation; either version 3 of
++// the License, or (at your option) any later version.
++//
++// This program is distributed in the hope that it will be useful,
++// but WITHOUT ANY WARRANTY; without even the implied warranty of
++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
++// General Public License for more details.
++//
++// You should have received a copy of the GNU General Public License along
++// with this program; if not, write to the Free Software Foundation, Inc.,
++// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
++//
++// Linking this library statically or dynamically with other modules is making
++// a combined work based on this library.  Thus, the terms and conditions of
++// the GNU General Public License cover the whole combination.
++//
++
++#ifndef VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++#define VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++
++
++#include "vmime/utility/seekableInputStream.hpp"
++
++
++namespace vmime {
++namespace utility {
++
++
++/** An adapter for reading a limited region of a seekable input stream.
++  */
++
++class seekableInputStreamRegionAdapter : public seekableInputStream
++{
++public:
++
++	/** Creates a new adapter for a seekableInputStream.
++	  *
++	  * @param stream source stream
++	  * @param begin start position in source stream
++	  * @param length region length in source stream
++	  */
++	seekableInputStreamRegionAdapter(ref <seekableInputStream> stream,
++		const size_type begin, const size_type length);
++
++	bool eof() const;
++	void reset();
++	size_type read(value_type* const data, const size_type count);
++	size_type skip(const size_type count);
++	size_type getPosition() const;
++	void seek(const size_type pos);
++
++private:
++
++	ref <seekableInputStream> m_stream;
++	size_type m_begin;
++	size_type m_length;
++};
++
++
++} // utility
++} // vmime
++
++
++#endif // VMIME_UTILITY_SEEKABLEINPUTSTREAMREGIONADAPTER_HPP_INCLUDED
++
+diff --git a/vmime/utility/stream.hpp b/vmime/utility/stream.hpp
+index 566ab9d..78be827 100644
+--- a/vmime/utility/stream.hpp
++++ b/vmime/utility/stream.hpp
+@@ -54,6 +54,10 @@ public:
+ 	  */
+ 	typedef string::size_type size_type;
+ 
++	/** Constant value with the greatest possible value for an element of type size_type.
++	  */
++	static const size_type npos;
++
+ 	/** Return the preferred maximum block size when reading
+ 	  * from or writing to this stream.
+ 	  *
+diff --git a/vmime/utility/streamUtils.hpp b/vmime/utility/streamUtils.hpp
+index cdf70aa..87c8fc5 100644
+--- a/vmime/utility/streamUtils.hpp
++++ b/vmime/utility/streamUtils.hpp
+@@ -45,6 +45,19 @@ namespace utility {
+ stream::size_type bufferedStreamCopy(inputStream& is, outputStream& os);
+ 
+ /** Copy data from one stream into another stream using a buffered method
++  * and copying only a specified range of data.
++  *
++  * @param is input stream (source data)
++  * @param os output stream (destination for data)
++  * @param start number of bytes to ignore before starting copying
++  * @param length maximum number of bytes to copy
++  * @return number of bytes copied
++  */
++
++stream::size_type bufferedStreamCopyRange(inputStream& is, outputStream& os,
++	const stream::size_type start, const stream::size_type length);
++
++/** Copy data from one stream into another stream using a buffered method
+   * and notify progress state of the operation.
+   *
+   * @param is input stream (source data)
+diff --git a/vmime/word.hpp b/vmime/word.hpp
+index ad848ec..492aab5 100644
+--- a/vmime/word.hpp
++++ b/vmime/word.hpp
+@@ -128,21 +128,52 @@ public:
+ #endif
+ 
+ 
+-	using component::parse;
+-	using component::generate;
++protected:
+ 
+-	void parse(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition = NULL);
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength = lineLengthLimits::infinite, const string::size_type curLinePos = 0, string::size_type* newLinePos = NULL) const;
++	void parseImpl
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition = NULL);
+ 
+-	void generate(utility::outputStream& os, const string::size_type maxLineLength, const string::size_type curLinePos, string::size_type* newLinePos, const int flags, generatorState* state) const;
++	void generateImpl
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength = lineLengthLimits::infinite,
++		 const string::size_type curLinePos = 0,
++		 string::size_type* newLinePos = NULL) const;
+ 
+-	const std::vector <ref <const component> > getChildComponents() const;
++public:
+ 
+-private:
++	using component::generate;
+ 
+-	static ref <word> parseNext(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition, bool prevIsEncoded, bool* isEncoded, bool isFirst);
++#ifndef VMIME_BUILDING_DOC
++	void generate
++		(utility::outputStream& os,
++		 const string::size_type maxLineLength,
++		 const string::size_type curLinePos,
++		 string::size_type* newLinePos,
++		 const int flags,
++		 generatorState* state) const;
++#endif
++
++	const std::vector <ref <component> > getChildComponents();
++
++private:
+ 
+-	static const std::vector <ref <word> > parseMultiple(const string& buffer, const string::size_type position, const string::size_type end, string::size_type* newPosition);
++	static ref <word> parseNext
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition,
++		 bool prevIsEncoded,
++		 bool* isEncoded,
++		 bool isFirst);
++
++	static const std::vector <ref <word> > parseMultiple
++		(const string& buffer,
++		 const string::size_type position,
++		 const string::size_type end,
++		 string::size_type* newPosition);
+ 
+ 
+ 	// The "m_buffer" of this word holds the data, and this data is encoded
+-- 
+1.7.10.3
+
+
+From 2e05e574fde890c7ec6dd9f3930d06b1b492ea80 Mon Sep 17 00:00:00 2001
+From: Vincent Richard <vincent@vincent-richard.net>
+Date: Fri, 27 Apr 2012 08:34:26 +0200
+Subject: [PATCH 38/38] Fixed duplicate file reference (thanks to Enes Albay).
+
+---
+ SConstruct |    1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/SConstruct b/SConstruct
+index 2690172..1f3c7c9 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -137,7 +137,6 @@ libvmime_sources = [
+ 	'utility/childProcess.hpp',
+ 	'utility/file.hpp',
+ 	'utility/datetimeUtils.cpp', 'utility/datetimeUtils.hpp',
+-	'utility/filteredStream.cpp', 'utility/filteredStream.hpp',
+ 	'utility/path.cpp', 'utility/path.hpp',
+ 	'utility/progressListener.cpp', 'utility/progressListener.hpp',
+ 	'utility/random.cpp', 'utility/random.hpp',
+-- 
+1.7.10.3
+
--- a/src/vmime.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/vmime.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,20 +10,16 @@
 $(PKG)_DEPS     := gcc libiconv gnutls libgsasl pthreads zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/vmime/files/vmime/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/vmime/files/vmime/' | \
     $(SED) -n 's,.*libvmime-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
 
 define $(PKG)_BUILD
+    $(SED) -i 's/pkg-config/$(TARGET)-pkg-config/g;'  '$(1)/SConstruct'
+
     # The configure script will make the real configuration, but
     # we need scons to generate configure.in, Makefile.am etc.
-    # ansi and pedantic are too strict for mingw.
-    # http://sourceforge.net/tracker/index.php?func=detail&aid=2373234&group_id=2435&atid=102435
-    $(SED) -i "s/'-ansi', //;"                        '$(1)/SConstruct'
-    $(SED) -i "s/'-pedantic', //;"                    '$(1)/SConstruct'
-    $(SED) -i 's/pkg-config/$(TARGET)-pkg-config/g;'  '$(1)/SConstruct'
-
     cd '$(1)' && scons autotools \
          prefix='$(PREFIX)/$(TARGET)' \
          target='$(TARGET)' \
@@ -33,6 +29,7 @@
     cd '$(1)' && ./configure \
         --prefix='$(PREFIX)/$(TARGET)' \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --enable-platform-windows \
         --disable-rpath \
--- a/src/vorbis.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/vorbis.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := vorbis
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 4b089ace4c8420c479b2fde9c5b01588cf86c959
+$(PKG)_CHECKSUM := 8dae60349292ed76db0e490dc5ee51088a84518b
 $(PKG)_SUBDIR   := libvorbis-$($(PKG)_VERSION)
 $(PKG)_FILE     := libvorbis-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://downloads.xiph.org/releases/vorbis/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc ogg
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xiph.org/downloads/' | \
+    $(WGET) -q -O- 'http://www.xiph.org/downloads/' | \
     $(SED) -n 's,.*libvorbis-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
@@ -18,6 +18,7 @@
 define $(PKG)_BUILD
     cd '$(1)' && ./configure \
         --host='$(TARGET)' \
+        --build="`config.guess`" \
         --disable-shared \
         --prefix='$(PREFIX)/$(TARGET)' \
         PKG_CONFIG='$(TARGET)-pkg-config'
--- a/src/vtk.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/vtk.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := qt expat freetype jpeg libxml2 libpng tiff zlib libodbc++ postgresql
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://vtk.org/gitweb?p=VTK.git;a=tags' | \
+    $(WGET) -q -O- 'http://vtk.org/gitweb?p=VTK.git;a=tags' | \
     grep 'refs/tags/v[0-9.]*"' | \
     $(SED) 's,.*refs/tags/v\(.*\)".*,\1,g;' | \
     head -1
--- a/src/w32api.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/w32api.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/' | \
     $(SED) -n 's,.*w32api-\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/winpcap.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/winpcap.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.winpcap.org/devel.htm' | \
+    $(WGET) -q -O- 'http://www.winpcap.org/devel.htm' | \
     $(SED) -n 's,.*WpcapSrc_\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
 endef
--- a/src/wt.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/wt.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc boost openssl libharu graphicsmagick pango postgresql sqlite
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/witty/files/witty/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/witty/files/witty/' | \
     $(SED) -n 's,.*wt-\([0-9][^>]*\)\.tar.*,\1,p' | \
     tail -1
 endef
@@ -31,6 +31,7 @@
         -DGM_PREFIX='$(PREFIX)/$(TARGET)' \
         -DGM_LIBS="`'$(TARGET)-pkg-config' --libs-only-l GraphicsMagick++`" \
         -DPANGO_FT2_LIBS="`'$(TARGET)-pkg-config' --libs-only-l pangoft2`" \
+        -DWT_CMAKE_FINDER_INSTALL_DIR='/lib/wt' \
         -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
         -DCMAKE_BUILD_TYPE:STRING="Release" \
         '$(1)'
--- a/src/wxwidgets.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/wxwidgets.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc libiconv libpng jpeg tiff sdl zlib expat
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/wxwindows/files/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/wxwindows/files/' | \
     $(SED) -n 's,.*/\([0-9][^"9]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/xerces.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xerces.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc libiconv curl
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.apache.org/dist/xerces/c/3/sources/?C=M;O=D' | \
+    $(WGET) -q -O- 'http://www.apache.org/dist/xerces/c/3/sources/?C=M;O=D' | \
     $(SED) -n 's,.*<a href="xerces-c-\([0-9][^"]*\)\.tar.*,\1,p' | \
     grep -v rc | \
     head -1
--- a/src/xine-lib-1-fixes.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xine-lib-1-fixes.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -1,62 +1,19 @@
 This file is part of MXE.
 See index.html for further information.
 
-Contains ad hoc patches for cross building.
-
-From 4968ed3c3300976ce8b24c52c729db6bd264057c Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Sun, 13 Nov 2011 11:48:07 +0100
-Subject: [PATCH 1/4] fix-install-def-file
-
-
-diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
-index 67ae63f..0f94abf 100644
---- a/src/xine-engine/Makefile.am
-+++ b/src/xine-engine/Makefile.am
-@@ -45,10 +45,10 @@ noinst_HEADERS = bswap.h ffmpeg_bswap.h xine_private.h
- 
- if WIN32
- install-exec-local:
--	cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
-+	-cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
- 
- uninstall-local:
--	rm -f $(DEF_FILE)
-+	-rm -f $(DESTDIR)$(libdir)/$(DEF_FILE)
- endif
- 
- $(XINEUTILS_LIB):
-diff --git a/src/xine-engine/Makefile.in b/src/xine-engine/Makefile.in
-index 167a32b..0664e1f 100644
---- a/src/xine-engine/Makefile.in
-+++ b/src/xine-engine/Makefile.in
-@@ -905,10 +905,10 @@ $(LIBXINEPOSIX):
- 	$(MAKE) -C $(top_builddir)/lib libxineposix.la
- 
- @WIN32_TRUE@install-exec-local:
--@WIN32_TRUE@	cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
-+@WIN32_TRUE@	-cp -p $(DEF_FILE) $(DESTDIR)$(libdir)
- 
- @WIN32_TRUE@uninstall-local:
--@WIN32_TRUE@	rm -f $(DEF_FILE)
-+@WIN32_TRUE@	-rm -f $(DESTDIR)$(libdir)/$(DEF_FILE)
- 
- $(XINEUTILS_LIB):
- 	$(MAKE) -C $(top_builddir)/src/xine-utils libxineutils.la
--- 
-1.7.8.3
-
-
-From 86f2d23f9229e17aa4a54ca982b8f95de5ee4644 Mon Sep 17 00:00:00 2001
-From: MXE
+From 6dc46ed1253c1fce1cfa8d360e352b5bc12d0d3b Mon Sep 17 00:00:00 2001
+From: "mxe@mxe.cc" <mxe@mxe.cc>
 Date: Sun, 13 Nov 2011 12:05:22 +0100
-Subject: [PATCH 2/4] fake missing definitions for WIN32
+Subject: [PATCH 1/4] fake missing definitions for WIN32
 
 Taken from:
 https://bugs.xine-project.org/show_bug.cgi?id=433
+---
+ src/audio_out/audio_file_out.c |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
 
 diff --git a/src/audio_out/audio_file_out.c b/src/audio_out/audio_file_out.c
-index 802461e..8b9b704 100644
+index bc40d4e..a613a89 100644
 --- a/src/audio_out/audio_file_out.c
 +++ b/src/audio_out/audio_file_out.c
 @@ -53,6 +53,18 @@
@@ -79,17 +36,20 @@
  
  struct wavhdr {
 -- 
-1.7.8.3
+1.7.10.4
 
 
-From 42946ec1f900d22b62cb28996b9f12d11d7be7a8 Mon Sep 17 00:00:00 2001
-From: MXE
+From 4a7cd803cbc3daa3f19fdc6b34fb93e1994bc2f5 Mon Sep 17 00:00:00 2001
+From: "mxe@mxe.cc" <mxe@mxe.cc>
 Date: Sun, 13 Nov 2011 13:45:21 +0100
-Subject: [PATCH 3/4] force graphicsmagick over imagemagick
+Subject: [PATCH 2/4] force graphicsmagick over imagemagick
 
+---
+ configure.ac |    9 ---------
+ 1 file changed, 9 deletions(-)
 
 diff --git a/configure.ac b/configure.ac
-index b175301..d37ba36 100644
+index 9112b58..67f1147 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1412,14 +1412,6 @@ AC_ARG_WITH([imagemagick],
@@ -116,37 +76,68 @@
        AC_MSG_ERROR([ImageMagick support requested, but neither Wand, MagickWand, nor GraphicsMagick were found])
     elif test "x$have_imagemagick" = "xyes"; then
 -- 
-1.7.8.3
+1.7.10.4
 
 
-From f0fa8b5b9570cdf88788067b1a76669c6863ac9f Mon Sep 17 00:00:00 2001
-From: MXE
-Date: Mon, 30 Jan 2012 09:21:33 +0100
-Subject: [PATCH 4/4] zlib 1.2.6 compatibility
+From 5b362f4aed3a814a351cd259efb62b40761ddb3d Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 23:28:57 +0200
+Subject: [PATCH 3/4] add missing localtime_r
+
+Previously provided by pthreads-w32-2-8-0-release, which is also
+the source of this version.
+---
+ src/localtime_r.h         |    3 +++
+ src/xine-engine/scratch.c |    1 +
+ 2 files changed, 4 insertions(+)
+ create mode 100644 src/localtime_r.h
+
+diff --git a/src/localtime_r.h b/src/localtime_r.h
+new file mode 100644
+index 0000000..ec778c5
+--- /dev/null
++++ b/src/localtime_r.h
+@@ -0,0 +1,3 @@
++#define localtime_r( _clock, _result ) \
++        ( *(_result) = *localtime( (_clock) ), \
++          (_result) )
+diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
+index 39bb592..41d561b 100644
+--- a/src/xine-engine/scratch.c
++++ b/src/xine-engine/scratch.c
+@@ -36,6 +36,7 @@
+ 
+ #include "xineutils.h"
+ #include "scratch.h"
++#include "localtime_r.h"
+ 
+ static void XINE_FORMAT_PRINTF(2, 0)
+   scratch_printf (scratch_buffer_t *this, const char *format, va_list argp)
+-- 
+1.7.10.4
 
 
-diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c
-index 1d22ea3..0fbde93 100644
---- a/src/xine-engine/osd.c
-+++ b/src/xine-engine/osd.c
-@@ -650,7 +650,7 @@ static void osd_set_position (osd_object_t *osd, int x, int y) {
-   osd->display_y = y;
+From 0d3546c3c12a8bf311c9751f0d0d2e3a95569657 Mon Sep 17 00:00:00 2001
+From: Mark Brand <mabrand@mabrand.nl>
+Date: Sun, 27 May 2012 23:23:19 +0200
+Subject: [PATCH 4/4] ffmpeg 0.11 removed avcodec_init
+
+---
+ src/combined/ffmpeg/ffmpeg_decoder.c |    1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/combined/ffmpeg/ffmpeg_decoder.c b/src/combined/ffmpeg/ffmpeg_decoder.c
+index 879df53..84ee1a3 100644
+--- a/src/combined/ffmpeg/ffmpeg_decoder.c
++++ b/src/combined/ffmpeg/ffmpeg_decoder.c
+@@ -312,7 +312,6 @@ void avcodec_register_all(void)
+ 
+ void init_once_routine(void) {
+   pthread_mutex_init(&ffmpeg_lock, NULL);
+-  avcodec_init();
+   avcodec_register_all();
  }
  
--static uint16_t gzread_i16(gzFile *fp) {
-+static uint16_t gzread_i16(gzFile fp) {
-   uint16_t ret;
-   ret = gzgetc(fp);
-   ret |= (gzgetc(fp)<<8);
-@@ -663,7 +663,7 @@ static uint16_t gzread_i16(gzFile *fp) {
- 
- static int osd_renderer_load_font(osd_renderer_t *this, char *filename) {
- 
--  gzFile      *fp;
-+  gzFile      fp;
-   osd_font_t  *font = NULL;
-   int          i, ret = 0;
- 
 -- 
-1.7.8.3
+1.7.10.4
 
--- a/src/xine-lib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xine-lib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := xine-lib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 68e85049723b491ccb22d5123bf8fa780529868a
+$(PKG)_CHECKSUM := 0adf20ef55d24f2a1b4a8974e57ad1be5133b236
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/xine/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc faad2 ffmpeg flac fontconfig freetype graphicsmagick libiconv libmng pthreads sdl speex theora vorbis zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://hg.debian.org/hg/xine-lib/xine-lib/tags' | \
+    $(WGET) -q -O- 'http://hg.debian.org/hg/xine-lib/xine-lib/tags' | \
     $(SED) -n 's,>,\n,gp' | \
     $(SED) -n 's,^\([0-9][^< ]*\)<.*,\1,p' | \
     head -1
--- a/src/xmlwrapp.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xmlwrapp.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,14 +3,14 @@
 
 PKG             := xmlwrapp
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := b3ef8bff215bbacd988790615b76379672105928
+$(PKG)_CHECKSUM := 7bd66ecc1204b296580a499fd929d77b79e6e85a
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc libxml2 libxslt
+$(PKG)_DEPS     := gcc boost libxml2 libxslt
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/xmlwrapp/files/xmlwrapp/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/xmlwrapp/files/xmlwrapp/' | \
     $(SED) -n 's,.*/\([0-9][^"]*\)/".*,\1,p' | \
     head -1
 endef
--- a/src/xvidcore.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xvidcore.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc pthreads
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://www.xvid.org/' | \
+    $(WGET) -q -O- 'http://www.xvid.org/' | \
     $(SED) -n 's,.*Xvid \([0-9][^ ]*\) .*,\1,p' | \
     head -1
 endef
--- a/src/xz.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/xz.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://tukaani.org/xz/' | \
+    $(WGET) -q -O- 'http://tukaani.org/xz/' | \
     $(SED) -n 's,.*xz-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
--- a/src/zlib-1-win32-static.patch	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/zlib-1-win32-static.patch	Wed Jun 13 19:11:14 2012 +0200
@@ -13,7 +13,7 @@
 index ea430bf..f2573e7 100644
 --- a/Makefile.in
 +++ b/Makefile.in
-@@ -188,11 +188,11 @@ install-libs: $(LIBS)
+@@ -190,11 +190,11 @@ install-libs: $(LIBS)
  	-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
  	-@if [ ! -d $(DESTDIR)$(man3dir)      ]; then mkdir -p $(DESTDIR)$(man3dir); fi
  	-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
@@ -31,7 +31,7 @@
 index 780317c..6e6a033 100755
 --- a/configure
 +++ b/configure
-@@ -180,10 +180,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
+@@ -205,10 +205,7 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) >> configure.log 2>&1; then
    CYGWIN* | Cygwin* | cygwin* | OS/2*)
          EXE='.exe' ;;
    MINGW* | mingw*)
--- a/src/zlib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/zlib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -3,7 +3,7 @@
 
 PKG             := zlib
 $(PKG)_IGNORE   :=
-$(PKG)_CHECKSUM := 3d445731e4bfea1cd00f36567d77d6e5f5a19be9
+$(PKG)_CHECKSUM := 858818fe6d358ec682d54ac5e106a2dd62628e7f
 $(PKG)_SUBDIR   := zlib-$($(PKG)_VERSION)
 $(PKG)_FILE     := zlib-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://zlib.net/$($(PKG)_FILE)
@@ -11,7 +11,7 @@
 $(PKG)_DEPS     := gcc
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://zlib.net/' | \
+    $(WGET) -q -O- 'http://zlib.net/' | \
     $(SED) -n 's,.*zlib-\([0-9][^>]*\)\.tar.*,\1,ip' | \
     head -1
 endef
--- a/src/zziplib.mk	Wed Jun 13 02:35:57 2012 -0700
+++ b/src/zziplib.mk	Wed Jun 13 19:11:14 2012 +0200
@@ -10,7 +10,7 @@
 $(PKG)_DEPS     := gcc zlib
 
 define $(PKG)_UPDATE
-    wget -q -O- 'http://sourceforge.net/projects/zziplib/files/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/zziplib/files/' | \
     $(SED) -n 's,.*zziplib-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef