21849039 update libtorrent to 0.13.6
authorRich Burridge <rich.burridge@oracle.com>
Tue, 20 Sep 2016 05:30:15 -0700
changeset 6932 ae9e3811b2ec
parent 6931 f6f7269f85a9
child 6933 e1fa2aa7bad7
21849039 update libtorrent to 0.13.6 21849064 update rtorrent to 0.9.6
components/libtorrent/Makefile
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/libtorrent/patches/rlibtorrent-06-parfait.patch
components/libtorrent/patches/rlibtorrent-07-openssl.patch
components/libtorrent/patches/rlibtorrent-08-gcc.patch
components/rtorrent/Makefile
components/rtorrent/files/rtorrent.1
components/rtorrent/patches/001-directory.h.patch
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/patches/rtorrent-06-gcc.patch
components/rtorrent/rtorrent.license
components/rtorrent/rtorrent.p5m
--- a/components/libtorrent/Makefile	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/libtorrent/Makefile	Tue Sep 20 05:30:15 2016 -0700
@@ -27,14 +27,14 @@
 include ../../make-rules/shared-macros.mk
 
 COMPONENT_NAME=		libtorrent
-COMPONENT_VERSION=	0.12.2
-COMPONENT_PROJECT_URL=	http://libtorrent.rakshasa.no/
+COMPONENT_VERSION=	0.13.6
+COMPONENT_PROJECT_URL=	https://rakshasa.github.io/rtorrent/
 COMPONENT_ARCHIVE_HASH=	\
-    sha256:cf9d2cd667fd6939a3e0bd27e48d0c7f35d9ab2f7affbb3214da03fd2c1360a8
-COMPONENT_ARCHIVE_URL=	http://libtorrent.rakshasa.no/downloads/$(COMPONENT_ARCHIVE)
+    sha256:2838a08c96edfd936aff8fbf99ecbb930c2bfca3337dd1482eb5fccdb80d5a04
+COMPONENT_ARCHIVE_URL=	http://rtorrent.net/downloads/$(COMPONENT_ARCHIVE)
 COMPONENT_BUGDB=	utility/rtorrent
 
-TPNO=			9038
+TPNO=			24572
 
 TEST_TARGET= $(NO_TESTS)
 
@@ -50,26 +50,23 @@
 COMPONENT_PRE_CONFIGURE_ACTION = \
 	($(CLONEY) $(SOURCE_DIR) $(@D))
 
-# requires an older automake to reconfigure.
-COMPONENT_PREP_ACTION = \
-	(cd $(@D) ; ACLOCAL=aclocal-1.11 AUTOMAKE=automake-1.11 autoreconf -fiv)
+# Uses aclocal-1.14 by default, which we don't have.
+COMPONENT_PREP_ACTION = (cd $(@D) ; autoreconf -fiv)
 
 CXXFLAGS += -std=c++11
 
 CONFIGURE_OPTIONS  +=	--enable-shared
 CONFIGURE_OPTIONS  +=	--disable-debug
 CONFIGURE_OPTIONS  +=	--disable-static
-CONFIGURE_OPTIONS  +=	--with-ports
-CONFIGURE_OPTIONS  +=	--disable-libtool-lock
 CONFIGURE_OPTIONS  +=	--srcdir=$(BUILD_DIR_$(BITS))
 
 ASLR_MODE = $(ASLR_NOT_APPLICABLE)
 
-REQUIRED_PACKAGES += developer/build/automake-111
+REQUIRED_PACKAGES += developer/build/automake-115
 REQUIRED_PACKAGES += library/c++/sigcpp
 REQUIRED_PACKAGES += library/security/openssl
-REQUIRED_PACKAGES += system/library/c++-runtime
+REQUIRED_PACKAGES += library/security/openssl/openssl-fips-140
+REQUIRED_PACKAGES += library/zlib
 REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime
 REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime
 REQUIRED_PACKAGES += system/library/math
-
--- a/components/libtorrent/libtorrent.license	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/libtorrent/libtorrent.license	Tue Sep 20 05:30:15 2016 -0700
@@ -1,350 +1,349 @@
-"libtorrent/src/utils/sha_fast.{cc,h}" is 
-originally from the Mozilla NSS and is under a triple license; MPL, 
-LGPL and GPL. An exception to non-NSS code has been added for linking 
-to OpenSSL as requested by Debian, though the author considers that 
-library to be part of the Operative System and thus linking is allowed 
-according to the GPL. 
+"libtorrent/src/utils/sha_fast.{cc,h}" is
+originally from the Mozilla NSS and is under a triple license; MPL,
+LGPL and GPL. An exception to non-NSS code has been added for linking
+to OpenSSL as requested by Debian, though the author considers that
+library to be part of the Operative System and thus linking is allowed
+according to the GPL.
 
- Use whatever fits your purpose, the code required to compile with 
-Mozilla's NSS implementation of SHA1 has been retained and can be 
-compiled if the user wishes to avoid using OpenSSL.                  
+ Use whatever fits your purpose, the code required to compile with
+Mozilla's NSS implementation of SHA1 has been retained and can be
+compiled if the user wishes to avoid using OpenSSL.
 
-  GNU GENERAL PUBLIC LICENSE 
-                       Version 2, June 1991 
+                    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. 
+ 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 
+                            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. 
+  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. 
+  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. 
+  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. 
+  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. 
+  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. 
+  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. 
+  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 
+  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". 
+  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. 
+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. 
+  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.
 
-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: 
+  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. 
+    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. 
+    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.) 
+    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. 
+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. 
+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. 
+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: 
+  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, 
+    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, 
+    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.) 
+    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. 
+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. 
+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. 
+  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. 
+  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. 
+  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. 
+  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. 
+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. 
+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. 
+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. 
+  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. 
+  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. 
+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 
+  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. 
+  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. 
+  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 
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
 
-            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. 
+  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. 
+  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> 
+    <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 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. 
+    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 
+    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: 
+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. 
+    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. 
+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: 
+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. 
+  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 
+  <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. 
-
+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.
--- a/components/libtorrent/libtorrent.p5m	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/libtorrent/libtorrent.p5m	Tue Sep 20 05:30:15 2016 -0700
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 <transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
@@ -40,6 +40,8 @@
 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/chunk_utils.h
+file path=usr/include/torrent/data/download_data.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
@@ -49,14 +51,23 @@
 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/download/choke_group.h
