[
  {
    "path": ".gitignore",
    "content": "# Packages\r\n*.gz\r\n*.bz2\r\n*.xz\r\n*.7z\r\n*.zip\r\n*.tar\r\n\r\n# Extracted folders\r\naria2/*\r\njemalloc/*\r\nexpat-*/*\r\nsqlite-autoconf-*/*\r\nc-ares-*/*\r\nlibssh2-*/*\r\n\r\n# Test scripts\r\n*_test.*\r\n\r\n# Prerequisites\r\n*.d\r\n\r\n# Object files\r\n*.o\r\n*.ko\r\n*.obj\r\n*.elf\r\n\r\n# Linker output\r\n*.ilk\r\n*.map\r\n*.exp\r\n\r\n# Precompiled Headers\r\n*.gch\r\n*.pch\r\n\r\n# Libraries\r\n*.lib\r\n*.a\r\n*.la\r\n*.lo\r\n\r\n# Shared objects (inc. Windows DLLs)\r\n*.dll\r\n*.so\r\n*.so.*\r\n*.dylib\r\n\r\n# Executables\r\n*.exe\r\n*.out\r\n*.app\r\n*.i*86\r\n*.x86_64\r\n*.hex\r\n\r\n# Debug files\r\n*.dSYM/\r\n*.su\r\n*.idb\r\n*.pdb\r\n\r\n# Kernel Module Compile Results\r\n*.mod*\r\n*.cmd\r\n.tmp_versions/\r\nmodules.order\r\nModule.symvers\r\nMkfile.old\r\ndkms.conf"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "## Readme\naria2 build scripts for `msys2` with custom patches.\n\n### Build Status\n[![Build status](https://ci.appveyor.com/api/projects/status/fndjci8g5f71gf6l?svg=true)](https://ci.appveyor.com/project/myfreeer/aria2-build-msys2)\n\n### License\n[![GitHub license](https://img.shields.io/github/license/myfreeer/aria2-build-msys2.svg)](LICENSE) \n\n### Changes\n* option `max-connection-per-server`: change maximum value to `*`, default value to `16`\n* option `min-split-size`: change minimum value to `1K`, default value to `1M`\n* option `piece-length`: change minimum value to `1K`, default value to `1M`\n* option `connect-timeout`: change default value to `30`\n* option `split`: change default value to `128`\n* option `continue`: change default value to `true`\n* option `retry-wait`: change default value to `1`\n* option `max-concurrent-downloads`: change default value to `16`\n* option `netrc-path` `conf-path` `dht-file-path` `dht-file-path6`: change default value to sub-folder of current directory\n* option `deamon`: make use of it on mingw\n* download: retry on slow speed and connection close\n* download: add option `retry-on-400` to retry on http 400 bad request, which only effective if retry-wait > 0\n* download: add option `retry-on-403` to retry on http 403 forbidden, which only effective if retry-wait > 0\n* download: add option `retry-on-406` to retry on http 406 not acceptable, which only effective if retry-wait > 0\n* ~~http: add option `http-want-digest` to choose whether to send the generated `Want-Digest` HTTP header or not ([#10](https://github.com/myfreeer/aria2-build-msys2/issues/10))~~\n    * Removed in favor of upstream [`no-want-digest-header`](https://aria2.github.io/manual/en/html/aria2c.html#cmdoption-no-want-digest-header) option after [release-1.37.0](https://github.com/aria2/aria2/releases/tag/release-1.37.0) by commit [839dd2ca](https://github.com/aria2/aria2/commit/839dd2caf77863503d18252a1aff16cd1dde274c) \n\n### Environment \n[MSYS2](http://www.msys2.org/)\nShould be set up with commands below:\n```sh\npacman -Syyuu --noconfirm\npacman -Su --noconfirm\npacman -S --noconfirm --needed base-devel zlib-devel sqlite git unzip zip tar gmp gmp-devel libssh2 libssh2-devel openssl-devel\n```\n\n### Artifacts\n* x86_64 (64-bits) version: [![aria2c.7z](https://img.shields.io/badge/download-aria2c.7z-brightgreen.svg)](https://ci.appveyor.com/api/projects/myfreeer/aria2-build-msys2/artifacts/aria2c.7z)\n* x86 (32-bits) version: [![aria2c_x86.7z](https://img.shields.io/badge/download-aria2c_x86.7z-brightgreen.svg)](https://ci.appveyor.com/api/projects/myfreeer/aria2-build-msys2/artifacts/aria2c_x86.7z)\n\n### Credits\n* https://github.com/aria2/aria2\n* https://gist.github.com/zhangyubaka/fb56f6bf9be50dbd28e64809cdc659be\n* https://github.com/jb-alvarado/media-autobuild_suite\n"
  },
  {
    "path": "appveyor.yml",
    "content": "version: 1.37.0-{build}\nskip_tags: true\ninstall:\n- ps: >-\n    $gitData = ConvertFrom-StringData (git log -1 --format=format:\"commitId=%H%nmessage=%s%ncommitted=%aD\" | out-string)\n\n    if ($gitData['message'] -eq \"\") { $gitData['message'] = \"No commit message available for $($gitData['commitid'])\" }\n\n    # View the data with Write-Output @gitData\n\n    Update-AppveyorBuild @gitData\nbuild_script:\n- cmd: >-\n    C:\\msys64\\usr\\bin\\pacman -S --noconfirm --needed --ask=20 base-devel git unzip zip tar\n\n    set MSYSTEM=MINGW64\n\n    C:\\msys64\\usr\\bin\\bash -lc \"cd \\\"$APPVEYOR_BUILD_FOLDER\\\" && exec ./build-aria2.sh\"\n\n    7z a aria2c.7z .\\aria2\\src\\aria2c.exe\n\n    appveyor PushArtifact aria2c.7z\n\n    rd /s /q aria2\n\n    set MSYSTEM=MINGW32\n\n    C:\\msys64\\usr\\bin\\bash -lc \"cd \\\"$APPVEYOR_BUILD_FOLDER\\\" && exec ./build-aria2.sh\"\n\n    7z a aria2c_x86.7z .\\aria2\\src\\aria2c.exe\n\n    appveyor PushArtifact aria2c_x86.7z\ntest: off\nskip_commits:\n  files:\n    - 'LICENSE'\n    - '*.md'\n    - '.gitingore'\n"
  },
  {
    "path": "aria2-0001-options-change-default-path-to-current-dir.patch",
    "content": "From c33446e390e8d4fc79d69031d391eaf12dce1766 Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Tue, 5 Jun 2018 16:49:07 +0800\nSubject: [PATCH 1/4] options: change default path to current dir\n\nand try to load config files in current dir if exists\n---\n src/OptionHandlerFactory.cc |  2 +-\n src/OptionHandlerImpl.cc    |  2 +-\n src/util.cc                 | 14 ++++++++++----\n 3 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc\nindex 3d76d33..cd00881 100644\n--- a/src/OptionHandlerFactory.cc\n+++ b/src/OptionHandlerFactory.cc\n@@ -1276,7 +1276,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(new LocalFilePathOptionHandler(\n-        PREF_NETRC_PATH, TEXT_NETRC_PATH, util::getHomeDir() + \"/.netrc\",\n+        PREF_NETRC_PATH, TEXT_NETRC_PATH, File::getCurrentDir() + \"/.netrc\",\n         /* acceptStdin = */ false, 0, /* mustExist = */ false));\n     handlers.push_back(op);\n   }\ndiff --git a/src/OptionHandlerImpl.cc b/src/OptionHandlerImpl.cc\nindex 6214e84..7f89226 100644\n--- a/src/OptionHandlerImpl.cc\n+++ b/src/OptionHandlerImpl.cc\n@@ -548,7 +548,7 @@ void LocalFilePathOptionHandler::parseArg(Option& option,\n     option.put(pref_, DEV_STDIN);\n   }\n   else {\n-    auto path = util::replace(optarg, \"${HOME}\", util::getHomeDir());\n+    auto path = util::replace(optarg, \"${HOME}\", File::getCurrentDir());\n     if (mustExist_) {\n       File f(path);\n       std::string err;\ndiff --git a/src/util.cc b/src/util.cc\nindex 2e700de..cc2531d 100644\n--- a/src/util.cc\n+++ b/src/util.cc\n@@ -1805,9 +1805,12 @@ std::string getXDGDir(const std::string& environmentVariable,\n \n std::string getConfigFile()\n {\n-  std::string filename = getHomeDir() + \"/.aria2/aria2.conf\";\n+  std::string filename = File::getCurrentDir() + \"/.aria2/aria2.conf\";\n   if (!File(filename).exists()) {\n-    filename = getXDGDir(\"XDG_CONFIG_HOME\", getHomeDir() + \"/.config\") +\n+    filename = File::getCurrentDir() + \"/aria2.conf\";\n+  }\n+  if (!File(filename).exists()) {\n+    filename = getXDGDir(\"XDG_CONFIG_HOME\", File::getCurrentDir() + \"/.config\") +\n                \"/aria2/aria2.conf\";\n   }\n   return filename;\n@@ -1816,9 +1819,12 @@ std::string getConfigFile()\n std::string getDHTFile(bool ipv6)\n {\n   std::string filename =\n-      getHomeDir() + (ipv6 ? \"/.aria2/dht6.dat\" : \"/.aria2/dht.dat\");\n+      File::getCurrentDir() + (ipv6 ? \"/.aria2/dht6.dat\" : \"/.aria2/dht.dat\");\n+  if (!File(filename).exists()) {\n+    filename = File::getCurrentDir() + (ipv6 ? \"/dht6.dat\" : \"/dht.dat\");\n+  }\n   if (!File(filename).exists()) {\n-    filename = getXDGDir(\"XDG_CACHE_HOME\", getHomeDir() + \"/.cache\") +\n+    filename = getXDGDir(\"XDG_CACHE_HOME\", File::getCurrentDir() + \"/.cache\") +\n                (ipv6 ? \"/aria2/dht6.dat\" : \"/aria2/dht.dat\");\n   }\n   return filename;\n-- \n2.17.1\n\n"
  },
  {
    "path": "aria2-0002-options-unlock-connection-per-server-limit.patch",
    "content": "From 733fa35774821b7c955a9f018d43de570aa98d17 Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Mon, 29 May 2017 22:11:33 +0800\nSubject: [PATCH 2/4] options: unlock connection-per-server limit\n\n---\n src/OptionHandlerFactory.cc | 16 ++++++++--------\n 1 file changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc\nindex cd00881..5768f7b 100644\n--- a/src/OptionHandlerFactory.cc\n+++ b/src/OptionHandlerFactory.cc\n@@ -158,7 +158,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(new BooleanOptionHandler(\n-        PREF_CONTINUE, TEXT_CONTINUE, A2_V_FALSE, OptionHandler::OPT_ARG, 'c'));\n+        PREF_CONTINUE, TEXT_CONTINUE, A2_V_TRUE, OptionHandler::OPT_ARG, 'c'));\n     op->addTag(TAG_BASIC);\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n@@ -432,7 +432,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   {\n     OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONCURRENT_DOWNLOADS,\n                                               TEXT_MAX_CONCURRENT_DOWNLOADS,\n-                                              \"5\", 1, -1, 'j'));\n+                                              \"16\", 1, -1, 'j'));\n     op->addTag(TAG_BASIC);\n     op->setChangeGlobalOption(true);\n     handlers.push_back(op);\n@@ -440,7 +440,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   {\n     OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONNECTION_PER_SERVER,\n                                               TEXT_MAX_CONNECTION_PER_SERVER,\n-                                              \"1\", 1, 16, 'x'));\n+                                              \"16\", 1, -1, 'x'));\n     op->addTag(TAG_BASIC);\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n@@ -501,7 +501,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(new UnitNumberOptionHandler(\n-        PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, \"20M\", 1_m, 1_g, 'k'));\n+        PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, \"1M\", 1_k, 1_g, 'k'));\n     op->addTag(TAG_BASIC);\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n@@ -834,7 +834,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(new NumberOptionHandler(\n-        PREF_CONNECT_TIMEOUT, TEXT_CONNECT_TIMEOUT, \"60\", 1, 600));\n+        PREF_CONNECT_TIMEOUT, TEXT_CONNECT_TIMEOUT, \"30\", 1, 600));\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n     op->setInitialOption(true);\n@@ -905,7 +905,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(new UnitNumberOptionHandler(\n-        PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, \"1M\", 1_m, 1_g));\n+        PREF_PIECE_LENGTH, TEXT_PIECE_LENGTH, \"1M\", 1_k, 1_g));\n     op->addTag(TAG_ADVANCED);\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n@@ -926,7 +926,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(\n-        new NumberOptionHandler(PREF_RETRY_WAIT, TEXT_RETRY_WAIT, \"0\", 0, 600));\n+        new NumberOptionHandler(PREF_RETRY_WAIT, TEXT_RETRY_WAIT, \"1\", 0, 600));\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n     op->setInitialOption(true);\n@@ -971,7 +971,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n   }\n   {\n     OptionHandler* op(\n-        new NumberOptionHandler(PREF_SPLIT, TEXT_SPLIT, \"5\", 1, -1, 's'));\n+        new NumberOptionHandler(PREF_SPLIT, TEXT_SPLIT, \"128\", 1, -1, 's'));\n     op->addTag(TAG_BASIC);\n     op->addTag(TAG_FTP);\n     op->addTag(TAG_HTTP);\n-- \n2.17.1\n\n"
  },
  {
    "path": "aria2-0003-download-retry-on-slow-speed-and-reset.patch",
    "content": "From 66524bee738e98742c908d93c993d0a78a2d9891 Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Sat, 18 Nov 2017 11:55:04 +0800\nSubject: [PATCH 3/4] download: retry on slow speed and conection close\n\nThis would provide better speed on bad network conditions\n---\n src/DownloadCommand.cc | 2 +-\n src/SocketBuffer.cc    | 3 ++-\n src/SocketCore.cc      | 2 +-\n 3 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc\nindex 2db41e4..f49eb80 100644\n--- a/src/DownloadCommand.cc\n+++ b/src/DownloadCommand.cc\n@@ -306,7 +306,7 @@ void DownloadCommand::checkLowestDownloadSpeed() const\n           startupIdleTime_) {\n     int nowSpeed = peerStat_->calculateDownloadSpeed();\n     if (nowSpeed <= lowestDownloadSpeedLimit_) {\n-      throw DL_ABORT_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,\n+      throw DL_RETRY_EX2(fmt(EX_TOO_SLOW_DOWNLOAD_SPEED, nowSpeed,\n                              lowestDownloadSpeedLimit_,\n                              getRequest()->getHost().c_str()),\n                          error_code::TOO_SLOW_DOWNLOAD_SPEED);\ndiff --git a/src/SocketBuffer.cc b/src/SocketBuffer.cc\nindex 62862ff..1906173 100644\n--- a/src/SocketBuffer.cc\n+++ b/src/SocketBuffer.cc\n@@ -39,6 +39,7 @@\n \n #include \"SocketCore.h\"\n #include \"DlAbortEx.h\"\n+#include \"DlRetryEx.h\"\n #include \"message.h\"\n #include \"fmt.h\"\n #include \"LogFactory.h\"\n@@ -158,7 +159,7 @@ ssize_t SocketBuffer::send()\n     }\n     ssize_t slen = socket_->writeVector(iov, num);\n     if (slen == 0 && !socket_->wantRead() && !socket_->wantWrite()) {\n-      throw DL_ABORT_EX(fmt(EX_SOCKET_SEND, \"Connection closed.\"));\n+      throw DL_RETRY_EX(fmt(EX_SOCKET_SEND, \"Connection closed.\"));\n     }\n     // A2_LOG_NOTICE(fmt(\"num=%zu, amount=%d, bufq.size()=%zu, SEND=%d\",\n     //                   num, amount, bufq_.size(), slen));\ndiff --git a/src/SocketCore.cc b/src/SocketCore.cc\nindex 77dc30c..537375a 100644\n--- a/src/SocketCore.cc\n+++ b/src/SocketCore.cc\n@@ -1009,7 +1009,7 @@ bool SocketCore::tlsHandshake(TLSContext* tlsctx, const std::string& hostname)\n \n     if (rv == TLS_ERR_ERROR) {\n       // Damn those error.\n-      throw DL_ABORT_EX(fmt(\"SSL/TLS handshake failure: %s\",\n+      throw DL_RETRY_EX(fmt(\"SSL/TLS handshake failure: %s\",\n                             handshakeError.empty()\n                                 ? tlsSession_->getLastErrorString().c_str()\n                                 : handshakeError.c_str()));\n-- \n2.17.1\n\n"
  },
  {
    "path": "aria2-0004-option_processing-make-use-of-deamon-on-mingw.patch",
    "content": "From 26816f5deb196c7000244b56edd55b17385381db Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Sat, 9 Jun 2018 15:24:29 +0800\nSubject: [PATCH 4/4] option_processing: make use of --deamon on mingw\n\n---\n src/option_processing.cc | 17 +++++++++++++++++\n 1 file changed, 17 insertions(+)\n\ndiff --git a/src/option_processing.cc b/src/option_processing.cc\nindex f9891fe..3952ed6 100644\n--- a/src/option_processing.cc\n+++ b/src/option_processing.cc\n@@ -319,6 +319,22 @@ error_code::Value option_processing(Option& op, bool standalone,\n     }\n   }\n   if (standalone && op.getAsBool(PREF_DAEMON)) {\n+#ifdef __MINGW32__\n+    std::wstring daemonCmdLine = GetCommandLineW();\n+    daemonCmdLine.append(L\" --daemon=false\");\n+    STARTUPINFOW si = {};\n+    PROCESS_INFORMATION pi = {};\n+    si.dwFlags = STARTF_USESHOWWINDOW;\n+    si.wShowWindow = FALSE;\n+    BOOL bRet = CreateProcessW(\n+      NULL, const_cast<LPWSTR>(daemonCmdLine.c_str()), NULL, NULL,\n+      FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);\n+    if (bRet) {\n+      CloseHandle(pi.hThread);\n+      CloseHandle(pi.hProcess);\n+      ExitProcess(0);\n+    }\n+#else // !__MINGW32__\n #if defined(__GNUC__) && defined(__APPLE__)\n // daemon() is deprecated on OSX since... forever.\n // Silence the warning for good, so that -Werror becomes feasible.\n@@ -334,6 +350,7 @@ error_code::Value option_processing(Option& op, bool standalone,\n       perror(MSG_DAEMON_FAILED);\n       return error_code::UNKNOWN_ERROR;\n     }\n+#endif // __MINGW32__\n   }\n   if (op.getAsBool(PREF_DEFERRED_INPUT) && op.defined(PREF_SAVE_SESSION)) {\n     A2_LOG_WARN(\"--deferred-input is disabled because of the presence of \"\n-- \n2.17.1\n\n"
  },
  {
    "path": "aria2-0005-option-add-option-to-retry-on-http-4xx.patch",
    "content": "From 8adbc01dc5975a64c55fe594d8c758c71e8183b3 Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Sun, 22 Jul 2018 19:59:02 +0800\nSubject: [PATCH] option: add option to retry on http 400, 403, 406, or unknown\n\n --retry-on-400[=true|false]  Configure whether retry or not when\n                              HTTP server returns 400 Bad Request.\n                              Only effective if retry-wait > 0.\n\n                              Possible Values: true, false\n                              Default: false\n                              Tags: #advanced, #http\n\n --retry-on-403[=true|false]  Configure whether retry or not when\n                              HTTP server returns 403 Forbidden.\n                              Only effective if retry-wait > 0.\n\n                              Possible Values: true, false\n                              Default: false\n                              Tags: #advanced, #http\n\n --retry-on-406[=true|false]  Configure whether retry or not when\n                              HTTP server returns 406 Not Acceptable.\n                              Only effective if retry-wait > 0.\n\n                              Possible Values: true, false\n                              Default: false\n                              Tags: #advanced, #http\n\n --retry-on-unknown[=true|false] Configure whether retry or not when\n                              HTTP server returns unknown status code.\n                              Only effective if retry-wait > 0.\n\n                              Possible Values: true, false\n                              Default: false\n                              Tags: #advanced, #http\n---\n src/HttpSkipResponseCommand.cc | 42 +++++++++++++++++++++++++++++-----\n src/OptionHandlerFactory.cc    | 40 ++++++++++++++++++++++++++++++++\n src/prefs.cc                   |  8 +++++++\n src/prefs.h                    |  8 +++++++\n src/usage_text.h               | 16 +++++++++++++\n 5 files changed, 108 insertions(+), 6 deletions(-)\n\ndiff --git a/src/HttpSkipResponseCommand.cc b/src/HttpSkipResponseCommand.cc\nindex a722d77..de4ad6c 100644\n--- a/src/HttpSkipResponseCommand.cc\n+++ b/src/HttpSkipResponseCommand.cc\n@@ -204,7 +204,7 @@ bool HttpSkipResponseCommand::processResponse()\n   auto statusCode = httpResponse_->getStatusCode();\n   if (statusCode >= 400) {\n     switch (statusCode) {\n-    case 401:\n+    case 401: // Unauthorized\n       if (getOption()->getAsBool(PREF_HTTP_AUTH_CHALLENGE) &&\n           !httpResponse_->getHttpRequest()->authenticationUsed() &&\n           getDownloadEngine()->getAuthConfigFactory()->activateBasicCred(\n@@ -213,15 +213,41 @@ bool HttpSkipResponseCommand::processResponse()\n         return prepareForRetry(0);\n       }\n       throw DL_ABORT_EX2(EX_AUTH_FAILED, error_code::HTTP_AUTH_FAILED);\n-    case 404:\n+    case 404: // Not Found\n       if (getOption()->getAsInt(PREF_MAX_FILE_NOT_FOUND) == 0) {\n         throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,\n                            error_code::RESOURCE_NOT_FOUND);\n       }\n       throw DL_RETRY_EX2(MSG_RESOURCE_NOT_FOUND,\n                          error_code::RESOURCE_NOT_FOUND);\n-    case 502:\n-    case 503:\n+    case 400: // Bad Request\n+      if (getOption()->getAsBool(PREF_RETRY_ON_400)\n+          && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {\n+        throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),\n+                          error_code::HTTP_PROTOCOL_ERROR);\n+      }\n+      break;\n+    case 403: // Forbidden\n+      if (getOption()->getAsBool(PREF_RETRY_ON_403)\n+          && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {\n+        throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),\n+                          error_code::HTTP_PROTOCOL_ERROR);\n+      }\n+      break;\n+    case 406: // Not Acceptable\n+      if (getOption()->getAsBool(PREF_RETRY_ON_406)\n+          && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {\n+        throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),\n+                          error_code::HTTP_PROTOCOL_ERROR);\n+      }\n+      break;\n+    case 408: // Request Timeout\n+    case 429: // Too Many Requests\n+    case 502: // Bad Gateway\n+    case 503: // Service Unavailable\n+    case 507: // Insufficient Storage\n+    case 520: // https://github.com/aria2/aria2/issues/1229\n+    case 521: // https://github.com/aria2/aria2/issues/1229\n       // Only retry if pretry-wait > 0. Hammering 'busy' server is not\n       // a good idea.\n       if (getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {\n@@ -230,12 +256,16 @@ bool HttpSkipResponseCommand::processResponse()\n       }\n       throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),\n                          error_code::HTTP_SERVICE_UNAVAILABLE);\n-    case 504:\n+    case 504: // Gateway Timeout\n       // This is Gateway Timeout, so try again\n       throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),\n                          error_code::HTTP_SERVICE_UNAVAILABLE);\n     };\n-\n+    if (getOption()->getAsBool(PREF_RETRY_ON_UNKNOWN)\n+        && getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {\n+      throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),\n+                        error_code::HTTP_PROTOCOL_ERROR);\n+    }\n     throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),\n                        error_code::HTTP_PROTOCOL_ERROR);\n   }\ndiff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc\nindex 5768f7b..decb03e 100644\n--- a/src/OptionHandlerFactory.cc\n+++ b/src/OptionHandlerFactory.cc\n@@ -934,6 +934,46 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()\n     op->setChangeOptionForReserved(true);\n     handlers.push_back(op);\n   }\n+  {\n+    OptionHandler* op(new BooleanOptionHandler(\n+        PREF_RETRY_ON_400, TEXT_RETRY_ON_400, A2_V_FALSE, OptionHandler::OPT_ARG));\n+    op->addTag(TAG_ADVANCED);\n+    op->addTag(TAG_HTTP);\n+    op->setInitialOption(true);\n+    op->setChangeGlobalOption(true);\n+    op->setChangeOptionForReserved(true);\n+    handlers.push_back(op);\n+  }\n+  {\n+    OptionHandler* op(new BooleanOptionHandler(\n+        PREF_RETRY_ON_403, TEXT_RETRY_ON_403, A2_V_FALSE, OptionHandler::OPT_ARG));\n+    op->addTag(TAG_ADVANCED);\n+    op->addTag(TAG_HTTP);\n+    op->setInitialOption(true);\n+    op->setChangeGlobalOption(true);\n+    op->setChangeOptionForReserved(true);\n+    handlers.push_back(op);\n+  }\n+  {\n+    OptionHandler* op(new BooleanOptionHandler(\n+        PREF_RETRY_ON_406, TEXT_RETRY_ON_406, A2_V_FALSE, OptionHandler::OPT_ARG));\n+    op->addTag(TAG_ADVANCED);\n+    op->addTag(TAG_HTTP);\n+    op->setInitialOption(true);\n+    op->setChangeGlobalOption(true);\n+    op->setChangeOptionForReserved(true);\n+    handlers.push_back(op);\n+  }\n+  {\n+    OptionHandler* op(new BooleanOptionHandler(\n+        PREF_RETRY_ON_UNKNOWN, TEXT_RETRY_ON_UNKNOWN, A2_V_FALSE, OptionHandler::OPT_ARG));\n+    op->addTag(TAG_ADVANCED);\n+    op->addTag(TAG_HTTP);\n+    op->setInitialOption(true);\n+    op->setChangeGlobalOption(true);\n+    op->setChangeOptionForReserved(true);\n+    handlers.push_back(op);\n+  }\n   {\n     OptionHandler* op(new BooleanOptionHandler(\n         PREF_REUSE_URI, TEXT_REUSE_URI, A2_V_TRUE, OptionHandler::OPT_ARG));\ndiff --git a/src/prefs.cc b/src/prefs.cc\nindex 937e927..33eff91 100644\n--- a/src/prefs.cc\n+++ b/src/prefs.cc\n@@ -327,6 +327,14 @@ PrefPtr PREF_ENABLE_ASYNC_DNS6 = makePref(\"enable-async-dns6\");\n PrefPtr PREF_MAX_DOWNLOAD_RESULT = makePref(\"max-download-result\");\n // value: 1*digit\n PrefPtr PREF_RETRY_WAIT = makePref(\"retry-wait\");\n+// value: true | false\n+PrefPtr PREF_RETRY_ON_400 = makePref(\"retry-on-400\");\n+// value: true | false\n+PrefPtr PREF_RETRY_ON_403 = makePref(\"retry-on-403\");\n+// value: true | false\n+PrefPtr PREF_RETRY_ON_406 = makePref(\"retry-on-406\");\n+// value: true | false\n+PrefPtr PREF_RETRY_ON_UNKNOWN = makePref(\"retry-on-unknown\");\n // value: string\n PrefPtr PREF_ASYNC_DNS_SERVER = makePref(\"async-dns-server\");\n // value: true | false\ndiff --git a/src/prefs.h b/src/prefs.h\nindex e1f8397..019e774 100644\n--- a/src/prefs.h\n+++ b/src/prefs.h\n@@ -280,6 +280,14 @@ extern PrefPtr PREF_ENABLE_ASYNC_DNS6;\n extern PrefPtr PREF_MAX_DOWNLOAD_RESULT;\n // value: 1*digit\n extern PrefPtr PREF_RETRY_WAIT;\n+// value: true | false\n+extern PrefPtr PREF_RETRY_ON_400;\n+// value: true | false\n+extern PrefPtr PREF_RETRY_ON_403;\n+// value: true | false\n+extern PrefPtr PREF_RETRY_ON_406;\n+// value: true | false\n+extern PrefPtr PREF_RETRY_ON_UNKNOWN;\n // value: string\n extern PrefPtr PREF_ASYNC_DNS_SERVER;\n // value: true | false\ndiff --git a/src/usage_text.h b/src/usage_text.h\nindex d73b50d..75d34a0 100644\n--- a/src/usage_text.h\n+++ b/src/usage_text.h\n@@ -64,6 +64,22 @@\n   _(\" --retry-wait=SEC             Set the seconds to wait between retries. \\n\" \\\n     \"                              With SEC > 0, aria2 will retry download when the\\n\" \\\n     \"                              HTTP server returns 503 response.\")\n+#define TEXT_RETRY_ON_400                                                 \\\n+  _(\" --retry-on-400[=true|false]  Configure whether retry or not when\\n\" \\\n+    \"                              HTTP server returns 400 Bad Request.\\n\" \\\n+    \"                              Only effective if retry-wait > 0.\")\n+#define TEXT_RETRY_ON_403                                                 \\\n+  _(\" --retry-on-403[=true|false]  Configure whether retry or not when\\n\" \\\n+    \"                              HTTP server returns 403 Forbidden.\\n\" \\\n+    \"                              Only effective if retry-wait > 0.\")\n+#define TEXT_RETRY_ON_406                                                 \\\n+  _(\" --retry-on-406[=true|false]  Configure whether retry or not when\\n\" \\\n+    \"                              HTTP server returns 406 Not Acceptable.\\n\" \\\n+    \"                              Only effective if retry-wait > 0.\")\n+#define TEXT_RETRY_ON_UNKNOWN                                                 \\\n+  _(\" --retry-on-unknown[=true|false] Configure whether retry or not when\\n\" \\\n+    \"                              HTTP server returns unknown status code.\\n\" \\\n+    \"                              Only effective if retry-wait > 0.\")\n #define TEXT_TIMEOUT                                            \\\n   _(\" -t, --timeout=SEC            Set timeout in seconds.\")\n #define TEXT_MAX_TRIES                                                  \\\n-- \n2.18.0\n\n"
  },
  {
    "path": "aria2-0006-feature-config-add-os-info-for-newer-windows.patch",
    "content": "From d36a15f8330057cee7c32b4035c8824bb03787af Mon Sep 17 00:00:00 2001\nFrom: myfreeer <myfreeer@users.noreply.github.com>\nDate: Fri, 10 Aug 2018 11:31:06 +0800\nSubject: [PATCH] FeatureConfig: add os info for newer windows\n\ngetOperatingSystemInfo: partial refactor\nreplace GetVersionEx with RtlGetVersion, and link with ntdll\n---\n configure.ac         |  2 +-\n src/FeatureConfig.cc | 69 +++++++++++++++++++++++++++-----------------\n src/FeatureConfig.h  | 14 +++++++++\n 3 files changed, 58 insertions(+), 27 deletions(-)\n\ndiff --git a/configure.ac b/configure.ac\nindex 1ab1d32..55c5c07 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -34,7 +34,7 @@ EXTRALIBS=\n case \"$host\" in\n   *mingw*)\n     win_build=yes\n-    EXTRALIBS=\"-lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi $EXTRALIBS\"\n+    EXTRALIBS=\"-lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi -lntdll $EXTRALIBS\"\n     # Define _POSIX_C_SOURCE to 1. This makes {asc,local}time_r\n     # available from <time.h> even without (un)helpful interference\n     # from <pthread.h>, and also defines __USE_MINGW_ANSI_STDIO.\ndiff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc\nindex 2b43c8b..e477aa9 100644\n--- a/src/FeatureConfig.cc\n+++ b/src/FeatureConfig.cc\n@@ -305,8 +305,8 @@ std::string getOperatingSystemInfo()\n #ifdef _WIN32\n   std::stringstream rv;\n   rv << \"Windows \";\n-  OSVERSIONINFOEX ovi = {sizeof(OSVERSIONINFOEX)};\n-  if (!GetVersionEx((LPOSVERSIONINFO)&ovi)) {\n+  RTL_OSVERSIONINFOEXW ovi = {sizeof(RTL_OSVERSIONINFOEXW)};\n+  if (RtlGetVersion((PRTL_OSVERSIONINFOEXW)&ovi) != STATUS_SUCCESS) {\n     rv << \"Unknown\";\n     return rv.str();\n   }\n@@ -314,37 +314,54 @@ std::string getOperatingSystemInfo()\n     rv << \"Legacy, probably XP\";\n     return rv.str();\n   }\n-  switch (ovi.dwMinorVersion) {\n-  case 0:\n-    if (ovi.wProductType == VER_NT_WORKSTATION) {\n+  DWORD dwVersion = (ovi.dwMajorVersion << 24U) | (ovi.dwMinorVersion << 8U) |\n+                    ovi.wProductType;\n+#define WIN32_VERSION(major, minor, type)                                      \\\n+    ((major##U << 24U) | (minor##U << 8U) | type)\n+  switch (dwVersion) {\n+  case WIN32_VERSION(6, 0, VER_NT_WORKSTATION):\n       rv << \"Vista\";\n-    }\n-    else {\n+      break;\n+  case WIN32_VERSION(6, 0, VER_NT_SERVER):\n       rv << \"Server 2008\";\n-    }\n-    break;\n-\n-  case 1:\n-    if (ovi.wProductType == VER_NT_WORKSTATION) {\n+      break;\n+  case WIN32_VERSION(6, 1, VER_NT_WORKSTATION):\n       rv << \"7\";\n-    }\n-    else {\n+      break;\n+  case WIN32_VERSION(6, 1, VER_NT_SERVER):\n       rv << \"Server 2008 R2\";\n-    }\n-    break;\n-\n+      break;\n+  case WIN32_VERSION(6, 2, VER_NT_WORKSTATION):\n+      rv << \"8\";\n+      break;\n+  case WIN32_VERSION(6, 2, VER_NT_SERVER):\n+      rv << \"Server 2012\";\n+      break;\n+  case WIN32_VERSION(6, 3, VER_NT_WORKSTATION):\n+      rv << \"8.1\";\n+      break;\n+  case WIN32_VERSION(6, 3, VER_NT_SERVER):\n+      rv << \"Server 2012 R2\";\n+      break;\n+  case WIN32_VERSION(10, 0, VER_NT_WORKSTATION):\n+      rv << \"10\";\n+      break;\n+  case WIN32_VERSION(10, 0, VER_NT_SERVER):\n+      rv << \"Server 2016\";\n+      break;\n   default:\n-    // Windows above 6.2 does not actually say so. :p\n+      // Windows above 6.2 does not actually say so. :p\n \n-    rv << ovi.dwMajorVersion;\n-    if (ovi.dwMinorVersion) {\n-      rv << \".\" << ovi.dwMinorVersion;\n-    }\n-    if (ovi.wProductType != VER_NT_WORKSTATION) {\n-      rv << \" Server\";\n-    }\n-    break;\n+      rv << ovi.dwMajorVersion;\n+      if (ovi.dwMinorVersion) {\n+          rv << \".\" << ovi.dwMinorVersion;\n+      }\n+      if (ovi.wProductType != VER_NT_WORKSTATION) {\n+          rv << \" Server\";\n+      }\n+      break;\n   }\n+#undef WIN32_VERSION\n   if (ovi.szCSDVersion[0]) {\n     rv << \" (\" << ovi.szCSDVersion << \")\";\n   }\ndiff --git a/src/FeatureConfig.h b/src/FeatureConfig.h\nindex 214dca2..55a3975 100644\n--- a/src/FeatureConfig.h\n+++ b/src/FeatureConfig.h\n@@ -76,4 +76,18 @@ std::string getOperatingSystemInfo();\n \n } // namespace aria2\n \n+#ifdef _WIN32\n+\n+typedef LONG NTSTATUS;\n+\n+#ifndef STATUS_SUCCESS\n+#define STATUS_SUCCESS   ((NTSTATUS)0x00000000L) // ntsubauth\n+#endif\n+\n+extern \"C\" NTSYSAPI NTSTATUS NTAPI RtlGetVersion(\n+    _Out_ PRTL_OSVERSIONINFOEXW lpVersionInformation\n+);\n+\n+#endif // _WIN32\n+\n #endif // D_FEATURE_CONFIG_H\n-- \n2.18.0\n\n"
  },
  {
    "path": "build-aria2.sh",
    "content": "#!bash\ncase $MSYSTEM in\nMINGW32)\n    export MINGW_PACKAGE_PREFIX=mingw-w64-i686\n    export HOST=i686-w64-mingw32\n    ;;\nMINGW64)\n    export MINGW_PACKAGE_PREFIX=mingw-w64-x86_64\n    export HOST=x86_64-w64-mingw32\n    ;;\nesac\n\n# workaround git user name and email not set\nGIT_USER_NAME=\"$(git config --global user.name)\"\nGIT_USER_EMAIL=\"$(git config --global user.email)\"\nif [[ \"${GIT_USER_NAME}\" = \"\" ]]; then\n    git config --global user.name \"Name\"\nfi\nif [[ \"${GIT_USER_EMAIL}\" = \"\" ]]; then\n    git config --global user.email \"you@example.com\"\nfi\n\npacman -S --noconfirm --needed $MINGW_PACKAGE_PREFIX-gcc \\\n    $MINGW_PACKAGE_PREFIX-winpthreads\n\nPREFIX=/usr/local/$HOST\nCPUCOUNT=$(grep -c ^processor /proc/cpuinfo)\ncurl_opts=(/usr/bin/curl --connect-timeout 15 --retry 3\n    --retry-delay 5 --silent --location --insecure --fail)\n\nclean_html_index() {\n    local url=\"$1\"\n    local filter=\"${2:-(?<=href=\\\")[^\\\"]+\\.(tar\\.(gz|bz2|xz)|7z)}\"\n    \"${curl_opts[@]}\" -l \"$url\" | grep -ioP \"$filter\" | sort -uV\n}\n\nclean_html_index_sqlite() {\n    local url=\"$1\"\n    local filter=\"${2:-(\\d+\\/sqlite-autoconf-\\d+\\.tar\\.gz)}\"\n    \"${curl_opts[@]}\" -l \"$url\" | grep -ioP \"$filter\" | sort -uV | tail -1\n}\n\nget_last_version() {\n    local filelist=\"$1\"\n    local filter=\"$2\"\n    local version=\"$3\"\n    local ret\n    ret=\"$(echo \"$filelist\" | /usr/bin/grep -E \"$filter\" | sort -V | tail -1)\"\n    [[ -n \"$version\" ]] && ret=\"$(echo \"$ret\" | /usr/bin/grep -oP \"$version\")\"\n    echo \"$ret\"\n}\n\n# expat\nexpat_ver=\"$(clean_html_index https://sourceforge.net/projects/expat/files/expat/ 'expat/[0-9]+\\.[0-9]+\\.[0-9]+')\"\nexpat_ver=\"$(get_last_version \"${expat_ver}\" expat '2\\.\\d+\\.\\d+')\"\nexpat_ver=\"${expat_ver:-2.2.10}\"\nwget -c --no-check-certificate \"https://downloads.sourceforge.net/project/expat/expat/${expat_ver}/expat-${expat_ver}.tar.bz2\"\ntar xf \"expat-${expat_ver}.tar.bz2\"\ncd \"expat-${expat_ver}\" || exit 1\n./configure \\\n    --disable-shared \\\n    --enable-static \\\n    --prefix=/usr/local/$HOST \\\n    --host=$HOST\nmake install -j$CPUCOUNT\ncd ..\nrm -rf \"expat-${expat_ver}\"\n\n# sqlite\nsqlite_ver=$(clean_html_index_sqlite \"https://www.sqlite.org/download.html\")\n[[ ! \"$sqlite_ver\" ]] && sqlite_ver=\"2020/sqlite-autoconf-3340000.tar.gz\"\nsqlite_file=$(echo ${sqlite_ver} | grep -ioP \"(sqlite-autoconf-\\d+\\.tar\\.gz)\")\nwget -c --no-check-certificate \"https://www.sqlite.org/${sqlite_ver}\"\ntar xf \"${sqlite_file}\"\necho ${sqlite_ver}\nsqlite_name=$(echo ${sqlite_ver} | grep -ioP \"(sqlite-autoconf-\\d+)\")\ncd \"${sqlite_name}\" || exit 1\n./configure \\\n    --disable-shared \\\n    --enable-static \\\n    --prefix=/usr/local/$HOST \\\n    --host=$HOST\nmake install -j$CPUCOUNT\ncd ..\nrm -rf \"${sqlite_name}\"\n\n# c-ares: Async DNS support\n[[ ! \"$cares_ver\" ]] &&\n    cares_ver=\"$(clean_html_index https://c-ares.org/)\" &&\n    cares_ver=\"$(get_last_version \"$cares_ver\" c-ares \"1\\.\\d+\\.\\d\")\"\necho \"current latest c-ares: ${cares_ver}\"\ncares_ver=\"1.19.1\"\necho \"c-ares-${cares_ver}\"\n# for newer version:\n# https://github.com/c-ares/c-ares/releases/download/v${cares_ver}/c-ares-${cares_ver}.tar.gz\nwget -c --no-check-certificate \"https://github.com/c-ares/c-ares/releases/download/cares-1_19_1/c-ares-1.19.1.tar.gz\"\ntar xf \"c-ares-${cares_ver}.tar.gz\"\ncd \"c-ares-${cares_ver}\" || exit 1\n# https://github.com/c-ares/c-ares/issues/384\n# https://github.com/c-ares/c-ares/commit/c35f8ff50710cd38776e9560389504dbd96307fa\nif [ \"${cares_ver}\" = \"1.17.1\" ]; then\n    patch -p1 < ../c-ares-1.17.1-fix-autotools-static-library.patch\n    autoreconf -fi || autoreconf -fiv\nfi\n./configure \\\n    --disable-shared \\\n    --enable-static \\\n    --without-random \\\n    --disable-tests \\\n    --prefix=/usr/local/$HOST \\\n    --host=$HOST\nmake install -j$CPUCOUNT\ncd ..\nrm -rf \"c-ares-${cares_ver}\"\n\n# libssh2\n[[ ! \"$ssh_ver\" ]] &&\n    ssh_ver=\"$(clean_html_index https://libssh2.org/download/)\" &&\n    ssh_ver=\"$(get_last_version \"$ssh_ver\" tar.gz \"1\\.\\d+\\.\\d\")\"\nssh_ver=\"${ssh_ver:-1.9.0}\"\necho \"${ssh_ver}\"\nwget -c --no-check-certificate \"https://libssh2.org/download/libssh2-${ssh_ver}.tar.gz\"\ntar xf \"libssh2-${ssh_ver}.tar.gz\"\ncd \"libssh2-${ssh_ver}\"\n# https://github.com/libssh2/libssh2/pull/479\n# https://github.com/libssh2/libssh2/commit/ba149e804ef653cc05ed9803dfc94519ce9328f7\nif [ \"${ssh_ver}\" = \"1.9.0\" ]; then\n    patch -p1 < ../libssh2-1.9.0-wincng-multiple-definition.patch\nfi\n./configure \\\n    --disable-shared \\\n    --enable-static \\\n    --prefix=/usr/local/$HOST \\\n    --host=$HOST \\\n    --with-crypto=wincng \\\n    LIBS=\"-lws2_32\"\nmake install -j$CPUCOUNT\ncd ..\nrm -rf \"libssh2-${ssh_ver}\"\n\nif [[ -d aria2 ]]; then\n    cd aria2\n    git checkout master || git checkout HEAD\n    git reset --hard origin || git reset --hard\n    git pull\nelse\n    git clone https://github.com/aria2/aria2 --depth=1 --config http.sslVerify=false\n    cd aria2 || exit 1\nfi\ngit checkout -b patch\ngit am -3 ../aria2-*.patch\n\nautoreconf -fi || autoreconf -fiv\n./configure \\\n    --host=$HOST \\\n    --prefix=$PREFIX \\\n    --without-included-gettext \\\n    --disable-nls \\\n    --with-libcares \\\n    --without-gnutls \\\n    --without-openssl \\\n    --with-sqlite3 \\\n    --without-libxml2 \\\n    --with-libexpat \\\n    --with-libz \\\n    --with-libgmp \\\n    --with-libssh2 \\\n    --without-libgcrypt \\\n    --without-libnettle \\\n    --with-cppunit-prefix=$PREFIX \\\n    ARIA2_STATIC=yes \\\n    CPPFLAGS=\"-I$PREFIX/include\" \\\n    LDFLAGS=\"-L$PREFIX/lib -Wl,--gc-sections,--build-id=none\" \\\n    PKG_CONFIG_PATH=\"$PREFIX/lib/pkgconfig\"\nmake -j$CPUCOUNT\nstrip -s src/aria2c.exe\ngit checkout master\ngit branch patch -D\ncd ..\n"
  },
  {
    "path": "c-ares-1.17.1-fix-autotools-static-library.patch",
    "content": "From c35f8ff50710cd38776e9560389504dbd96307fa Mon Sep 17 00:00:00 2001\nFrom: bradh352 <brad@brad-house.com>\nDate: Mon, 23 Nov 2020 08:07:30 -0500\nSubject: [PATCH] Win32: Fix tools build with autotools static library When\n c-ares is being built as static on Win32, CARES_STATICLIB must be defined,\n but it wasn't being pulled in for the tools.\n\nFixes: #384\nFix By: Brad House (@bradh352)\n---\n src/tools/Makefile.am | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/src/tools/Makefile.am b/src/tools/Makefile.am\nindex 3fe28143..c503723c 100644\n--- a/src/tools/Makefile.am\n+++ b/src/tools/Makefile.am\n@@ -15,6 +15,10 @@ AM_CPPFLAGS = -I$(top_builddir)/include \\\n               -I$(top_srcdir)/include \\\n               -I$(top_srcdir)/src/lib\n \n+if USE_CPPFLAG_CARES_STATICLIB\n+AM_CPPFLAGS += $(CPPFLAG_CARES_STATICLIB)\n+endif\n+\n include Makefile.inc\n \n LDADD = $(top_builddir)/src/lib/libcares.la\n"
  },
  {
    "path": "init-msys2.bat",
    "content": "@echo off\npushd \"%~dp0\"\nsetlocal EnableExtensions EnableDelayedExpansion\n\n:Deps\nset MSYSTEM=MINGW64\nREM MINGW64 means 64-bit build; MINGW32 means 32-bit build;\n\nset msysbin=msys64\\usr\\bin\nset sh=%msysbin%\\bash\nset pacman=%msysbin%\\pacman\nif exist msys64\\mingw64.exe goto :Update\nif exist busybox.exe if exist msys2-x86_64-latest.tar.xz goto :Extract\necho. dependency broken. download msys2-x86_64-latest.tar.xz and busybox.exe and put them in the same folder of the script.\necho. download busybox.exe from https://frippery.org/files/busybox/busybox.exe\necho. and deonload msys2-x86_64-latest.tar.xz from http://repo.msys2.org/distrib/msys2-x86_64-latest.tar.xz\npause\nexit /B -1\n\n:Extract\nbusybox tar -Jxvf msys2-x86_64-latest.tar.xz\n\n:Init\n%sh%  -lc \"pacman-key --init && exit\" 2>&1 | busybox tee -a init.log\n\n:Chi_Mirror\nfor %%i in (mirrorlist.mingw32 mirrorlist.mingw64 mirrorlist.msys) do if exist %%i copy /y %%i msys64\\etc\\pacman.d\\\n\n:Update\n%pacman% -Syyuu --needed --noconfirm --ask=20 2>&1 | busybox tee -a update.log\n%pacman% -Suu --needed --noconfirm --ask=20 2>&1 | busybox tee -a update.log\n\n:Install\n%pacman% -S --needed --noconfirm base-devel zlib-devel sqlite git unzip zip tar gmp gmp-devel libssh2 libssh2-devel openssl-devel 2>&1 | busybox tee -a install.log\n%pacman% -Sc --noconfirm 2>&1 | busybox tee -a install.log\n\n:Clone\n%sh%  -lc \"if [[ -d ~/aria2 ]]; then cd aria2; git pull; else git clone https://github.com/myfreeer/aria2-build-msys2.git aria2; cd aria2; git pull; fi\" 2>&1 | busybox tee -a clone.log\n\n:Build\n%sh%  -lc \"cd ~/aria2 && exec ./build-aria2.sh\" 2>&1 | busybox tee -a build.log\npause\n"
  },
  {
    "path": "libssh2-1.9.0-wincng-multiple-definition.patch",
    "content": "From ba149e804ef653cc05ed9803dfc94519ce9328f7 Mon Sep 17 00:00:00 2001\nFrom: Marc Hoersken <info@marc-hoersken.de>\nDate: Sun, 31 May 2020 21:24:58 +0200\nSubject: [PATCH] wincng: fix multiple definition of `_libssh2_wincng' (#479)\n\nAdd missing include guard and move global state\nfrom header to source file by using extern.\n---\n src/wincng.c | 2 ++\n src/wincng.h | 8 ++++++--\n 2 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/src/wincng.c b/src/wincng.c\nindex 4bebc6407..dffd2ed36 100755\n--- a/src/wincng.c\n+++ b/src/wincng.c\n@@ -208,6 +208,8 @@\n  * Windows CNG backend: Generic functions\n  */\n \n+struct _libssh2_wincng_ctx _libssh2_wincng;\n+\n void\n _libssh2_wincng_init(void)\n {\ndiff --git a/src/wincng.h b/src/wincng.h\nindex f5838d0e6..c817f090c 100755\n--- a/src/wincng.h\n+++ b/src/wincng.h\n@@ -1,5 +1,7 @@\n+#ifndef __LIBSSH2_WINCNG_H\n+#define __LIBSSH2_WINCNG_H\n /*\n- * Copyright (C) 2013-2015 Marc Hoersken <info@marc-hoersken.de>\n+ * Copyright (C) 2013-2020 Marc Hoersken <info@marc-hoersken.de>\n  * All rights reserved.\n  *\n  * Redistribution and use in source and binary forms,\n@@ -101,7 +103,7 @@ struct _libssh2_wincng_ctx {\n     BCRYPT_ALG_HANDLE hAlg3DES_CBC;\n };\n \n-struct _libssh2_wincng_ctx _libssh2_wincng;\n+extern struct _libssh2_wincng_ctx _libssh2_wincng;\n \n \n /*******************************************************************/\n@@ -569,3 +571,5 @@ _libssh2_dh_secret(_libssh2_dh_ctx *dhctx, _libssh2_bn *secret,\n                    _libssh2_bn *f, _libssh2_bn *p);\n extern void\n _libssh2_dh_dtor(_libssh2_dh_ctx *dhctx);\n+\n+#endif /* __LIBSSH2_WINCNG_H */\n"
  }
]