7046137 move *torrent to userland
authorMike Sullivan <Mike.Sullivan@Oracle.COM>
Thu, 19 May 2011 10:10:26 -0700
changeset 248 3011f7a1ed77
parent 247 c57f32335aee
child 249 a26c7270b713
7046137 move *torrent to userland
components/libtorrent/Makefile
components/libtorrent/libtorrent.3
components/libtorrent/libtorrent.license
components/libtorrent/libtorrent.p5m
components/libtorrent/patches/rlibtorrent-01-madvise.patch
components/libtorrent/patches/rlibtorrent-02-event-ports.patch
components/libtorrent/patches/rlibtorrent-03-dh-generate.patch
components/libtorrent/patches/rlibtorrent-04-sunpro.patch
components/libtorrent/patches/rlibtorrent-05-tracker-usable.patch
components/meta-packages/history/SUNWlibtorrent.p5m
components/meta-packages/history/SUNWrtorrent.p5m
components/rtorrent/Makefile
components/rtorrent/patches/rtorrent-01-solaris.patch
components/rtorrent/patches/rtorrent-02-event-ports.patch
components/rtorrent/patches/rtorrent-03-curl-event.patch
components/rtorrent/patches/rtorrent-04-sunpro.patch
components/rtorrent/patches/rtorrent-05-sunpro-crash.patch
components/rtorrent/rtorrent.license
components/rtorrent/rtorrent.p5m
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/Makefile	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,84 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../make-rules/shared-macros.mk
+
+COMPONENT_NAME=		libtorrent
+COMPONENT_VERSION=	0.12.2
+COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
+COMPONENT_PROJECT_URL=	http://libtorrent.rakshasa.no/
+COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.gz
+COMPONENT_ARCHIVE_HASH=	sha1:a53d2c671e9f2dd971d0622d5b3672da91c46ef9
+COMPONENT_ARCHIVE_URL=	http://libtorrent.rakshasa.no/downloads/$(COMPONENT_ARCHIVE)
+
+include ../../make-rules/prep.mk
+include ../../make-rules/configure.mk
+include ../../make-rules/ips.mk
+
+COMPONENT_PRE_CONFIGURE_ACTION = \
+	($(CLONEY) $(SOURCE_DIR) $(@D))
+
+COMPONENT_PREP_ACTION = \
+        (cd $(@D) ; \
+	    aclocal-1.10 -I./scripts -I. ; \
+	    autoheader; \
+	    libtoolize --automake --copy --force; \
+	    automake-1.10; \
+	    autoconf )
+
+# Although -norunpath is set for CXXFLAGS, we need to put -norunpath 
+# here, otherwise -norunpath doesn't get set when creating the shared 
+# libraries (CC -G).
+CXX+=   $(studio_NORUNPATH)
+
+# this is needed or we can't compile the rak headers
+CC=$(CXX)
+
+CXXFLAGS +=	-i
+CXXFLAGS +=	-xspace
+CXXFLAGS +=	-mr
+CXXFLAGS +=	$(studio_XREGS)
+
+CONFIGURE_OPTIONS  +=	--enable-shared
+CONFIGURE_OPTIONS  +=	--disable-debug
+CONFIGURE_OPTIONS  +=	--disable-static
+CONFIGURE_OPTIONS  +=	--with-ports
+CONFIGURE_OPTIONS  +=	--disable-libtool-lock
+CONFIGURE_OPTIONS.32 +=	--srcdir=$(BUILD_DIR_32)
+CONFIGURE_OPTIONS.64 +=	--srcdir=$(BUILD_DIR_64)
+CONFIGURE_OPTIONS  +=	CFLAGS="$(CFLAGS)"
+CONFIGURE_OPTIONS  +=	CXXFLAGS="$(CXXFLAGS)"
+
+
+# common targets
+build:		$(BUILD_32_and_64)
+
+install:	$(INSTALL_32_and_64)
+
+test:		$(NO_TESTS)
+
+BUILD_PKG_DEPENDENCIES =	$(BUILD_TOOLS)
+
+include ../../make-rules/depend.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/libtorrent.3	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,156 @@
+'\" t
+.TH "LIBTORRENT" "3" "03 Jun 2009" "SunOS 5.11"
+
+.SH NAME
+libtorrent \- a BitTorrent library
+.sp
+.SH DESCRIPTION
+.sp
+.LP
+LibTorrent is a BitTorrent library written in C++ for *nix, with a focus on high performance and good code. The library differentiates itself from other implementations by transfering directly from file pages to the network stack. On high-bandwidth connections it is able to seed at 3 times the speed of the official client.
+.sp
+Torrent State 
+.RS +4
+.TP
+.ie t \(bu
+.el o
+Closed
+.sp
+This is the initial state of a download. When switching to this mode, 
+all tracker requests are closed and the bitfield of completed 
+chunks is cleared. File paths can only be changed in this state.
+Functions for getting information on bitfields, chunk count and 
+various others will return size 0 in this state. 
+.sp
+.nf
+torrent::Download::is_open() == false;
+torrent::Download::is_active() == false;
+torrent::Download::is_tracker_busy() == false;
+.fi
+.RE
+.RS +4
+.TP
+.ie t \(bu
+.el o
+Open
+.sp
+This is the state after a successfull call to torrent::Download::open().  
+This  function  throws torrent::local_error if the download could not be 
+opened. All files in the download have been created  and are open. The 
+initial hash check must be done to get a valid bitfield of completed chunks.
+.sp
+.nf
+torrent::Download::is_open() == true;
+torrent::Download::is_active() == false;
+.fi
+.RE
+.RS +4
+.TP
+.ie t \(bu
+.el o
+Active
+.sp
+A  download  is  active  after   calling   torrent::Download::start(). 
+Only downloads that are in an open state and has a valid bitfield of 
+completed chunks can be activated.
+.sp
+.nf
+torrent::Download::is_open() == true;
+torrent::Download::is_active() == true;
+torrent::Download::is_hash_checked() == true;
+.fi
+
+A tracker request will be made when torrent::Download::stop()  is
+called  on an active download. It is not required to wait for the
+tracker  request  to   finish   before   calling   torrent::Down
+load::close(),  but  it  is  recommened so the tracker knows this
+client is not available.File
+.RE
+
+.TP
+Paths
+.sp
+The paths of files in a  Download  consists  of two parts, the 
+root directory and the paths of each file. The file paths are 
+read from the torrent file and  the files usually reside in the 
+root directory. The root directory is by default "./" for single 
+file torrents and  "./[torrent_name]/" for multifile torrents.
+.sp
+.nf
+// Get and set the root directory.
+std::string    torrent::Download::get_root_dir();
+void           torrent::Download::set_root_dir(const std::string& dir);
+
+// Get the torrent::Entry class for each file in the download.
+torrent::Entry torrent::Download::get_entry(uint32_t index);
+uint32_t       torrent::Download::get_entry_size();
+
+typedef std::list<std::string> torrent::Entry::Path;
+
+// Get and set the file path.
+std::string    torrent::Entry::get_path();
+const Path&    torrent::Entry::get_path_list();
+void           torrent::Entry::set_path_list(const Path& l);
+.fi
+.sp
+The  modifications  can  only  be done while the download is in a
+closed state. Modifying the file paths will not change the  "info
+hash" part of the bencoded torrent associated with the download.
+
+.TP
+Http handler Introduction
+.sp
+LibTorrent depends on the client to handle http downloads, thus 
+the  library does  not have a dependency on any specific http library. 
+The library provides a base class named torrent::Http with virtual 
+member  functions  that the client must implement, and a sigc++ slot
+which must be set to create  an  instance  of  the  derived  tor
+rent::Http  class  when  called.  
+
+The torrent::Http class and the factory slot related functions can 
+be found in the  header  "torrent/http.h".  
+The http handler should have reasonable connection timeouts, be 
+nonblocking and not do reconnects on  failed  downloads.
+
+.TP
+Factory Slot
+.sp
+The client registers the desired factory slot with the static 
+torrent::Http::set_factory member function. Using
+sigc++ the client may bind values to the arguments of their func
+tion to avoid depending on globals. The factory slot must  return
+a pointer to a new instance with the base type torrent::Http, and
+the caller takes responsibility of deleting  the  object.  (Note:
+consider  making  the cleanup a slot)
+
+.TP
+Output Stream
+.sp
+The data downloaded  by the http handler is to be written to
+torrent::Http::m_stream which is a pointer to an std::iostream. 
+The http handler must not change any of the flags on the stream.
+
+StartHttp::start is called by the library when it wishes to initiate a
+http download. Your Http derived class must implement this  func
+tion. It must be nonblocking and threadsafe. This means that if
+a seperate thread is used for downloading then it must  not  emit
+any  signal  while  the  main  thread is inside the library.
+
+closeHttp::close is used by the library to stop and close a  download.
+No signals may be emited after this. Http::m_data should not be
+cleared. The library may clear the Http::m_data pointer after
+this.
+
+.TP
+Signals
+.sp
+There  are  two mutually exclusive signals that are
+called when the download has stopped. The signal tor
+rent::Http::m_signalDone is called if the download was successful
+and torrent::Http::m_stream contains the complete data. Or if the
+download was unsuccessful for some reason, then tor
+rent::Http::m_signalFailed is called with an error message.
+.SH SEE ALSO
+.sp
+.LP
+\fBrtorrent\fR(1)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/libtorrent.license	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,352 @@
+Oracle elects to use only the GNU Lesser General Public License version
+2.1 (LGPL)/GNU General Public License version 2 (GPL) for any software
+where a choice of LGPL/GPL license versions are made available with the
+language indicating that LGPLv2.1/GPLv2 or any later version may be
+used, or where a choice of which version of the LGPL/GPL is applied is
+unspecified.  Unless specifically stated otherwise, where a choice
+exists between another license and either the GPL or the LGPL, Oracle
+chooses the other license.
+====================================================================
+
+Copyright (C) 2005-2007, Jari Sundell <jaris (a] ifi.uio.no>
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/libtorrent.p5m	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,103 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+<transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
+
+set name=pkg.fmri value=pkg:/library/libtorrent@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary value="libtorrent - a Bittorrent library for rtorrent"
+set name=info.classification value="org.opensolaris.category.2008:System/Libraries"
+set name=info.upstream_url value=$(COMPONENT_PROJECT_URL)
+set name=info.source_url value=$(COMPONENT_ARCHIVE_URL)
+set name=opensolaris.arc_url \
+    value=http://arc.opensolaris.org/caselog/PSARC/2009/336
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+
+license libtorrent.license license='GPLv2'
+
+dir path=usr
+dir path=usr/include
+dir path=usr/include/torrent
+dir path=usr/include/torrent/data
+dir path=usr/include/torrent/peer
+dir path=usr/lib
+dir path=usr/lib/$(MACH64)
+dir path=usr/lib/$(MACH64)/pkgconfig
+dir path=usr/lib/pkgconfig
+dir path=usr/share
+dir path=usr/share/man
+dir path=usr/share/man/man3
+file path=usr/include/torrent/bitfield.h
+file path=usr/include/torrent/chunk_manager.h
+file path=usr/include/torrent/common.h
+file path=usr/include/torrent/connection_manager.h
+file path=usr/include/torrent/data/block.h
+file path=usr/include/torrent/data/block_list.h
+file path=usr/include/torrent/data/block_transfer.h
+file path=usr/include/torrent/data/file.h
+file path=usr/include/torrent/data/file_list.h
+file path=usr/include/torrent/data/file_list_iterator.h
+file path=usr/include/torrent/data/file_manager.h
+file path=usr/include/torrent/data/file_utils.h
+file path=usr/include/torrent/data/piece.h
+file path=usr/include/torrent/data/transfer_list.h
+file path=usr/include/torrent/dht_manager.h
+file path=usr/include/torrent/download.h
+file path=usr/include/torrent/error.h
+file path=usr/include/torrent/event.h
+file path=usr/include/torrent/exceptions.h
+file path=usr/include/torrent/hash_string.h
+file path=usr/include/torrent/http.h
+file path=usr/include/torrent/object.h
+file path=usr/include/torrent/object_stream.h
+file path=usr/include/torrent/path.h
+file path=usr/include/torrent/peer/client_info.h
+file path=usr/include/torrent/peer/client_list.h
+file path=usr/include/torrent/peer/connection_list.h
+file path=usr/include/torrent/peer/peer.h
+file path=usr/include/torrent/peer/peer_info.h
+file path=usr/include/torrent/peer/peer_list.h
+file path=usr/include/torrent/poll.h
+file path=usr/include/torrent/poll_epoll.h
+file path=usr/include/torrent/poll_kqueue.h
+file path=usr/include/torrent/poll_ports.h
+file path=usr/include/torrent/poll_select.h
+file path=usr/include/torrent/rate.h
+file path=usr/include/torrent/resume.h
+file path=usr/include/torrent/throttle.h
+file path=usr/include/torrent/torrent.h
+file path=usr/include/torrent/tracker.h
+file path=usr/include/torrent/tracker_list.h
+file path=usr/lib/$(MACH64)/libtorrent.so.9.2.0
+file path=usr/lib/$(MACH64)/pkgconfig/libtorrent.pc
+file path=usr/lib/libtorrent.so.9.2.0
+file path=usr/lib/pkgconfig/libtorrent.pc
+file libtorrent.3 path=usr/share/man/man3/libtorrent.3
+link path=usr/lib/$(MACH64)/libtorrent.so target=libtorrent.so.9.2.0
+link path=usr/lib/$(MACH64)/libtorrent.so.9 target=libtorrent.so.9.2.0
+link path=usr/lib/libtorrent.so target=libtorrent.so.9.2.0
+link path=usr/lib/libtorrent.so.9 target=libtorrent.so.9.2.0
+
+legacy pkg=SUNWlibtorrent \
+    desc="libtorrent - a Bittorrent library for rtorrent (0.12.2)" \
+    name=libtorrent
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/patches/rlibtorrent-01-madvise.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,30 @@
+--- libtorrent-0.12.2.orig/src/data/memory_chunk.cc	(revision 1060)
++++ libtorrent-0.12.2/src/data/memory_chunk.cc	(working copy)
+@@ -41,6 +41,16 @@
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
++#if defined(__sun) && defined(__SVR4)
++/* Ugly hack to make this compile on Solaris with g++. See
++ * http://www.opensolaris.org/jive/thread.jspa?threadID=21035&tstart=0
++ */
++#if (_POSIX_C_SOURCE > 2) || defined(_XPG4_2)
++extern "C" {
++extern int madvise(caddr_t, size_t, int);
++}
++#endif
++#endif
+ #include <rak/error_number.h>
+ 
+ #include "torrent/exceptions.h"
+--- libtorrent-0.12.2.orig/scripts/common.m4	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/scripts/common.m4	2008-06-23 17:04:24.567475080 -0400
+@@ -170,7 +170,7 @@
+   AC_COMPILE_IFELSE(
+     [[#include <sys/types.h>
+           #include <sys/mman.h>
+-          void f() { static char test[1024]; madvise((void *)test, sizeof(test), MADV_NORMAL); }
++          void f() { static char test[1024]; madvise((char *)test, sizeof(test), MADV_NORMAL); }
+     ]],
+     [
+       AC_MSG_RESULT(yes)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/patches/rlibtorrent-02-event-ports.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,500 @@
+diff -x configure -x aclocal.m4 -ru libtorrent-0.11.9/configure.ac libtorrent-0.11.9-new/configure.ac
+--- libtorrent-0.11.9/configure.ac	2007-10-25 09:48:32.000000000 +0000
++++ libtorrent-0.11.9-new/configure.ac	2008-01-13 17:13:30.892756466 +0000
+@@ -43,6 +43,7 @@
+ 
+ dnl TORRENT_WITH_XFS
+ TORRENT_WITH_KQUEUE
++TORRENT_WITH_PORTS
+ TORRENT_WITHOUT_EPOLL
+ TORRENT_WITH_POSIX_FALLOCATE
+ TORRENT_WITH_ADDRESS_SPACE
+diff -x configure -x aclocal.m4 -ru libtorrent-0.11.9/scripts/checks.m4 libtorrent-0.11.9-new/scripts/checks.m4
+--- libtorrent-0.11.9/scripts/checks.m4	2007-10-09 01:41:07.000000000 +0000
++++ libtorrent-0.11.9-new/scripts/checks.m4	2008-01-13 17:04:39.692325909 +0000
+@@ -85,6 +85,15 @@
+     ])
+ ])
+ 
++AC_DEFUN([TORRENT_WITH_PORTS], [
++  AC_ARG_WITH(ports,
++    [  --with-ports            enable Solaris event ports. [[default=no]]],
++    [
++        if test "$withval" = "yes"; then
++            AC_DEFINE(USE_PORTS, 1, Enable event ports.)
++        fi
++    ])
++])
+ 
+ AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [
+   AC_ARG_WITH(variable-fdset,
+diff -x configure -x aclocal.m4 -ru libtorrent-0.11.9/src/torrent/Makefile.am libtorrent-0.11.9-new/src/torrent/Makefile.am
+--- libtorrent-0.11.9/src/torrent/Makefile.am	2007-02-02 11:09:56.000000000 +0000
++++ libtorrent-0.11.9-new/src/torrent/Makefile.am	2008-01-13 17:51:02.471766611 +0000
+@@ -33,6 +33,8 @@
+ 	poll_epoll.h \
+ 	poll_kqueue.h \
+ 	poll_kqueue.cc \
++	poll_ports.h \
++	poll_ports.cc \
+ 	poll_select.h \
+ 	poll_select.cc \
+ 	rate.cc \
+@@ -65,6 +67,7 @@
+ 	path.h \
+ 	poll.h \
+ 	poll_epoll.h \
++	poll_ports.h \
+ 	poll_kqueue.h \
+ 	poll_select.h \
+ 	rate.h \
+diff -urN libtorrent.orig/src/torrent/poll_ports.h libtorrent/src/torrent/poll_ports.h
+--- libtorrent.orig/src/torrent/poll_ports.h	1969-12-31 19:00:00.000000000 -0500
++++ libtorrent/src/torrent/poll_ports.h	2008-05-12 00:42:15.000000000 -0400
+@@ -0,0 +1,104 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#ifndef LIBTORRENT_TORRENT_POLL_PORTS_H
++#define LIBTORRENT_TORRENT_POLL_PORTS_H
++
++#include <vector>
++#include <map>
++#include <torrent/poll.h>
++
++struct port_event;
++
++namespace torrent {
++
++class LIBTORRENT_EXPORT PollPorts : public torrent::Poll {
++public:
++  typedef std::pair<Event*,int> ObjectMask;
++  typedef std::vector<ObjectMask> Table;
++
++  static PollPorts*   create(int maxOpenSockets);
++  virtual ~PollPorts();
++
++  int                 poll(int msec);
++  void                perform();
++
++  int                 file_descriptor() { return m_fd; }
++
++  virtual uint32_t    open_max() const { return m_table.size(); }
++
++  // torrent::Event::get_fd() is guaranteed to be valid and remain constant
++  // from open(...) is called to close(...) returns.
++  virtual void        open(torrent::Event* event);
++  virtual void        close(torrent::Event* event);
++
++  // Functions for checking whetever the torrent::Event is listening to r/w/e?
++  virtual bool        in_read(torrent::Event* event);
++  virtual bool        in_write(torrent::Event* event);
++  virtual bool        in_error(torrent::Event* event);
++
++  // These functions may be called on 'event's that might, or might
++  // not, already be in the set.
++  virtual void        insert_read(torrent::Event* event);
++  virtual void        insert_write(torrent::Event* event);
++  virtual void        insert_error(torrent::Event* event);
++
++  virtual void        remove_read(torrent::Event* event);
++  virtual void        remove_write(torrent::Event* event);
++  virtual void        remove_error(torrent::Event* event);
++
++private:
++  PollPorts(int fd, int maxEvents, int maxOpenSockets);
++
++  inline Event*       event_object(Event* e);
++  inline int          event_mask(Event* e);
++  inline void         set_event_object(Event* e);
++  inline void         set_event_mask(Event* e, int m);
++
++  inline void         modify(torrent::Event* event, int mask);
++
++  int                 m_fd;
++
++  int                 m_maxEvents;
++  int                 m_waitingEvents;
++
++  Table               m_table;
++  port_event*         m_events;
++};
++
++}
++
++#endif
+diff -urN libtorrent.orig/src/torrent/poll_ports.cc libtorrent/src/torrent/poll_ports.cc
+--- libtorrent.orig/src/torrent/poll_ports.cc	1969-12-31 19:00:00.000000000 -0500
++++ libtorrent/src/torrent/poll_ports.cc	2008-06-10 14:48:05.000000000 -0400
+@@ -0,0 +1,338 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#include "config.h"
++
++#include <cerrno>
++#include <cstring>
++#include <iostream>
++
++#include <unistd.h>
++#include <torrent/exceptions.h>
++#include <torrent/event.h>
++
++#include "poll_ports.h"
++
++#ifdef USE_PORTS
++/*
++ * We should use <poll.h> here, but it seems to conflict with the
++ * <torrent/poll.h> header, so use <sys/poll.h> instead.  Since all
++ * poll.h does is include sys/poll.h, this shouldn't cause any
++ * problems.
++ */
++# include <sys/poll.h>
++# include <port.h>
++#endif
++
++namespace torrent {
++
++#ifdef USE_PORTS
++inline Event*
++PollPorts::event_object(Event* e) {
++  return m_table[e->file_descriptor()].first;
++}
++
++inline int
++PollPorts::event_mask(Event* e) {
++  if (event_object(e) != e)
++    return 0;
++  return m_table[e->file_descriptor()].second;
++}
++
++inline void
++PollPorts::set_event_object(Event* e) {
++  m_table[e->file_descriptor()] = std::pair<Event*,int>(e, 0);
++}
++
++inline void
++PollPorts::set_event_mask(Event* e, int m) {
++  m_table[e->file_descriptor()].second = m;
++}
++
++inline void
++PollPorts::modify(Event* event, int mask) {
++  if (event_object(event) != event)
++    return;
++
++  if (event_mask(event) == mask)
++    return;
++
++  set_event_mask(event, mask);
++
++  if (mask == 0) {
++    port_dissociate(m_fd, PORT_SOURCE_FD, event->file_descriptor());
++    return;
++  }
++
++  if (port_associate(m_fd, PORT_SOURCE_FD, event->file_descriptor(),
++		  mask, event) == -1)
++	  throw internal_error("PollPorts::modify(...) port_associate failed");
++}
++
++PollPorts*
++PollPorts::create(int maxOpenSockets) {
++  int fd = port_create();
++
++  if (fd == -1)
++    return NULL;
++
++  return new PollPorts(fd, 1024, maxOpenSockets);
++}
++
++PollPorts::PollPorts(int fd, int maxEvents, int maxOpenSockets) :
++  m_fd(fd),
++  m_maxEvents(maxEvents),
++  m_waitingEvents(0),
++  m_events(new port_event_t[maxEvents]) {
++  m_table.resize(maxOpenSockets);
++}
++
++PollPorts::~PollPorts() {
++  m_table.clear();
++  delete [] m_events;
++
++  ::close(m_fd);
++}
++
++int
++PollPorts::poll(int msec) {
++  timespec_t timeout;
++  timeout.tv_sec = msec / 1000;
++  timeout.tv_nsec = (msec * 1000000L) % 1000000000L;
++
++  uint_t nfds = 1;
++
++  int ret = port_getn(m_fd, m_events, m_maxEvents, &nfds, &timeout);
++
++  if (ret == -1 && errno != ETIME) {
++	  std::cerr << "error from ports, maxevents="<<m_maxEvents<<", nfds="<<nfds<<" msec="<<msec<<"\n";
++    return -1;
++  }
++
++  return m_waitingEvents = nfds;
++}
++
++// We check m_table to make sure the Event is still listening to the
++// event, so it is safe to remove Event's while in working.
++//
++// TODO: Do we want to guarantee if the Event has been removed from
++// some event but not closed, it won't call that event? Think so...
++void
++PollPorts::perform() {
++  for (port_event_t *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr) {
++
++    // Each branch must check for data.ptr != NULL to allow the socket
++    // to remove itself between the calls.
++    //
++    // TODO: Make it so that it checks that read/write is wanted, that
++    // it wasn't removed from one of them but not closed.
++
++    Event *e = static_cast<Event*>(itr->portev_user);
++    if (e == NULL)
++      continue;
++
++    if (itr->portev_events & POLLERR 
++        && event_mask(e) & POLLERR)
++      e->event_error();
++
++    if (itr->portev_user != e)
++      continue;
++
++    if (itr->portev_events & POLLIN
++        && event_mask(e) & POLLIN)
++      e->event_read();
++
++    if (itr->portev_user != e)
++      continue;
++
++    if (itr->portev_events & POLLOUT
++        && event_mask(e) & POLLOUT)
++      e->event_write();
++
++    if (itr->portev_user != e)
++      continue;
++
++    // Since port events are one-shot, re-add the fd after we process
++    // its events.
++
++    port_associate(m_fd, PORT_SOURCE_FD, itr->portev_object,
++        event_mask(e), e);
++  }
++
++  m_waitingEvents = 0;
++}
++
++void
++PollPorts::open(Event* event) {
++  if (event_object(event) == event && event_mask(event) != 0)
++    throw internal_error("PollPorts::open(...) called but the file descriptor is active");
++  set_event_object(event);
++}
++
++void
++PollPorts::close(Event* event) {
++  if (event_mask(event) != 0)
++    throw internal_error("PollPorts::close(...) called but the file descriptor is active");
++
++  for (port_event_t *itr = m_events, *last = m_events + m_waitingEvents; itr != last; ++itr)
++    if (itr->portev_user == event)
++      itr->portev_user = NULL;
++}
++
++bool
++PollPorts::in_read(Event* event) {
++  return event_mask(event) & POLLIN;
++}
++
++bool
++PollPorts::in_write(Event* event) {
++  return event_mask(event) & POLLOUT;
++}
++
++bool
++PollPorts::in_error(Event* event) {
++  return event_mask(event) & POLLERR;
++}
++
++void
++PollPorts::insert_read(Event* event) {
++  modify(event, event_mask(event) | POLLIN);
++}
++
++void
++PollPorts::insert_write(Event* event) {
++  modify(event, event_mask(event) | POLLOUT);
++}
++
++void
++PollPorts::insert_error(Event* event) {
++  modify(event, event_mask(event) | POLLERR);
++}
++
++void
++PollPorts::remove_read(Event* event) {
++  modify(event, event_mask(event) & ~POLLIN);
++}
++
++void
++PollPorts::remove_write(Event* event) {
++  modify(event, event_mask(event) & ~POLLOUT);
++}
++
++void
++PollPorts::remove_error(Event* event) {
++  modify(event, event_mask(event) & ~POLLERR);
++}
++
++#else // USE_PORTS
++
++PollPorts*
++PollPorts::create(int maxOpenSockets) {
++  return NULL;
++}
++
++PollPorts::~PollPorts() {
++}
++
++int
++PollPorts::poll(int msec) {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++void
++PollPorts::perform() {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++uint32_t
++PollPorts::open_max() const {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++void
++PollPorts::open(torrent::Event* event) {
++}
++
++void
++PollPorts::close(torrent::Event* event) {
++}
++
++bool
++PollPorts::in_read(torrent::Event* event) {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++bool
++PollPorts::in_write(torrent::Event* event) {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++bool
++PollPorts::in_error(torrent::Event* event) {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++void
++PollPorts::insert_read(torrent::Event* event) {
++}
++
++void
++PollPorts::insert_write(torrent::Event* event) {
++}
++
++void
++PollPorts::insert_error(torrent::Event* event) {
++}
++
++void
++PollPorts::remove_read(torrent::Event* event) {
++}
++
++void
++PollPorts::remove_write(torrent::Event* event) {
++}
++
++void
++PollPorts::remove_error(torrent::Event* event) {
++}
++
++PollPorts::PollPorts(int fd, int maxEvents, int maxOpenSockets) {
++  throw internal_error("An PollPorts function was called, but it is disabled.");
++}
++
++#endif // USE_PORTS
++
++}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/patches/rlibtorrent-03-dh-generate.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,93 @@
+--- libtorrent-0.12.2.orig/src/utils/diffie_hellman.cc	Wed May  7 12:19:12 2008
++++ libtorrent-0.12.2/src/utils/diffie_hellman.cc	Sun Jun 15 10:51:31 2008
+@@ -47,6 +47,80 @@
+ 
+ namespace torrent {
+ 
++static int generate_key(DH *dh)
++	{
++	int ok=0;
++	int generate_new_key=0;
++	unsigned l;
++	BN_CTX *ctx;
++	BN_MONT_CTX *mont=NULL;
++	BIGNUM *pub_key=NULL,*priv_key=NULL;
++
++	ctx = BN_CTX_new();
++	if (ctx == NULL) goto err;
++
++	if (dh->priv_key == NULL)
++		{
++		priv_key=BN_new();
++		if (priv_key == NULL) goto err;
++		generate_new_key=1;
++		}
++	else
++		priv_key=dh->priv_key;
++
++	if (dh->pub_key == NULL)
++		{
++		pub_key=BN_new();
++		if (pub_key == NULL) goto err;
++		}
++	else
++		pub_key=dh->pub_key;
++
++
++	if (dh->flags & DH_FLAG_CACHE_MONT_P)
++		{
++		mont = BN_MONT_CTX_set_locked((BN_MONT_CTX **)(&dh->method_mont_p),
++				CRYPTO_LOCK_DH, dh->p, ctx);
++		if (!mont)
++			goto err;
++		}
++
++	if (generate_new_key)
++		{
++		l = dh->length ? dh->length : BN_num_bits(dh->p)-1; /* secret exponent length */
++		if (!BN_rand(priv_key, l, 0, 0))
++			if (!BN_pseudo_rand(priv_key, l, 0, 0)) goto err;
++		}
++
++	{
++		BIGNUM local_prk;
++		BIGNUM *prk;
++
++		if ((dh->flags & DH_FLAG_NO_EXP_CONSTTIME) == 0)
++			{
++			BN_init(&local_prk);
++			prk = &local_prk;
++			BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
++			}
++		else
++			prk = priv_key;
++
++		if (!dh->meth->bn_mod_exp(dh, pub_key, dh->g, prk, dh->p, ctx, mont)) goto err;
++	}
++
++	dh->pub_key=pub_key;
++	dh->priv_key=priv_key;
++	ok=1;
++err:
++	if (ok != 1) {
++	}
++
++	if ((pub_key != NULL)  && (dh->pub_key == NULL))  BN_free(pub_key);
++	if ((priv_key != NULL) && (dh->priv_key == NULL)) BN_free(priv_key);
++	BN_CTX_free(ctx);
++	return(ok);
++}
++
+ DiffieHellman::DiffieHellman(const unsigned char *prime, int primeLength,
+                              const unsigned char *generator, int generatorLength) :
+   m_secret(NULL) {
+@@ -56,7 +130,8 @@
+   m_dh->p = BN_bin2bn(prime, primeLength, NULL);
+   m_dh->g = BN_bin2bn(generator, generatorLength, NULL);
+ 
+-  DH_generate_key(m_dh);
++  if (!generate_key(m_dh))
++    throw internal_error("Unable to generate encryption key.");
+ #else
+   throw internal_error("Compiled without encryption support.");
+ #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/patches/rlibtorrent-04-sunpro.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,887 @@
+--- rtorrent-0.8.2.orig/rak/string_manip.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/string_manip.h	2008-06-25 02:14:10.028329996 -0400
+@@ -62,7 +62,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end())))
++  if (seq.empty() || !std::isspace(*(seq.end()-1)))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+@@ -93,7 +93,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end_classic(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end()), std::locale::classic()))
++  if (seq.empty() || !std::isspace(*(seq.end()-1), std::locale::classic()))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+--- libtorrent-0.12.2.orig/rak/path.h	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/rak/path.h	2008-06-25 01:57:52.656513911 -0400
+@@ -42,6 +42,7 @@
+ 
+ #include <cstdlib>
+ #include <string>
++#include <algorithm>
+ 
+ namespace rak {
+ 
+@@ -91,7 +92,7 @@
+     if (home == NULL)
+       return first;
+ 
+-    first += strlcpy(first, home, std::distance(first, last));
++    first += strlcpy(first, home, last-first);
+ 
+     if (first > last)
+       return last;
+@@ -99,7 +100,7 @@
+     src++;
+   }
+ 
+-  return std::max(first + strlcpy(first, src, std::distance(first, last)), last);
++  return std::max(first + strlcpy(first, src, last-first), last);
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/rak/unordered_vector.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/unordered_vector.h	2008-06-25 02:29:35.381434005 -0400
+@@ -90,7 +90,7 @@
+ unordered_vector<_Tp>::insert(iterator position, const value_type& x) {
+   Base::push_back(x);
+ 
+-  return --end();
++  return end()-1;
+ }
+ 
+ template <typename _Tp>
+--- rtorrent-0.8.2.orig/rak/socket_address.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/socket_address.h	2008-06-25 01:58:48.126132462 -0400
+@@ -50,6 +50,7 @@
+ #include <cstring>
+ #include <string>
+ #include <stdexcept>
++#include <algorithm>
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
+ #include <sys/types.h>
+--- rtorrent-0.8.2.orig/rak/regex.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/regex.h	2008-06-25 02:10:05.332867456 -0400
+@@ -75,7 +75,7 @@
+   std::list<unsigned int> paths;
+   paths.push_front(0);
+ 
+-  for (std::string::const_iterator itrText = ++text.begin(), lastText = text.end(); itrText != lastText; ++itrText) {
++  for (std::string::const_iterator itrText = text.begin()+1, lastText = text.end(); itrText != lastText; ++itrText) {
+     
+     for (std::list<unsigned int>::iterator itrPaths = paths.begin(), lastPaths = paths.end(); itrPaths != lastPaths; ) {
+ 
+--- rtorrent-0.8.2.orig/rak/algorithm.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/algorithm.h	2008-06-25 17:27:39.728352000 -0400
+@@ -40,6 +40,63 @@
+ #include <algorithm>
+ #include <functional>
+ 
++#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
++namespace std {
++  template <class Iterator> struct iterator_traits
++  {
++    typedef typename Iterator::value_type value_type;
++    typedef typename Iterator::difference_type difference_type;
++    typedef typename Iterator::pointer pointer;
++    typedef typename Iterator::reference reference;
++    typedef typename Iterator::iterator_category iterator_category;
++  };
++  template <class T> struct iterator_traits<T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef T* pointer;
++    typedef T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++  template <class T> struct iterator_traits<const T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef const T* pointer;
++    typedef const T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++
++  template <class ForwardIterator>
++  inline typename iterator_traits<ForwardIterator>::difference_type
++  distance (ForwardIterator first, ForwardIterator last)
++  {
++    typename iterator_traits<ForwardIterator>::difference_type n = 0;
++    __distance(first, last, n, 
++               iterator_traits<ForwardIterator>::iterator_category());
++    return n;
++  }
++
++  template <class InputIterator, class T>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count (InputIterator first, InputIterator last, const T& value)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count(first, last, value, n);
++    return n;
++  }
++
++  template <class InputIterator, class Predicate>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count_if (InputIterator first, InputIterator last, Predicate pred)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count_if(first, last, pred, n);
++    return n;
++  }
++}
++#endif
++
+ namespace rak {
+ 
+ template <typename _InputIter, typename _Function>
+--- libtorrent-0.12.2.orig/src/download/choke_manager.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/download/choke_manager.cc	2008-06-24 13:40:32.322166472 -0400
+@@ -41,8 +41,10 @@
+ #include <numeric>
+ #include <cstdlib>
+ 
++#include "rak/algorithm.h"
+ #include "protocol/peer_connection_base.h"
+ #include "torrent/peer/connection_list.h"
++#include "resource_manager.h"
+ 
+ #include "choke_manager.h"
+ #include "choke_manager_node.h"
+@@ -261,7 +263,7 @@
+                                         rak::less(i * ChokeManager::order_base + (ChokeManager::order_base - 1),
+                                                   rak::mem_ref(&ChokeManager::value_type::second)));
+ 
+-    if (std::distance(target[i].second, target[i + 1].second) != 0)
++    if (target[i].second != target[i + 1].second)
+       weightTotal += weights[i];
+   }
+ 
+--- libtorrent-0.12.2.orig/src/download/delegator.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/download/delegator.cc	2008-06-24 13:42:52.016431294 -0400
+@@ -46,7 +46,9 @@
+ #include "torrent/data/block.h"
+ #include "torrent/data/block_list.h"
+ #include "torrent/data/block_transfer.h"
++#include "torrent/data/file_list.h"
+ #include "protocol/peer_chunks.h"
++#include "download/chunk_selector.h"
+ 
+ #include "delegator.h"
+ 
+--- libtorrent-0.12.2.orig/src/download/download_constructor.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/download/download_constructor.cc	2008-06-24 14:56:59.728556042 -0400
+@@ -317,7 +317,7 @@
+   Path p;
+   p.set_encoding(enc);
+ 
+-  std::transform(plist.begin(), plist.end(), std::back_inserter(p), std::mem_fun_ref<const Object::string_type&>(&Object::as_string));
++  std::transform(((Object::list_type&)plist).begin(), ((Object::list_type&)plist).end(), std::back_inserter(p), std::mem_fun_ref<Object::string_type&>(&Object::as_string));
+ 
+   return p;
+ }
+--- libtorrent-0.12.2.orig/src/download/download_info.h	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/download/download_info.h	2008-06-28 00:07:50.060545422 -0400
+@@ -186,10 +186,13 @@
+ };
+ 
+ // Move somewhere else.
++#if defined(__APPLE__) || defined(__SUNPRO_CC)
++#pragma pack(1)
++#endif
+ struct SocketAddressCompact {
+-  SocketAddressCompact() {}
+-  SocketAddressCompact(uint32_t a, uint16_t p) : addr(a), port(p) {}
+-  SocketAddressCompact(const rak::socket_address_inet* sa) : addr(sa->address_n()), port(sa->port_n()) {}
++  //SocketAddressCompact() {}
++  //SocketAddressCompact(uint32_t a, uint16_t p) : addr(a), port(p) {}
++  //SocketAddressCompact(const rak::socket_address_inet* sa) : addr(sa->address_n()), port(sa->port_n()) {}
+ 
+   operator rak::socket_address () const {
+     rak::socket_address sa;
+@@ -205,6 +208,9 @@
+ 
+   const char*         c_str() const { return reinterpret_cast<const char*>(this); }
+ } __attribute__ ((packed));
++#if defined(__APPLE__) || defined(__SUNPRO_CC)
++#pragma pack()
++#endif
+ 
+ }
+ 
+--- libtorrent-0.12.2.orig/src/download/download_main.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/download/download_main.cc	2008-06-28 16:05:20.725211632 -0400
+@@ -356,8 +356,13 @@
+     PeerConnectionBase* pcb = (*itr)->m_ptr();
+     const rak::socket_address* sa = rak::socket_address::cast_from(pcb->peer_info()->socket_address());
+ 
+-    if (pcb->peer_info()->listen_port() != 0 && sa->family() == rak::socket_address::af_inet)
+-      current.push_back(SocketAddressCompact(sa->sa_inet()->address_n(), pcb->peer_info()->listen_port()));
++    if (pcb->peer_info()->listen_port() != 0 && sa->family() == rak::socket_address::af_inet) {
++      SocketAddressCompact s = {
++        sa->sa_inet()->address_n(),
++        pcb->peer_info()->listen_port()
++      };
++      current.push_back(s);
++    }
+ 
+     if (!pcb->extensions()->is_remote_supported(ProtocolExtension::UT_PEX))
+       continue;
+--- libtorrent-0.12.2.orig/src/dht/dht_router.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_router.cc	2008-06-24 13:22:15.691370259 -0400
+@@ -88,7 +88,7 @@
+   }
+ 
+   set_bucket(new DhtBucket(zero_id, ones_id));
+-  m_routingTable.insert(std::make_pair(bucket()->id_range_end(), bucket()));
++  m_routingTable.insert(DhtBucketList::value_type(bucket()->id_range_end(), bucket()));
+ 
+   if (cache.has_key("nodes")) {
+     const Object::map_type& nodes = cache.get_key_map("nodes");
+@@ -163,12 +163,12 @@
+   if (!create)
+     return NULL;
+ 
+-  std::pair<DhtTrackerList::accessor, bool> res = m_trackers.insert(std::make_pair(hash, new DhtTracker()));
++  std::pair<DhtTrackerList::iterator, bool> res = m_trackers.insert(std::make_pair(hash, new DhtTracker()));
+ 
+   if (!res.second)
+     throw internal_error("DhtRouter::get_tracker did not actually insert tracker.");
+ 
+-  return res.first.tracker();
++  return (*res.first).second;
+ }
+ 
+ bool
+@@ -552,7 +552,7 @@
+     throw internal_error("DhtRouter::split_bucket router ID ended up in wrong bucket.");
+ 
+   // Insert new bucket with iterator hint = just before current bucket.
+-  DhtBucketList::iterator other = m_routingTable.insert(itr, std::make_pair(newBucket->id_range_end(), newBucket));
++  DhtBucketList::iterator other = m_routingTable.insert(itr, DhtBucketList::value_type(newBucket->id_range_end(), newBucket));
+ 
+   // Check that the bucket we're not adding the node to isn't empty.
+   if (other->second->is_in_range(node->id())) {
+--- libtorrent-0.12.2.orig/src/dht/dht_router.h	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_router.h	2008-06-24 13:05:12.790210488 -0400
+@@ -137,7 +137,7 @@
+   // Maximum number of potential contacts to keep until bootstrap complete.
+   static const unsigned int num_bootstrap_contacts = 64;
+ 
+-  typedef std::map<const HashString, DhtBucket*> DhtBucketList;
++  typedef std::map<HashString, DhtBucket*> DhtBucketList;
+ 
+   DhtBucketList::iterator find_bucket(const HashString& id);
+ 
+--- libtorrent-0.12.2.orig/src/dht/dht_server.h	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_server.h	2008-06-28 00:08:34.254158759 -0400
+@@ -108,6 +108,9 @@
+ 
+   typedef std::deque<DhtTransactionPacket*> packet_queue;
+ 
++#if defined(__APPLE__) || defined(__SUNPRO_CC)
++#pragma pack(1)
++#endif
+   struct compact_node_info {
+     char                 _id[20];
+     SocketAddressCompact _addr;
+@@ -115,6 +118,9 @@
+     HashString&          id()          { return *HashString::cast_from(_id); }
+     rak::socket_address  address()     { return rak::socket_address(_addr); }
+   } __attribute__ ((packed));
++#if defined(__APPLE__) || defined(__SUNPRO_CC)
++#pragma pack()
++#endif
+   typedef std::list<compact_node_info> node_info_list;
+ 
+   // Pending transactions.
+--- libtorrent-0.12.2.orig/src/dht/dht_transaction.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_transaction.cc	2008-06-24 13:33:28.590473835 -0400
+@@ -68,7 +68,7 @@
+   if (m_concurrency != 3)
+     throw internal_error("DhtSearch::~DhtSearch with invalid concurrency limit.");
+ 
+-  for (accessor itr = begin(); itr != end(); ++itr)
++  for (accessor itr = begin(); static_cast<const_accessor>(itr) != end(); ++itr)
+     delete itr.node();
+ }
+ 
+@@ -141,7 +141,7 @@
+   // We're done if we can't find any more nodes to contact.
+   m_next = end();
+ 
+-  for (accessor itr = base_type::begin(); itr != end(); ) {
++  for (accessor itr = base_type::begin(); static_cast<const_accessor>(itr) != end(); ) {
+     // If we have all we need, delete current node unless it is
+     // currently being contacted.
+     if (!itr.node()->is_active() && needClosest <= 0 && (!itr.node()->is_good() || needGood <= 0)) {
+@@ -264,7 +264,7 @@
+ void
+ DhtTransactionPacket::build_buffer(const Object& data) {
+   char buffer[1500];  // If the message would exceed an Ethernet frame, something went very wrong.
+-  object_buffer_t result = object_write_bencode_c(object_write_to_buffer, NULL, std::make_pair(buffer, buffer + sizeof(buffer)), &data);
++  object_buffer_t result = object_write_bencode_c(object_write_to_buffer, NULL, std::make_pair((char*)buffer, buffer + sizeof(buffer)), &data);
+ 
+   m_length = result.second - buffer;
+   m_data = new char[m_length];
+--- libtorrent-0.12.2.orig/src/dht/dht_bucket.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_bucket.cc	2008-06-24 02:41:04.089051646 -0400
+@@ -36,6 +36,7 @@
+ 
+ #include "config.h"
+ 
++#include "rak/algorithm.h"
+ #include "torrent/exceptions.h"
+ 
+ #include "dht_bucket.h"
+--- libtorrent-0.12.2.orig/src/dht/dht_node.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_node.cc	2008-06-28 15:57:24.639449987 -0400
+@@ -77,7 +77,10 @@
+ DhtNode::store_compact(char* buffer) const {
+   HashString::cast_from(buffer)->assign(data());
+ 
+-  SocketAddressCompact sa(address()->sa_inet());
++  SocketAddressCompact sa = {
++    m_socketAddress.sa_inet()->address_n(),
++    m_socketAddress.sa_inet()->port_n()
++  };
+   std::memcpy(buffer + 20, sa.c_str(), 6);
+ 
+   return buffer + 26;
+--- libtorrent-0.12.2.orig/src/dht/dht_server.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_server.cc	2008-06-24 13:24:40.374916857 -0400
+@@ -582,7 +582,7 @@
+   }
+ 
+   // We know where to insert it, so pass that as hint.
+-  insertItr = m_transactions.insert(insertItr, std::make_pair(transaction->key(id), transaction));
++  insertItr = m_transactions.insert(insertItr, transaction_map::value_type(transaction->key(id), transaction));
+ 
+   create_query(insertItr, id, transaction->address(), priority);
+ 
+--- libtorrent-0.12.2.orig/src/dht/dht_tracker.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/dht/dht_tracker.cc	2008-06-28 16:03:29.929469325 -0400
+@@ -47,7 +47,7 @@
+   if (port == 0)
+     return;
+ 
+-  SocketAddressCompact compact(addr, port);
++  SocketAddressCompact compact = { addr, port };
+ 
+   unsigned int oldest = 0;
+   uint32_t minSeen = ~uint32_t();
+--- libtorrent-0.12.2.orig/src/protocol/extensions.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/protocol/extensions.cc	2008-06-24 15:01:20.887800483 -0400
+@@ -119,7 +119,7 @@
+   message.insert_key("reqq", 2048);  // maximum request queue size
+ 
+   char buffer[1024];
+-  object_buffer_t result = object_write_bencode_c(object_write_to_buffer, NULL, std::make_pair(buffer, buffer + sizeof(buffer)), &message);
++  object_buffer_t result = object_write_bencode_c(object_write_to_buffer, NULL, std::make_pair((char*)buffer, buffer + sizeof(buffer)), &message);
+ 
+   int length = result.second - buffer;
+   char* copy = new char[length];
+--- libtorrent-0.12.2.orig/src/protocol/peer_connection_leech.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/protocol/peer_connection_leech.cc	2008-06-24 15:19:28.492038823 -0400
+@@ -697,7 +697,9 @@
+   }
+ }
+ 
++#ifndef __SUNPRO_CC
+ template<>
++#endif
+ void
+ PeerConnection<Download::CONNECTION_INITIAL_SEED>::offer_chunk() {
+   // If bytes left to send in this chunk minus bytes about to be sent is zero,
+@@ -718,7 +720,9 @@
+   m_data.bytesLeft = m_download->file_list()->chunk_index_size(index);
+ }
+ 
++#ifndef __SUNPRO_CC
+ template<>
++#endif
+ bool
+ PeerConnection<Download::CONNECTION_INITIAL_SEED>::should_upload() {
+   // For initial seeding, check if chunk is well seeded now, and if so
+--- libtorrent-0.12.2.orig/src/protocol/handshake_manager.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/protocol/handshake_manager.cc	2008-06-24 15:11:50.179786185 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <rak/socket_address.h>
++#include <rak/algorithm.h>
+ 
+ #include "torrent/exceptions.h"
+ #include "torrent/error.h"
+--- libtorrent-0.12.2.orig/src/protocol/handshake.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/protocol/handshake.cc	2008-06-24 15:05:32.683533289 -0400
+@@ -36,8 +36,10 @@
+ 
+ #include "config.h"
+ 
++#include "rak/algorithm.h"
+ #include "download/download_info.h"
+ #include "download/download_main.h"
++#include "download/download_manager.h"
+ #include "net/throttle_list.h"
+ #include "torrent/dht_manager.h"
+ #include "torrent/exceptions.h"
+@@ -324,14 +326,16 @@
+       return false;
+   }
+ 
++  uint32_t len = std::distance(m_readBuffer.position(), itr);
++
+   if (m_incoming) {
+     // We've found HASH('req1' + S), skip that and go on reading the
+     // SKEY hash.
+-    m_readBuffer.consume(std::distance(m_readBuffer.position(), itr) + 20);
++    m_readBuffer.consume(len + 20);
+     m_state = READ_ENC_SKEY;
+ 
+   } else {
+-    m_readBuffer.consume(std::distance(m_readBuffer.position(), itr));
++    m_readBuffer.consume(len);
+     m_state = READ_ENC_NEGOT;
+   }
+ 
+@@ -935,10 +939,12 @@
+   m_writeBuffer.move_end(96);
+ 
+   int length = random() % enc_pad_size;
+-  char pad[length];
++  char* pad = new char[length];
+ 
+   std::generate_n(pad, length, &::random);
+   m_writeBuffer.write_len(pad, length);
++
++  delete pad;
+ }
+ 
+ void
+--- libtorrent-0.12.2.orig/src/data/memory_chunk.h	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/data/memory_chunk.h	2008-06-25 21:14:31.067671826 -0400
+@@ -47,28 +47,30 @@
+   // Consider information about whetever the memory maps to a file or
+   // not, since mincore etc can only be called on files.
+ 
+-  static const int prot_exec              = PROT_EXEC;
+-  static const int prot_read              = PROT_READ;
+-  static const int prot_write             = PROT_WRITE;
+-  static const int prot_none              = PROT_NONE;
+-  static const int map_shared             = MAP_SHARED;
++  enum {
++    prot_exec              = PROT_EXEC,
++    prot_read              = PROT_READ,
++    prot_write             = PROT_WRITE,
++    prot_none              = PROT_NONE,
++    map_shared             = MAP_SHARED,
+ 
+ #ifdef USE_MADVISE
+-  static const int advice_normal          = MADV_NORMAL;
+-  static const int advice_random          = MADV_RANDOM;
+-  static const int advice_sequential      = MADV_SEQUENTIAL;
+-  static const int advice_willneed        = MADV_WILLNEED;
+-  static const int advice_dontneed        = MADV_DONTNEED;
++    advice_normal          = MADV_NORMAL,
++    advice_random          = MADV_RANDOM,
++    advice_sequential      = MADV_SEQUENTIAL,
++    advice_willneed        = MADV_WILLNEED,
++    advice_dontneed        = MADV_DONTNEED,
+ #else
+-  static const int advice_normal          = 0;
+-  static const int advice_random          = 1;
+-  static const int advice_sequential      = 2;
+-  static const int advice_willneed        = 3;
+-  static const int advice_dontneed        = 4;
++    advice_normal          = 0,
++    advice_random          = 1,
++    advice_sequential      = 2,
++    advice_willneed        = 3,
++    advice_dontneed        = 4,
+ #endif
+-  static const int sync_sync              = MS_SYNC;
+-  static const int sync_async             = MS_ASYNC;
+-  static const int sync_invalidate        = MS_INVALIDATE;
++    sync_sync              = MS_SYNC,
++    sync_async             = MS_ASYNC,
++    sync_invalidate        = MS_INVALIDATE,
++  };
+ 
+   MemoryChunk() { clear(); }
+   ~MemoryChunk() { clear(); }
+--- libtorrent-0.12.2.orig/src/data/chunk_list.cc	2008-06-25 01:44:37.768468000 -0400
++++ libtorrent-0.12.2/src/data/chunk_list.cc	2008-06-25 23:55:12.466495173 -0400
+@@ -301,27 +301,18 @@
+ 
+ std::pair<int, bool>
+ ChunkList::sync_options(ChunkListNode* node, int flags) {
+-  // Using if statements since some linkers have problem with static
+-  // const int members inside the ?: operators. The compiler should
+-  // be optimizing this anyway.
++  int sync = MemoryChunk::sync_async;
++  bool end = true;
+ 
+-  if (flags & sync_force) {
++  if (flags & sync_safe) {
+ 
+-    if (flags & sync_safe)
+-      return std::make_pair(MemoryChunk::sync_sync, true);
++    if (flags & sync_force || node->sync_triggered())
++      sync = MemoryChunk::sync_sync;
+     else
+-      return std::make_pair(MemoryChunk::sync_async, true);
+-
+-  } else if (flags & sync_safe) {
+-      
+-    if (node->sync_triggered())
+-      return std::make_pair(MemoryChunk::sync_sync, true);
+-    else
+-      return std::make_pair(MemoryChunk::sync_async, false);
+-
+-  } else {
+-    return std::make_pair(MemoryChunk::sync_async, true);
++      end = false;
+   }
++
++  return std::make_pair(sync, end);
+ }
+ 
+ // Using a rather simple algorithm for now. This should really be more
+--- libtorrent-0.12.2.orig/src/data/memory_chunk.cc	2008-06-23 17:08:43.395684068 -0400
++++ libtorrent-0.12.2/src/data/memory_chunk.cc	2008-06-24 02:39:28.399927218 -0400
+@@ -152,11 +152,15 @@
+ bool
+ MemoryChunk::is_incore(uint32_t offset, uint32_t length) {
+   uint32_t size = pages_touched(offset, length);
+-  char buf[size];
++  char* buf = new char[size];
+   
+   incore(buf, offset, length);
+ 
+-  return std::find(buf, buf + size, 0) == buf + size;
++  bool ret = (std::find(buf, buf + size, 0) == buf + size);
++
++  delete buf;
++
++  return ret;
+ }
+ 
+ }
+--- libtorrent-0.12.2.orig/src/data/hash_torrent.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/data/hash_torrent.cc	2008-06-24 02:36:22.017033961 -0400
+@@ -38,6 +38,7 @@
+ 
+ #include "data/chunk_list.h"
+ #include "torrent/exceptions.h"
++#include "download/download_wrapper.h"
+ 
+ #include "hash_torrent.h"
+ #include "hash_queue.h"
+--- libtorrent-0.12.2.orig/src/data/hash_queue.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/data/hash_queue.cc	2008-06-23 19:17:24.270411715 -0400
+@@ -39,6 +39,7 @@
+ #include <functional>
+ 
+ #include "torrent/exceptions.h"
++#include "download/download_wrapper.h"
+ 
+ #include "hash_queue.h"
+ #include "hash_chunk.h"
+--- libtorrent-0.12.2.orig/src/data/chunk_part.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/data/chunk_part.cc	2008-06-23 19:16:19.997055043 -0400
+@@ -39,6 +39,7 @@
+ #include <algorithm>
+ #include <unistd.h>
+ 
++#include "rak/algorithm.h"
+ #include "torrent/exceptions.h"
+ #include "chunk_part.h"
+ 
+@@ -70,11 +71,13 @@
+ 
+   int length = size() - pos;
+   int touched = m_chunk.pages_touched(pos, length);
+-  char buf[touched];
++  char* buf = new char[touched];
+ 
+   m_chunk.incore(buf, pos, length);
+ 
+   int dist = std::distance(buf, std::find(buf, buf + touched, 0));
++
++  delete buf;
+ 
+   return std::min(dist ? (dist * m_chunk.page_size() - m_chunk.page_align()) : 0,
+                   size() - pos);
+--- libtorrent-0.12.2.orig/src/data/chunk_list.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/data/chunk_list.cc	2008-06-23 19:14:40.468978454 -0400
+@@ -38,6 +38,8 @@
+ 
+ #include "torrent/exceptions.h"
+ #include "torrent/chunk_manager.h"
++#include "torrent/data/file_utils.h"
++#include "download/download_wrapper.h"
+ 
+ #include "chunk_list.h"
+ #include "chunk.h"
+@@ -349,16 +351,18 @@
+     bool required = std::find_if(itr, range, std::bind1st(std::mem_fun(&ChunkList::check_node), this)) != range;
+     dontSkip = dontSkip || required;
+ 
+-    if (!required && std::distance(itr, range) < maxDistance) {
++    unsigned int l = range - itr;
++
++    if (!required && l < maxDistance) {
+       // Don't sync this range.
+-      unsigned int l = std::min(range - itr, itr - first);
++      l = std::min(l, (unsigned int)(itr - first));
+       std::swap_ranges(first, first + l, range - l);
+ 
+       first += l;
+ 
+     } else {
+       // This probably increases too fast.
+-      weight -= std::distance(itr, range) * std::distance(itr, range);
++      weight -= l * l;
+     }
+ 
+     itr = range;
+--- libtorrent-0.12.2.orig/src/utils/sha1.h	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/utils/sha1.h	2008-06-24 02:34:12.101392402 -0400
+@@ -37,11 +37,10 @@
+ #ifndef LIBTORRENT_HASH_COMPUTE_H
+ #define LIBTORRENT_HASH_COMPUTE_H
+ 
+-#include <cstring>
+-
+ #if defined USE_NSS_SHA
+ #include "sha_fast.h"
+ #elif defined USE_OPENSSL_SHA
++#include <stdlib.h>
+ #include <openssl/sha.h>
+ #else
+ #error "No SHA1 implementation selected, choose between Mozilla's NSS and OpenSSL."
+--- libtorrent-0.12.2.orig/src/tracker/tracker_http.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/tracker/tracker_http.cc	2008-06-24 15:21:07.562782258 -0400
+@@ -48,6 +48,7 @@
+ #include "torrent/http.h"
+ #include "torrent/object_stream.h"
+ #include "torrent/tracker_list.h"
++#include "torrent/data/file_list.h"
+ 
+ #include "tracker_http.h"
+ 
+--- libtorrent-0.12.2.orig/src/tracker/tracker_manager.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/tracker/tracker_manager.cc	2008-06-24 15:23:58.547482693 -0400
+@@ -36,7 +36,9 @@
+ 
+ #include "config.h"
+ 
++#include "rak/algorithm.h"
+ #include "download/download_info.h"
++#include "download/download_wrapper.h"
+ #include "torrent/exceptions.h"
+ #include "torrent/tracker.h"
+ #include "torrent/tracker_list.h"
+--- libtorrent-0.12.2.orig/src/tracker/tracker_udp.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/tracker/tracker_udp.cc	2008-06-24 15:35:31.207275209 -0400
+@@ -45,6 +45,7 @@
+ #include "torrent/connection_manager.h"
+ #include "torrent/poll.h"
+ #include "torrent/tracker_list.h"
++#include "torrent/data/file_list.h"
+ 
+ #include "tracker_udp.h"
+ #include "manager.h"
+@@ -325,7 +326,7 @@
+       m_readBuffer->read_32() != m_transactionId)
+     return false;
+ 
+-  receive_failed("Received error message: " + std::string(m_readBuffer->position(), m_readBuffer->end()));
++  receive_failed("Received error message: " + std::string((char*)m_readBuffer->position(), m_readBuffer->remaining()));
+   return true;
+ }
+ 
+--- libtorrent-0.12.2.orig/src/torrent/chunk_manager.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/chunk_manager.cc	2008-06-23 18:46:12.474491305 -0400
+@@ -112,7 +112,7 @@
+   if (itr == base_type::end())
+     throw internal_error("ChunkManager::erase(...) itr == base_type::end().");
+ 
+-  std::iter_swap(itr, --base_type::end());
++  std::iter_swap(itr, base_type::end()-1);
+   base_type::pop_back();
+ 
+   chunkList->set_manager(NULL);
+--- libtorrent-0.12.2.orig/src/torrent/peer/connection_list.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/peer/connection_list.cc	2008-06-23 18:42:38.710410872 -0400
+@@ -141,7 +141,7 @@
+   // Need to do it one connection at the time to ensure that when the
+   // signal is emited everything is in a valid state.
+   while (pos != end())
+-    erase(--end(), flags);
++    erase(end()-1, flags);
+ 
+   m_download->info()->set_accepting_new_peers(size() < m_maxSize);
+ }
+--- libtorrent-0.12.2.orig/src/torrent/object_stream.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/object_stream.cc	2008-06-23 22:07:52.705714634 -0400
+@@ -39,6 +39,7 @@
+ #include <iterator>
+ #include <iostream>
+ #include <rak/functional.h>
++#include <rak/algorithm.h>
+ 
+ #include "utils/sha1.h"
+ 
+@@ -233,7 +234,7 @@
+     src /= 10;
+   }
+ 
+-  object_write_bencode_c_string(output, first, 20 - std::distance(buffer, first));
++  object_write_bencode_c_string(output, first, 20 - (first - buffer));
+ }
+ 
+ void
+--- libtorrent-0.12.2.orig/src/torrent/download.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/download.cc	2008-06-23 18:56:21.847160292 -0400
+@@ -36,6 +36,7 @@
+ 
+ #include "config.h"
+ 
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ #include <sigc++/adaptors/bind.h>
+ #include <sigc++/adaptors/hide.h>
+--- libtorrent-0.12.2.orig/src/torrent/data/file_list.cc	2008-06-23 18:17:42.415878000 -0400
++++ libtorrent-0.12.2/src/torrent/data/file_list.cc	2008-06-23 18:21:51.029221269 -0400
+@@ -42,6 +42,7 @@
+ #include <limits>
+ #include <memory>
+ #include <set>
++#include <rak/algorithm.h>
+ #include <rak/error_number.h>
+ #include <rak/file_stat.h>
+ #include <rak/fs_stat.h>
+--- libtorrent-0.12.2.orig/src/torrent/data/file_utils.cc	2008-06-23 18:25:06.488832000 -0400
++++ libtorrent-0.12.2/src/torrent/data/file_utils.cc	2008-06-23 18:25:31.066012126 -0400
+@@ -60,7 +60,7 @@
+   FileList::split_type* splitItr = splitList;
+ 
+   unsigned int nameSize = srcPath->back().size() + suffix.size();
+-  char         name[nameSize + 4];
++  char* name = new char[nameSize + 4];
+ 
+   std::memcpy(name, srcPath->back().c_str(), srcPath->back().size());
+   std::memcpy(name + srcPath->back().size(), suffix.c_str(), suffix.size());
+@@ -80,6 +80,8 @@
+     splitItr->second.back() = name;
+   }
+ 
++  delete name;
++
+   return fileList->split(position, splitList, splitItr).second;
+ }
+ 
+--- libtorrent-0.12.2.orig/src/torrent/data/block.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/data/block.cc	2008-06-23 17:24:05.346918013 -0400
+@@ -38,6 +38,7 @@
+ 
+ #include <algorithm>
+ #include <functional>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ 
+ #include "peer/peer_info.h"
+--- libtorrent-0.12.2.orig/src/torrent/data/transfer_list.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/data/transfer_list.cc	2008-06-24 15:09:29.809436919 -0400
+@@ -39,9 +39,12 @@
+ #include <algorithm>
+ #include <functional>
+ #include <set>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ 
+ #include "data/chunk.h"
++#include "download/download_main.h"
++#include "download/chunk_selector.h"
+ #include "peer/peer_info.h"
+ 
+ #include "block_failed.h"
+--- libtorrent-0.12.2.orig/src/torrent/poll_select.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/poll_select.cc	2008-06-23 19:06:09.911597997 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <algorithm>
++#include <functional>
+ 
+ #include <unistd.h>
+ #include <sys/time.h>
+--- libtorrent-0.12.2.orig/src/torrent/hash_string.h	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/hash_string.h	2008-06-23 17:11:39.337687346 -0400
+@@ -56,8 +56,16 @@
+   typedef const value_type*                       const_iterator;
+   typedef std::size_t                             size_type;
+   typedef std::ptrdiff_t                          difference_type;
++#ifndef __SUNPRO_CC
+   typedef std::reverse_iterator<iterator>         reverse_iterator;
+   typedef std::reverse_iterator<const_iterator>   const_reverse_iterator;
++#else
++  typedef std::reverse_iterator<iterator, std::random_access_iterator_tag,
++                                int, int&, int*, ptrdiff_t> reverse_iterator;
++
++  typedef std::reverse_iterator<const_iterator, std::random_access_iterator_tag,
++                                int, const int&, const int*, ptrdiff_t> const_reverse_iterator;
++#endif /* SIGC_HAVE_SUN_REVERSE_ITERATOR */
+ 
+   static const size_type size_data = 20;
+ 
+--- libtorrent-0.12.2.orig/src/torrent/resume.cc	2008-05-07 08:19:13.000000000 -0400
++++ libtorrent-0.12.2/src/torrent/resume.cc	2008-06-28 15:58:08.634117091 -0400
+@@ -310,8 +310,13 @@
+ 
+     const rak::socket_address* sa = rak::socket_address::cast_from(itr->second->socket_address());
+ 
+-    if (sa->family() == rak::socket_address::af_inet)
+-      peer.insert_key("inet", std::string(SocketAddressCompact(sa->sa_inet()->address_n(), htons(itr->second->listen_port())).c_str(), sizeof(SocketAddressCompact)));
++    if (sa->family() == rak::socket_address::af_inet) {
++      SocketAddressCompact s = {
++        sa->sa_inet()->address_n(),
++        htons(itr->second->listen_port())
++      };
++      peer.insert_key("inet", std::string(s.c_str(), sizeof(SocketAddressCompact)));
++    }
+ 
+     peer.insert_key("failed",  itr->second->failed_counter());
+     peer.insert_key("last",    itr->second->is_connected() ? cachedTime.seconds() : itr->second->last_connection());
+--- libtorrent-0.12.2.orig/src/net/throttle_list.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/net/throttle_list.cc	2008-06-24 15:00:32.453025557 -0400
+@@ -40,6 +40,8 @@
+ #include <limits>
+ #include <torrent/exceptions.h>
+ 
++#include "socket_base.h"
++
+ #include "throttle_list.h"
+ #include "throttle_node.h"
+ 
+--- libtorrent-0.12.2.orig/src/net/listen.cc	2008-05-07 08:19:12.000000000 -0400
++++ libtorrent-0.12.2/src/net/listen.cc	2008-06-24 14:59:01.383033240 -0400
+@@ -45,6 +45,7 @@
+ #include "torrent/exceptions.h"
+ #include "torrent/connection_manager.h"
+ #include "torrent/poll.h"
++#include "protocol/handshake_manager.h"
+ 
+ #include "listen.h"
+ #include "manager.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/libtorrent/patches/rlibtorrent-05-tracker-usable.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,48 @@
+--- libtorrent-0.12.2.orig/src/torrent/tracker_list.cc	2008-07-01 22:21:49.641937000 -0400
++++ libtorrent-0.12.2/src/torrent/tracker_list.cc	2008-07-01 22:22:08.525804085 -0400
+@@ -66,14 +66,9 @@
+   return m_itr != end() && (*m_itr)->is_busy();
+ }
+ 
+-// Need a custom predicate because the is_usable function is virtual.
+-struct tracker_usable_t : public std::unary_function<TrackerList::value_type, bool> {
+-  bool operator () (const TrackerList::value_type& value) const { return value->is_usable(); }
+-};
+-
+ bool
+ TrackerList::has_usable() const {
+-  return std::find_if(begin(), end(), tracker_usable_t()) != end();
++  return find_usable(begin()) != end();
+ }
+ 
+ void
+@@ -90,6 +85,8 @@
+ 
+   set_state(s);
+   m_itr = find_usable(m_itr);
++  if (m_itr == end())
++    m_itr = find_usable(begin());
+ 
+   if (m_itr != end())
+     (*m_itr)->send_state(state());
+@@ -134,18 +131,12 @@
+ 
+ TrackerList::iterator
+ TrackerList::find_usable(iterator itr) {
+-  while (itr != end() && !tracker_usable_t()(*itr))
+-    ++itr;
+-
+-  return itr;
++  return std::find_if(itr, end(), std::mem_fun(&Tracker::is_usable));
+ }
+ 
+ TrackerList::const_iterator
+ TrackerList::find_usable(const_iterator itr) const {
+-  while (itr != end() && !tracker_usable_t()(*itr))
+-    ++itr;
+-
+-  return itr;
++  return std::find_if(itr, end(), std::mem_fun(&Tracker::is_usable));
+ }
+ 
+ TrackerList::iterator
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/meta-packages/history/SUNWlibtorrent.p5m	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+set name=pkg.fmri value=pkg:/[email protected],5.11-0.133
+set name=pkg.renamed value=true
+
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+
+depend fmri=library/[email protected] type=require
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/meta-packages/history/SUNWrtorrent.p5m	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,29 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+set name=pkg.fmri value=pkg:/[email protected],5.11-0.133
+set name=pkg.renamed value=true
+
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+
+depend fmri=network/[email protected] type=require
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/Makefile	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,77 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+include ../../make-rules/shared-macros.mk
+
+COMPONENT_NAME=		rtorrent
+COMPONENT_VERSION=	0.8.2
+COMPONENT_SRC=		$(COMPONENT_NAME)-$(COMPONENT_VERSION)
+COMPONENT_PROJECT_URL=	http://libtorrent.rakshasa.no/
+COMPONENT_ARCHIVE=	$(COMPONENT_SRC).tar.gz
+COMPONENT_ARCHIVE_HASH=	sha1:891093c5d600c2e3853eadbbec369a12dfe6ec11
+COMPONENT_ARCHIVE_URL=	http://libtorrent.rakshasa.no/downloads/$(COMPONENT_ARCHIVE)
+
+include ../../make-rules/prep.mk
+include ../../make-rules/configure.mk
+include ../../make-rules/ips.mk
+
+COMPONENT_PRE_CONFIGURE_ACTION = \
+	($(CLONEY) $(SOURCE_DIR) $(@D))
+
+COMPONENT_PREP_ACTION = \
+        (cd $(@D) ; \
+	    aclocal-1.10 -I./scripts -I. ; \
+	    autoheader; \
+	    libtoolize --automake --copy --force; \
+	    automake-1.10; \
+	    autoconf )
+
+# this is needed or we can't compile the rak headers
+CC=$(CXX)
+
+LDFLAGS += -L/usr/gnu/lib -R/usr/gnu/lib -lnsl -lsocket
+
+CXXFLAGS +=	-i
+CXXFLAGS +=	-xspace
+CXXFLAGS +=	-mr
+CXXFLAGS +=	$(studio_XREGS)
+CXXFLAGS +=	-I/usr/include/ncurses
+CONFIGURE_OPTIONS.32 +=		--srcdir=$(BUILD_DIR_32)
+CONFIGURE_OPTIONS +=		--disable-debug
+CONFIGURE_OPTIONS +=		CFLAGS="$(CFLAGS)"
+CONFIGURE_OPTIONS +=		LDFLAGS="$(LDFLAGS)"
+CONFIGURE_OPTIONS +=		CXXFLAGS="$(CXXFLAGS)"
+
+
+# common targets
+build:		$(BUILD_32)
+
+install:	$(INSTALL_32)
+
+test:		$(NO_TESTS)
+
+BUILD_PKG_DEPENDENCIES =	$(BUILD_TOOLS)
+
+include ../../make-rules/depend.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/rtorrent-01-solaris.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,131 @@
+--- rtorrent-0.8.2/src/input/input_event.cc.orig	2008-05-10 18:44:08.970350312 +1200
++++ rtorrent-0.8.2/src/input/input_event.cc	2008-05-10 18:44:41.438283333 +1200
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <ncurses.h>
++#define NCURSES_ERR -1
+ 
+ #include "input_event.h"
+ 
+@@ -58,7 +59,7 @@
+ InputEvent::event_read() {
+   int c;
+ 
+-  while ((c = getch()) != ERR)
++  while ((c = getch()) != NCURSES_ERR)
+     m_slotPressed(c);
+ }
+ 
+--- rtorrent-0.8.2/src/input/path_input.cc.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/input/path_input.cc	2008-05-10 18:46:38.159258850 +1200
+@@ -42,7 +42,8 @@
+ #include <rak/path.h>
+ 
+ #include <sys/types.h>
+-#include <sys/dir.h>
++#include <sys/dirent.h>
++#include <sys/stat.h>
+ 
+ #include "path_input.h"
+ 
+@@ -71,9 +72,12 @@
+ }
+ 
+ struct _transform_filename {
++  struct stat s;
+   void operator () (utils::directory_entry& entry) {
+-    if (entry.d_type == DT_DIR)
++    stat(entry.d_name.c_str(), &s);
++    if (s.st_mode & S_IFDIR) {
+       entry.d_name += '/';
++    }
+   }
+ };
+ 
+--- rtorrent-0.8.2/src/utils/directory.h.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/utils/directory.h	2008-05-10 18:40:49.485871875 +1200
+@@ -48,9 +48,7 @@
+   bool is_file() const { return true; }
+ 
+   // The name and types should match POSIX.
+-  uint32_t            d_fileno;
+   uint32_t            d_reclen;
+-  uint8_t             d_type;
+ 
+   std::string         d_name;
+ };
+--- rtorrent-0.8.2/src/utils/directory.cc.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/utils/directory.cc	2008-05-10 18:40:49.485525951 +1200
+@@ -76,9 +76,7 @@
+ 
+     iterator itr = base_type::insert(end(), value_type());
+ 
+-    itr->d_fileno = entry->d_fileno;
+     itr->d_reclen = entry->d_reclen;
+-    itr->d_type   = entry->d_type;
+ 
+ #ifdef DIRENT_NAMLEN_EXISTS_FOOBAR
+     itr->d_name   = std::string(entry->d_name, entry->d_name + entry->d_namlen);
+--- rtorrent-0.8.2/src/signal_handler.h.orig	2008-05-08 00:19:11.000000000 +1200
++++ rtorrent-0.8.2/src/signal_handler.h	2008-05-10 18:40:49.485083889 +1200
+@@ -37,7 +37,7 @@
+ #ifndef RTORRENT_SIGNAL_HANDLER_H
+ #define RTORRENT_SIGNAL_HANDLER_H
+ 
+-#include <sys/signal.h>
++#include <signal.h>
+ #include <sigc++/functors/slot.h>
+ 
+ class SignalHandler {
+--- rtorrent-0.8.2/src/rpc/scgi.cc.orig	2008-05-08 00:19:10.000000000 +1200
++++ rtorrent-0.8.2/src/rpc/scgi.cc	2008-05-10 18:40:49.457064063 +1200
+@@ -88,7 +88,7 @@
+   char buffer[sizeof(sockaddr_un) + filename.size()];
+   sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
+ 
+-  sa->sun_family = AF_LOCAL;
++  sa->sun_family = AF_UNIX;
+   std::memcpy(sa->sun_path, filename.c_str(), filename.size() + 1);
+ 
+   if (!get_fd().open_local())
+diff -urN rtorrent-0.8.2.orig/src/core/curl_get.cc rtorrent-0.8.2/src/core/curl_get.cc
+--- rtorrent-0.8.2.orig/src/core/curl_get.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/curl_get.cc	2008-05-24 04:58:48.995868197 -0400
+@@ -81,7 +81,7 @@
+   curl_easy_setopt(m_handle, CURLOPT_NOSIGNAL,       1);
+   curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, 1);
+   curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS,      5);
+-  curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE,      CURL_IPRESOLVE_V4);
++  curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE,      CURL_IPRESOLVE_WHATEVER);
+   curl_easy_setopt(m_handle, CURLOPT_ENCODING,       "");
+ 
+   m_stack->add_get(this);
+--- rtorrent-0.8.2.orig/src/main.cc	2008-07-01 16:49:14.445080000 -0400
++++ rtorrent-0.8.2/src/main.cc	2008-07-02 10:37:19.052279890 -0400
+@@ -44,7 +44,13 @@
+ #include <torrent/torrent.h>
+ #include <torrent/exceptions.h>
+ #include <rak/functional.h>
++#include <locale.h>
+ 
++#if defined(__sun) && defined(__SVR4)
++#include <stdio.h>
++#include <stdio_ext.h>
++#endif
++
+ #ifdef USE_EXECINFO
+ #include <execinfo.h>
+ #endif
+@@ -165,6 +170,11 @@
+     SignalHandler::set_handler(SIGSEGV,  sigc::bind(sigc::ptr_fun(&do_panic), SIGSEGV));
+     SignalHandler::set_handler(SIGBUS,   sigc::bind(sigc::ptr_fun(&do_panic), SIGBUS));
+     SignalHandler::set_handler(SIGFPE,   sigc::bind(sigc::ptr_fun(&do_panic), SIGFPE));
++    SignalHandler::set_handler(SIGABRT,   sigc::bind(sigc::ptr_fun(&do_panic), SIGABRT));
++
++#if defined(__sun) && defined(__SVR4)
++    enable_extended_FILE_stdio(-1, SIGABRT);
++#endif
+ 
+     control->core()->initialize_first();
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/rtorrent-02-event-ports.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,222 @@
+diff -urN rtorrent-0.8.2.orig/src/core/Makefile.am rtorrent-0.8.2/src/core/Makefile.am
+--- rtorrent-0.8.2.orig/src/core/Makefile.am	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/Makefile.am	2008-05-24 04:58:48.995508910 -0400
+@@ -26,6 +26,8 @@
+ 	poll_manager.h \
+ 	poll_manager_epoll.cc \
+ 	poll_manager_epoll.h \
++	poll_manager_ports.cc \
++	poll_manager_ports.h \
+ 	poll_manager_kqueue.cc \
+ 	poll_manager_kqueue.h \
+ 	poll_manager_select.cc \
+diff -urN rtorrent-0.8.2.orig/src/core/manager.cc rtorrent-0.8.2/src/core/manager.cc
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-05-24 04:58:48.996596707 -0400
+@@ -69,6 +69,7 @@
+ #include "manager.h"
+ #include "poll_manager_epoll.h"
+ #include "poll_manager_kqueue.h"
++#include "poll_manager_ports.h"
+ #include "poll_manager_select.h"
+ #include "view.h"
+ 
+@@ -189,6 +190,9 @@
+   if ((m_pollManager = PollManagerEPoll::create(sysconf(_SC_OPEN_MAX))) != NULL)
+     m_logImportant.push_front("Using 'epoll' based polling.");
+ 
++  else if ((m_pollManager = PollManagerPorts::create(sysconf(_SC_OPEN_MAX))) != NULL)
++    m_logImportant.push_front("Using 'ports' based polling.");
++
+   else if ((m_pollManager = PollManagerKQueue::create(sysconf(_SC_OPEN_MAX))) != NULL)
+     m_logImportant.push_front("Using 'kqueue' based polling.");
+ 
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc rtorrent-0.8.2/src/core/poll_manager_ports.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/poll_manager_ports.cc	2008-05-10 19:04:07.000000000 -0400
+@@ -0,0 +1,118 @@
++// rTorrent - BitTorrent client
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#include "config.h"
++
++#include <cstring>
++#include <iostream>
++#include <stdexcept>
++#include <unistd.h>
++#include <sys/time.h>
++#include <torrent/poll_ports.h>
++#include <torrent/torrent.h>
++
++#include "poll_manager_ports.h"
++
++namespace core {
++
++PollManagerPorts*
++PollManagerPorts::create(int maxOpenSockets) {
++  torrent::PollPorts* p = torrent::PollPorts::create(maxOpenSockets);
++
++  if (p == NULL)
++    return NULL;
++  else
++    return new PollManagerPorts(p);
++}
++
++PollManagerPorts::~PollManagerPorts() {
++}
++
++void
++PollManagerPorts::poll(rak::timer timeout) {
++  // Add 1ms to ensure we don't idle loop due to the lack of
++  // resolution.
++  torrent::perform();
++  timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
++
++  if (!m_httpStack.empty()) {
++    // When we're using libcurl we need to use select, but as this is
++    // inefficient we try avoiding it whenever possible.
++#if defined USE_VARIABLE_FDSET
++    std::memset(m_readSet, 0, m_setSize);
++    std::memset(m_writeSet, 0, m_setSize);
++    std::memset(m_errorSet, 0, m_setSize);
++#else
++    FD_ZERO(m_readSet);
++    FD_ZERO(m_writeSet);
++    FD_ZERO(m_errorSet);
++#endif    
++    FD_SET(static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(), m_readSet);
++
++    unsigned int maxFd = std::max((unsigned int)static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(),
++                                  m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
++
++    timeval t = timeout.tval();
++
++    if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1) {
++	    std::cerr << "error from select\n";
++      return check_error();
++    }
++    m_httpStack.perform();
++
++    if (!FD_ISSET(static_cast<torrent::PollPorts*>(m_poll)->file_descriptor(), m_readSet)) {
++      // Need to call perform here so that scheduled task get done
++      // even if there's no socket events outside of the http stuff.
++      torrent::perform();
++      return;
++    }
++
++    // Clear the timeout since we've already used it in the select call.
++    timeout = rak::timer();
++  }
++
++  // Yes, below is how much code really *should* have been in this
++  // function. ;)
++
++  if (static_cast<torrent::PollPorts*>(m_poll)->poll((timeout.usec() + 999) / 1000) == -1) {
++	  std::cerr << "error from ports poll\n";
++    return check_error();
++  }
++  torrent::perform();
++  static_cast<torrent::PollPorts*>(m_poll)->perform();
++}
++
++}
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.h rtorrent-0.8.2/src/core/poll_manager_ports.h
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.h	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/poll_manager_ports.h	2008-05-10 19:04:07.000000000 -0400
+@@ -0,0 +1,63 @@
++// rTorrent - BitTorrent client
++// Copyright (C) 2005-2007, Jari Sundell
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#ifndef RTORRENT_CORE_POLL_MANAGER_PORTS_H
++#define RTORRENT_CORE_POLL_MANAGER_PORTS_H
++
++#include "poll_manager.h"
++
++namespace torrent {
++  class PollPorts;
++}
++
++namespace core {
++
++class PollManagerPorts : public PollManager {
++public:
++  static PollManagerPorts* create(int maxOpenSockets);
++  ~PollManagerPorts();
++
++  torrent::Poll*      get_torrent_poll();
++
++  void                poll(rak::timer timeout);
++
++private:
++  PollManagerPorts(torrent::Poll* p) : PollManager(p) {}
++};
++
++}
++
++#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/rtorrent-03-curl-event.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,490 @@
+diff -urN rtorrent-0.8.2.orig/src/core/curl_event.cc rtorrent-0.8.2/src/core/curl_event.cc
+--- rtorrent-0.8.2.orig/src/core/curl_event.cc	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/curl_event.cc	2008-06-10 14:40:41.403064000 -0400
+@@ -0,0 +1,63 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2008 Albert Lee
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#include "config.h"
++
++#include <torrent/exceptions.h>
++
++#include "rak/functional.h"
++
++#include "curl_event.h"
++#include "curl_stack.h"
++
++namespace core {
++
++void
++CurlEvent::event_read() {
++  m_stack->perform(m_fileDesc);
++}
++
++void
++CurlEvent::event_write() {
++  m_stack->perform(m_fileDesc);
++}
++
++void
++CurlEvent::event_error() {
++  m_stack->perform(m_fileDesc);
++}
++
++}
+diff -urN rtorrent-0.8.2.orig/src/core/curl_event.h rtorrent-0.8.2/src/core/curl_event.h
+--- rtorrent-0.8.2.orig/src/core/curl_event.h	1969-12-31 19:00:00.000000000 -0500
++++ rtorrent-0.8.2/src/core/curl_event.h	2008-06-10 14:37:59.758119000 -0400
+@@ -0,0 +1,61 @@
++// libTorrent - BitTorrent library
++// Copyright (C) 2008 Albert Lee
++//
++// 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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++//
++// In addition, as a special exception, the copyright holders give
++// permission to link the code of portions of this program with the
++// OpenSSL library under certain conditions as described in each
++// individual source file, and distribute linked combinations
++// including the two.
++//
++// You must obey the GNU General Public License in all respects for
++// all of the code used other than OpenSSL.  If you modify file(s)
++// with this exception, you may extend this exception to your version
++// of the file(s), but you are not obligated to do so.  If you do not
++// wish to do so, delete this exception statement from your version.
++// If you delete this exception statement from all source files in the
++// program, then also delete it here.
++//
++// Contact:  Jari Sundell <[email protected]>
++//
++//           Skomakerveien 33
++//           3185 Skoppum, NORWAY
++
++#ifndef RTORRENT_CORE_CURL_EVENT_H
++#define RTORRENT_CORE_CURL_EVENT_H
++
++#include <torrent/event.h>
++
++namespace core {
++
++class CurlStack;
++
++class CurlEvent : public torrent::Event {
++public:
++  CurlEvent(CurlStack* s, int fd) : m_stack(s) { m_fileDesc = fd; }
++  virtual ~CurlEvent() {}
++
++  virtual void        event_read();
++  virtual void        event_write();
++  virtual void        event_error();
++
++protected:
++  CurlStack*          m_stack;
++};
++
++}
++
++#endif
+diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.cc rtorrent-0.8.2/src/core/curl_stack.cc
+--- rtorrent-0.8.2.orig/src/core/curl_stack.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/curl_stack.cc	2008-06-10 14:32:12.992249000 -0400
+@@ -44,13 +44,77 @@
+ #include "rak/functional.h"
+ #include "curl_get.h"
+ #include "curl_stack.h"
++#include "curl_event.h"
++
++#include "poll_manager.h"
+ 
+ namespace core {
+ 
+-CurlStack::CurlStack() :
++#if LIBCURL_VERSION_NUM >= 0x071000
++static void timer_callback(curl_socket_t socket, int action, void* event_data)
++{
++  CurlStack* s = static_cast<CurlStack*>(event_data);
++  CURLM* handle = (CURLM*)(s->handle());
++  CURLMcode rc;
++  int count;
++
++  while (CURLM_CALL_MULTI_PERFORM == (rc = curl_multi_socket(handle, CURL_SOCKET_TIMEOUT, &count)));
++}
++#endif
++
++static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data)
++{
++  CurlStack* stack = static_cast<CurlStack*>(socket_data);
++  torrent::Event* event = static_cast<torrent::Event*>(assign_data);
++  torrent::Poll* poll = stack->poll();
++
++  if (!event) {
++    event = new CurlEvent(stack, socket);
++    curl_multi_assign((CURLM*)(stack->handle()), socket, event);
++    if (socket > poll->open_max())
++      throw torrent::internal_error("Socket too large for " + poll->open_max());
++    poll->open(event);
++  } else {
++    poll->remove_read(event);
++    poll->remove_write(event);
++    poll->remove_error(event);
++  }
++
++  switch (action) {
++    case CURL_POLL_NONE:
++      break;
++    case CURL_POLL_IN:
++      poll->insert_read(event);
++      break;
++    case CURL_POLL_OUT:
++      poll->insert_write(event);
++      break;
++    case CURL_POLL_INOUT:
++      poll->insert_read(event);
++      poll->insert_write(event);
++      break;
++    case CURL_POLL_REMOVE:
++      poll->close(event);
++      delete event;
++      break;
++    default:
++      throw torrent::internal_error("socket_callback(...) called with unsupported action");
++  }
++
++  return 0;
++}
++
++CurlStack::CurlStack(torrent::Poll* poll) :
+   m_handle((void*)curl_multi_init()),
++  m_poll(poll),
+   m_active(0),
+   m_maxActive(32) {
++  curl_multi_setopt(m_handle, CURLMOPT_SOCKETDATA, this);
++  curl_multi_setopt(m_handle, CURLMOPT_SOCKETFUNCTION, socket_callback);
++#if LIBCURL_VERSION_NUM >= 0x071000
++  curl_multi_setopt(m_handle, CURLMOPT_TIMERDATA, this);
++  curl_multi_setopt(m_handle, CURLMOPT_TIMERFUNCTION, timer_callback);
++#endif
+ }
+ 
+ CurlStack::~CurlStack() {
+@@ -66,35 +130,59 @@
+ }
+ 
+ void
+-CurlStack::perform() {
++CurlStack::process() {
++  int t;
++  CURLMsg* msg;
++
++  while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
++    if (msg->msg != CURLMSG_DONE)
++      throw torrent::internal_error("CurlStack::process() msg->msg != CURLMSG_DONE.");
++
++    iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
++
++    if (itr == end())
++      throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
++        
++    if (msg->data.result == CURLE_OK)
++      (*itr)->signal_done().emit();
++    else
++      (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
++  }
++}
++
++void
++CurlStack::perform(curl_socket_t sockfd) {
+   CURLMcode code;
+ 
+   do {
+     int count;
+-    code = curl_multi_perform((CURLM*)m_handle, &count);
++    code = curl_multi_socket((CURLM*)m_handle, sockfd, &count);
+ 
+     if (code > 0)
+-      throw torrent::internal_error("Error calling curl_multi_perform.");
++      throw torrent::internal_error("Error calling curl_multi_socket.");
+ 
+     if ((unsigned int)count != size()) {
+       // Done with some handles.
+-      int t;
+-      CURLMsg* msg;
++      process();
++    }
+ 
+-      while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
+-        if (msg->msg != CURLMSG_DONE)
+-          throw torrent::internal_error("CurlStack::perform() msg->msg != CURLMSG_DONE.");
++  } while (code == CURLM_CALL_MULTI_PERFORM);
++}
+ 
+-        iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
++void
++CurlStack::perform() {
++  CURLMcode code;
+ 
+-        if (itr == end())
+-          throw torrent::internal_error("Could not find CurlGet with the right easy_handle.");
+-        
+-        if (msg->data.result == CURLE_OK)
+-          (*itr)->signal_done().emit();
+-        else
+-          (*itr)->signal_failed().emit(curl_easy_strerror(msg->data.result));
+-      }
++  do {
++    int count;
++    code = curl_multi_perform((CURLM*)m_handle, &count);
++
++    if (code > 0)
++      throw torrent::internal_error("Error calling curl_multi_perform.");
++
++    if ((unsigned int)count != size()) {
++      // Done with some handles.
++      process();
+     }
+ 
+   } while (code == CURLM_CALL_MULTI_PERFORM);
+diff -urN rtorrent-0.8.2.orig/src/core/curl_stack.h rtorrent-0.8.2/src/core/curl_stack.h
+--- rtorrent-0.8.2.orig/src/core/curl_stack.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/curl_stack.h	2008-06-10 13:54:21.695024000 -0400
+@@ -40,11 +40,19 @@
+ #include <deque>
+ #include <string>
+ #include <sigc++/functors/slot.h>
++#include <curl/curl.h>
++
++class torrent::Poll;
+ 
+ namespace core {
+ 
+ class CurlGet;
+ 
++#if LIBCURL_VERSION_NUM >= 0x071000
++static void timer_callback(curl_socket_t socket, int action, void* event_data);
++#endif
++static int socket_callback(CURL *easy, curl_socket_t socket, int action, void* socket_data, void* assign_data);
++
+ // By using a deque instead of vector we allow for cheaper removal of
+ // the oldest elements, those that will be first in the in the
+ // deque.
+@@ -76,16 +84,19 @@
+   using base_type::size;
+   using base_type::empty;
+ 
+-  CurlStack();
++  CurlStack(torrent::Poll* poll);
+   ~CurlStack();
+ 
+   CurlGet*            new_object();
+ 
++  void                perform(curl_socket_t sockfd);
+   void                perform();
+ 
+   // TODO: Set fd_set's only once?
+   unsigned int        fdset(fd_set* readfds, fd_set* writefds, fd_set* exceptfds);
+ 
++  void*               handle()                               { return m_handle; }
++  torrent::Poll*      poll()                                 { return m_poll; }         
+   unsigned int        active() const                         { return m_active; }
+   unsigned int        max_active() const                     { return m_maxActive; }
+   void                set_max_active(unsigned int a)         { m_maxActive = a; }
+@@ -111,12 +122,14 @@
+  protected:
+   void                add_get(CurlGet* get);
+   void                remove_get(CurlGet* get);
++  void                process();
+ 
+  private:
+   CurlStack(const CurlStack&);
+   void operator = (const CurlStack&);
+ 
+   void*               m_handle;
++  torrent::Poll*      m_poll;
+ 
+   unsigned int        m_active;
+   unsigned int        m_maxActive;
+diff -urN rtorrent-0.8.2.orig/src/core/Makefile.am rtorrent-0.8.2/src/core/Makefile.am
+--- rtorrent-0.8.2.orig/src/core/Makefile.am	2008-06-10 15:13:49.786345331 -0400
++++ rtorrent-0.8.2/src/core/Makefile.am	2008-06-10 02:25:32.809721000 -0400
+@@ -1,6 +1,8 @@
+ noinst_LIBRARIES = libsub_core.a
+ 
+ libsub_core_a_SOURCES = \
++	curl_event.cc \
++	curl_event.h \
+ 	curl_get.cc \
+ 	curl_get.h \
+ 	curl_stack.cc \
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc rtorrent-0.8.2/src/core/poll_manager_epoll.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_epoll.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_epoll.cc	2008-06-10 14:17:27.568558000 -0400
+@@ -67,6 +67,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -101,6 +102,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc rtorrent-0.8.2/src/core/poll_manager_kqueue.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_kqueue.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_kqueue.cc	2008-06-10 14:17:31.672907000 -0400
+@@ -68,6 +68,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -102,6 +103,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc rtorrent-0.8.2/src/core/poll_manager_ports.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_ports.cc	2008-06-10 15:13:49.790288665 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_ports.cc	2008-06-10 14:31:09.552278000 -0400
+@@ -68,6 +68,7 @@
+   torrent::perform();
+   timeout = std::min(timeout, rak::timer(torrent::next_timeout())) + 1000;
+ 
++#if 0
+   if (!m_httpStack.empty()) {
+     // When we're using libcurl we need to use select, but as this is
+     // inefficient we try avoiding it whenever possible.
+@@ -103,6 +104,7 @@
+     // Clear the timeout since we've already used it in the select call.
+     timeout = rak::timer();
+   }
++#endif
+ 
+   // Yes, below is how much code really *should* have been in this
+   // function. ;)
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager_select.cc rtorrent-0.8.2/src/core/poll_manager_select.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager_select.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager_select.cc	2008-06-10 02:37:17.419878000 -0400
+@@ -77,16 +77,16 @@
+ 
+   unsigned int maxFd = static_cast<torrent::PollSelect*>(m_poll)->fdset(m_readSet, m_writeSet, m_errorSet);
+ 
+-  if (!m_httpStack.empty())
+-    maxFd = std::max(maxFd, m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet));
++  if (!m_httpStack->empty())
++    maxFd = std::max(maxFd, m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet));
+ 
+   timeval t = timeout.tval();
+ 
+   if (select(maxFd + 1, m_readSet, m_writeSet, m_errorSet, &t) == -1)
+     return check_error();
+ 
+-  if (!m_httpStack.empty())
+-    m_httpStack.perform();
++  if (!m_httpStack->empty())
++    m_httpStack->perform();
+ 
+   torrent::perform();
+   static_cast<torrent::PollSelect*>(m_poll)->perform(m_readSet, m_writeSet, m_errorSet);
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.cc rtorrent-0.8.2/src/core/poll_manager.cc
+--- rtorrent-0.8.2.orig/src/core/poll_manager.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager.cc	2008-06-10 02:35:35.523377000 -0400
+@@ -44,7 +44,8 @@
+ namespace core {
+ 
+ PollManager::PollManager(torrent::Poll* poll) :
+-  m_poll(poll) {
++  m_poll(poll),
++  m_httpStack(new CurlStack(poll)) {
+ 
+   if (m_poll == NULL)
+     throw std::logic_error("PollManager::PollManager(...) received poll == NULL");
+@@ -74,10 +75,11 @@
+ 
+   // Call this so curl has valid fd_set pointers if curl_multi_perform
+   // is called before it gets set when polling.
+-  m_httpStack.fdset(m_readSet, m_writeSet, m_errorSet);
++  m_httpStack->fdset(m_readSet, m_writeSet, m_errorSet);
+ }
+ 
+ PollManager::~PollManager() {
++  delete m_httpStack;
+   delete m_poll;
+ 
+ #if defined USE_VARIABLE_FDSET
+diff -urN rtorrent-0.8.2.orig/src/core/poll_manager.h rtorrent-0.8.2/src/core/poll_manager.h
+--- rtorrent-0.8.2.orig/src/core/poll_manager.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/poll_manager.h	2008-06-10 02:34:57.898088000 -0400
+@@ -58,7 +58,7 @@
+ 
+   unsigned int        get_open_max() const         { return m_poll->open_max(); }
+ 
+-  CurlStack*          get_http_stack()             { return &m_httpStack; }
++  CurlStack*          get_http_stack()             { return m_httpStack; }
+   torrent::Poll*      get_torrent_poll()           { return m_poll; }
+ 
+   virtual void        poll(rak::timer timeout) = 0;
+@@ -70,7 +70,7 @@
+   void                check_error();
+ 
+   torrent::Poll*      m_poll;
+-  CurlStack           m_httpStack;
++  CurlStack*          m_httpStack;
+ 
+   unsigned int        m_setSize;
+   fd_set*             m_readSet;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/rtorrent-04-sunpro.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,712 @@
+--- rtorrent-0.8.2.orig/rak/string_manip.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/string_manip.h	2008-06-25 02:14:10.028329996 -0400
+@@ -62,7 +62,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end())))
++  if (seq.empty() || !std::isspace(*(seq.end()-1)))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+@@ -93,7 +93,7 @@
+ 
+ template <typename Sequence>
+ Sequence trim_end_classic(const Sequence& seq) {
+-  if (seq.empty() || !std::isspace(*(--seq.end()), std::locale::classic()))
++  if (seq.empty() || !std::isspace(*(seq.end()-1), std::locale::classic()))
+     return seq;
+ 
+   typename Sequence::size_type pos = seq.size();
+--- rtorrent-0.8.2.orig/rak/path.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/path.h	2008-06-25 01:57:52.656513911 -0400
+@@ -42,6 +42,7 @@
+ 
+ #include <cstdlib>
+ #include <string>
++#include <algorithm>
+ 
+ namespace rak {
+ 
+@@ -91,7 +92,7 @@
+     if (home == NULL)
+       return first;
+ 
+-    first += strlcpy(first, home, std::distance(first, last));
++    first += strlcpy(first, home, last-first);
+ 
+     if (first > last)
+       return last;
+@@ -99,7 +100,7 @@
+     src++;
+   }
+ 
+-  return std::min(first + strlcpy(first, src, std::distance(first, last)), last);
++  return std::min(first + strlcpy(first, src, last-first), last);
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/rak/unordered_vector.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/unordered_vector.h	2008-06-25 02:29:35.381434005 -0400
+@@ -90,7 +90,7 @@
+ unordered_vector<_Tp>::insert(iterator position, const value_type& x) {
+   Base::push_back(x);
+ 
+-  return --end();
++  return end()-1;
+ }
+ 
+ template <typename _Tp>
+--- rtorrent-0.8.2.orig/rak/socket_address.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/socket_address.h	2008-06-25 01:58:48.126132462 -0400
+@@ -50,6 +50,7 @@
+ #include <cstring>
+ #include <string>
+ #include <stdexcept>
++#include <algorithm>
+ #include <arpa/inet.h>
+ #include <netinet/in.h>
+ #include <sys/types.h>
+--- rtorrent-0.8.2.orig/rak/regex.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/regex.h	2008-06-25 02:10:05.332867456 -0400
+@@ -75,7 +75,7 @@
+   std::list<unsigned int> paths;
+   paths.push_front(0);
+ 
+-  for (std::string::const_iterator itrText = ++text.begin(), lastText = text.end(); itrText != lastText; ++itrText) {
++  for (std::string::const_iterator itrText = text.begin()+1, lastText = text.end(); itrText != lastText; ++itrText) {
+     
+     for (std::list<unsigned int>::iterator itrPaths = paths.begin(), lastPaths = paths.end(); itrPaths != lastPaths; ) {
+ 
+--- rtorrent-0.8.2.orig/rak/algorithm.h	2008-05-07 08:19:12.000000000 -0400
++++ rtorrent-0.8.2/rak/algorithm.h	2008-06-25 17:27:39.728352000 -0400
+@@ -40,6 +40,63 @@
+ #include <algorithm>
+ #include <functional>
+ 
++#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
++namespace std {
++  template <class Iterator> struct iterator_traits
++  {
++    typedef typename Iterator::value_type value_type;
++    typedef typename Iterator::difference_type difference_type;
++    typedef typename Iterator::pointer pointer;
++    typedef typename Iterator::reference reference;
++    typedef typename Iterator::iterator_category iterator_category;
++  };
++  template <class T> struct iterator_traits<T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef T* pointer;
++    typedef T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++  template <class T> struct iterator_traits<const T*>
++  {
++    typedef T value_type;
++    typedef ptrdiff_t difference_type;
++    typedef const T* pointer;
++    typedef const T& reference;
++    typedef random_access_iterator_tag iterator_category;
++  };
++
++  template <class ForwardIterator>
++  inline typename iterator_traits<ForwardIterator>::difference_type
++  distance (ForwardIterator first, ForwardIterator last)
++  {
++    typename iterator_traits<ForwardIterator>::difference_type n = 0;
++    __distance(first, last, n, 
++               iterator_traits<ForwardIterator>::iterator_category());
++    return n;
++  }
++
++  template <class InputIterator, class T>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count (InputIterator first, InputIterator last, const T& value)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count(first, last, value, n);
++    return n;
++  }
++
++  template <class InputIterator, class Predicate>
++  inline typename iterator_traits<InputIterator>::difference_type
++  count_if (InputIterator first, InputIterator last, Predicate pred)
++  {
++    typename iterator_traits<InputIterator>::difference_type n = 0;
++    count_if(first, last, pred, n);
++    return n;
++  }
++}
++#endif
++
+ namespace rak {
+ 
+ template <typename _InputIter, typename _Function>
+--- rtorrent-0.8.2.orig/src/command_file.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/command_file.cc	2008-06-25 18:06:51.985365949 -0400
+@@ -64,7 +64,7 @@
+   torrent::Object resultRaw(*file->path()->begin());
+   torrent::Object::string_type& result = resultRaw.as_string();
+ 
+-  for (torrent::Path::const_iterator itr = ++file->path()->begin(), last = file->path()->end(); itr != last; itr++)
++  for (torrent::Path::const_iterator itr = (file->path()->begin())+1, last = file->path()->end(); itr != last; itr++)
+     result += '/' + *itr;
+ 
+   return resultRaw;
+--- rtorrent-0.8.2.orig/src/display/window_download_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_download_list.cc	2008-06-25 03:05:03.087916943 -0400
+@@ -90,9 +90,9 @@
+     ++range.second;
+ 
+   int pos = 1;
++  char* buffer = new char[m_canvas->width() + 1];
+ 
+   while (range.first != range.second) {
+-    char buffer[m_canvas->width() + 1];
+     char* position;
+     char* last = buffer + m_canvas->width() - 2 + 1;
+ 
+@@ -107,6 +107,8 @@
+ 
+     ++range.first;
+   }    
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/window_text.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_text.cc	2008-06-25 03:18:19.930779231 -0400
+@@ -93,8 +93,9 @@
+   if (m_canvas->height() == 0)
+     return;
+ 
++  char* buffer = new char[m_canvas->width() + 1];
++
+   if (m_errorHandler != NULL && m_target.second == NULL) {
+-    char buffer[m_canvas->width() + 1];
+ 
+     Canvas::attributes_list attributes;
+     attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
+@@ -102,6 +103,9 @@
+     char* last = m_errorHandler->print(buffer, buffer + m_canvas->width(), &attributes, m_target);
+ 
+     m_canvas->print_attributes(0, position, buffer, last, &attributes);
++
++    delete buffer;
++
+     return;
+   }
+ 
+@@ -109,8 +113,6 @@
+     if (*itr == NULL)
+       continue;
+ 
+-    char buffer[m_canvas->width() + 1];
+-
+     Canvas::attributes_list attributes;
+     attributes.push_back(Attributes(buffer, Attributes::a_normal, Attributes::color_default));
+ 
+@@ -118,6 +120,8 @@
+ 
+     m_canvas->print_attributes(0, position, buffer, last, &attributes);
+   }
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/frame.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/frame.h	2008-06-25 02:47:06.518734587 -0400
+@@ -92,9 +92,9 @@
+ 
+   Window*             window() const                    { return m_window; }
+ 
+-  Frame*              frame(size_type idx)              { return m_container[idx]; }
++  Frame*              frame(size_type idx)              { return m_container.frames[idx]; }
+ 
+-  size_type           container_size() const            { return m_containerSize; }
++  size_type           container_size() const            { return m_container.size; }
+   void                set_container_size(size_type size);
+ 
+   void                initialize_window(Window* window);
+@@ -120,13 +120,14 @@
+   uint32_t            m_width;
+   uint32_t            m_height;
+ 
++  typedef struct {
++    size_type           size;
++    Frame*              frames[max_size];
++  } container_t;
++
+   union {
+     Window*             m_window;
+-    
+-    struct {
+-      size_type           m_containerSize;
+-      Frame*              m_container[max_size];
+-    };
++    container_t         m_container;
+   };
+ };
+ 
+--- rtorrent-0.8.2.orig/src/display/text_element_string.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/text_element_string.cc	2008-06-25 02:57:08.521853302 -0400
+@@ -36,6 +36,7 @@
+ 
+ #include "config.h"
+ 
++#include <rak/algorithm.h>
+ #include <rak/string_manip.h>
+ 
+ #include "rpc/parse_commands.h"
+@@ -52,17 +52,21 @@
+     return first;
+ 
+   if (m_flags & flag_escape_hex) {
+-    char buffer[last - first];
++    char* buffer = new char[last - first];
+     char* bufferLast = copy_string(buffer, buffer + (last - first), target);
+ 
+     first = rak::transform_hex(buffer, bufferLast, first, last);
+ 
++    delete buffer;
++
+   } else if (m_flags & flag_escape_html) {
+-    char buffer[last - first];
++    char* buffer = new char[last - first];
+     char* bufferLast = copy_string(buffer, buffer + (last - first), target);
+ 
+     first = rak::copy_escape_html(buffer, bufferLast, first, last);
+ 
++    delete buffer;
++
+   } else {
+     first = copy_string(first, last, target);
+   }  
+--- rtorrent-0.8.2.orig/src/display/window.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window.h	2008-06-26 00:42:49.975992333 -0400
+@@ -41,6 +41,7 @@
+ #include <rak/functional.h>
+ 
+ #include "canvas.h"
++#include "manager.h"
+ #include "globals.h"
+ 
+ namespace display {
+--- rtorrent-0.8.2.orig/src/display/window_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_statusbar.cc	2008-06-25 03:15:15.445557476 -0400
+@@ -53,7 +53,7 @@
+   m_canvas->erase();
+ 
+   // TODO: Make a buffer with size = get_width?
+-  char buffer[m_canvas->width() + 1];
++  char* buffer = new char[m_canvas->width() + 1];
+   char* position;
+   char* last = buffer + m_canvas->width();
+ 
+@@ -68,6 +68,8 @@
+   }
+ 
+   m_lastTick = control->tick();
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/display/window_file_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_file_list.cc	2008-06-25 03:08:33.655012018 -0400
+@@ -84,7 +84,7 @@
+   if (fl->size_files() == 0 || m_canvas->height() < 2)
+     return;
+ 
+-  iterator entries[m_canvas->height() - 1];
++  iterator* entries = new iterator[m_canvas->height() - 1];
+ 
+   unsigned int last = 0;
+ 
+@@ -134,7 +134,7 @@
+       m_canvas->print(16 + itr.depth() - 1, pos, "/");
+ 
+     } else if (itr.is_file()) {
+-      char buffer[std::max<unsigned int>(m_canvas->width() + 1, 256)];
++      char* buffer = new char[std::max<unsigned int>(m_canvas->width() + 1, 256)];
+       Canvas::attributes_list attributes;
+ 
+       torrent::File* e = *itr;
+@@ -169,6 +169,8 @@
+ 
+       m_canvas->print_attributes(0, pos, buffer, buffer + std::strlen(buffer), &attributes);
+ 
++      delete buffer;
++
+     } else {
+       m_canvas->print(0, pos, "BORK BORK");
+     }
+@@ -179,6 +181,8 @@
+     pos++;
+     first = (first + 1) % (m_canvas->height() - 1);
+   }
++
++  delete entries;
+ }
+ 
+ int
+--- rtorrent-0.8.2.orig/src/display/window_log.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_log.cc	2008-06-25 03:13:37.195603865 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <ctime>
++#include <rak/algorithm.h>
+ 
+ #include "canvas.h"
+ #include "utils.h"
+--- rtorrent-0.8.2.orig/src/display/frame.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/frame.cc	2008-06-25 02:51:41.636803977 -0400
+@@ -41,6 +41,8 @@
+ #include <rak/algorithm.h>
+ #include <torrent/exceptions.h>
+ 
++#include "manager.h"
++
+ #include "frame.h"
+ #include "window.h"
+ 
+@@ -63,8 +65,8 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->is_width_dynamic())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->is_width_dynamic())
+         return true;
+ 
+     return false;
+@@ -81,8 +83,8 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->is_height_dynamic())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->is_height_dynamic())
+         return true;
+ 
+     return false;
+@@ -99,8 +101,8 @@
+   case TYPE_WINDOW: return m_window->is_active() && m_window->is_left();
+ 
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->has_left_frame())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->has_left_frame())
+         return true;
+ 
+     return false;
+@@ -117,8 +119,8 @@
+   case TYPE_WINDOW: return m_window->is_active() && m_window->is_bottom();
+ 
+   case TYPE_ROW:
+-    for (size_type i = 0; i < m_containerSize; ++i)
+-      if (m_container[i]->has_bottom_frame())
++    for (size_type i = 0; i < m_container.size; ++i)
++      if (m_container.frames[i]->has_bottom_frame())
+         return true;
+ 
+     return false;
+@@ -145,8 +147,8 @@
+     {
+       bounds_type accum(0, 0, 0, 0);
+ 
+-      for (size_type i = 0; i < m_containerSize; ++i) {
+-        bounds_type p = m_container[i]->preferred_size();
++      for (size_type i = 0; i < m_container.size; ++i) {
++        bounds_type p = m_container.frames[i]->preferred_size();
+  
+         accum.minWidth += p.minWidth;
+         accum.minHeight += p.minHeight;
+@@ -174,13 +176,13 @@
+   if ((m_type != TYPE_ROW && m_type != TYPE_COLUMN) || size >= max_size)
+     throw torrent::internal_error("Frame::set_container_size(...) Bad state.");
+ 
+-  while (m_containerSize > size) {
+-    delete m_container[--m_containerSize];
+-    m_container[m_containerSize] = NULL;
++  while (m_container.size > size) {
++    delete m_container.frames[--m_container.size];
++    m_container.frames[m_container.size] = NULL;
+   }
+ 
+-  while (m_containerSize < size) {
+-    m_container[m_containerSize++] = new Frame();
++  while (m_container.size < size) {
++    m_container.frames[m_container.size++] = new Frame();
+   }
+ }
+ 
+@@ -202,10 +204,10 @@
+     throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
+ 
+   m_type = TYPE_ROW;
+-  m_containerSize = size;
++  m_container.size = size;
+ 
+-  for (size_type i = 0; i < m_containerSize; ++i)
+-    m_container[i] = new Frame();
++  for (size_type i = 0; i < m_container.size; ++i)
++    m_container.frames[i] = new Frame();
+ }
+ 
+ void
+@@ -217,10 +219,10 @@
+     throw torrent::internal_error("Frame::initialize_container(...) size >= max_size.");
+ 
+   m_type = TYPE_COLUMN;
+-  m_containerSize = size;
++  m_container.size = size;
+ 
+-  for (size_type i = 0; i < m_containerSize; ++i)
+-    m_container[i] = new Frame();
++  for (size_type i = 0; i < m_container.size; ++i)
++    m_container.frames[i] = new Frame();
+ }
+ 
+ void
+@@ -234,9 +236,9 @@
+     
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (size_type i = 0; i < m_containerSize; ++i) {
+-      m_container[i]->clear();
+-      delete m_container[i];
++    for (size_type i = 0; i < m_container.size; ++i) {
++      m_container.frames[i]->clear();
++      delete m_container.frames[i];
+     }
+     break;
+ 
+@@ -261,7 +263,7 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
++    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
+       (*itr)->refresh();
+ 
+     break;
+@@ -282,7 +284,7 @@
+ 
+   case TYPE_ROW:
+   case TYPE_COLUMN:
+-    for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr)
++    for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr)
+       (*itr)->redraw();
+ 
+     break;
+@@ -343,7 +345,7 @@
+ 
+   int remaining = height;
+   
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     bounds_type bounds = (*itr)->preferred_size();
+     
+     if ((*itr)->is_height_dynamic()) {
+@@ -391,7 +393,7 @@
+   // the frame is too small, it will set the remaining windows to zero
+   // extent which will flag them as offscreen.
+ 
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     // If there is any remaining space, check if we want to shift
+     // the subsequent frames to the other side of this frame.
+     if (remaining > 0 && (*itr)->has_bottom_frame()) {
+@@ -417,7 +419,7 @@
+ 
+   int remaining = width;
+   
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     bounds_type bounds = (*itr)->preferred_size();
+     
+     if ((*itr)->is_width_dynamic()) {
+@@ -465,7 +469,7 @@
+   // the frame is too small, it will set the remaining windows to zero
+   // extent which will flag them as offscreen.
+ 
+-  for (Frame **itr = m_container, **last = m_container + m_containerSize; itr != last; ++itr) {
++  for (Frame **itr = m_container.frames, **last = m_container.frames + m_container.size; itr != last; ++itr) {
+     // If there is any remaining space, check if we want to shift
+     // the subsequent frames to the other side of this frame.
+     if (remaining > 0 && (*itr)->has_left_frame()) {
+--- rtorrent-0.8.2.orig/src/display/window_download_statusbar.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_download_statusbar.cc	2008-06-25 03:05:11.110750771 -0400
+@@ -61,7 +61,7 @@
+ 
+   m_canvas->erase();
+ 
+-  char buffer[m_canvas->width()];
++  char* buffer = new char[m_canvas->width()];
+   char* position;
+   char* last = buffer + m_canvas->width() - 2;
+ 
+@@ -88,6 +88,8 @@
+                   m_download->tracker_list()->has_active() ? 'C' : ' ',
+                   (int)(m_download->download()->tracker_list()->time_next_connection()),
+                   buffer);
++
++  delete buffer;
+ }
+ 
+ }
+--- rtorrent-0.8.2.orig/src/core/scheduler.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/scheduler.cc	2008-06-25 02:19:20.043037414 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <algorithm>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ #include <torrent/exceptions.h>
+ 
+--- rtorrent-0.8.2.orig/src/core/view.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/core/view.cc	2008-06-25 02:28:36.651635274 -0400
+@@ -38,6 +38,7 @@
+ 
+ #include <algorithm>
+ #include <functional>
++#include <rak/algorithm.h>
+ #include <rak/functional.h>
+ #include <rak/functional_fun.h>
+ #include <rpc/parse_commands.h>
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-06-25 01:44:38.134154000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-06-25 02:08:43.144712661 -0400
+@@ -352,19 +352,25 @@
+   int port;
+   rak::address_info* ai;
+ 
+-  char buf[addr.length() + 1];
++  char* buf = new char[addr.length() + 1];
+ 
+   int err = std::sscanf(addr.c_str(), "%[^:]:%i", buf, &port);
+ 
+-  if (err <= 0)
++  if (err <= 0) {
++    delete buf;
+     throw torrent::input_error("Could not parse proxy address.");
++  }
+ 
+   if (err == 1)
+     port = 80;
+ 
+-  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0)
++  if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0) {
++    delete buf;
+     throw torrent::input_error("Could not set proxy address: " + std::string(rak::address_info::strerror(err)) + ".");
+-  
++  }
++
++  delete buf;
++
+   try {
+ 
+     ai->address()->set_port(port);
+--- rtorrent-0.8.2.orig/src/rpc/parse.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/parse.cc	2008-06-25 17:30:55.775246860 -0400
+@@ -37,6 +37,7 @@
+ #include "config.h"
+ 
+ #include <locale>
++#include <rak/algorithm.h>
+ #include <rak/path.h>
+ #include <torrent/exceptions.h>
+ 
+--- rtorrent-0.8.2.orig/src/rpc/xmlrpc.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/xmlrpc.cc	2008-06-25 17:54:04.404987582 -0400
+@@ -477,7 +477,8 @@
+   xmlrpc_env_init(&localEnv);
+ 
+   xmlrpc_registry_add_method_w_doc(&localEnv, (xmlrpc_registry*)m_registry, NULL, name,
+-                                   &xmlrpc_call_command, const_cast<char*>(name), parm, doc);
++                                   (const xmlrpc_method)(&xmlrpc_call_command),
++				   const_cast<char*>(name), parm, doc);
+ 
+   if (localEnv.fault_occurred)
+     throw torrent::internal_error("Fault occured while inserting xmlrpc call.");
+--- rtorrent-0.8.2.orig/src/rpc/scgi.cc	2008-06-25 01:44:38.128033000 -0400
++++ rtorrent-0.8.2/src/rpc/scgi.cc	2008-06-25 17:32:13.998638901 -0400
+@@ -85,7 +85,7 @@
+   if (filename.empty() || filename.size() > 4096)
+     throw torrent::resource_error("Invalid filename length.");
+ 
+-  char buffer[sizeof(sockaddr_un) + filename.size()];
++  char* buffer = new char[sizeof(sockaddr_un) + filename.size()];
+   sockaddr_un* sa = reinterpret_cast<sockaddr_un*>(buffer);
+ 
+   sa->sun_family = AF_UNIX;
+@@ -96,6 +96,7 @@
+ 
+   open(sa, offsetof(struct sockaddr_un, sun_path) + filename.size() + 1);
+   m_path = filename;
++  delete buffer;
+ }
+ 
+ void
+--- rtorrent-0.8.2.orig/src/rpc/scgi_task.cc	2008-05-07 08:19:10.000000000 -0400
++++ rtorrent-0.8.2/src/rpc/scgi_task.cc	2008-06-25 17:41:41.493886588 -0400
+@@ -134,7 +134,7 @@
+     if (current == m_buffer || *current != ':' || headerSize < 17 || headerSize > max_header_size)
+       goto event_read_failed;
+ 
+-    if (std::distance(++current, m_position) < headerSize + 1)
++    if (m_position - (++current) < headerSize + 1)
+       return;
+ 
+     if (std::memcmp(current, "CONTENT_LENGTH", 15) != 0)
+@@ -147,7 +147,7 @@
+       goto event_read_failed;
+ 
+     m_body = current + headerSize + 1;
+-    headerSize = std::distance(m_buffer, m_body);
++    headerSize = m_body - m_buffer;
+ 
+     if ((unsigned int)(contentSize + headerSize) < m_bufferSize) {
+       m_bufferSize = contentSize + headerSize;
+@@ -155,26 +155,26 @@
+     } else if ((unsigned int)contentSize <= default_buffer_size) {
+       m_bufferSize = contentSize;
+ 
+-      std::memmove(m_buffer, m_body, std::distance(m_body, m_position));
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      std::memmove(m_buffer, m_body, m_position - m_body);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+ 
+     } else {
+-      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, std::distance(m_body, m_position));
++      realloc_buffer((m_bufferSize = contentSize) + 1, m_body, m_position - m_body);
+ 
+-      m_position = m_buffer + std::distance(m_body, m_position);
++      m_position = m_buffer + (m_position - m_body);
+       m_body = m_buffer;
+     }
+   }
+ 
+-  if ((unsigned int)std::distance(m_buffer, m_position) != m_bufferSize)
++  if ((unsigned int)(m_position - m_buffer) != m_bufferSize)
+     return;
+ 
+   control->poll()->remove_read(this);
+   control->poll()->insert_write(this);
+ 
+   // Close if the call failed, else stay open to write back data.
+-  if (!m_parent->receive_call(this, m_body, m_bufferSize - std::distance(m_buffer, m_body)))
++  if (!m_parent->receive_call(this, m_body, m_bufferSize - (m_body - m_buffer)))
+     close();
+ 
+   return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/rtorrent-05-sunpro-crash.patch	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,52 @@
+--- rtorrent-0.8.2.orig/src/ui/download_list.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/ui/download_list.cc	2008-06-27 21:16:40.822674954 -0400
+@@ -234,7 +234,7 @@
+ 
+   input::PathInput* input = new input::PathInput;
+ 
+-  const char* title;
++  std::string title;
+ 
+   switch (type) {
+   case INPUT_LOAD_DEFAULT:
+--- rtorrent-0.8.2.orig/src/display/window_input.cc	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_input.cc	2008-06-27 21:12:27.929764942 -0400
+@@ -43,6 +43,11 @@
+ 
+ namespace display {
+ 
++WindowInput::WindowInput() :
++  Window(new Canvas, 0, 0, 1, extent_full, 1),
++  m_input(NULL),
++  m_focus(false) {}
++
+ void
+ WindowInput::redraw() {
+   m_canvas->erase();
+--- rtorrent-0.8.2.orig/src/display/window_input.h	2008-05-07 08:19:11.000000000 -0400
++++ rtorrent-0.8.2/src/display/window_input.h	2008-06-27 20:40:35.526518241 -0400
+@@ -49,10 +49,7 @@
+ 
+ class WindowInput : public Window {
+ public:
+-  WindowInput() :
+-    Window(new Canvas, 0, 0, 1, extent_full, 1),
+-    m_input(NULL),
+-    m_focus(false) {}
++  WindowInput();
+ 
+   input::TextInput*   input()                            { return m_input; }
+   void                set_input(input::TextInput* input) { m_input = input; }
+--- rtorrent-0.8.2.orig/src/core/manager.cc	2008-06-26 00:37:03.743465000 -0400
++++ rtorrent-0.8.2/src/core/manager.cc	2008-06-26 22:13:52.331952728 -0400
+@@ -219,7 +219,9 @@
+   m_downloadList->slot_map_insert()["1_connect_logs"] = "d.initialize_logs=";
+   m_downloadList->slot_map_erase()["9_delete_tied"]   = "d.delete_tied=";
+ 
+-  torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
++  torrent::ConnectionManager::signal_handshake_type& s = torrent::connection_manager()->signal_handshake_log();
++  s.connect(sigc::mem_fun(this, &Manager::handshake_log));
++  //torrent::connection_manager()->set_signal_handshake_log(sigc::mem_fun(this, &Manager::handshake_log));
+ }
+ 
+ void
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/rtorrent.license	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,352 @@
+Oracle elects to use only the GNU Lesser General Public License version
+2.1 (LGPL)/GNU General Public License version 2 (GPL) for any software
+where a choice of LGPL/GPL license versions are made available with the
+language indicating that LGPLv2.1/GPLv2 or any later version may be
+used, or where a choice of which version of the LGPL/GPL is applied is
+unspecified.  Unless specifically stated otherwise, where a choice
+exists between another license and either the GPL or the LGPL, Oracle
+chooses the other license.
+====================================================================
+
+Copyright (C) 2005-2007, Jari Sundell <jaris (a] ifi.uio.no>
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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 2 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/rtorrent.p5m	Thu May 19 10:10:26 2011 -0700
@@ -0,0 +1,48 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+<transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
+
+set name=pkg.fmri value=pkg:/network/rtorrent@$(IPS_COMPONENT_VERSION),$(BUILD_VERSION)
+set name=pkg.summary value="rtorrent - a BitTorrent client for ncurses"
+set name=info.classification value="org.opensolaris.category.2008:Applications/Internet"
+set name=info.upstream_url value=$(COMPONENT_PROJECT_URL)
+set name=info.source_url value=$(COMPONENT_ARCHIVE_URL)
+set name=opensolaris.arc_url \
+    value=http://arc.opensolaris.org/caselog/PSARC/2009/336
+set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
+
+license rtorrent.license license='GPLv2'
+
+dir path=usr
+dir path=usr/bin
+dir path=usr/share
+dir path=usr/share/man
+dir path=usr/share/man/man1
+file path=usr/bin/rtorrent
+file path=usr/share/man/man1/rtorrent.1
+
+legacy pkg=SUNWrtorrent \
+    desc="rtorrent - a BitTorrent client for ncurses (0.8.2)" \
+    name=rtorrent
+