+file path=usr/include/torrent/download/choke_queue.h
+file path=usr/include/torrent/download/download_manager.h
+file path=usr/include/torrent/download/group_entry.h
+file path=usr/include/torrent/download/resource_manager.h
+file path=usr/include/torrent/download_info.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_raw_bencode.h
+file path=usr/include/torrent/object_static_map.h
 file path=usr/include/torrent/object_stream.h
 file path=usr/include/torrent/path.h
+file path=usr/include/torrent/peer/choke_status.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
@@ -66,21 +77,30 @@
 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_controller.h
 file path=usr/include/torrent/tracker_list.h
-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
-file path=usr/lib/$(MACH64)/libtorrent.so.9.2.0
+file path=usr/include/torrent/utils/extents.h
+file path=usr/include/torrent/utils/log.h
+file path=usr/include/torrent/utils/log_buffer.h
+file path=usr/include/torrent/utils/net.h
+file path=usr/include/torrent/utils/option_strings.h
+file path=usr/include/torrent/utils/ranges.h
+file path=usr/include/torrent/utils/resume.h
+file path=usr/include/torrent/utils/signal_bitfield.h
+file path=usr/include/torrent/utils/thread_base.h
+file path=usr/include/torrent/utils/thread_interrupt.h
+link path=usr/lib/$(MACH64)/libtorrent.so target=libtorrent.so.19.0.0
+link path=usr/lib/$(MACH64)/libtorrent.so.19 target=libtorrent.so.19.0.0
+file path=usr/lib/$(MACH64)/libtorrent.so.19.0.0
 file path=usr/lib/$(MACH64)/pkgconfig/libtorrent.pc
-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
-file path=usr/lib/libtorrent.so.9.2.0
+link path=usr/lib/libtorrent.so target=libtorrent.so.19.0.0
+link path=usr/lib/libtorrent.so.19 target=libtorrent.so.19.0.0
+file path=usr/lib/libtorrent.so.19.0.0
 file path=usr/lib/pkgconfig/libtorrent.pc
 file libtorrent.3 path=usr/share/man/man3/libtorrent.3
 license libtorrent.license license=GPLv2
--- a/components/libtorrent/patches/rlibtorrent-01-madvise.patch	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/libtorrent/patches/rlibtorrent-01-madvise.patch	Tue Sep 20 05:30:15 2016 -0700
@@ -1,30 +1,28 @@
---- libtorrent-0.12.2.orig/src/data/memory_chunk.cc	(revision 1060)
-+++ libtorrent-0.12.2/src/data/memory_chunk.cc	(working copy)
[email protected]@ -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
[email protected]@ -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); }
-     ]],
+Changes needed to allow libtorrent to compile with g++ and the Solaris
+version of madvise.
+
+These changes should be sent upstream if they can be adjusted to an
+acceptable form.
+
+--- libtorrent-0.13.6/scripts/common.m4.orig	2016-09-15 17:07:33.144629366 +0000
++++ libtorrent-0.13.6/scripts/common.m4	2016-09-15 17:08:17.259446458 +0000
[email protected]@ -171,7 +171,7 @@
+   AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+       #include <sys/types.h>
+       #include <sys/mman.h>
+-        void f() { static char [email protected]<:@[email protected]:>@; madvise((void *)test, sizeof(test), MADV_NORMAL); }
++        void f() { static char [email protected]<:@[email protected]:>@; madvise((char *)test, sizeof(test), MADV_NORMAL); }
+       ])],
      [
        AC_MSG_RESULT(yes)
+--- libtorrent-0.13.6/src/data/memory_chunk.cc.orig	2016-09-15 17:08:59.127701605 +0000
++++ libtorrent-0.13.6/src/data/memory_chunk.cc	2016-09-15 17:24:27.343279729 +0000
[email protected]@ -45,7 +45,7 @@
+ #include "memory_chunk.h"
+ 
+ #ifdef __sun__
+-extern "C" int madvise(void *, size_t, int);
++extern "C" int madvise(caddr_t, size_t, int);
+ //#include <sys/mman.h>
+ //Should be the include line instead, but Solaris
+ //has an annoying bug wherein it doesn't declare
--- a/components/libtorrent/patches/rlibtorrent-02-event-ports.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,521 +0,0 @@
-# replaced -fvisibility=hidden with -template=no%extdef in CXXFLAGS.
-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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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 \
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
-+
-+}
---- libtorrent-0.12.2/scripts/attributes.m4	2008-05-07 05:19:12.000000000 -0700
-+++ libtorrent-0.12.2/scripts/attributes.m4	2015-01-29 08:45:29.333056494 -0800
[email protected]@ -62,7 +62,7 @@
-         AC_LANG_PUSH(C++)
- 
-         tmp_CXXFLAGS=$CXXFLAGS
--        CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
-+        CXXFLAGS="$CXXFLAGS -template=no%extdef"
- 
- 	AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))],
- 		[cc_cv_attribute_visibility],
[email protected]@ -78,7 +78,7 @@
- 
- 	if test "x$cc_cv_attribute_visibility" = "xyes"; then
- 		AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.])
--                CXXFLAGS="$CXXFLAGS -fvisibility=hidden"
-+                CXXFLAGS="$CXXFLAGS -template=no%extdef"
- 		$1
- 	else
-                 true
--- a/components/libtorrent/patches/rlibtorrent-03-dh-generate.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
---- 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
[email protected]@ -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) {
[email protected]@ -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
--- a/components/libtorrent/patches/rlibtorrent-04-sunpro.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,867 +0,0 @@
-# Remove Studio C++ 12.3 specific patch for
-# src/protocol/peer_connection_leech.cc.
---- 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
[email protected]@ -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();
[email protected]@ -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
[email protected]@ -42,6 +42,7 @@
- 
- #include <cstdlib>
- #include <string>
-+#include <algorithm>
- 
- namespace rak {
- 
[email protected]@ -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;
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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"
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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;
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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");
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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;
[email protected]@ -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
[email protected]@ -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();
- }
- 
[email protected]@ -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)) {
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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/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
[email protected]@ -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
[email protected]@ -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"
[email protected]@ -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;
-   }
- 
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -39,6 +39,7 @@
- #include <algorithm>
- #include <unistd.h>
- 
-+#include "rak/algorithm.h"
- #include "torrent/exceptions.h"
- #include "chunk_part.h"
- 
[email protected]@ -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
[email protected]@ -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"
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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"
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -39,6 +39,7 @@
- #include <iterator>
- #include <iostream>
- #include <rak/functional.h>
-+#include <rak/algorithm.h>
- 
- #include "utils/sha1.h"
- 
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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());
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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"
--- a/components/libtorrent/patches/rlibtorrent-05-tracker-usable.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
---- 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
[email protected]@ -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
[email protected]@ -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());
[email protected]@ -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
--- a/components/libtorrent/patches/rlibtorrent-06-parfait.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
---- libtorrent-0.12.2/rak/functional.h.orig	Mon Apr 29 10:51:44 2013
-+++ libtorrent-0.12.2/rak/functional.h	Mon Apr 29 10:51:54 2013
[email protected]@ -38,6 +38,7 @@
- #define RAK_FUNCTIONAL_H
- 
- #include <functional>
-+#include <stdio.h>
- 
- namespace rak {
- 
--- a/components/libtorrent/patches/rlibtorrent-07-openssl.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-# Internal patch.
-# Remove dependency on whether or not OPENSSL_NO_DEPRECATED
-# is raised or not.
-# Not for upstream. This version of libtorrent is much too old anyway.
---- libtorrent-0.12.2/src/utils/diffie_hellman.cc	2015-04-09 07:53:18.395899128 -0700
-+++ libtorrent-0.12.2/src/utils/diffie_hellman.cc	2015-04-09 07:59:11.807442371 -0700
[email protected]@ -100,7 +100,7 @@
- 			{
- 			BN_init(&local_prk);
- 			prk = &local_prk;
--			BN_with_flags(prk, priv_key, BN_FLG_EXP_CONSTTIME);
-+			BN_with_flags(prk, priv_key, BN_FLG_CONSTTIME);
- 			}
- 		else
- 			prk = priv_key;
--- a/components/libtorrent/patches/rlibtorrent-08-gcc.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-Changes for successful compilation on Solaris.  
-
-Evaluate to possibly send upstream
-
-
---- libtorrent-0.12.2/src/dht/dht_hash_map.h	2016-07-21 14:25:16.783986236 -0700
-+++ libtorrent-0.12.2/src/dht/dht_hash_map.h	2016-07-21 14:25:27.729767142 -0700
[email protected]@ -167,7 +167,7 @@
- 
- inline
- DhtNode* DhtNodeList::add_node(DhtNode* n) {
--  insert(std::make_pair<const HashString*, DhtNode*>(n, n));
-+  insert(std::pair<const HashString*, DhtNode*>(n, n));
-   return n;
- }
- 
---- libtorrent-0.12.2/src/torrent/data/block.h	2008-05-07 05:19:13.000000000 -0700
-+++ libtorrent-0.12.2/src/torrent/data/block.h	2016-07-21 14:22:47.000352058 -0700
[email protected]@ -37,6 +37,7 @@
- #ifndef LIBTORRENT_BLOCK_H
- #define LIBTORRENT_BLOCK_H
- 
-+#include <cstring>
- #include <vector>
- #include <torrent/common.h>
- #include <torrent/data/block_transfer.h>
---- libtorrent-0.12.2/src/torrent/exceptions.cc	2016-07-21 14:32:05.972670769 -0700
-+++ libtorrent-0.12.2/src/torrent/exceptions.cc	2016-07-21 14:32:23.871378484 -0700
[email protected]@ -37,6 +37,7 @@
- #include "config.h"
- 
- #include <cerrno>
-+#include <cstring>
- 
- #include "exceptions.h"
- 
---- libtorrent-0.12.2/src/torrent/object_stream.cc	2016-07-21 14:34:49.458499366 -0700
-+++ libtorrent-0.12.2/src/torrent/object_stream.cc	2016-07-21 14:35:46.590821537 -0700
[email protected]@ -38,6 +38,7 @@
- 
- #include <iterator>
- #include <iostream>
-+#include <cstring>
- #include <rak/functional.h>
- #include <rak/algorithm.h>
- 
---- libtorrent-0.12.2/src/data/chunk.cc	2016-07-21 14:36:43.901801737 -0700
-+++ libtorrent-0.12.2/src/data/chunk.cc	2016-07-21 14:37:40.676713436 -0700
[email protected]@ -38,6 +38,7 @@
- 
- #include <algorithm>
- #include <functional>
-+#include <cstring>
- 
- #include "torrent/exceptions.h"
- 
---- libtorrent-0.12.2/src/utils/diffie_hellman.cc	2016-07-21 14:41:11.573426007 -0700
-+++ libtorrent-0.12.2/src/utils/diffie_hellman.cc	2016-07-21 14:41:26.800532608 -0700
[email protected]@ -37,6 +37,7 @@
- #include "config.h"
- 
- #include <string>
-+#include <cstring>
- 
- #ifdef USE_OPENSSL
- #include <openssl/bn.h>
--- a/components/rtorrent/Makefile	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/rtorrent/Makefile	Tue Sep 20 05:30:15 2016 -0700
@@ -29,13 +29,13 @@
 include ../../make-rules/shared-macros.mk
 
 COMPONENT_NAME=		rtorrent
-COMPONENT_VERSION=	0.8.2
-COMPONENT_PROJECT_URL=	http://libtorrent.rakshasa.no/
+COMPONENT_VERSION=	0.9.6
+COMPONENT_PROJECT_URL=	https://rakshasa.github.io/rtorrent/
 COMPONENT_ARCHIVE_HASH=	\
-    sha256:76135a63869e43fa0392829bb45d94c0aa55e94350dddc272685ccfac1bbb2ed
-COMPONENT_ARCHIVE_URL=	http://libtorrent.rakshasa.no/downloads/$(COMPONENT_ARCHIVE)
+    sha256:1e69c24f1f26f8f07d58d673480dc392bfc4317818c1115265b08a7813ff5b0e
+COMPONENT_ARCHIVE_URL=	http://rtorrent.net/downloads/$(COMPONENT_ARCHIVE)
 
-TPNO=			8824
+TPNO=			24573
 
 TEST_TARGET= $(NO_TESTS)
 
@@ -51,15 +51,6 @@
 COMPONENT_PRE_CONFIGURE_ACTION = \
 	($(CLONEY) $(SOURCE_DIR) $(@D))
 
-# requires an older automake to reconfigure
-COMPONENT_PREP_ACTION = \
-        (cd $(@D) ; \
-	    aclocal-1.11 -I./scripts -I. ; \
-	    autoheader; \
-	    libtoolize --automake --copy --force; \
-	    automake-1.11; \
-	    autoconf )
-
 CXXFLAGS += -std=c++11
 
 LDFLAGS += -L$(GNULIB64) -R$(GNULIB64)
@@ -67,23 +58,26 @@
 LDFLAGS += -lnsl -lsocket
 endif
 
-CXXFLAGS +=	-I$(USRINCDIR)/ncurses
-CONFIGURE_OPTIONS.64 +=         --srcdir=$(BUILD_DIR_64)
-CONFIGURE_OPTIONS +=		--disable-debug
+CXXFLAGS +=		-I$(USRINCDIR)/ncurses
+CONFIGURE_OPTIONS.64 +=	--srcdir=$(BUILD_DIR_64)
+CONFIGURE_OPTIONS +=	--enable-shared
+CONFIGURE_OPTIONS +=	--disable-static
+CONFIGURE_OPTIONS +=	--disable-debug
 
 # Delete this when libtorrent is updated in the build servers
 LIBTORRENT_BASE = $(WS_COMPONENTS)/libtorrent/build/prototype/$(MACH)
-PKG_CONFIG_PATHS += $(LIBTORRENT_BASE)$(PKG_CONFIG_PATH.$(BITS)) 
-LD_OPTIONS += -L$(LIBTORRENT_BASE)$(USRLIB.$(BITS)) 
-CXXFLAGS += -I$(LIBTORRENT_BASE)$(USRINCDIR)/torrent 
-COMPONENT_BUILD_ENV += LD_LIBRARY_PATH_$(BITS)="$(LIBTORRENT_BASE)$(USRLIB.$(BITS))" 
+PKG_CONFIG_PATHS += $(LIBTORRENT_BASE)$(PKG_CONFIG_PATH.$(BITS))
+LD_OPTIONS += -L$(LIBTORRENT_BASE)$(USRLIB.$(BITS))
+CXXFLAGS += -I$(LIBTORRENT_BASE)$(USRINCDIR)
+CXXFLAGS += -I$(LIBTORRENT_BASE)$(USRINCDIR)/torrent
+CXXFLAGS += -I$(LIBTORRENT_BASE)$(USRINCDIR)/torrent/utils
+COMPONENT_BUILD_ENV += LD_LIBRARY_PATH_$(BITS)="$(LIBTORRENT_BASE)$(USRLIB.$(BITS))"
 #end Delete
 
-REQUIRED_PACKAGES += developer/build/automake-111
+REQUIRED_PACKAGES += developer/build/automake-115
 REQUIRED_PACKAGES += library/c++/sigcpp
 REQUIRED_PACKAGES += library/libtorrent
 REQUIRED_PACKAGES += library/ncurses
-REQUIRED_PACKAGES += system/library/c++-runtime
 REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime
 REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime
 REQUIRED_PACKAGES += system/library/math
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/files/rtorrent.1	Tue Sep 20 05:30:15 2016 -0700
@@ -0,0 +1,542 @@
+.\" This manpage has been automatically generated by docbook2man 
+.\" from a DocBook document.  This tool can be found at:
+.\" <http://shell.ipoline.com/~elmert/comp/docbook2X/> 
+.\" Please send any bug reports, improvements, comments, patches, 
+.\" etc. to Steve Cheng <[email protected]>.
+.TH "RTORRENT" "1" "07 May 2008" "BitTorrent client for ncurses" ""
+
+.SH NAME
+rtorrent \- a BitTorrent client for ncurses
+.SH SYNOPSIS
+
+\fBrtorrent\fR [ \fB-h\fR ] [ \fB-n\fR ] [ \fB-o key1=opt1,...\fR ] [ \fB-O key=opt\fR ] [ \fBURL | FILE\fR\fI ...\fR ]
+
+.SH "DESCRIPTION"
+.PP
+\fBrtorrent\fR is a BitTorrent client for ncurses, using
+the \fBlibtorrent\fR library. The client and library is
+written in C++ with emphasis on speed and efficiency, while delivering
+equivalent features to those found in GUI based clients in an ncurses
+client.
+.PP
+Most of the options below have their own default unit in addition to
+supporting B, K, M and G suffixes.
+.SH "KEYBOARD CONTROL"
+.PP
+.SS "GLOBAL KEYS"
+.TP
+\fB^q\fR
+Initiate shutdown, press again to force the shutdown and
+skip sending the stop signal to trackers.
+.TP
+\fBup | down | left | right arrow keys\fR
+.TP
+\fB^P | ^N | ^B | ^F\fR
+Select entries or change windows. The right arrow key or ^F is often
+used for viewing details about the selected entry, while the left
+arrow key or ^B often returns to the previous screen.
+.TP
+\fBa | s | d\fR
+Increase the upload throttle by 1/5/50 KB.
+.TP
+\fBA | S | D\fR
+Increase the download throttle by 1/5/50 KB.
+.TP
+\fBz | x | c\fR
+Decrease the upload throttle by 1/5/50 KB.
+.TP
+\fBZ | X | C\fR
+Decrease the download throttle by 1/5/50 KB.
+.SS "MAIN VIEW KEYS"
+.TP
+\fB->\fR
+View download.
+.TP
+\fB1 - 7\fR
+Change view.
+.TP
+\fB^S\fR
+Start download.
+.TP
+\fB^D\fR
+Stop an active download, or remove a stopped download.
+.TP
+\fB^K\fR
+Close a torrent and its files.
+.TP
+\fB^E\fR
+Set the 'create/resize queued' flags on all files in a torrent. This
+is necessary if the underlying files in a torrent have been deleted or
+truncated, and thus rtorrent must recreate them.
+.TP
+\fB^R\fR
+Initiate hash check of torrent.
+.TP
+\fB^O\fR
+Change the destination directory of the download. The torrent must be
+closed.
+.TP
+\fB^X\fR
+Call commands or change settings.
+.TP
+\fB^B\fR
+Set download to perform initial seeding. Only use when
+you are the first and only seeder so far for the download.
+.TP
+\fB+ | -\fR
+Change the priority of the download.
+.TP
+\fBbackspace\fR
+Add torrent using an URL or file path. Use
+\fBtab\fR to view directory content and do
+auto-complete.
+.TP
+\fBl\fR
+View log. Exit by pressing the space-bar.
+.TP
+\fBU\fR
+Delete the file the torrent is tied to, and clear the association.
+.TP
+\fBI\fR
+Toggle whether torrent ignores ratio settings.
+.SS "DOWNLOAD VIEW KEYS"
+.TP
+\fB->\fR
+View torrent file list. Use the space-bar to change the file priority
+and \fB*\fR to change the priority of all
+files. Use \fB/\fR to collapse the directories. OUTDATED
+.TP
+\fB1 | 2\fR
+Adjust max uploads.
+.TP
+\fB3 | 4\fR
+Adjust min peers.
+.TP
+\fB5 | 6\fR
+Adjust max peers.
+.TP
+\fBu\fR
+Display transfering blocks.
+.TP
+\fBi\fR
+Display chunk rarity.
+.TP
+\fBo\fR
+Display the tracker list. Cycle the trackers in a group with the
+space-bar.
+.TP
+\fBp\fR
+View peer and torrent information.
+.TP
+\fBt | T\fR
+Initiate tracker request. Use capital T to force the request, ignoring
+the "min interval" set by the tracker.
+.TP
+\fBk\fR
+Disconnect peer.
+.TP
+\fB*\fR
+Choke/Snub peer.
+.SH "OPTIONS"
+.TP
+\fB-b \fIa.b.c.d\fB\fR
+Bind listening socket and outgoing connections to this network
+interface address.
+.TP
+\fB-d \fIdirectory\fB\fR
+Set the default download directory. Defaults to "./".
+.TP
+\fB-h\fR
+Display help and exit.
+.TP
+\fB-i \fIa.b.c.d\fB\fR
+Set the address reported to the tracker.
+.TP
+\fB-n\fR
+Don't load ~/.rtorrent.rc on startup.
+.TP
+\fB-o key1=opt1,...\fR
+.TP
+\fB-O key=opt\fR
+Set any number of options, see the SETTINGS section. The options given
+here override the resource files. Use capital \fB-O\fR
+to allow comma in the option.
+.TP
+\fB-p \fIa-b\fB\fR
+Try to open a listening port in the range \fBa\fR up to
+and including \fBb\fR\&.
+.TP
+\fB-s \fIdirectory\fB\fR
+Session management will be enabled and the torrent files for all open
+downloads will be stored in this directory. Only one instance of
+rtorrent should be used with each session directory, though at the
+moment no locking is done. An empty string will disable the session
+directory.
+.SH "GENERAL SETTINGS"
+.PP
+.TP
+\fBbind = \fIa.b.c.d\fB\fR
+Bind listening socket and outgoing connections to this network
+interface address.
+.TP
+\fBip = \fIa.b.c.d\fB\fR
+.TP
+\fBip = \fIhostname\fB\fR
+Set the address reported to the tracker.
+.TP
+\fBport_range = \fIa-b\fB\fR
+Try to open a listening port in the range \fBa\fR up to
+and including \fBb\fR\&.
+.TP
+\fBport_random = \fIyes | no\fB\fR
+Open the listening port at a random position in the port range.
+.TP
+\fBcheck_hash = \fIyes | no\fB\fR
+Perform hash check on torrents that have finished downloading.
+.TP
+\fBdirectory = \fIdirectory\fB\fR
+Set the default download directory. Defaults to "./".
+.TP
+\fBsession = \fIdirectory\fB\fR
+Session management will be enabled and the torrent files for all open
+downloads will be stored in this directory. Only one instance of
+rtorrent can be used per session directory. An empty string will
+disable the session directory.
+.TP
+\fBhttp_proxy = \fIurl\fB\fR
+Use a http proxy. Use an empty string to disable.
+.TP
+\fBencoding_list = \fIencoding\fB\fR
+Add a preferred filename encoding to the list. The encodings are
+attempted in the order they are inserted, if none match the torrent
+default is used.
+.TP
+\fBencryption = \fIoption\fB,\fI\&...\fB\fR
+Set how rtorrent should deal with encrypted Bittorrent connections. By
+default, encryption is disabled, equivalent to specifying the option
+\fBnone\fR\&. Alternatively, any number of the following
+options may be specified:
+
+\fBallow_incoming\fR (allow incoming encrypted connections), 
+\fBtry_outgoing\fR (use encryption for outgoing connections),
+\fBrequire\fR (disable unencrypted handshakes), 
+\fBrequire_RC4\fR (also disable plaintext transmission after the
+initial encrypted handshake),
+\fBenable_retry\fR (if the initial outgoing connection fails, retry
+with encryption turned on if it was off or off if it was on), 
+\fBprefer_plaintext\fR (choose plaintext when peer offers a choice 
+between plaintext transmission and RC4 encryption, otherwise RC4 will be used).
+.TP
+\fBpeer_exchange = \fIyes | no\fB\fR
+Enable/disable peer exchange for torrents that aren't marked private. Disabled by default.
+.TP
+\fBschedule = \fIid\fB,\fIstart\fB,\fIinterval\fB,\fIcommand\fB\fR
+Call \fBcommand\fR every \fBinterval\fR
+seconds, starting from \fBstart\fR\&. An
+\fBinterval\fR of zero calls the task once, while a
+\fBstart\fR of zero calls it immediately. Currently
+\fBcommand\fR is forwarded to the option handler.
+\fBstart\fR and \fBinterval\fR may
+optionally use a time format, \fBdd:hh:mm:ss\fR\&. F.ex to
+start a task every day at \fB18:00\fR, use
+\fB18:00:00,24:00:00\fR\&.
+.TP
+\fBschedule_remove = \fIid\fB\fR
+Delete \fBid\fR from the scheduler.
+.TP
+\fBstart_tied =\fR
+Start torrents that are tied to filenames that have been re-added.
+.TP
+\fBstop_untied =\fR
+.TP
+\fBclose_untied =\fR
+.TP
+\fBremove_untied =\fR
+Stop, close or remove the torrents that are tied to filenames that
+have been deleted. Clear the association with the 'U' key.
+.TP
+\fBclose_low_diskspace = \fIspace\fB\fR
+Close any active torrents on filesystems with less than
+\fBspace\fR diskspace left. Use with
+the \fBschedule\fR option. A default scheduled event
+with id \fBlow_diskspace\fR is set to 500Mb.
+.TP
+\fBload = \fIfile\fB\fR
+.TP
+\fBload_verbose = \fIfile\fB\fR
+.TP
+\fBload_start = \fIfile\fB\fR
+.TP
+\fBload_start_verbose = \fIfile\fB\fR
+Load and possibly start a file, or possibly multiple files by using the
+wild-card "*". This is meant for use with
+\fBschedule\fR, though ensure that the
+\fBstart\fR is non-zero. The loaded file will be tied
+to the filename provided.
+.TP
+\fBimport = \fIfile\fB\fR
+.TP
+\fBtry_import = \fIfile\fB\fR
+Load a resource file. \fBtry_import\fR does not throw
+torrent::input_error exception on bad input.
+.TP
+\fBstop_on_ratio = \fImin_ratio\fB\fR
+.TP
+\fBstop_on_ratio = \fImin_ratio\fB,\fImin_upload\fB\fR
+.TP
+\fBstop_on_ratio = \fImin_ratio\fB,\fImin_upload\fB,\fImax_ratio\fB\fR
+Stop torrents when they reach the given upload ratio
+\fBmin_ratio\fR in percent. If the optional
+\fBmin_upload\fR is given, require a total
+upload amount of this many bytes as well. If the optional
+\fBmax_ratio\fR is given, stop the torrent
+when reaching this ratio regardless of the total upload
+amount. Exclude certain torrent by pressing 
+\fBShift+I\fR in the downlist list.
+Use with the \fBschedule\fR option.
+.TP
+\fBon_insert = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_erase = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_open = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_close = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_start = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_stop = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_hash_queued = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_hash_removed = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_hash_done = \fIid\fB,\fIcommand\fB\fR
+.TP
+\fBon_finished = \fIid\fB,\fIcommand\fB\fR
+Call a command on a download when its state changes. Only a subset of
+commands are available.
+.SH "THROTTLE SETTINGS"
+.TP
+\fBupload_rate = \fIKB\fB\fR
+.TP
+\fBdownload_rate = \fIKB\fB\fR
+Set the maximum global uploand and download rates.
+.TP
+\fBmin_peers = \fIvalue\fB\fR
+.TP
+\fBmax_peers = \fIvalue\fB\fR
+Set the minimum and maximum number of peers to allow in each download.
+.TP
+\fBmin_peers_seed = \fIvalue\fB\fR
+.TP
+\fBmax_peers_seed = \fIvalue\fB\fR
+Set the minimum nad maximum number of peers to allow while seeding, or
+-1 (default) to use max_peers.
+.TP
+\fBmax_uploads = \fIvalue\fB\fR
+Set the maximum number of simultaneous uploads per download.
+.TP
+\fBmax_uploads_div = \fIvalue\fB\fR
+.TP
+\fBmax_downloads_div = \fIvalue\fB\fR
+Change the divider used to calculate the max upload and download slots
+to use when the throttle is changed. Disable by
+setting \fB0\fR\&.
+.TP
+\fBmax_uploads_global = \fIvalue\fB\fR
+.TP
+\fBmax_downloads_global = \fIvalue\fB\fR
+Max upload and download slots allowed. Disable by
+setting \fB0\fR\&.
+.SH "TRACKER RELATED SETTINGS"
+.PP
+Tracker related settings.
+.TP
+\fBenable_trackers = \fIyes\fB\fR
+Set to \fBno\fR to disable all tracker requests. Useful
+for disabling rtorrent with the \fBschedule\fR command.
+.TP
+\fBtracker_dump = \fIfilename\fB\fR
+Dump tracker requests to \fBfilename\fR, disable by
+supplying an empty string. Only torrents loaded while
+\fBtracker_dump\fR contains a non-empty string will be
+logged at the moment, although disabling it will work as expected.
+.TP
+\fBtracker_numwant = \fInumber\fB\fR
+Set the numwant field sent to the tracker, which indicates how many
+peers we want. A negative value disables this feature.
+.TP
+\fBuse_udp_trackers = \fIyes\fB\fR
+Use UDP trackers. Disable if you are behind a firewall, etc, that does
+not allow connections to UDP trackers.
+.TP
+\fBdht = \fIdisabled|off|auto|on\fB\fR
+Support for querying the distributed hash table (DHT) to find peers for trackerless
+torrents or when all trackers are down. Set to \fBdisable\fR to completely
+disable DHT, \fBoff\fR (default) to enable DHT but to not start the
+DHT server, \fBauto\fR to automatically start and stop the DHT server
+as needed or \fBon\fR for permanently keeping the DHT server running.
+When set to automatic, the DHT server will start up when the first non-private torrent
+is started, and will stop 15-30 minutes after the last non-private torrent is
+stopped (or when rTorrent quits). For DHT to work, a session directory must be set (for
+saving the DHT cache).
+.TP
+\fBdht_port = \fInumber\fB\fR
+Set the UDP listen port for DHT. Defaults to 6881.
+.TP
+\fBdht_add_node = \fIhost[:port]\fB\fR
+Not intended for use in the configuration file but as one-time option in the
+client or on the command line to bootstrap an empty DHT node table. Contacts 
+the given node and attempts to bootstrap from it if it replies.
+The port is optional, with port 6881 being used by default.
+.TP
+\fBhttp_capath = \fIpath\fB\fR
+.TP
+\fBhttp_cacert = \fIfilename\fB\fR
+Set the certificates to use in http requests. See Curl's
+CURLOPT_CAPATH and CURLOPT_CAINFO options for further information.
+.SH "USER-INTERFACE SETTINGS"
+.PP
+Display related settings.
+.TP
+\fBview_add = \fIname\fB\fR
+Create a new view.
+.TP
+\fBview_sort = \fIname\fB\fR
+.TP
+\fBview_sort = \fIname\fB,\fIseconds\fB\fR
+Sort a view according the the criteria set by
+\fBview_sort_current\fR\&. If the optional argument is
+supplied, the view is not sorted if a change happened during the last
+\fBseconds\fR\&. This command is meant to be used with
+\fBschedule\fR\&.
+.TP
+\fBview_sort_new = \fIname\fB,\fI\&...\fB\fR
+.TP
+\fBview_sort_current = \fIname\fB,\fI\&...\fB\fR
+Set the sorting criteria for when new elements inserted or
+\fBview_sort\fR is called. The list can contain any
+number of criteria, including zero, from the following:
+
+\fBname\fR, \fBname_reverse\fR,
+\fBstopped\fR, \fBstarted\fR,
+\fBcomplete\fR, \fBincomplete\fR,
+\fBstate_changed\fR,
+\fBstate_changed_reverse\fR
+.TP
+\fBkey_layout = \fIqwerty|azerty|qwertz|dvorak\fB\fR
+Change the key-bindings.
+.SH "FILE-SYSTEM SETTINGS"
+.PP
+File-system related settings.
+.TP
+\fBmax_file_size = \fIsize\fB\fR
+Set the maximum size a file can have. Disable by
+passing \fB-1\fR\&.
+.TP
+\fBsplit_file_size = \fIsize\fB\fR
+Split files in a torrent larger than \fBsize\fR into
+seperate files. Disable by passing \fB-1\fR\&.
+.TP
+\fBsplit_suffix = \fIstring\fB\fR
+Set the suffix used on split files. Defaults
+to \fB\&.part\fR\&.
+.SH "DOWNLOAD SETTINGS"
+.PP
+Settings that require a download as a target, the options need to be
+called through f.ex \fBon_finished\fR\&.
+.TP
+\fBcreate_link = \fItype\fB,\fIpath\fB,\fIsuffix\fB\fR
+.TP
+\fBdelete_link = \fItype\fB,\fIpath\fB,\fIsuffix\fB\fR
+Create or delete a symbolic link. The link path is the concatenation
+of \fBpath\fR, the result of
+the \fBtype\fR on the download,
+and \fBsuffix\fR\&.
+
+Available types are; \fBbase_path\fR uses the base path
+of the download, \fBbase_filename\fR uses the base
+filename of the download, \fBtied\fR uses the path of
+the file the download is tied to, see \fBstart_tied\fR\&.
+.SH "ADVANCED SETTINGS"
+.PP
+This list contains settings users shouldn't need to touch, some may
+even cause crashes or similar if incorrectly set.
+.TP
+\fBhash_read_ahead = \fIMB\fB\fR
+Configure how far ahead we ask the kernel to read when doing hash
+checking. The hash checker uses madvise(..., MADV_WILLNEED) for the
+requests.
+.TP
+\fBhash_interval = \fIms\fB\fR
+Interval between attempts to check the hash when the chunk is not in
+memory, in milliseconds.
+.TP
+\fBhash_max_tries = \fItries\fB\fR
+Number of attempts to check the hash while using the mincore status,
+before forcing. Overworked systems might need lower values to get a
+decent hash checking rate.
+.TP
+\fBsafe_sync = \fIyes|no\fB\fR
+Always use MS_SYNC rather than MS_ASYNC when syncing chunks. This may
+be nessesary in case of filesystem bugs like NFS in linux ~2.6.13.
+.TP
+\fBmax_open_files = \fIvalue\fB\fR
+Number of files to simultaneously keep open. LibTorrent dynamically
+opens and closes files as necessary when mapping files to
+memory. Default is based on sysconf(_SC_OPEN_MAX).
+You probably only think you know what this option does, so don't touch
+it.
+.TP
+\fBmax_open_sockets = \fIvalue\fB\fR
+Number of network sockets to simultaneously keep open. This value is
+set to a reasonable value based on \fBsysconf(_SC_OPEN_MAX)\fR\&.
+.TP
+\fBmax_open_http = \fIvalue\fB\fR
+Number of sockets to simultaneously keep open. This value is set
+to \fB32\fR by default.
+.TP
+\fBmax_memory_usage = \fIbytes\fB\fR
+Set the max amount of memory space used to mapping file chunks. This
+may also be set using \fBulimit -m\fR where 3/4 will be
+allocated to file chunks.
+.TP
+\fBsend_buffer_size = \fIvalue\fB\fR
+.TP
+\fBreceive_buffer_size = \fIvalue\fB\fR
+Adjust the send and receive buffer size for socket.
+.TP
+\fBumask = \fI0022\fB\fR
+Set the umask for this process, which is applied to all files created
+by the program.
+.TP
+\fBcwd = \fIdirectory\fB\fR
+Changes the working directory of the process using
+\fBchdir\fR\&.
+.TP
+\fBsession_on_completion = \fIyes\fB\fR
+Controls if the session torrent is saved when a torrent finishes. By
+default on.
+.TP
+\fBsession_lock = \fIyes\fB\fR
+Controls if a lock file is created in the session directory on startup.
+.TP
+\fBsession_save = \fR
+Save the session files for all downloads.
+.TP
+\fBtos = \fIdefault|lowdelay|throughput|reliability|mincost\fB\fR
+.TP
+\fBtos = \fIhex\fB\fR
+Change the TOS of peer connections, by default set to
+\fBthroughput\fR\&. If the option is set to
+\fBdefault\fR then the system default TOS is used. A
+hex value may be used for non-standard settings.
+.TP
+\fBhandshake_log = \fIyes\fB\fR
+Enable logging of the peer handshake. This generates a large number of
+log messages, but may be useful to debug connection problems.
+.SH "AUTHORS"
+.PP
+
+Jari "Rakshasa" Sundell <[email protected]>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/rtorrent/patches/001-directory.h.patch	Tue Sep 20 05:30:15 2016 -0700
@@ -0,0 +1,39 @@
+Provide definitions that are missing on Solaris.
+
+This patch should be sent upstream.
+
+--- rtorrent-0.9.6/src/utils/directory.h.orig	2015-09-07 13:12:40.000000000 -0700
++++ rtorrent-0.9.6/src/utils/directory.h	2015-09-16 09:22:02.113830073 -0700
[email protected]@ -41,6 +41,32 @@
+ #include <vector>
+ #include <inttypes.h>
+ 
++#if defined(sun) || defined(__sun) || defined(__sun__)
++extern "C" {
++  enum
++  {
++    DT_UNKNOWN = 0,
++#define DT_UNKNOWN     DT_UNKNOWN
++    DT_FIFO = 1,
++#define DT_FIFO        DT_FIFO
++    DT_CHR = 2,
++#define DT_CHR         DT_CHR
++    DT_DIR = 4,
++#define DT_DIR         DT_DIR
++    DT_BLK = 6,
++#define DT_BLK         DT_BLK
++    DT_REG = 8,
++#define DT_REG         DT_REG
++    DT_LNK = 10,
++#define DT_LNK         DT_LNK
++    DT_SOCK = 12,
++#define DT_SOCK        DT_SOCK
++    DT_WHT = 14
++#define DT_WHT         DT_WHT
++  };
++};
++#endif
++
+ namespace utils {
+ 
+ struct directory_entry {
--- a/components/rtorrent/patches/rtorrent-01-solaris.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-# Removed Studio C++-specific patch for src/input/path_input.cc.
---- 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
[email protected]@ -37,6 +37,7 @@
- #include "config.h"
- 
- #include <ncurses.h>
-+#define NCURSES_ERR -1
- 
- #include "input_event.h"
- 
[email protected]@ -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-07 05:19:11.000000000 -0700
-+++ rtorrent-0.8.2/src/input/path_input.cc	2015-02-01 12:12:30.800473449 -0800
[email protected]@ -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"
- 
[email protected]@ -71,10 +72,13 @@
- }
- 
- 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 += '/';
-   }
-+  }
- };
- 
- void
[email protected]@ -109,7 +113,9 @@
-   mark_dirty();
- 
-   // Only emit if there are more than one option.
--  m_showNext = ++utils::Directory::iterator(r.first) != r.second;
-+  utils::Directory::iterator itr(r.first);
-+  ++itr;
-+  m_showNext = itr != r.second;
- 
-   if (m_showNext)
-     m_signalShowRange.emit(r.first, r.second);
- 
---- 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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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();
- 
--- a/components/rtorrent/patches/rtorrent-02-event-ports.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,222 +0,0 @@
-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
[email protected]@ -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
[email protected]@ -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"
- 
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
--- a/components/rtorrent/patches/rtorrent-03-curl-event.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,490 +0,0 @@
-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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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() {
[email protected]@ -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
[email protected]@ -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.
[email protected]@ -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; }
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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.
[email protected]@ -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
[email protected]@ -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.
[email protected]@ -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
[email protected]@ -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.
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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");
[email protected]@ -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
[email protected]@ -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;
[email protected]@ -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;
--- a/components/rtorrent/patches/rtorrent-04-sunpro.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,712 +0,0 @@
---- 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
[email protected]@ -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();
[email protected]@ -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
[email protected]@ -42,6 +42,7 @@
- 
- #include <cstdlib>
- #include <string>
-+#include <algorithm>
- 
- namespace rak {
- 
[email protected]@ -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;
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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;
- 
[email protected]@ -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
[email protected]@ -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));
[email protected]@ -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;
-   }
- 
[email protected]@ -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));
- 
[email protected]@ -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
[email protected]@ -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);
[email protected]@ -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
[email protected]@ -36,6 +36,7 @@
- 
- #include "config.h"
- 
-+#include <rak/algorithm.h>
- #include <rak/string_manip.h>
- 
- #include "rpc/parse_commands.h"
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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();
- 
[email protected]@ -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
[email protected]@ -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;
- 
[email protected]@ -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;
[email protected]@ -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");
-     }
[email protected]@ -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
[email protected]@ -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
[email protected]@ -41,6 +41,8 @@
- #include <rak/algorithm.h>
- #include <torrent/exceptions.h>
- 
-+#include "manager.h"
-+
- #include "frame.h"
- #include "window.h"
- 
[email protected]@ -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;
[email protected]@ -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;
[email protected]@ -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;
[email protected]@ -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;
[email protected]@ -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;
[email protected]@ -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();
-   }
- }
- 
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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;
- 
[email protected]@ -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;
[email protected]@ -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;
[email protected]@ -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()) {
[email protected]@ -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()) {
[email protected]@ -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()) {
[email protected]@ -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
[email protected]@ -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;
- 
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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;
[email protected]@ -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
[email protected]@ -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)
[email protected]@ -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;
[email protected]@ -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;
--- a/components/rtorrent/patches/rtorrent-05-sunpro-crash.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
---- 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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
[email protected]@ -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
--- a/components/rtorrent/patches/rtorrent-06-gcc.patch	Tue Sep 20 03:54:40 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-Changes for successful compilation on Solaris.
-
-Evaluate to possibly send upstream
-
---- rtorrent-0.8.2/src/rpc/parse.cc	2016-07-21 14:56:37.128876142 -0700
-+++ rtorrent-0.8.2/src/rpc/parse.cc	2016-07-21 14:56:47.788833146 -0700
[email protected]@ -37,6 +37,7 @@
- #include "config.h"
- 
- #include <locale>
-+#include <cstring>
- #include <rak/algorithm.h>
- #include <rak/path.h>
- #include <torrent/exceptions.h>
--- a/components/rtorrent/rtorrent.license	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/rtorrent/rtorrent.license	Tue Sep 20 05:30:15 2016 -0700
@@ -1,12 +1,12 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
+                    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
+     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
+                            Preamble
 
   The licenses for most software are designed to take away your
 freedom to share and change it.  By contrast, the GNU General Public
@@ -55,8 +55,8 @@
 
   The precise terms and conditions for copying, distribution and
 modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
+^L
+                    GNU GENERAL PUBLIC LICENSE
    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 
   0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@
     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.)
-
+^L
 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
@@ -168,7 +168,7 @@
 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.
-
+^L
   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
@@ -225,7 +225,7 @@
 
 This section is intended to make thoroughly clear what is believed to
 be a consequence of the rest of this License.
-
+^L
   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
@@ -255,7 +255,7 @@
 of preserving the free status of all derivatives of our free software and
 of promoting the sharing and reuse of software generally.
 
-			    NO WARRANTY
+                            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
@@ -277,9 +277,9 @@
 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
+                     END OF TERMS AND CONDITIONS
+^L
+            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
@@ -313,7 +313,7 @@
 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 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.
--- a/components/rtorrent/rtorrent.p5m	Tue Sep 20 03:54:40 2016 -0700
+++ b/components/rtorrent/rtorrent.p5m	Tue Sep 20 05:30:15 2016 -0700
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 <transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
@@ -33,6 +33,6 @@
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
 set name=org.opensolaris.arc-caseid value=PSARC/2009/336
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
-file path=usr/bin/rtorrent
-file path=usr/share/man/man1/rtorrent.1
+file path=usr/bin/rtorrent pkg.depend.bypass-generate=.*/libtorrent.*
+file files/rtorrent.1 path=usr/share/man/man1/rtorrent.1
 license rtorrent.license license=GPLv2